You can subscribe to this list here.
2002 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(14) |
Sep
(76) |
Oct
(65) |
Nov
(177) |
Dec
(147) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2003 |
Jan
(257) |
Feb
(313) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <tr...@us...> - 2002-09-07 12:04:13
|
Update of /cvsroot/basedb/basedb/www In directory usw-pr-cvs1:/tmp/cvs-serv28434 Modified Files: mysql.inc.php Log Message: fixed tpyo in LOAD DATA... Index: mysql.inc.php =================================================================== RCS file: /cvsroot/basedb/basedb/www/mysql.inc.php,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** mysql.inc.php 7 Sep 2002 11:36:32 -0000 1.1 --- mysql.inc.php 7 Sep 2002 12:04:05 -0000 1.2 *************** *** 194,198 **** function db_tabfile_load($filename, $table, $columns) { ! $query = "LOAD LOCAL DATA INFILE '".addslashes($filename)."' ". "INTO TABLE $table (".implode(", ", $columns).")"; if(!query($query)) --- 194,198 ---- function db_tabfile_load($filename, $table, $columns) { ! $query = "LOAD DATA LOCAL INFILE '".addslashes($filename)."' ". "INTO TABLE $table (".implode(", ", $columns).")"; if(!query($query)) |
From: <tr...@us...> - 2002-09-07 11:59:43
|
Update of /cvsroot/basedb/basedb/www In directory usw-pr-cvs1:/tmp/cvs-serv27623 Modified Files: bio.inc.php Log Message: fixed broken c-style comment Index: bio.inc.php =================================================================== RCS file: /cvsroot/basedb/basedb/www/bio.inc.php,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** bio.inc.php 7 Sep 2002 11:36:31 -0000 1.17 --- bio.inc.php 7 Sep 2002 11:59:40 -0000 1.18 *************** *** 37,41 **** $this->Item("Sample", $name, $descr, $owner, $addedDate, $id, $visible); $this->tissue = (int)$tissue; ! /* $this->project = (int)$project;/* } --- 37,41 ---- $this->Item("Sample", $name, $descr, $owner, $addedDate, $id, $visible); $this->tissue = (int)$tissue; ! /* $this->project = (int)$project;*/ } |
From: <tr...@us...> - 2002-09-07 11:52:00
|
Update of /cvsroot/basedb/basedb/exec/source/baseftpd In directory usw-pr-cvs1:/tmp/cvs-serv26039 Added Files: .cvsignore Log Message: Added binaries --- NEW FILE: .cvsignore --- spawner baseftpd |
From: <tr...@us...> - 2002-09-07 11:50:34
|
Update of /cvsroot/basedb/basedb/exec In directory usw-pr-cvs1:/tmp/cvs-serv25732 Modified Files: jobController.php updateGenes.php Log Message: Changed luDatabase->BaseDatabase, column names Index: jobController.php =================================================================== RCS file: /cvsroot/basedb/basedb/exec/jobController.php,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** jobController.php 5 Aug 2002 11:37:53 -0000 1.14 --- jobController.php 7 Sep 2002 11:50:31 -0000 1.15 *************** *** 50,54 **** // Open database connection ! $curDb = new luDatabase($config["dbHost"], $config["dbUser"], $config["dbPassword"], $config["dbDatabase"]); unset($config["dbPassword"]); --- 50,54 ---- // Open database connection ! $curDb = new BaseDatabase($config["dbHost"], $config["dbUser"], $config["dbPassword"], $config["dbDatabase"]); unset($config["dbPassword"]); *************** *** 167,171 **** $set->setName("After ".$tran->getName()); $set->setTransformation($tran->getId()); ! $set->setUser($oldset->getUser()); $set->setExperiment($oldset->getExperiment()); --- 167,171 ---- $set->setName("After ".$tran->getName()); $set->setTransformation($tran->getId()); ! $set->setOwner($oldset->getOwner()); $set->setExperiment($oldset->getExperiment()); *************** *** 320,324 **** $jf = new JobFile($job->getId()); $jf->setName($fullname); ! $jf->setSize(filesize($fname)); if(!$jf->write()) return "Error adding file '$fullname'"; --- 320,324 ---- $jf = new JobFile($job->getId()); $jf->setName($fullname); ! $jf->setFileSize(filesize($fname)); if(!$jf->write()) return "Error adding file '$fullname'"; Index: updateGenes.php =================================================================== RCS file: /cvsroot/basedb/basedb/exec/updateGenes.php,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** updateGenes.php 5 Aug 2002 11:37:53 -0000 1.5 --- updateGenes.php 7 Sep 2002 11:50:31 -0000 1.6 *************** *** 37,41 **** // Open database connection ! $curDb = new luDatabase($config["dbHost"], $config["dbUser"], $config["dbPassword"], $config["dbDatabase"]); unset($config["dbPassword"]); --- 37,41 ---- // Open database connection ! $curDb = new BaseDatabase($config["dbHost"], $config["dbUser"], $config["dbPassword"], $config["dbDatabase"]); unset($config["dbPassword"]); |
Update of /cvsroot/basedb/basedb/www In directory usw-pr-cvs1:/tmp/cvs-serv23030 Modified Files: acquisition.inc.php array.inc.php array_batch.phtml basefile.inc.php bio.inc.php bioassay.inc.php bioassayset.inc.php db.inc.php eventlog.inc.php experiment.inc.php gene_explore.phtml genelist.inc.php hyb.inc.php hyb_result.phtml image.inc.php item.inc.php job.inc.php left.phtml molecule.inc.php newinit.inc.php news.inc.php plate.inc.php plot.inc.php program.inc.php protocol.inc.php raw.inc.php sampleannotation.inc.php sampletissue.inc.php search.inc.php session.inc.php test.phtml transformation.inc.php upload.inc.php user.inc.php ware.inc.php wizzzard.inc.php Added Files: mysql.inc.php Log Message: First steps towards RDBMS independence. Added API for things like LOAD DATA INFILE, REPLACE, LIMIT etc. --- NEW FILE: mysql.inc.php --- <? // $Id: mysql.inc.php,v 1.1 2002/09/07 11:36:32 troein Exp $ // // BioArray Software Environment (BASE) - homepage http://base.thep.lu.se/ // Copyright (C) 2002 Lao Saal, Carl Troein, Johan Vallon-Christersson (LSCTJVC) // // Write to LSCTJVC, Dept. of Oncology, Lund University Hospital, // Klinikgatan 7, SE-22185, Lund, Sweden. // // This file is part of BASE. // // BASE is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License // as published by the Free Software Foundation; either version 2 // of the License, or (at your option) any later version. // // BASE is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the [...202 lines suppressed...] { error_log("Name of table '$from' not found in SHOW CREATE TABLE"); return false; } $tmp = $temporary ? "TEMPORARY" : ""; $query = ereg_replace("CREATE TABLE `?$from`?(.*)\$", "CREATE $tmp TABLE $to\\1", $row[1]); return (bool)query($query); } // This function drops a table quietly. It exists because we want to use // persistent connections and we might come across temporary tables that // haven't been deleted because of script errors. function db_table_drop($table) { $query = "DROP TABLE IF EXISTS $table"; return (bool)query($query); } ?> Index: acquisition.inc.php =================================================================== RCS file: /cvsroot/basedb/basedb/www/acquisition.inc.php,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** acquisition.inc.php 29 Aug 2002 16:51:32 -0000 1.11 --- acquisition.inc.php 7 Sep 2002 11:36:31 -0000 1.12 *************** *** 75,79 **** $query = "DELETE FROM ImageAcquisition ". "WHERE id = $this->id AND scanner = 0"; ! if(!query($query) || mysql_affected_rows() != 1) return false; @unlink("$config[rawImageDir]/$this->owner/$this->id"); --- 75,79 ---- $query = "DELETE FROM ImageAcquisition ". "WHERE id = $this->id AND scanner = 0"; ! if(!query($query) || db_affected_rows() != 1) return false; @unlink("$config[rawImageDir]/$this->owner/$this->id"); *************** *** 102,106 **** $res = query($query); $rc = true; ! while($row = mysql_fetch_row($res)) if(!Image::removeId($row[0])) $rc = false; return $rc; --- 102,106 ---- $res = query($query); $rc = true; ! while($row =& db_fetch_row($res)) if(!Image::removeId($row[0])) $rc = false; return $rc; *************** *** 137,141 **** $query = "UPDATE ImageAcquisition SET scanner = $val ". "WHERE id = $this->id AND scanner = $this->scanner"; ! if(query($query) && mysql_affected_rows() > 0) { if($this->scanner) Hardware::unlockId($this->scanner, false); --- 137,141 ---- $query = "UPDATE ImageAcquisition SET scanner = $val ". "WHERE id = $this->id AND scanner = $this->scanner"; ! if(query($query) && db_affected_rows() > 0) { if($this->scanner) Hardware::unlockId($this->scanner, false); *************** *** 162,166 **** $search->getWhere()." ".$search->getExtraWhere(); $res = query($query); ! if($row = mysql_fetch_row($res)) $cnt = $row[0]; else $cnt = 0; $search->setHits($cnt); --- 162,167 ---- $search->getWhere()." ".$search->getExtraWhere(); $res = query($query); ! if($row =& db_fetch_row($res)) ! $cnt = $row[0]; else $cnt = 0; $search->setHits($cnt); *************** *** 187,192 **** "GROUP BY ia.id $ob ".$search->makeLimit(); $arr = array(); ! if(!($res = query($query))) return $arr; ! while($row = mysql_fetch_array($res)) $arr[] = $row; return $arr; } --- 188,195 ---- "GROUP BY ia.id $ob ".$search->makeLimit(); $arr = array(); ! if(!($res = query($query))) ! return $arr; ! while($row =& db_fetch_assoc($res)) ! $arr[] = $row; return $arr; } *************** *** 197,201 **** "WHERE hybridization = ".(int)$hyb; $res = query($query); ! if($row = mysql_fetch_array($res)) return $row[0]; return 0; } --- 200,205 ---- "WHERE hybridization = ".(int)$hyb; $res = query($query); ! if($row =& db_fetch_row($res)) ! return $row[0]; return 0; } Index: array.inc.php =================================================================== RCS file: /cvsroot/basedb/basedb/www/array.inc.php,v retrieving revision 1.31 retrieving revision 1.32 diff -C2 -d -r1.31 -r1.32 *** array.inc.php 29 Aug 2002 16:51:33 -0000 1.31 --- array.inc.php 7 Sep 2002 11:36:31 -0000 1.32 *************** *** 69,76 **** } function remove() { $query = "DELETE FROM ArrayType WHERE id = $this->id"; ! if(!query($query) || mysql_affected_rows() < 1) return false; $query = "DELETE FROM ArrayTypePlate WHERE arrayType = $this->id"; query($query); --- 69,81 ---- } [...625 lines suppressed...] $res = query($query); ! if($row =& db_fetch_row($res)) ! $cnt = $row[0]; else $cnt = 0; $search->setHits($cnt); *************** *** 916,920 **** $arr = array(); $res = query($query); ! while($row = mysql_fetch_assoc($res)) $arr[] = $row; return $arr; } --- 947,952 ---- $arr = array(); $res = query($query); ! while($row =& db_fetch_assoc($res)) ! $arr[] = $row; return $arr; } Index: array_batch.phtml =================================================================== RCS file: /cvsroot/basedb/basedb/www/array_batch.phtml,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** array_batch.phtml 29 Aug 2002 16:51:33 -0000 1.17 --- array_batch.phtml 7 Sep 2002 11:36:31 -0000 1.18 *************** *** 87,91 **** { if($curDb->dupKey()) $errs[$pos] = ! "Barcode (or position) already in use"; else $errs[$pos] = "Unable to save array"; } --- 87,91 ---- { if($curDb->dupKey()) $errs[$pos] = ! "Barcode already in use"; else $errs[$pos] = "Unable to save array"; } Index: basefile.inc.php =================================================================== RCS file: /cvsroot/basedb/basedb/www/basefile.inc.php,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** basefile.inc.php 5 Aug 2002 11:29:31 -0000 1.7 --- basefile.inc.php 7 Sep 2002 11:36:31 -0000 1.8 *************** *** 122,126 **** $res = query($query); $arr = array(); ! while($row = mysql_fetch_row($res)) $arr[(int)$row[0]] = $row[1]; return $arr; } --- 122,127 ---- $res = query($query); $arr = array(); ! while($row =& db_fetch_row($res)) ! $arr[(int)$row[0]] = $row[1]; return $arr; } *************** *** 131,143 **** $name = addslashes($name); $query = "SELECT id FROM BaseFileSection WHERE name = '$name'"; ! if(!($res = query($query))) return 0; ! if($row = mysql_fetch_row($res)) return $row[0]; ! if(!$add) return 0; ! $query2 = "INSERT INTO BaseFileSection (name) VALUES ('$name')"; ! if(query($query2)) ! return mysql_insert_id(); // Remove race condition $res = query($query); ! if($row = mysql_fetch_row($res)) return $row[0]; return 0; } --- 132,150 ---- $name = addslashes($name); $query = "SELECT id FROM BaseFileSection WHERE name = '$name'"; ! if(!($res = query($query))) ! return 0; ! if($row =& db_fetch_row($res)) ! return $row[0]; ! if(!$add) ! return 0; ! $names = array("name"); ! $values = array($name); ! $id = db_insert("BaseFileSection", $names, $values); ! if($id) ! return $id; // Remove race condition $res = query($query); ! if($row =& db_fetch_row($res)) ! return $row[0]; return 0; } *************** *** 147,151 **** $query = "SELECT name FROM BaseFileSection WHERE id = ".(int)$id; $res = query($query); ! if($row = mysql_fetch_row($res)) return $row[0]; return ""; } --- 154,159 ---- $query = "SELECT name FROM BaseFileSection WHERE id = ".(int)$id; $res = query($query); ! if($row =& db_fetch_row($res)) ! return $row[0]; return ""; } Index: bio.inc.php =================================================================== RCS file: /cvsroot/basedb/basedb/www/bio.inc.php,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** bio.inc.php 29 Aug 2002 16:51:33 -0000 1.16 --- bio.inc.php 7 Sep 2002 11:36:31 -0000 1.17 *************** *** 26,41 **** // require_once("item.inc.php"); ! require_once("project.inc.php"); class Sample extends Item { ! var $tissue, $project; function Sample($name = "", $descr = "", $owner = 0, $addedDate = "", ! $tissue = 0, $project = 0, $id = 0, $visible = 0) [...385 lines suppressed...] ! if(!($res = query($query))) ! return $arr; ! while($row =& db_fetch_assoc($res)) ! $arr[] = $row; return $arr; } *************** *** 731,735 **** $query = "SELECT COUNT(*) FROM LabeledExtract WHERE extract = $extract"; $res = query($query); ! if($row = mysql_fetch_row($res)) $cnt = $row[0]; else $cnt = 0; return $cnt; --- 742,747 ---- $query = "SELECT COUNT(*) FROM LabeledExtract WHERE extract = $extract"; $res = query($query); ! if($row =& db_fetch_row($res)) ! $cnt = $row[0]; else $cnt = 0; return $cnt; Index: bioassay.inc.php =================================================================== RCS file: /cvsroot/basedb/basedb/www/bioassay.inc.php,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -d -r1.29 -r1.30 *** bioassay.inc.php 29 Aug 2002 16:51:33 -0000 1.29 --- bioassay.inc.php 7 Sep 2002 11:36:31 -0000 1.30 *************** *** 72,76 **** $query = "DELETE FROM BioAssay WHERE id = $this->id"; ! if(!query($query) || mysql_affected_rows() <= 0) return false; $query = "DELETE FROM $config[dbDynamic].BioAssayData$this->experiment ". --- 72,77 ---- $query = "DELETE FROM BioAssay WHERE id = $this->id"; ! if(!query($query) || db_affected_rows() != 1) ! return false; [...269 lines suppressed...] } --- 953,957 ---- $query = "SELECT rawBioAssay FROM BioAssay WHERE id = ".(int)$id; $res = query($query); ! if($row =& db_fetch_row($res)) return $row[0]; return false; } *************** *** 1034,1038 **** $res = query($query); $arr = array(); ! while($row = mysql_fetch_row($res)) $arr[] = $row; return $arr; --- 1043,1047 ---- $res = query($query); $arr = array(); ! while($row =& db_fetch_row($res)) $arr[] = $row; return $arr; Index: bioassayset.inc.php =================================================================== RCS file: /cvsroot/basedb/basedb/www/bioassayset.inc.php,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** bioassayset.inc.php 29 Aug 2002 16:51:33 -0000 1.23 --- bioassayset.inc.php 7 Sep 2002 11:36:31 -0000 1.24 *************** *** 82,86 **** $rc = true; if(!($res = query($query))) $rc = false; ! while($row = mysql_fetch_row($res)) if(!BioAssay::removeId($row[0])) $rc = false; if(!$rc) return false; --- 82,86 ---- $rc = true; if(!($res = query($query))) $rc = false; ! while($row =& db_fetch_row($res)) if(!BioAssay::removeId($row[0])) $rc = false; [...348 lines suppressed...] ! $key = array("bioAssaySet"); ! $kval = array($this->id); ! ! return db_update_or_insert("BioAssaySetCreation", $key, ! $kval, $names, $vals); } *************** *** 696,700 **** "WHERE bioAssaySet = $this->id"; $res = query($query); ! return mysql_fetch_assoc($res); } --- 698,702 ---- "WHERE bioAssaySet = $this->id"; $res = query($query); ! return db_fetch_assoc($res); } Index: db.inc.php =================================================================== RCS file: /cvsroot/basedb/basedb/www/db.inc.php,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** db.inc.php 5 Aug 2002 11:29:31 -0000 1.9 --- db.inc.php 7 Sep 2002 11:36:32 -0000 1.10 *************** *** 25,94 **** // ! class LuDatabase ! { ! var $serv, $db; ! function LuDatabase($server, $user, $password, $database) ! { ! if($password == "") ! { ! $this->serv = mysql_pconnect($server, $user) ! or die("mysql_pconnect() failed: ".mysql_error()."\n"); ! } ! else ! { ! $this->serv = mysql_pconnect($server, $user, $password) ! or die("mysql_pconnect() failed: ".mysql_error()."\n"); ! } ! $this->db = mysql_select_db($database, $this->serv) ! or die("mysql_select_db() failed: ".mysql_error()."\n"); ! } ! ! function errorMessage() ! { ! return mysql_error(); ! } ! ! // Returns true if the last query failed because of a duplicate key ! function dupKey() ! { ! return mysql_errno() == 1062; ! } ! } ! ! function query(&$query, $quiet = 0) ! { ! // if(strpos("$query","Search"))error_log("Q: $query"); ! // if(strlen($query) < 1000 && strpos("$query"," ExpressionValue ")) ! // error_log("Q: $query"); ! // error_log("Q: $query"); ! ! $res = mysql_query($query); ! if(!$res && !$quiet) ! error_log("MySQL query failed: \"".$query."\" : ".mysql_error()); ! return $res; ! } ! ! // This function copies the table structure from table $from to ! // table $to. ! function copyTable($from, $to, $temporary = false) ! { ! $query = "SHOW CREATE TABLE $from"; ! $res = query($query); ! if(!$res) return false; ! if(!($row = mysql_fetch_row($res))) ! { ! error_log("Failed to copy table '$from': No such table(?)"); ! return false; ! } ! if(!ereg("CREATE TABLE `?$from`?", $row[1])) ! { ! error_log("Name of table '$from' not found in SHOW CREATE TABLE"); ! return false; ! } ! $tmp = $temporary ? "TEMPORARY" : ""; ! $query = ereg_replace("CREATE TABLE `?$from`?(.*)\$", ! "CREATE $tmp TABLE $to\\1", $row[1]); ! return (bool)query($query); ! } ?> --- 25,29 ---- // ! require_once("mysql.inc.php"); ?> Index: eventlog.inc.php =================================================================== RCS file: /cvsroot/basedb/basedb/www/eventlog.inc.php,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** eventlog.inc.php 5 Aug 2002 11:29:31 -0000 1.3 --- eventlog.inc.php 7 Sep 2002 11:36:32 -0000 1.4 *************** *** 40,47 **** $query = "SELECT eventDate AS date, eventType AS type, message ". "FROM EventLog WHERE eventType='broadcast' ". ! "ORDER BY eventDate DESC LIMIT ".(int)$cnt; $res = query($query); $arr = array(); ! while($row = mysql_fetch_array($res)) $arr[] = $row; return $arr; } --- 40,48 ---- $query = "SELECT eventDate AS date, eventType AS type, message ". "FROM EventLog WHERE eventType='broadcast' ". ! "ORDER BY eventDate DESC ".db_limit(0, (int)$cnt); $res = query($query); $arr = array(); ! while($row =& db_fetch_assoc($res)) ! $arr[] = $row; return $arr; } Index: experiment.inc.php =================================================================== RCS file: /cvsroot/basedb/basedb/www/experiment.inc.php,v retrieving revision 1.42 retrieving revision 1.43 diff -C2 -d -r1.42 -r1.43 *** experiment.inc.php 29 Aug 2002 16:51:33 -0000 1.42 --- experiment.inc.php 7 Sep 2002 11:36:32 -0000 1.43 *************** *** 87,95 **** if($rc) { ! if(!copyTable("TemplateBioAssayData", "$config[dbDynamic].BioAssayData$this->id") || ! !copyTable("TemplateBioAssaySetGene", "$config[dbDynamic].BioAssaySetGene$this->id") || ! !copyTable("TemplateBioAssaySetPosGene", "$config[dbDynamic].BioAssaySetPosGene$this->id")) { --- 87,95 ---- [...130 lines suppressed...] Experiment::unlockId($expid, false); --- 390,394 ---- $query = "DELETE FROM ExperimentRawBioAssay ". "WHERE experiment = $expid AND rawBioAssay = $rawid"; ! if(query($query) && db_affected_rows() == 1) { Experiment::unlockId($expid, false); *************** *** 408,412 **** "WHERE experiment = $this->id"; $res = query($query); ! if($row = mysql_fetch_row($res)) return $row[0]; else return false; } --- 405,409 ---- "WHERE experiment = $this->id"; $res = query($query); ! if($row =& db_fetch_row($res)) return $row[0]; else return false; } Index: gene_explore.phtml =================================================================== RCS file: /cvsroot/basedb/basedb/www/gene_explore.phtml,v retrieving revision 1.49 retrieving revision 1.50 diff -C2 -d -r1.49 -r1.50 *** gene_explore.phtml 29 Aug 2002 16:51:33 -0000 1.49 --- gene_explore.phtml 7 Sep 2002 11:36:32 -0000 1.50 *************** *** 336,342 **** $gsort = $expl["subSort"]; ! if(isset($i_backend)) $expl["showBackend"] = (int)(bool)$i_backend; $showBackend = $expl["showBackend"]; ! if($gpage < 0) $showBackend = false; // Only needs to be saved if something is changed, but it's quite --- 336,344 ---- $gsort = $expl["subSort"]; [...71 lines suppressed...] $ann = "<td bgcolor=$tdbg[2]> </td>"; --- 624,628 ---- if($annot) { ! if(!isset($e["annotation"])) { $ann = "<td bgcolor=$tdbg[2]> </td>"; *************** *** 629,633 **** else { ! $v = $e["value"]; $col = $anncolors[$anncolor[$v]]; $ann = "<td bgcolor=$col>".html($v)."</td>"; --- 631,635 ---- else { ! $v = $e["annotation"]; $col = $anncolors[$anncolor[$v]]; $ann = "<td bgcolor=$col>".html($v)."</td>"; Index: genelist.inc.php =================================================================== RCS file: /cvsroot/basedb/basedb/www/genelist.inc.php,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** genelist.inc.php 29 Aug 2002 16:51:33 -0000 1.15 --- genelist.inc.php 7 Sep 2002 11:36:32 -0000 1.16 *************** *** 68,72 **** $query = "DELETE FROM GeneList WHERE id = $id ". "AND owner = ".(int)$owner; ! if(query($query) && mysql_affected_rows() > 0) { $query = "DELETE FROM GeneListGene WHERE geneList = $id"; --- 68,72 ---- $query = "DELETE FROM GeneList WHERE id = $id ". "AND owner = ".(int)$owner; ! if(query($query) && db_affected_rows() > 0) { [...196 lines suppressed...] } --- 283,287 ---- $res = query($query); $arr = array(); ! while($row =& db_fetch_assoc($res)) $arr[] = $row; return $arr; } *************** *** 289,293 **** $res = query($query); $arr = array(); ! while($row = mysql_fetch_row($res)) $arr[$row[0]] = $row[1]; return $arr; } --- 295,299 ---- $res = query($query); $arr = array(); ! while($row =& db_fetch_row($res)) $arr[$row[0]] = $row[1]; return $arr; } Index: hyb.inc.php =================================================================== RCS file: /cvsroot/basedb/basedb/www/hyb.inc.php,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** hyb.inc.php 29 Aug 2002 16:51:33 -0000 1.16 --- hyb.inc.php 7 Sep 2002 11:36:32 -0000 1.17 *************** *** 54,58 **** $id = (int)$id; $query = "DELETE FROM Hybridization WHERE id = $id"; ! if(!query($query) || mysql_affected_rows() != 1) return false; $query = "DELETE FROM SharedHybridization WHERE item = $id"; --- 54,58 ---- $id = (int)$id; $query = "DELETE FROM Hybridization WHERE id = $id"; ! if(!query($query) || db_affected_rows() != 1) return false; [...102 lines suppressed...] } --- 263,267 ---- "WHERE ia.hybridization = $this->id AND r.imageAcquisition = ia.id"; $res = query($query); ! if($row =& db_fetch_row($res)) return($row[0]); return 0; } *************** *** 274,278 **** "WHERE hybridization = $this->id AND position = ".(int)$position; query($query); ! return mysql_affected_rows() > 0; } --- 274,278 ---- "WHERE hybridization = $this->id AND position = ".(int)$position; query($query); ! return db_affected_rows() > 0; } Index: hyb_result.phtml =================================================================== RCS file: /cvsroot/basedb/basedb/www/hyb_result.phtml,v retrieving revision 1.52 retrieving revision 1.53 diff -C2 -d -r1.52 -r1.53 *** hyb_result.phtml 29 Aug 2002 16:51:34 -0000 1.52 --- hyb_result.phtml 7 Sep 2002 11:36:32 -0000 1.53 *************** *** 494,498 **** else $idmol = array(0, $molecules[$cid]); } ! fwrite($tfd, "$rawid\t$idmol[0]\t$idmol[1]"); // Channel 2 set to 1.0 is undefined (for affy) if($arr[16] === false) --- 494,498 ---- else $idmol = array(0, $molecules[$cid]); } ! fwrite($tfd, "$rawid\t$datalines\t$idmol[0]\t$idmol[1]"); // Channel 2 set to 1.0 is undefined (for affy) if($arr[16] === false) Index: image.inc.php =================================================================== RCS file: /cvsroot/basedb/basedb/www/image.inc.php,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** image.inc.php 29 Aug 2002 16:51:34 -0000 1.8 --- image.inc.php 7 Sep 2002 11:36:32 -0000 1.9 *************** *** 71,75 **** { $query = "DELETE FROM Image WHERE id = $this->id"; ! if(!query($query) || mysql_affected_rows() != 1) return false; unlink($this->getRepositoryFilename(false)); --- 71,75 ---- { $query = "DELETE FROM Image WHERE id = $this->id"; ! if(!query($query) || db_affected_rows() != 1) return false; unlink($this->getRepositoryFilename(false)); *************** *** 134,138 **** $search->getWhere()." ".$search->getExtraWhere(); $res = query($query); ! if($row = mysql_fetch_row($res)) $cnt = $row[0]; else $cnt = 0; $search->setHits($cnt); --- 134,138 ---- $search->getWhere()." ".$search->getExtraWhere(); $res = query($query); ! if($row =& db_fetch_row($res)) $cnt = $row[0]; else $cnt = 0; $search->setHits($cnt); *************** *** 154,158 **** $arr = array(); if(!($res = query($query))) return $arr; ! while($row = mysql_fetch_array($res)) $arr[] = $row; return $arr; } --- 154,158 ---- $arr = array(); if(!($res = query($query))) return $arr; ! while($row =& db_fetch_assoc($res)) $arr[] = $row; return $arr; } Index: item.inc.php =================================================================== RCS file: /cvsroot/basedb/basedb/www/item.inc.php,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** item.inc.php 29 Aug 2002 16:51:34 -0000 1.22 --- item.inc.php 7 Sep 2002 11:36:32 -0000 1.23 *************** *** 25,28 **** --- 25,29 ---- // require_once("db.inc.php"); + require_once("misc.inc.php"); class Item *************** *** 44,48 **** { $res = query($query); [...487 lines suppressed...] } $query = "UPDATE $type SET useCount = useCount - 1 ". "WHERE id = $id AND useCount > 0"; ! return query($query) && db_affected_rows() == 1; } *************** *** 441,445 **** $query = "SELECT useCount FROM $this->type WHERE id = $this->id"; $res = query($query); ! if($row = mysql_fetch_row($res)) return $row[0]; return -2; } --- 448,453 ---- $query = "SELECT useCount FROM $this->type WHERE id = $this->id"; $res = query($query); ! if($row =& db_fetch_row($res)) ! return $row[0]; return -2; } Index: job.inc.php =================================================================== RCS file: /cvsroot/basedb/basedb/www/job.inc.php,v retrieving revision 1.32 retrieving revision 1.33 diff -C2 -d -r1.32 -r1.33 *** job.inc.php 31 Aug 2002 11:47:53 -0000 1.32 --- job.inc.php 7 Sep 2002 11:36:32 -0000 1.33 *************** *** 49,53 **** { $res = query($query); ! if(!($row = mysql_fetch_array($res))) return false; $this->id = (int)$row["id"]; --- 49,53 ---- { $res = query($query); ! if(!($row =& db_fetch_assoc($res))) return false; [...281 lines suppressed...] ! // worst thing that can happen isn't all that horrible. ! $query = "INSERT INTO JobFileSection ". "(jobFile, fileSection, sectionCount) ". "VALUES ($this->id, $section, $count)"; ! return (bool)query($query); } *************** *** 644,648 **** "WHERE jobFile = $this->id AND fileSection = ".(int)$section; $res = query($query); ! if($row = mysql_fetch_row($res)) return $row[0]; return 0; --- 654,658 ---- "WHERE jobFile = $this->id AND fileSection = ".(int)$section; $res = query($query); ! if($row =& db_fetch_row($res)) return $row[0]; return 0; Index: left.phtml =================================================================== RCS file: /cvsroot/basedb/basedb/www/left.phtml,v retrieving revision 1.43 retrieving revision 1.44 diff -C2 -d -r1.43 -r1.44 *** left.phtml 29 Aug 2002 16:51:34 -0000 1.43 --- left.phtml 7 Sep 2002 11:36:32 -0000 1.44 *************** *** 207,211 **** >Sample annotations</a></td></tr> <tr><td><img src='img/1.gif' alt='' width=1 height=1></td></tr> ! <tr><td><a target=main href="project_list.phtml">Projects</a></td></tr> <tr><td><a target=main href="sample_list.phtml">Samples</a></td></tr> <tr><td><a target=main href="extract_list.phtml">Extracts</a></td></tr> --- 207,211 ---- >Sample annotations</a></td></tr> <tr><td><img src='img/1.gif' alt='' width=1 height=1></td></tr> ! <!-- <tr><td><a target=main href="project_list.phtml">Projects</a></td></tr> --> <tr><td><a target=main href="sample_list.phtml">Samples</a></td></tr> <tr><td><a target=main href="extract_list.phtml">Extracts</a></td></tr> Index: molecule.inc.php =================================================================== RCS file: /cvsroot/basedb/basedb/www/molecule.inc.php,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** molecule.inc.php 20 Aug 2002 17:38:37 -0000 1.25 --- molecule.inc.php 7 Sep 2002 11:36:32 -0000 1.26 *************** *** 73,77 **** $query = "SELECT * FROM Molecule WHERE $where"; $res = query($query); ! if($row = mysql_fetch_array($res)) { $this->id = (int)$row["id"]; --- 73,77 ---- $query = "SELECT * FROM Molecule WHERE $where"; $res = query($query); ! if($row =& db_fetch_assoc($res)) { [...133 lines suppressed...] $search->setHits($cnt); --- 629,633 ---- "WHERE 1 ".$search->getWhere()." ".$search->getExtraWhere(); $res = query($query); ! if($row =& db_fetch_row($res)) $cnt = $row[0]; else $cnt = 0; $search->setHits($cnt); *************** *** 654,658 **** $arr = array(); if(!($res = query($query))) return $arr; ! while($row = mysql_fetch_assoc($res)) { $row["cloneId"] = substr($row["cloneId"], 1); --- 656,660 ---- $arr = array(); if(!($res = query($query))) return $arr; ! while($row =& db_fetch_assoc($res)) { $row["cloneId"] = substr($row["cloneId"], 1); Index: newinit.inc.php =================================================================== RCS file: /cvsroot/basedb/basedb/www/newinit.inc.php,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** newinit.inc.php 29 Aug 2002 16:51:34 -0000 1.9 --- newinit.inc.php 7 Sep 2002 11:36:32 -0000 1.10 *************** *** 38,42 **** $sec ^ (getmypid() << 16)); ! $curDb = new luDatabase($config["dbHost"], $config["dbUser"], $config["dbPassword"], $config["dbDatabase"]); unset($config["dbPassword"]); // Perfectly normal paranoia --- 38,42 ---- $sec ^ (getmypid() << 16)); ! $curDb = new BaseDatabase($config["dbHost"], $config["dbUser"], $config["dbPassword"], $config["dbDatabase"]); unset($config["dbPassword"]); // Perfectly normal paranoia Index: news.inc.php =================================================================== RCS file: /cvsroot/basedb/basedb/www/news.inc.php,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** news.inc.php 29 Aug 2002 16:51:34 -0000 1.4 --- news.inc.php 7 Sep 2002 11:36:32 -0000 1.5 *************** *** 44,54 **** function getLatest($count, $from = 0) { - $count = (int)$count; - $from = (int)$from; $query = "SELECT * FROM News ORDER BY addedDate DESC ". ! "LIMIT $from, $count"; $res = query($query); $arr = array(); ! while($row = mysql_fetch_array($res)) { $arr[] = new News($row["name"], $row["descr"], $row["owner"], --- 44,52 ---- function getLatest($count, $from = 0) { $query = "SELECT * FROM News ORDER BY addedDate DESC ". ! db_limit((int)$from, (int)$count); $res = query($query); $arr = array(); ! while($row =& db_fetch_assoc($res)) { $arr[] = new News($row["name"], $row["descr"], $row["owner"], *************** *** 70,74 **** "WHERE 1 ".$search->getWhere(); $res = query($query); ! if($row = mysql_fetch_row($res)) $cnt = $row[0]; else $cnt = 0; $search->setHits($cnt); --- 68,72 ---- "WHERE 1 ".$search->getWhere(); $res = query($query); ! if($row =& db_fetch_row($res)) $cnt = $row[0]; else $cnt = 0; $search->setHits($cnt); *************** *** 90,94 **** $arr = array(); $res = query($query); ! while($row = mysql_fetch_array($res)) $arr[] = $row; return $arr; } --- 88,92 ---- $arr = array(); $res = query($query); ! while($row =& db_fetch_assoc($res)) $arr[] = $row; return $arr; } *************** *** 98,102 **** $query = "SELECT COUNT(*) FROM News"; $res = query($query); ! if($row = mysql_fetch_array($res)) return $row[0]; return 0; } --- 96,100 ---- $query = "SELECT COUNT(*) FROM News"; $res = query($query); ! if($row =& db_fetch_assoc($res)) return $row[0]; return 0; } Index: plate.inc.php =================================================================== RCS file: /cvsroot/basedb/basedb/www/plate.inc.php,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -d -r1.27 -r1.28 *** plate.inc.php 29 Aug 2002 16:51:34 -0000 1.27 --- plate.inc.php 7 Sep 2002 11:36:32 -0000 1.28 *************** *** 67,71 **** { $query = "SELECT pt.* FROM PlateType pt ". ! "WHERE pt.wells = ".(int)$wells." LIMIT 1"; return $this->readQuery($query); } --- 67,71 ---- { $query = "SELECT pt.* FROM PlateType pt ". ! "WHERE pt.wells = ".(int)$wells." ".db_limit(0, 1); return $this->readQuery($query); [...737 lines suppressed...] return $arr; --- 948,952 ---- if(!$res) return false; $arr = array(); ! while($row =& db_fetch_row($res)) $arr[] = $row[0]; return $arr; *************** *** 961,965 **** if(!$res) return false; $wells = array(); ! while($row = mysql_fetch_assoc($res)) $wells[$row["id"]] = $row; --- 967,971 ---- if(!$res) return false; $wells = array(); ! while($row =& db_fetch_assoc($res)) $wells[$row["id"]] = $row; Index: plot.inc.php =================================================================== RCS file: /cvsroot/basedb/basedb/www/plot.inc.php,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** plot.inc.php 29 Aug 2002 16:51:34 -0000 1.18 --- plot.inc.php 7 Sep 2002 11:36:32 -0000 1.19 *************** *** 486,490 **** { $query = "SELECT $ex1, $ex2 FROM $table1, $table2 ". ! "WHERE t1.orderNumber = t2.orderNumber"; } $query .= " AND t1.".($a1->type == "v" ? "bioAssay" : "rawBioAssay"). --- 486,490 ---- { $query = "SELECT $ex1, $ex2 FROM $table1, $table2 ". ! "WHERE t1.position = t2.position"; } $query .= " AND t1.".($a1->type == "v" ? "bioAssay" : "rawBioAssay"). *************** *** 507,511 **** if($rotMode) { ! while($row = mysql_fetch_row($res)) { if($row[0] === NULL || $row[1] === NULL) continue; --- 507,511 ---- if($rotMode) { ! while($row =& db_fetch_row($res)) { if($row[0] === NULL || $row[1] === NULL) continue; *************** *** 515,519 **** } } ! else while($row = mysql_fetch_row($res)) { if($row[0] === NULL || $row[1] === NULL) continue; --- 515,519 ---- } } ! else while($row =& db_fetch_row($res)) { if($row[0] === NULL || $row[1] === NULL) continue; Index: program.inc.php =================================================================== RCS file: /cvsroot/basedb/basedb/www/program.inc.php,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** program.inc.php 31 Aug 2002 11:36:20 -0000 1.18 --- program.inc.php 7 Sep 2002 11:36:32 -0000 1.19 *************** *** 70,74 **** if(!query($query)) return false; $query = "DELETE FROM Program WHERE id = $this->id"; ! if(!query($query) || mysql_affected_rows() < 1) return false; return true; } --- 70,74 ---- if(!query($query)) return false; $query = "DELETE FROM Program WHERE id = $this->id"; ! if(!query($query) || db_affected_rows() < 1) return false; return true; [...89 lines suppressed...] ! while($row =& db_fetch_assoc($res)) $arr[] = $row; return $arr; } *************** *** 289,295 **** function isInUse() { ! $query = "SELECT 1 FROM Job WHERE program = $this->id LIMIT 1"; $res = query($query); ! if(!$res || mysql_num_rows($res) < 1) return false; return true; } --- 289,295 ---- function isInUse() { ! $query = "SELECT 1 FROM Job WHERE program = $this->id ".db_limit(0, 1); $res = query($query); ! if(!$res || db_num_rows($res) < 1) return false; return true; } Index: protocol.inc.php =================================================================== RCS file: /cvsroot/basedb/basedb/www/protocol.inc.php,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** protocol.inc.php 29 Aug 2002 16:51:34 -0000 1.6 --- protocol.inc.php 7 Sep 2002 11:36:32 -0000 1.7 *************** *** 48,52 **** "WHERE id = $this->id"; $res = query($query); ! if($row = mysql_fetch_array($res)) { $this->id = (int)$row["id"]; --- 48,52 ---- "WHERE id = $this->id"; $res = query($query); ! if($row =& db_fetch_assoc($res)) { [...149 lines suppressed...] --- 247,251 ---- } $res = query($query); ! return db_num_rows($res) == 1; } *************** *** 263,267 **** "AND p.id = ".(int)$id; $res = query($query); ! return mysql_num_rows($res) == 1; } } --- 256,260 ---- "AND p.id = ".(int)$id; $res = query($query); ! return db_num_rows($res) == 1; } } Index: raw.inc.php =================================================================== RCS file: /cvsroot/basedb/basedb/www/raw.inc.php,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** raw.inc.php 29 Aug 2002 16:51:34 -0000 1.30 --- raw.inc.php 7 Sep 2002 11:36:32 -0000 1.31 *************** *** 74,78 **** { $query = "DELETE FROM RawBioAssay WHERE id = $this->id"; ! if(!query($query) || mysql_affected_rows() <= 0) return false; ImageAcquisition::unlockId($this->imageAcquisition, false); --- 74,78 ---- { $query = "DELETE FROM RawBioAssay WHERE id = $this->id"; ! if(!query($query) || db_affected_rows() <= 0) return false; [...306 lines suppressed...] } --- 753,757 ---- } $res2 = query($query); ! if($row2 =& db_fetch_row($res2)) $row[3] = $row2[0]; else $row[3] = false; } *************** *** 765,769 **** "WHERE id = $this->imageAcquisition"; $res = query($query); ! if($row = mysql_fetch_row($res)) return $row[0]; return 0; } --- 771,775 ---- "WHERE id = $this->imageAcquisition"; $res = query($query); ! if($row =& db_fetch_row($res)) return $row[0]; return 0; } Index: sampleannotation.inc.php =================================================================== RCS file: /cvsroot/basedb/basedb/www/sampleannotation.inc.php,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** sampleannotation.inc.php 29 Aug 2002 16:51:34 -0000 1.14 --- sampleannotation.inc.php 7 Sep 2002 11:36:32 -0000 1.15 *************** *** 46,50 **** $query = "SELECT * FROM SampleAnnotationType WHERE id = $id"; $res = query($query); ! if($row = mysql_fetch_array($res)) { $this->id = (int)$row["id"]; --- 46,50 ---- $query = "SELECT * FROM SampleAnnotationType WHERE id = $id"; $res = query($query); ! if($row =& db_fetch_assoc($res)) { [...168 lines suppressed...] --- 266,271 ---- $arr = array(); $res = query($query); ! while($row =& db_fetch_assoc($res)) ! $arr[$row["id"]] = $row; return $arr; } *************** *** 286,290 **** $arr = array(); $res = query($query); ! while($row = mysql_fetch_row($res)) $arr[$row[0]] = $row[1]; return $arr; --- 279,283 ---- $arr = array(); $res = query($query); ! while($row =& db_fetch_row($res)) $arr[$row[0]] = $row[1]; return $arr; Index: sampletissue.inc.php =================================================================== RCS file: /cvsroot/basedb/basedb/www/sampletissue.inc.php,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** sampletissue.inc.php 5 Aug 2002 11:29:35 -0000 1.6 --- sampletissue.inc.php 7 Sep 2002 11:36:32 -0000 1.7 *************** *** 43,52 **** $query = "SELECT * FROM SampleTissue WHERE id = $id"; $res = query($query); ! if($row = mysql_fetch_array($res)) { $this->id = (int)$row["id"]; $this->parent = (int)$row["parent"]; $this->name = $row["name"]; - mysql_free_result($res); return true; } [...116 lines suppressed...] } --- 180,184 ---- } else $id = 0; ! unset($res); if(!$id) break; } *************** *** 192,196 **** $query = "SELECT COUNT(*) FROM SampleTissue WHERE parent = $this->id"; $res = query($query); ! if($row = mysql_fetch_row($res)) return (bool)$row[0]; return false; } --- 192,196 ---- $query = "SELECT COUNT(*) FROM SampleTissue WHERE parent = $this->id"; $res = query($query); ! if($row =& db_fetch_row($res)) return (bool)$row[0]; return false; } Index: search.inc.php =================================================================== RCS file: /cvsroot/basedb/basedb/www/search.inc.php,v retrieving revision 1.33 retrieving revision 1.34 diff -C2 -d -r1.33 -r1.34 *** search.inc.php 29 Aug 2002 16:51:34 -0000 1.33 --- search.inc.php 7 Sep 2002 11:36:32 -0000 1.34 *************** *** 118,122 **** { $res = query($query); ! if($row = mysql_fetch_array($res)) { $this->search = (int)$row["search"]; --- 118,122 ---- { $res = query($query); ! if($row =& db_fetch_assoc($res)) { [...221 lines suppressed...] } else if($type == SEARCH_LIKESTRINGLIKE) { + $arr[$j] = (string)$arr[$j]; // if($wc) $arr[$j] = "%$arr[$j]%"; } *************** *** 991,995 **** $view[] = $s; } ! else error_log("Invalid field type $type in search $this->search"); } $this->translated =& $arr; --- 1001,1006 ---- $view[] = $s; } ! else ! error_log("Invalid field type $type in search $this->search"); } $this->translated =& $arr; Index: session.inc.php =================================================================== RCS file: /cvsroot/basedb/basedb/www/session.inc.php,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** session.inc.php 29 Aug 2002 16:51:34 -0000 1.3 --- session.inc.php 7 Sep 2002 11:36:32 -0000 1.4 *************** *** 47,51 **** if($ip != "") $query .= "AND IP = '".addslashes($ip)."'"; $res = query($query); ! if($row = mysql_fetch_array($res)) { $this->cookie = $row["cookie"]; --- 47,51 ---- if($ip != "") $query .= "AND IP = '".addslashes($ip)."'"; $res = query($query); ! if($row =& db_fetch_assoc($res)) { $this->cookie = $row["cookie"]; *************** *** 54,58 **** $this->IP = $row["IP"]; $this->exists = 1; - mysql_free_result($res); return true; } --- 54,57 ---- *************** *** 91,95 **** if($ip != "") $query .= " AND IP = '".addslashes($ip)."'"; query($query); ! return mysql_affected_rows() == 1; } --- 90,94 ---- if($ip != "") $query .= " AND IP = '".addslashes($ip)."'"; query($query); ! return db_affected_rows() == 1; } *************** *** 100,104 **** query($query); $this->exists = 0; ! return mysql_affected_rows() == 1; } --- 99,103 ---- query($query); $this->exists = 0; ! return db_affected_rows() == 1; } *************** *** 204,208 **** $query = "SELECT COUNT(DISTINCT owner) FROM Cookie"; $res = query($query); ! if($row = mysql_fetch_row($res)) return $row[0]; return 0; } --- 203,207 ---- $query = "SELECT COUNT(DISTINCT owner) FROM Cookie"; $res = query($query); ! if($row =& db_fetch_row($res)) return $row[0]; return 0; } *************** *** 214,218 **** $res = query($query); $arr = array(); ! while($row = mysql_fetch_row($res)) $arr[] = $row[0]; return $arr; } --- 213,217 ---- $res = query($query); $arr = array(); ! while($row =& db_fetch_row($res)) $arr[] = $row[0]; return $arr; } Index: test.phtml =================================================================== RCS file: /cvsroot/basedb/basedb/www/test.phtml,v retrieving revision 1.46 retrieving revision 1.47 diff -C2 -d -r1.46 -r1.47 *** test.phtml 5 Aug 2002 11:29:35 -0000 1.46 --- test.phtml 7 Sep 2002 11:36:32 -0000 1.47 *************** *** 24,30 **** // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // ! // header("content-type: text/plain"); - phpinfo(); ?> --- 24,75 ---- // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // ! header("content-type: text/plain"); ! ! require_once("init.inc.php"); ! ! echo "Testing db...\n"; ! ob_implicit_flush(1); ! $s = array(0, 0, 0); ! for($j = 0; $j < 5; $j++) ! { ! $t = array(); ! $query = "SELECT * FROM Molecule"; ! $res = query($query); ! $t[0] = microtime(); ! while($row =& mysql_fetch_assoc($res)) ; ! $t[1] = microtime(); ! ! $query = "SELECT * FROM Molecule"; ! $res = query($query); ! $t[2] = microtime(); ! while($row = db_fetch_assoc($res)) ; ! $t[3] = microtime(); ! ! $query = "SELECT * FROM Molecule"; ! $res = query($query); ! $t[4] = microtime(); ! while($row =& db_fetch_assoc($res)) ; ! $t[5] = microtime(); ! ! for($i = 0; $i < 6; $i++) ! { ! $t[$i] = explode(" ", $t[$i]); ! $t[$i] = $t[$i][0] + $t[$i][1]; ! } ! $d0 = $t[1]-$t[0]; ! $d1 = $t[3]-$t[2]; ! $d2 = $t[5]-$t[4]; ! $s[0] += $d0; ! $s[1] += $d1; ! $s[2] += $d2; ! echo "&mysql_fetch_assoc: $d0 s\n"; ! echo "db_fetch_assoc2: $d1 s\n"; ! echo "&db_fetch_assoc2: $d2 s\n"; ! } ! echo "\n\nAverages:\n"; ! echo "&mysql_fetch_assoc: $s[0] s\n"; ! echo "db_fetch_assoc2: $s[1] s\n"; ! echo "&db_fetch_assoc2: $s[2] s\n"; ?> Index: transformation.inc.php =================================================================== RCS file: /cvsroot/basedb/basedb/www/transformation.inc.php,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** transformation.inc.php 29 Aug 2002 16:51:34 -0000 1.12 --- transformation.inc.php 7 Sep 2002 11:36:32 -0000 1.13 *************** *** 77,81 **** "WHERE transformation = $this->id"; $res = query($query); ! while($row = mysql_fetch_row($res)) if(!BioAssaySet::removeId($row[0])) $rc = false; if(!$rc) return false; --- 77,81 ---- "WHERE transformation = $this->id"; $res = query($query); ! while($row =& db_fetch_row($res)) if(!BioAssaySet::removeId($row[0])) $rc = false; [...98 lines suppressed...] } --- 220,224 ---- "AND bas.experiment = $expid"; $res = query($query); ! if($row =& db_fetch_row($res)) return true; return false; } *************** *** 229,233 **** "WHERE p.id = j.program AND j.transformation = ".(int)$id; $res = query($query); ! if($row = mysql_fetch_row($res)) return $row[0]; return ""; } --- 229,233 ---- "WHERE p.id = j.program AND j.transformation = ".(int)$id; $res = query($query); ! if($row =& db_fetch_row($res)) return $row[0]; return ""; } Index: upload.inc.php =================================================================== RCS file: /cvsroot/basedb/basedb/www/upload.inc.php,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** upload.inc.php 29 Aug 2002 16:51:34 -0000 1.18 --- upload.inc.php 7 Sep 2002 11:36:32 -0000 1.19 *************** *** 68,72 **** $query = "DELETE FROM Upload WHERE id = $this->id AND hidden = 0"; query($query); ! if(mysql_affected_rows() <= 0) $ret = false; else { --- 68,72 ---- $query = "DELETE FROM Upload WHERE id = $this->id AND hidden = 0"; query($query); ! if(db_affected_rows() <= 0) $ret = false; else [...85 lines suppressed...] $search->setHits($cnt); --- 292,296 ---- "WHERE !up.hidden ".$search->getExtraWhere()." ".$search->getWhere(); $res = query($query); ! if($row =& db_fetch_row($res)) $cnt = $row[0]; else $cnt = 0; $search->setHits($cnt); *************** *** 318,322 **** $arr = array(); $res = query($query); ! while($row = mysql_fetch_assoc($res)) $arr[] = $row; return $arr; } --- 318,322 ---- $arr = array(); $res = query($query); ! while($row =& db_fetch_assoc($res)) $arr[] = $row; return $arr; } Index: user.inc.php =================================================================== RCS file: /cvsroot/basedb/basedb/www/user.inc.php,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** user.inc.php 5 Aug 2002 11:31:53 -0000 1.4 --- user.inc.php 7 Sep 2002 11:36:32 -0000 1.5 *************** *** 59,63 **** { $res = query($query); ! if($row = mysql_fetch_assoc($res)) { $this->id = (int)$row["id"]; --- 59,63 ---- { $res = query($query); ! if($row =& db_fetch_assoc($res)) { [...95 lines suppressed...] else --- 360,364 ---- "WHERE 1 ".$search->getWhere(); $res = query($query); ! if($row =& db_fetch_row($res)) $cnt = $row[0]; else *************** *** 395,399 **** $arr = array(); $res = query($query); ! while($row = mysql_fetch_assoc($res)) $arr[] = $row; return $arr; --- 385,389 ---- $arr = array(); $res = query($query); ! while($row =& db_fetch_assoc($res)) $arr[] = $row; return $arr; Index: ware.inc.php =================================================================== RCS file: /cvsroot/basedb/basedb/www/ware.inc.php,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** ware.inc.php 29 Aug 2002 16:51:34 -0000 1.7 --- ware.inc.php 7 Sep 2002 11:36:32 -0000 1.8 *************** *** 50,54 **** $id = (int)$id; $query = "DELETE FROM $type WHERE id = $id"; ! if(!query($query) || mysql_affected_rows() != 1) return false; return true; --- 50,54 ---- $id = (int)$id; $query = "DELETE FROM $type WHERE id = $id"; ! if(!query($query) || db_affected_rows() != 1) return false; return true; *************** *** 94,98 **** $search->getWhere()." ".$search->getExtraWhere(); $res = query($query); ! if($row = mysql_fetch_row($res)) $cnt = $row[0]; else $cnt = 0; $search->setHits($cnt); --- 94,98 ---- $search->getWhere()." ".$search->getExtraWhere(); $res = query($query); ! if($row =& db_fetch_row($res)) $cnt = $row[0]; else $cnt = 0; $search->setHits($cnt); *************** *** 116,120 **** $arr = array(); if(!($res = query($query))) return $arr; ! while($row = mysql_fetch_array($res)) $arr[] = $row; return $arr; } --- 116,120 ---- $arr = array(); if(!($res = query($query))) return $arr; ! while($row =& db_fetch_assoc($res)) $arr[] = $row; return $arr; } *************** *** 159,163 **** "WHERE id = ".(int)$id; $res = query($query); ! if($row = mysql_fetch_assoc($res)) return $row; return false; } --- 159,163 ---- "WHERE id = ".(int)$id; $res = query($query); ! if($row =& db_fetch_assoc($res)) return $row; return false; } *************** *** 169,173 **** $res = query($query); $arr = array(); ! while($row = mysql_fetch_assoc($res)) $arr[$row["id"]] = $row; return $arr; } --- 169,173 ---- $res = query($query); $arr = array(); ! while($row =& db_fetch_assoc($res)) $arr[$row["id"]] = $row; return $arr; } *************** *** 226,230 **** "WHERE id = ".(int)$id; $res = query($query); ! if($row = mysql_fetch_assoc($res)) return $row; return false; } --- 226,230 ---- "WHERE id = ".(int)$id; $res = query($query); ! if($row =& db_fetch_assoc($res)) return $row; return false; } *************** *** 236,240 **** $res = query($query); $arr = array(); ! while($row = mysql_fetch_assoc($res)) $arr[$row["id"]] = $row; return $arr; } --- 236,240 ---- $res = query($query); $arr = array(); ! while($row =& db_fetch_assoc($res)) $arr[$row["id"]] = $row; return $arr; } Index: wizzzard.inc.php =================================================================== RCS file: /cvsroot/basedb/basedb/www/wizzzard.inc.php,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** wizzzard.inc.php 29 Aug 2002 16:51:34 -0000 1.23 --- wizzzard.inc.php 7 Sep 2002 11:36:32 -0000 1.24 *************** *** 60,68 **** $query = "SELECT * FROM Wizzzard WHERE id = $this->id"; $res = query($query); ! if($row = mysql_fetch_array($res)) { $vars = array("id", "owner", "etype", "name", "numCols", "extraCols", "dataHeader", "typeHeader", "typeHeaderLine", "mapping"); ! for($i = 0; $i < count($vars); $i++) $this->$vars[$i] = $row[$vars[$i]]; } else --- 60,69 ---- [...124 lines suppressed...] } function useF($wizid, $ownerid) { ! $query = "INSERT INTO WizzzardUser (owner, wizzzard) VALUES ". "(".(int)$ownerid.", ".(int)$wizid.")"; query($query); *************** *** 713,717 **** $query = "SELECT owner FROM Wizzzard WHERE id = ".(int)$id; $res = query($query); ! if($row = mysql_fetch_row($res)) return $row[0] == (int)$owner; return false; } --- 713,717 ---- $query = "SELECT owner FROM Wizzzard WHERE id = ".(int)$id; $res = query($query); ! if($row =& db_fetch_row($res)) return $row[0] == (int)$owner; return false; } |
From: <tr...@us...> - 2002-09-07 11:34:20
|
Update of /cvsroot/basedb/basedb In directory usw-pr-cvs1:/tmp/cvs-serv22642 Modified Files: base.sql Log Message: Renamed columns and did other changes for postgresql compatibility Index: base.sql =================================================================== RCS file: /cvsroot/basedb/basedb/base.sql,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** base.sql 10 Jul 2002 17:57:32 -0000 1.6 --- base.sql 7 Sep 2002 11:34:17 -0000 1.7 *************** *** 33,37 **** printStartDate datetime NOT NULL default '0000-00-00 00:00:00', printEndDate datetime NOT NULL default '0000-00-00 00:00:00', ! user int(11) NOT NULL default '0', name varchar(40) NOT NULL default '', addedDate date NOT NULL default '0000-00-00', --- 33,37 ---- printStartDate datetime NOT NULL default '0000-00-00 00:00:00', printEndDate datetime NOT NULL default '0000-00-00 00:00:00', ! owner int(11) NOT NULL default '0', name varchar(40) NOT NULL default '', [...939 lines suppressed...] ! KEY usertype (owner,etype) ) TYPE=MyISAM; *************** *** 1160,1166 **** CREATE TABLE WizzzardUser ( wizzzard int(11) NOT NULL default '0', ! user int(11) NOT NULL default '0', ! PRIMARY KEY (wizzzard,user), ! KEY user (user) ) TYPE=MyISAM; --- 1197,1203 ---- CREATE TABLE WizzzardUser ( wizzzard int(11) NOT NULL default '0', ! owner int(11) NOT NULL default '0', ! PRIMARY KEY (wizzzard,owner), ! KEY owner (owner) ) TYPE=MyISAM; |
From: <tr...@us...> - 2002-09-07 11:32:06
|
Update of /cvsroot/basedb/basedb/exec/migration_tools In directory usw-pr-cvs1:/tmp/cvs-serv22206 Modified Files: dbmigrate.php Log Message: Added schema versions 1.1.1 and 1.1.2 Index: dbmigrate.php =================================================================== RCS file: /cvsroot/basedb/basedb/exec/migration_tools/dbmigrate.php,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** dbmigrate.php 30 Aug 2002 10:18:37 -0000 1.8 --- dbmigrate.php 7 Sep 2002 11:32:02 -0000 1.9 *************** *** 39,44 **** // Add new versions here, and further down add functions like the // existing ones. ! $versions = array("1.0.1", "1.0.1a", "1.0.1b", "1.0.2", "1.1.1"); ! $lastVersion = "1.1.1"; require_once("../getconfig2.inc.php"); --- 39,45 ---- // Add new versions here, and further down add functions like the // existing ones. ! $versions = array("1.0.1", "1.0.1a", "1.0.1b", "1.0.2", "1.1.1", ! "1.1.2"); ! $lastVersion = "1.1.2"; require_once("../getconfig2.inc.php"); *************** *** 48,52 **** // Open database connection ! $curDb = new luDatabase($config["dbHost"], $config["dbUser"], $config["dbPassword"], $config["dbDatabase"]); unset($config["dbPassword"]); --- 49,53 ---- // Open database connection ! $curDb = new BaseDatabase($config["dbHost"], $config["dbUser"], $config["dbPassword"], $config["dbDatabase"]); unset($config["dbPassword"]); *************** *** 352,355 **** --- 353,412 ---- return ""; } + + + function migrateFrom_1_1_1(&$version) + { + $query = "ALTER TABLE HybridizedLabeled ". + "CHANGE position position tinyint(4) NOT NULL default '0'"; + if(!myquery($query)) + return "Failed to remove auto_increment from HybridizedLabeled"; + + $query = "ALTER TABLE RawBioAssayData ". + "CHANGE position position mediumint(9) NOT NULL default '0'"; + if(!myquery($query)) + return "Failed to remove auto_increment from RawBioAssayData"; + + $query = "ALTER TABLE TemplateBioAssayData ". + "CHANGE position position mediumint(9) NOT NULL default '0'"; + if(!myquery($query)) + return "Failed to remove auto_increment from TemplateBioAssayData"; + + $query = "ALTER TABLE ImageAcquisition + ADD spotImage int(11) default NULL, + ADD spotXOffset int(11) NOT NULL default '0', + ADD spotYOffset int(11) NOT NULL default '0', + ADD spotScale float NOT NULL default '0'"; + if(!myquery($query)) + return "Failed to add spot image columns to ImageAcquisition"; + + $query = "CREATE TABLE TemplateGeneListTemp ( + molecule int(11) NOT NULL default '0', + score int(11) NOT NULL auto_increment, + PRIMARY KEY (score) + ) TYPE=MyISAM"; + if(!myquery($query)) + return "Failed to create table TemplateGeneListTemp"; + + $query = "UPDATE SchemaVersion + SET baseVersion = '1.1', schemaVersion = '1.1.2', + lastChanged = NOW()"; + if(!myquery($query) || mysql_affected_rows() < 1) + return "Can't update SchemaVersion table"; + + $version = "1.1.2"; + return ""; + } + + + + + + + + + + + + /* function migrateFrom_1_1_1(&$version) |
Update of /cvsroot/basedb/basedb/exec/source/spotimage/tifftopnm In directory usw-pr-cvs1:/tmp/cvs-serv30058 Added Files: Makefile README shhopt.README shhopt.c shhopt.h tifftopnm.README tifftopnm.c Log Message: Added workng version of tifftopnm --- NEW FILE: Makefile --- FILES = tifftopnm FLAGS = -c -O3 -Wall C = gcc CC = g++ LDFLAGS = SOURCE = tifftopnm.c shhopt.c OBJ_TTP = tifftopnm.o shhopt.o OBJ_ALL = Makedep.rule $(OBJ_TTP) all: $(FILES) .cc.o: $(CC) $(FLAGS) -o $@ $< .c.o: $(C) $(FLAGS) -o $@ $< clean: rm -f $(OBJ_ALL) $(FILES) *~ touch -d20020101 Makedep.rule depend: $(CC) $(FLAGS) -MM $(SOURCE) >Makedep.rule Makedep.rule: Makefile @echo "The makefile has changed since the last 'make depend'." install: cp $(FILES) ../../extras # Dependencies for executables tifftopnm: $(OBJ_TTP) $(C) $(LDFLAGS) -o $@ $(OBJ_TTP) -lpnm -ltiff # Dependencies for object files include Makedep.rule --- NEW FILE: README --- tifftopnm, a part of the netpbm package (http://netpbm.sourceforge.net/), has been malfunctioning when applied to TIFF files with 16 bits per pixel ever since version 9.17. The source for version 10.8 says: Before Netpbm 9.17, this program assumed that scanbuf[] contained an array of bytes as read from the Tiff file. In fact, in this bps == 16 case, it's an array of "shorts", each stored in whatever format this platform uses (which is none of our concern). The pre-9.17 code also presumed that the TIFF "FILLORDER" tag determined the order in which the bytes of each sample appear in a TIFF file, which is contrary to the TIFF spec. However, it turns out that version 9.16 produces the correct output with the TIFF files I've seen, so something is wrong somewhere and the easy solution to the problem is to use the pre-9.17 code. The version included here is based on 10.8, but the part that deals with the 16-bit case is taken from 9.16. I've also done a couple of changes to get rid of warnings about possibly uninitialized variables. //Carl Troein <ca...@th...> 2002-09-06 --- NEW FILE: shhopt.README --- shhopt was originally written by Sverre H. Huseby, and extended by Bryan Henderson in March 2000 for use in Neptbm. Below is the README file from Huseby's package. The following changes were made to shhopt for Netpbm: - OPT_FLOAT (floating point number) data type added - optParseOptions2() added. Advantages over optParseOptions(): You can have a syntax where there is no such thing as a short option (e.g. -a. Maybe stacked like -tanp). Then the long options can have either 1 or 2 dashes (e.g. -width or --width). Of course, -w could be an abbreviation of -width; that's not the same thing as a short option. - optParseOptions3() added. Advantages over optParseOptions2(): Tells you whether (how many times, actually) an option was specified - no need to play games with defaults. Also, no need [...154 lines suppressed...] Author ------ The program is written by Sverre H. Huseby sve...@on... Lofthusvn. 11 B http://home.sol.no/~sverrehu/ N-0587 Oslo Norway You can use and copy this for _free_, but I would be very happy if you send me an E-mail and tell me that you use it. If you insist on paying something, please donate some money to an organization that strives to make the world a better place for everyone. I don't like bugs, so please help me removing them by reporting whatever you find! --- NEW FILE: shhopt.c --- /* $Id: shhopt.c,v 1.1 2002/09/06 12:28:30 troein Exp $ */ /*------------------------------------------------------------------------ | FILE shhopt.c | | DESCRIPTION Functions for parsing command line arguments. Values | of miscellaneous types may be stored in variables, | or passed to functions as specified. | | REQUIREMENTS Some systems lack the ANSI C -function strtoul. If your | system is one of those, you'll ned to write one yourself, | or get the GNU liberty-library (from prep.ai.mit.edu). | | WRITTEN BY Sverre H. Huseby <sve...@on...> +----------------------------------------------------------------------*/ /************************************************************************* This is based on work by Sverre H. Huseby <sve...@on...>, released by him into the public domain in 1999. These functions are backward compatible with the 'shhopt' distributed by Huseby. [...773 lines suppressed...] if (opt.short_allowed) { /* It's a cluster of (one or more) short options */ parse_short_option_token(argv, *argc_p, ai, opt.opt_table, &tokens_consumed); } else { /* It's a long option that starts with "-" */ parse_long_option(argv, *argc_p, ai, 1, opt.opt_table, &tokens_consumed); } } /* remove option and any argument from the argv-array. */ { int i; for (i = 0; i < tokens_consumed; i++) argvRemove(argc_p, argv, ai); } } } } --- NEW FILE: shhopt.h --- /*============================================================================== HERE IS AN EXAMPLE OF THE USE OF SHHOPT: #include <shhopt.h> int main ( int argc, char **argv ) { int help_flag = 7; unsigned int help_spec =7; unsigned int height_spec =7; unsigned int name_spec= 7; char *name= "initial"; int height=7; int verbose_flag=7; int debug_flag=7; optStruct3 opt; unsigned int option_def_index = 0; [...176 lines suppressed...] void optSetFatalFunc(void (*f)(const char *, ...)); void optParseOptions(int *argc, char *argv[], optStruct opt[], int allowNegNum); void optParseOptions2(int * const argc_p, char *argv[], const optStruct2 opt, const unsigned long flags); void optParseOptions3(int * const argc_p, char *argv[], const optStruct3 opt, const unsigned int optStructSize, const unsigned long flags); #ifdef __cplusplus } #endif #endif --- NEW FILE: tifftopnm.README --- tifftopnm.c - converts a Tagged Image File to a portable anymap Derived by Jef Poskanzer from tif2ras.c, which is: Copyright (c) 1990 by Sun Microsystems, Inc. Author: Patrick J. Naughton nau...@wi... Permission to use, copy, modify, and distribute this software and its documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting documentation. This file is provided AS IS with no warranties of any kind. The author shall have no liability with respect to the infringement of copyrights, trade secrets or any patents by this file or any part thereof. In no event will the author be liable for any lost revenue or profits or other special, indirect and consequential damages. --- NEW FILE: tifftopnm.c --- /* ** tifftopnm.c - converts a Tagged Image File to a portable anymap ** ** Derived by Jef Poskanzer from tif2ras.c, which is: ** ** Copyright (c) 1990 by Sun Microsystems, Inc. ** ** Author: Patrick J. Naughton ** nau...@wi... ** ** Permission to use, copy, modify, and distribute this software and its ** documentation for any purpose and without fee is hereby granted, ** provided that the above copyright notice appear in all copies and that ** both that copyright notice and this permission notice appear in ** supporting documentation. ** ** This file is provided AS IS with no warranties of any kind. The author ** shall have no liability with respect to the infringement of copyrights, ** trade secrets or any patents by this file or any part thereof. In no [...738 lines suppressed...] if (imageoutFile != NULL) pnm_writepnminit( imageoutFile, cols, rows, (xelval) maxval, format, 0 ); if (alphaFile != NULL) pgm_writepgminit( alphaFile, cols, rows, (gray) maxval, 0 ); convertRaster(imageoutFile, alphaFile, cols, rows, maxval, format, tif, photomet, planarconfig, bps, spp, fillorder, colormap); if (imageoutFile != NULL) pm_close( imageoutFile ); if (alphaFile != NULL) pm_close( alphaFile ); /* If the program failed, it previously aborted with nonzero completion code, via various function calls. */ return 0; } |
From: <tr...@us...> - 2002-09-06 12:26:57
|
Update of /cvsroot/basedb/basedb/exec/source/spotimage/tifftopnm In directory usw-pr-cvs1:/tmp/cvs-serv29619/tifftopnm Log Message: Directory /cvsroot/basedb/basedb/exec/source/spotimage/tifftopnm added to the repository |
From: <tr...@us...> - 2002-09-06 12:26:49
|
Update of /cvsroot/basedb/basedb/exec/source/spotimage In directory usw-pr-cvs1:/tmp/cvs-serv29563 Modified Files: graystorgb.cc Log Message: Updated example to reflect program name change Index: graystorgb.cc =================================================================== RCS file: /cvsroot/basedb/basedb/exec/source/spotimage/graystorgb.cc,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** graystorgb.cc 29 Aug 2002 12:20:12 -0000 1.2 --- graystorgb.cc 6 Sep 2002 12:26:45 -0000 1.3 *************** *** 29,36 **** // other from file descriptor number five. // Example of how to use this program if you have two PGMs already: ! // $ spotimage <red.pnm 5<green.pnm >rgb.pnm // If you have a 2-image TIFF you can do this: ! // $ tiffsplit foo.tif ! // $ tifftopnm xab.tif | { tifftopnm xaa.tif | spotimage >rgb.pnm; } 5<&0 // $ rm xaa.tif xab.tif --- 29,36 ---- // other from file descriptor number five. // Example of how to use this program if you have two PGMs already: ! // $ graystorgb <red.pnm 5<green.pnm >rgb.pnm // If you have a 2-image TIFF you can do this: ! // $ graystorgb foo.tif ! // $ tifftopnm xab.tif | { tifftopnm xaa.tif | graystorgb >rgb.pnm; } 5<&0 // $ rm xaa.tif xab.tif |
From: <tr...@us...> - 2002-08-31 13:06:56
|
Update of /cvsroot/basedb/basedb/exec/source/clustering In directory usw-pr-cvs1:/tmp/cvs-serv19361 Modified Files: Makefile Log Message: Added unpacking and compiling of Cgraph Index: Makefile =================================================================== RCS file: /cvsroot/basedb/basedb/exec/source/clustering/Makefile,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** Makefile 20 Aug 2002 19:39:54 -0000 1.7 --- Makefile 31 Aug 2002 13:06:54 -0000 1.8 *************** *** 1,4 **** BINARIES = basehclust findsubtree drawmatrix drawgenetree drawassaytree ! FILES = $(BINARIES) clusteringscript clusteringscript cgraphdir = Cgraph --- 1,4 ---- BINARIES = basehclust findsubtree drawmatrix drawgenetree drawassaytree ! FILES = $(BINARIES) clusteringscript cgraphdir = Cgraph *************** *** 58,71 **** cp $(FILES) ../../apps # Dependencies for executables ! basehclust: $(OBJ_BHC) $(CC) -o $@ $(OBJ_BHC) $(LDFLAGS) ! findsubtree: $(OBJ_FST) $(CC) -o $@ $(OBJ_FST) $(LDFLAGS) ! drawmatrix: $(OBJ_DM) $(CC) -o $@ $(OBJ_DM) $(LDFLAGS) ! drawgenetree: $(OBJ_DGT) $(CC) -o $@ $(OBJ_DGT) $(LDFLAGS) ! drawassaytree: $(OBJ_DAT) $(CC) -o $@ $(OBJ_DAT) $(LDFLAGS) --- 58,75 ---- cp $(FILES) ../../apps + Cgraph: Cgraph2.04-working.tar.gz + tar -xzvf Cgraph2.04-working.tar.gz + make -C Cgraph + # Dependencies for executables ! basehclust: $(cgraphdir) $(OBJ_BHC) $(CC) -o $@ $(OBJ_BHC) $(LDFLAGS) ! findsubtree: $(cgraphdir) $(OBJ_FST) $(CC) -o $@ $(OBJ_FST) $(LDFLAGS) ! drawmatrix: $(cgraphdir) $(OBJ_DM) $(CC) -o $@ $(OBJ_DM) $(LDFLAGS) ! drawgenetree: $(cgraphdir) $(OBJ_DGT) $(CC) -o $@ $(OBJ_DGT) $(LDFLAGS) ! drawassaytree: $(cgraphdir) $(OBJ_DAT) $(CC) -o $@ $(OBJ_DAT) $(LDFLAGS) |
From: <tr...@us...> - 2002-08-31 13:06:34
|
Update of /cvsroot/basedb/basedb/exec/source/clustering In directory usw-pr-cvs1:/tmp/cvs-serv19312 Modified Files: .cvsignore Log Message: Added Cgraph Index: .cvsignore =================================================================== RCS file: /cvsroot/basedb/basedb/exec/source/clustering/.cvsignore,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** .cvsignore 14 Aug 2002 16:46:21 -0000 1.1 --- .cvsignore 31 Aug 2002 13:06:31 -0000 1.2 *************** *** 4,5 **** --- 4,6 ---- drawmatrix findsubtree + Cgraph |
From: <tr...@us...> - 2002-08-31 13:06:21
|
Update of /cvsroot/basedb/basedb/exec/source/clustering In directory usw-pr-cvs1:/tmp/cvs-serv19277 Added Files: Cgraph2.04-working.tar.gz Log Message: This version compiles on linux --- NEW FILE: Cgraph2.04-working.tar.gz --- (This appears to be a binary file; contents omitted.) |
Update of /cvsroot/basedb/basedb/exec/source/clustering/cgraph/docs In directory usw-pr-cvs1:/tmp/cvs-serv7196/docs Removed Files: cgraph.ps cgraph.wp dashlist.eps eofill.eps eofillTailor.eps eofillTailor2.eps fill.eps markerlist.eps Log Message: Removing old cgraph version --- cgraph.ps DELETED --- --- cgraph.wp DELETED --- --- dashlist.eps DELETED --- --- eofill.eps DELETED --- --- eofillTailor.eps DELETED --- --- eofillTailor2.eps DELETED --- --- fill.eps DELETED --- --- markerlist.eps DELETED --- |
From: <tr...@us...> - 2002-08-31 12:03:59
|
Update of /cvsroot/basedb/basedb/exec/source/clustering/cgraph In directory usw-pr-cvs1:/tmp/cvs-serv7196 Removed Files: cgraph.h libcgraph.a Log Message: Removing old cgraph version --- cgraph.h DELETED --- --- libcgraph.a DELETED --- |
From: <tr...@us...> - 2002-08-31 11:47:56
|
Update of /cvsroot/basedb/basedb/www In directory usw-pr-cvs1:/tmp/cvs-serv4004 Modified Files: job.inc.php Log Message: Changed missed 'user' to 'owner' Index: job.inc.php =================================================================== RCS file: /cvsroot/basedb/basedb/www/job.inc.php,v retrieving revision 1.31 retrieving revision 1.32 diff -C2 -d -r1.31 -r1.32 *** job.inc.php 29 Aug 2002 16:51:34 -0000 1.31 --- job.inc.php 31 Aug 2002 11:47:53 -0000 1.32 *************** *** 69,78 **** } ! function readOwned($id, $userid) { $id = (int)$id; ! $userid = (int)$userid; $query = "SELECT j.* FROM Job j, Experiment e ". ! "WHERE j.id = $id AND e.id = j.experiment AND e.user = $userid"; return $this->readQuery($query); } --- 69,78 ---- } ! function readOwned($id, $ownerid) { $id = (int)$id; ! $ownerid = (int)$ownerid; $query = "SELECT j.* FROM Job j, Experiment e ". ! "WHERE j.id = $id AND e.id = j.experiment AND e.owner = $ownerid"; return $this->readQuery($query); } |
From: <tr...@us...> - 2002-08-31 11:44:06
|
Update of /cvsroot/basedb/basedb/www In directory usw-pr-cvs1:/tmp/cvs-serv3384 Modified Files: program_edit.phtml Log Message: Fixed import. 'type' had been changed to 'valueType' where it shouldn't. Index: program_edit.phtml =================================================================== RCS file: /cvsroot/basedb/basedb/www/program_edit.phtml,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** program_edit.phtml 29 Aug 2002 16:51:34 -0000 1.20 --- program_edit.phtml 31 Aug 2002 11:44:03 -0000 1.21 *************** *** 514,518 **** $cN = isset($cols["name"]) ? $cols["name"] : -1; $cCN = isset($cols["commonName"]) ? $cols["commonName"] : -1; ! $cT = isset($cols["valueType"]) ? $cols["valueType"] : -1; $cO = isset($cols["options"]) ? $cols["options"] : -1; $cDV = isset($cols["defaultValue"]) ? $cols["defaultValue"] : -1; --- 514,518 ---- $cN = isset($cols["name"]) ? $cols["name"] : -1; $cCN = isset($cols["commonName"]) ? $cols["commonName"] : -1; ! $cT = isset($cols["type"]) ? $cols["type"] : -1; $cO = isset($cols["options"]) ? $cols["options"] : -1; $cDV = isset($cols["defaultValue"]) ? $cols["defaultValue"] : -1; |
From: <tr...@us...> - 2002-08-31 11:36:23
|
Update of /cvsroot/basedb/basedb/www In directory usw-pr-cvs1:/tmp/cvs-serv2094 Modified Files: program.inc.php Log Message: Changed type valueType in setParameter() Index: program.inc.php =================================================================== RCS file: /cvsroot/basedb/basedb/www/program.inc.php,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** program.inc.php 29 Aug 2002 16:51:34 -0000 1.17 --- program.inc.php 31 Aug 2002 11:36:20 -0000 1.18 *************** *** 174,178 **** } ! // Returns array position => array(name,commonName,type,options, // defaultValue,enumOptions) function getParameters() --- 174,178 ---- } ! // Returns array position => array(name,commonName,valueType,options, // defaultValue,enumOptions) function getParameters() *************** *** 202,216 **** } ! // Assumes the type to be valid. ! function setParameter($pos, $name, $commonName, $type, $options, $defaultValue, $enumOptions) { $query = "REPLACE INTO ProgramParameter ". ! "(program, position, name, commonName, type, options, ". "defaultValue, enumOptions) VALUES ". "($this->id, ".(int)$pos.", ". "'".addslashes($name)."', ". "'".addslashes($commonName)."', ". ! "'".addslashes($type)."', ". "'".addslashes($options)."', ". "'".addslashes($defaultValue)."', ". --- 202,216 ---- } ! // Assumes the valueType to be valid. ! function setParameter($pos, $name, $commonName, $valueType, $options, $defaultValue, $enumOptions) { $query = "REPLACE INTO ProgramParameter ". ! "(program, position, name, commonName, valueType, options, ". "defaultValue, enumOptions) VALUES ". "($this->id, ".(int)$pos.", ". "'".addslashes($name)."', ". "'".addslashes($commonName)."', ". ! "'".addslashes($valueType)."', ". "'".addslashes($options)."', ". "'".addslashes($defaultValue)."', ". |
From: <tr...@us...> - 2002-08-31 11:12:58
|
Update of /cvsroot/basedb/CVSROOT In directory usw-pr-cvs1:/tmp/cvs-serv29984 Modified Files: syncmail Log Message: Decreased maximum diff size Index: syncmail =================================================================== RCS file: /cvsroot/basedb/CVSROOT/syncmail,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** syncmail 21 Aug 2002 13:23:47 -0000 1.1 --- syncmail 31 Aug 2002 11:12:55 -0000 1.2 *************** *** 109,113 **** DIFF_HEAD_LINES = 20 DIFF_TAIL_LINES = 20 ! DIFF_TRUNCATE_IF_LARGER = 1000 EMPTYSTRING = '' --- 109,113 ---- DIFF_HEAD_LINES = 20 DIFF_TAIL_LINES = 20 ! DIFF_TRUNCATE_IF_LARGER = 100 EMPTYSTRING = '' |
Update of /cvsroot/basedb/basedb/exec/source/pca/gnuplot_i-2.6/html In directory usw-pr-cvs1:/tmp/cvs-serv28128/gnuplot_i-2.6/html Added Files: doxygen.css gnuplot_i_c-source.html gnuplot_i_c.html gnuplot_i_h-source.html gnuplot_i_h.html index.html struct__GNUPLOT_CTRL_.html Log Message: Added PCA plugin from Greg Voronin --- NEW FILE: doxygen.css --- H1 { text-align: center; } A.qindex {} A.qindexRef {} A.el { text-decoration: none; font-weight: bold } A.elRef { font-weight: bold } A.code { text-decoration: none; font-weight: normal; color: #4444ee } A.codeRef { font-weight: normal; color: #4444ee } DL.el { margin-left: -1cm } DIV.fragment { width: 100%; border: none; background-color: #eeeeee } DIV.ah { background-color: black; margin-bottom: 3; margin-top: 3 } TD.md { background-color: #f2f2ff } DIV.groupHeader { margin-left: 16; margin-top: 12; margin-bottom: 6; font-weight: bold } DIV.groupText { margin-left: 16; font-style: italic; font-size: smaller } FONT.keyword { color: #008000 } FONT.keywordtype { color: #604020 } FONT.keywordflow { color: #e08000 } FONT.comment { color: #800000 } FONT.preprocessor { color: #806020 } FONT.stringliteral { color: #002080 } FONT.charliteral { color: #008080 } --- NEW FILE: gnuplot_i_c-source.html --- <html> <head> <meta name="author" content="nde...@fr..."> <meta name="editor" content="nde...@fr..."> <meta name="maintainer" content="nde...@fr..."> <meta name="keywords" content="gnuplot, interface, ANSI C"> <link href="doxygen.css" rel="stylesheet" type="text/css"> <title>gnuplot_i 2.x</title> </head> <body text="#000000" bgcolor="#ffffff"> <!-- Generated by Doxygen 1.2.5 on Tue Oct 23 15:29:10 2001 --> <h1>gnuplot_i.c</h1><a href="gnuplot_i_c.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001 00002 00003 <font class="comment">/*-------------------------------------------------------------------------*/</font> 00017 <font class="comment">/*--------------------------------------------------------------------------*/</font> 00018 00019 <font class="comment">/*</font> 00020 <font class="comment"> $Id: gnuplot_i_c-source.html,v 1.1 2002/08/31 11:04:52 troein Exp $</font> 00021 <font class="comment"> $Author: troein $</font> 00022 <font class="comment"> $Date: 2002/08/31 11:04:52 $</font> 00023 <font class="comment"> $Revision: 1.1 $</font> 00024 <font class="comment"> */</font> 00025 00026 <font class="comment">/*---------------------------------------------------------------------------</font> 00027 <font class="comment"> Includes</font> 00028 <font class="comment"> ---------------------------------------------------------------------------*/</font> 00029 00030 <font class="preprocessor">#include "<a class="code" href="gnuplot_i_h.html">gnuplot_i.h</a>"</font> 00031 00032 <font class="comment">/*---------------------------------------------------------------------------</font> 00033 <font class="comment"> Defines</font> 00034 <font class="comment"> ---------------------------------------------------------------------------*/</font> 00035 00037 <font class="preprocessor">#define GP_CMD_SIZE 2048</font> 00038 <font class="preprocessor"></font> 00039 <font class="preprocessor">#define GP_TITLE_SIZE 80</font> 00040 <font class="preprocessor"></font> 00041 <font class="preprocessor">#define GP_EQ_SIZE 512</font> 00042 <font class="preprocessor"></font> 00043 <font class="preprocessor">#define PATH_MAXNAMESZ 4096</font> 00044 <font class="preprocessor"></font> 00046 <font class="preprocessor">#ifndef P_tmpdir</font> 00047 <font class="preprocessor"></font><font class="preprocessor">#define P_tmpdir "."</font> 00048 <font class="preprocessor"></font><font class="preprocessor">#endif</font> 00049 <font class="preprocessor"></font> 00050 <font class="comment">/*---------------------------------------------------------------------------</font> 00051 <font class="comment"> Function codes</font> 00052 <font class="comment"> ---------------------------------------------------------------------------*/</font> 00053 00054 00055 <font class="comment">/*-------------------------------------------------------------------------*/</font> 00083 <font class="comment">/*-------------------------------------------------------------------------*/</font> <a name="l00084"></a><a class="code" href="gnuplot_i_c.html#a1">00084</a> <font class="keywordtype">char</font> * <a class="code" href="gnuplot_i_h.html#a1">gnuplot_get_program_path</a>(<font class="keywordtype">char</font> * pname)<font class="keyword"></font> 00085 <font class="keyword"></font>{ 00086 <font class="keywordtype">int</font> i, j, lg; 00087 <font class="keywordtype">char</font> * path; 00088 <font class="keyword">static</font> <font class="keywordtype">char</font> buf[PATH_MAXNAMESZ]; 00089 00090 <font class="comment">/* Trivial case: try in CWD */</font> 00091 sprintf(buf, <font class="stringliteral">"./%s"</font>, pname) ; 00092 <font class="keywordflow">if</font> (access(buf, X_OK)==0) { 00093 sprintf(buf, <font class="stringliteral">"."</font>); 00094 <font class="keywordflow">return</font> buf ; 00095 } 00096 <font class="comment">/* Try out in all paths given in the PATH variable */</font> 00097 buf[0] = 0; 00098 path = getenv(<font class="stringliteral">"PATH"</font>) ; 00099 <font class="keywordflow">if</font> (path!=NULL) { 00100 <font class="keywordflow">for</font> (i=0; path[i]; ) { 00101 <font class="keywordflow">for</font> (j=i ; (path[j]) && (path[j]!=<font class="charliteral">':'</font>) ; j++); 00102 lg = j - i; 00103 strncpy(buf, path + i, lg); 00104 <font class="keywordflow">if</font> (lg == 0) buf[lg++] = <font class="charliteral">'.'</font>; 00105 buf[lg++] = <font class="charliteral">'/'</font>; 00106 strcpy(buf + lg, pname); 00107 <font class="keywordflow">if</font> (access(buf, X_OK) == 0) { 00108 <font class="comment">/* Found it! */</font> 00109 <font class="keywordflow">break</font> ; 00110 } 00111 buf[0] = 0; 00112 i = j; 00113 <font class="keywordflow">if</font> (path[i] == <font class="charliteral">':'</font>) i++ ; 00114 } 00115 } <font class="keywordflow">else</font> { 00116 fprintf(stderr, <font class="stringliteral">"PATH variable not set\n"</font>); 00117 } 00118 <font class="comment">/* If the buffer is still empty, the command was not found */</font> 00119 <font class="keywordflow">if</font> (buf[0] == 0) <font class="keywordflow">return</font> NULL ; 00120 <font class="comment">/* Otherwise truncate the command name to yield path only */</font> 00121 lg = strlen(buf) - 1 ; 00122 <font class="keywordflow">while</font> (buf[lg]!=<font class="charliteral">'/'</font>) { 00123 buf[lg]=0 ; 00124 lg -- ; 00125 } 00126 buf[lg] = 0; 00127 <font class="keywordflow">return</font> buf ; 00128 } 00129 00130 00131 00132 <font class="comment">/*-------------------------------------------------------------------------*/</font> 00143 <font class="comment">/*--------------------------------------------------------------------------*/</font> 00144 <a name="l00145"></a><a class="code" href="gnuplot_i_c.html#a2">00145</a> <a class="code" href="struct__GNUPLOT_CTRL_.html">gnuplot_ctrl</a> * <a class="code" href="gnuplot_i_c.html#a1">gnuplot_init</a>(<font class="keywordtype">void</font>)<font class="keyword"></font> 00146 <font class="keyword"></font>{ 00147 <a class="code" href="struct__GNUPLOT_CTRL_.html">gnuplot_ctrl</a> * handle ; 00148 00149 <font class="keywordflow">if</font> (getenv(<font class="stringliteral">"DISPLAY"</font>) == NULL) { 00150 fprintf(stderr, <font class="stringliteral">"cannot find DISPLAY variable: is it set?\n"</font>) ; 00151 } 00152 <font class="keywordflow">if</font> (<a class="code" href="gnuplot_i_h.html#a1">gnuplot_get_program_path</a>(<font class="stringliteral">"gnuplot"</font>)==NULL) { 00153 fprintf(stderr, <font class="stringliteral">"cannot find gnuplot in your PATH"</font>); 00154 <font class="keywordflow">return</font> NULL ; 00155 } 00156 00157 <font class="comment">/* </font> 00158 <font class="comment"> * Structure initialization:</font> 00159 <font class="comment"> */</font> 00160 handle = (<a class="code" href="struct__GNUPLOT_CTRL_.html">gnuplot_ctrl</a>*)malloc(<font class="keyword">sizeof</font>(<a class="code" href="struct__GNUPLOT_CTRL_.html">gnuplot_ctrl</a>)) ; 00161 handle->nplots = 0 ; 00162 <a class="code" href="gnuplot_i_h.html#a5">gnuplot_setstyle</a>(handle, <font class="stringliteral">"points"</font>) ; 00163 handle->ntmp = 0 ; 00164 00165 handle->gnucmd = popen(<font class="stringliteral">"gnuplot"</font>, <font class="stringliteral">"w"</font>) ; 00166 <font class="keywordflow">if</font> (handle->gnucmd == NULL) { 00167 fprintf(stderr, <font class="stringliteral">"error starting gnuplot\n"</font>) ; 00168 free(handle) ; 00169 <font class="keywordflow">return</font> NULL ; 00170 } 00171 <font class="keywordflow">return</font> handle; 00172 } 00173 00174 00175 <font class="comment">/*-------------------------------------------------------------------------*/</font> 00186 <font class="comment">/*--------------------------------------------------------------------------*/</font> 00187 <a name="l00188"></a><a class="code" href="gnuplot_i_c.html#a3">00188</a> <font class="keywordtype">void</font> <a class="code" href="gnuplot_i_h.html#a3">gnuplot_close</a>(<a class="code" href="struct__GNUPLOT_CTRL_.html">gnuplot_ctrl</a> * handle)<font class="keyword"></font> 00189 <font class="keyword"></font>{ 00190 <font class="keywordtype">int</font> i ; 00191 00192 <font class="keywordflow">if</font> (pclose(handle->gnucmd) == -1) { 00193 fprintf(stderr, <font class="stringliteral">"problem closing communication to gnuplot\n"</font>) ; 00194 <font class="keywordflow">return</font> ; 00195 } 00196 <font class="keywordflow">if</font> (handle->ntmp) { 00197 <font class="keywordflow">for</font> (i=0 ; i<handle->ntmp ; i++) { 00198 remove(handle->to_delete[i]) ; 00199 } 00200 } 00201 free(handle) ; 00202 <font class="keywordflow">return</font> ; 00203 } 00204 00205 00206 <font class="comment">/*-------------------------------------------------------------------------*/</font> 00229 <font class="comment">/*--------------------------------------------------------------------------*/</font> 00230 <a name="l00231"></a><a class="code" href="gnuplot_i_c.html#a4">00231</a> <font class="keywordtype">void</font> <a class="code" href="gnuplot_i_h.html#a4">gnuplot_cmd</a>(<a class="code" href="struct__GNUPLOT_CTRL_.html">gnuplot_ctrl</a> * handle, <font class="keywordtype">char</font> * cmd, ...)<font class="keyword"></font> 00232 <font class="keyword"></font>{ 00233 va_list ap ; 00234 <font class="keywordtype">char</font> local_cmd[GP_CMD_SIZE]; 00235 00236 va_start(ap, cmd); 00237 vsprintf(local_cmd, cmd, ap); 00238 va_end(ap); 00239 00240 strcat(local_cmd, <font class="stringliteral">"\n"</font>); 00241 00242 fputs(local_cmd, handle->gnucmd) ; 00243 fflush(handle->gnucmd) ; 00244 <font class="keywordflow">return</font> ; 00245 } 00246 00247 00248 <font class="comment">/*-------------------------------------------------------------------------*/</font> 00268 <font class="comment">/*--------------------------------------------------------------------------*/</font> 00269 <a name="l00270"></a><a class="code" href="gnuplot_i_c.html#a5">00270</a> <font class="keywordtype">void</font> <a class="code" href="gnuplot_i_h.html#a5">gnuplot_setstyle</a>(<a class="code" href="struct__GNUPLOT_CTRL_.html">gnuplot_ctrl</a> * h, <font class="keywordtype">char</font> * plot_style)<font class="keyword"> </font> 00271 <font class="keyword"></font>{ 00272 <font class="keywordflow">if</font> (strcmp(plot_style, <font class="stringliteral">"lines"</font>) && 00273 strcmp(plot_style, <font class="stringliteral">"points"</font>) && 00274 strcmp(plot_style, <font class="stringliteral">"linespoints"</font>) && 00275 strcmp(plot_style, <font class="stringliteral">"impulses"</font>) && 00276 strcmp(plot_style, <font class="stringliteral">"dots"</font>) && 00277 strcmp(plot_style, <font class="stringliteral">"steps"</font>) && 00278 strcmp(plot_style, <font class="stringliteral">"errorbars"</font>) && 00279 strcmp(plot_style, <font class="stringliteral">"boxes"</font>) && 00280 strcmp(plot_style, <font class="stringliteral">"boxerrorbars"</font>)) { 00281 fprintf(stderr, <font class="stringliteral">"warning: unknown requested style: using points\n"</font>) ; 00282 strcpy(h->pstyle, "points") ; 00283 } <font class="keywordflow">else</font> { 00284 strcpy(h->pstyle, plot_style) ; 00285 } 00286 <font class="keywordflow">return</font> ; 00287 } 00288 00289 00290 <font class="comment">/*-------------------------------------------------------------------------*/</font> 00299 <font class="comment">/*--------------------------------------------------------------------------*/</font> 00300 <a name="l00301"></a><a class="code" href="gnuplot_i_c.html#a6">00301</a> <font class="keywordtype">void</font> <a class="code" href="gnuplot_i_h.html#a6">gnuplot_set_xlabel</a>(<a class="code" href="struct__GNUPLOT_CTRL_.html">gnuplot_ctrl</a> * h, <font class="keywordtype">char</font> * label)<font class="keyword"></font> 00302 <font class="keyword"></font>{ 00303 <font class="keywordtype">char</font> cmd[GP_CMD_SIZE] ; 00304 00305 sprintf(cmd, <font class="stringliteral">"set xlabel \"%s\""</font>, label) ; 00306 <a class="code" href="gnuplot_i_h.html#a4">gnuplot_cmd</a>(h, cmd) ; 00307 <font class="keywordflow">return</font> ; 00308 } 00309 00310 00311 <font class="comment">/*-------------------------------------------------------------------------*/</font> 00320 <font class="comment">/*--------------------------------------------------------------------------*/</font> 00321 <a name="l00322"></a><a class="code" href="gnuplot_i_c.html#a7">00322</a> <font class="keywordtype">void</font> <a class="code" href="gnuplot_i_h.html#a7">gnuplot_set_ylabel</a>(<a class="code" href="struct__GNUPLOT_CTRL_.html">gnuplot_ctrl</a> * h, <font class="keywordtype">char</font> * label)<font class="keyword"></font> 00323 <font class="keyword"></font>{ 00324 <font class="keywordtype">char</font> cmd[GP_CMD_SIZE] ; 00325 00326 sprintf(cmd, <font class="stringliteral">"set ylabel \"%s\""</font>, label) ; 00327 <a class="code" href="gnuplot_i_h.html#a4">gnuplot_cmd</a>(h, cmd) ; 00328 <font class="keywordflow">return</font> ; 00329 } 00330 00331 00332 <font class="comment">/*-------------------------------------------------------------------------*/</font> 00341 <font class="comment">/*--------------------------------------------------------------------------*/</font> 00342 <a name="l00343"></a><a class="code" href="gnuplot_i_c.html#a8">00343</a> <font class="keywordtype">void</font> <a class="code" href="gnuplot_i_h.html#a8">gnuplot_resetplot</a>(<a class="code" href="struct__GNUPLOT_CTRL_.html">gnuplot_ctrl</a> * h)<font class="keyword"></font> 00344 <font class="keyword"></font>{ 00345 <font class="keywordtype">int</font> i ; 00346 <font class="keywordflow">if</font> (h->ntmp) { 00347 <font class="keywordflow">for</font> (i=0 ; i<h->ntmp ; i++) { 00348 remove(h->to_delete[i]) ; 00349 } 00350 } 00351 h->ntmp = 0 ; 00352 h->nplots = 0 ; 00353 <font class="keywordflow">return</font> ; 00354 } 00355 00356 00357 00358 <font class="comment">/*-------------------------------------------------------------------------*/</font> 00387 <font class="comment">/*--------------------------------------------------------------------------*/</font> 00388 <a name="l00389"></a><a class="code" href="gnuplot_i_c.html#a9">00389</a> <font class="keywordtype">void</font> <a class="code" href="gnuplot_i_h.html#a9">gnuplot_plot_x</a>( 00390 <a class="code" href="struct__GNUPLOT_CTRL_.html">gnuplot_ctrl</a> * handle, 00391 <font class="keywordtype">double</font> * d, 00392 <font class="keywordtype">int</font> n, 00393 <font class="keywordtype">char</font> * title 00394 )<font class="keyword"></font> 00395 <font class="keyword"></font>{ 00396 <font class="keywordtype">int</font> i ; 00397 <font class="keywordtype">int</font> tmpfd ; 00398 <font class="keywordtype">char</font> name[128] ; 00399 <font class="keywordtype">char</font> cmd[GP_CMD_SIZE] ; 00400 <font class="keywordtype">char</font> line[GP_CMD_SIZE] ; 00401 00402 00403 <font class="keywordflow">if</font> (handle==NULL || d==NULL || (n<1)) <font class="keywordflow">return</font> ; 00404 00405 <font class="comment">/* Open one more temporary file? */</font> 00406 <font class="keywordflow">if</font> (handle->ntmp == GP_MAX_TMP_FILES - 1) { 00407 fprintf(stderr, 00408 <font class="stringliteral">"maximum # of temporary files reached (%d): cannot open more"</font>, 00409 GP_MAX_TMP_FILES) ; 00410 <font class="keywordflow">return</font> ; 00411 } 00412 00413 <font class="comment">/* Open temporary file for output */</font> 00414 sprintf(name, <font class="stringliteral">"%s/gnuplot-i-XXXXXX"</font>, P_tmpdir); 00415 <font class="keywordflow">if</font> ((tmpfd=mkstemp(name))==-1) { 00416 fprintf(stderr,<font class="stringliteral">"cannot create temporary file: exiting plot"</font>) ; 00417 <font class="keywordflow">return</font> ; 00418 } 00419 00420 <font class="comment">/* Store file name in array for future deletion */</font> 00421 strcpy(handle->to_delete[handle->ntmp], name) ; 00422 handle->ntmp ++ ; 00423 <font class="comment">/* Write data to this file */</font> 00424 <font class="keywordflow">for</font> (i=0 ; i<n ; i++) { 00425 sprintf(line, <font class="stringliteral">"%g\n"</font>, d[i]); 00426 write(tmpfd, line, strlen(line)); 00427 } 00428 close(tmpfd) ; 00429 00430 <font class="comment">/* Command to be sent to gnuplot */</font> 00431 <font class="keywordflow">if</font> (handle->nplots > 0) { 00432 strcpy(cmd, <font class="stringliteral">"replot"</font>) ; 00433 } <font class="keywordflow">else</font> { 00434 strcpy(cmd, <font class="stringliteral">"plot"</font>) ; 00435 } 00436 00437 <font class="keywordflow">if</font> (title == NULL) { 00438 sprintf(line, <font class="stringliteral">"%s \"%s\" with %s"</font>, cmd, name, handle->pstyle) ; 00439 } <font class="keywordflow">else</font> { 00440 sprintf(line, <font class="stringliteral">"%s \"%s\" title \"%s\" with %s"</font>, cmd, name, 00441 title, handle->pstyle) ; 00442 } 00443 00444 <font class="comment">/* send command to gnuplot */</font> 00445 <a class="code" href="gnuplot_i_h.html#a4">gnuplot_cmd</a>(handle, line) ; 00446 handle->nplots++ ; 00447 <font class="keywordflow">return</font> ; 00448 } 00449 00450 00451 00452 <font class="comment">/*-------------------------------------------------------------------------*/</font> 00482 <font class="comment">/*--------------------------------------------------------------------------*/</font> 00483 <a name="l00484"></a><a class="code" href="gnuplot_i_c.html#a10">00484</a> <font class="keywordtype">void</font> <a class="code" href="gnuplot_i_h.html#a10">gnuplot_plot_xy</a>( 00485 <a class="code" href="struct__GNUPLOT_CTRL_.html">gnuplot_ctrl</a> * handle, 00486 <font class="keywordtype">double</font> * x, 00487 <font class="keywordtype">double</font> * y, 00488 <font class="keywordtype">int</font> n, 00489 <font class="keywordtype">char</font> * title 00490 )<font class="keyword"></font> 00491 <font class="keyword"></font>{ 00492 <font class="keywordtype">int</font> i ; 00493 <font class="keywordtype">int</font> tmpfd ; 00494 <font class="keywordtype">char</font> name[128] ; 00495 <font class="keywordtype">char</font> cmd[GP_CMD_SIZE] ; 00496 <font class="keywordtype">char</font> line[GP_CMD_SIZE] ; 00497 00498 <font class="keywordflow">if</font> (handle==NULL || x==NULL || y==NULL || (n<1)) <font class="keywordflow">return</font> ; 00499 00500 <font class="comment">/* Open one more temporary file? */</font> 00501 <font class="keywordflow">if</font> (handle->ntmp == GP_MAX_TMP_FILES - 1) { 00502 fprintf(stderr, 00503 <font class="stringliteral">"maximum # of temporary files reached (%d): cannot open more"</font>, 00504 GP_MAX_TMP_FILES) ; 00505 <font class="keywordflow">return</font> ; 00506 } 00507 00508 <font class="comment">/* Open temporary file for output */</font> 00509 sprintf(name, <font class="stringliteral">"%s/gnuplot-i-XXXXXX"</font>, P_tmpdir); 00510 <font class="keywordflow">if</font> ((tmpfd=mkstemp(name))==-1) { 00511 fprintf(stderr,<font class="stringliteral">"cannot create temporary file: exiting plot"</font>) ; 00512 <font class="keywordflow">return</font> ; 00513 } 00514 <font class="comment">/* Store file name in array for future deletion */</font> 00515 strcpy(handle->to_delete[handle->ntmp], name) ; 00516 handle->ntmp ++ ; 00517 00518 <font class="comment">/* Write data to this file */</font> 00519 <font class="keywordflow">for</font> (i=0 ; i<n; i++) { 00520 sprintf(line, <font class="stringliteral">"%g %g\n"</font>, x[i], y[i]) ; 00521 write(tmpfd, line, strlen(line)); 00522 } 00523 close(tmpfd) ; 00524 00525 <font class="comment">/* Command to be sent to gnuplot */</font> 00526 <font class="keywordflow">if</font> (handle->nplots > 0) { 00527 strcpy(cmd, <font class="stringliteral">"replot"</font>) ; 00528 } <font class="keywordflow">else</font> { 00529 strcpy(cmd, <font class="stringliteral">"plot"</font>) ; 00530 } 00531 00532 <font class="keywordflow">if</font> (title == NULL) { 00533 sprintf(line, <font class="stringliteral">"%s \"%s\" with %s"</font>, cmd, name, handle->pstyle) ; 00534 } <font class="keywordflow">else</font> { 00535 sprintf(line, <font class="stringliteral">"%s \"%s\" title \"%s\" with %s"</font>, cmd, name, 00536 title, handle->pstyle) ; 00537 } 00538 00539 <font class="comment">/* send command to gnuplot */</font> 00540 <a class="code" href="gnuplot_i_h.html#a4">gnuplot_cmd</a>(handle, line) ; 00541 handle->nplots++ ; 00542 <font class="keywordflow">return</font> ; 00543 } 00544 00545 00546 00547 <font class="comment">/*-------------------------------------------------------------------------*/</font> 00566 <font class="comment">/*--------------------------------------------------------------------------*/</font> 00567 <a name="l00568"></a><a class="code" href="gnuplot_i_c.html#a11">00568</a> <font class="keywordtype">void</font> <a class="code" href="gnuplot_i_h.html#a11">gnuplot_plot_once</a>( 00569 <font class="keywordtype">char</font> * title, 00570 <font class="keywordtype">char</font> * style, 00571 <font class="keywordtype">char</font> * label_x, 00572 <font class="keywordtype">char</font> * label_y, 00573 <font class="keywordtype">double</font> * x, 00574 <font class="keywordtype">double</font> * y, 00575 <font class="keywordtype">int</font> n 00576 )<font class="keyword"></font> 00577 <font class="keyword"></font>{ 00578 <a class="code" href="struct__GNUPLOT_CTRL_.html">gnuplot_ctrl</a> * handle ; 00579 00580 <font class="keywordflow">if</font> (x==NULL || n<1) <font class="keywordflow">return</font> ; 00581 00582 handle = <a class="code" href="gnuplot_i_c.html#a1">gnuplot_init</a>(); 00583 <font class="keywordflow">if</font> (style!=NULL) { 00584 <a class="code" href="gnuplot_i_h.html#a5">gnuplot_setstyle</a>(handle, style); 00585 } <font class="keywordflow">else</font> { 00586 <a class="code" href="gnuplot_i_h.html#a5">gnuplot_setstyle</a>(handle, <font class="stringliteral">"lines"</font>); 00587 } 00588 <font class="keywordflow">if</font> (label_x!=NULL) { 00589 <a class="code" href="gnuplot_i_h.html#a6">gnuplot_set_xlabel</a>(handle, label_x); 00590 } <font class="keywordflow">else</font> { 00591 <a class="code" href="gnuplot_i_h.html#a6">gnuplot_set_xlabel</a>(handle, <font class="stringliteral">"X"</font>); 00592 } 00593 <font class="keywordflow">if</font> (label_y!=NULL) { 00594 <a class="code" href="gnuplot_i_h.html#a7">gnuplot_set_ylabel</a>(handle, label_y); 00595 } <font class="keywordflow">else</font> { 00596 <a class="code" href="gnuplot_i_h.html#a7">gnuplot_set_ylabel</a>(handle, <font class="stringliteral">"Y"</font>); 00597 } 00598 <font class="keywordflow">if</font> (y==NULL) { 00599 <a class="code" href="gnuplot_i_h.html#a9">gnuplot_plot_x</a>(handle, x, n, title); 00600 } <font class="keywordflow">else</font> { 00601 <a class="code" href="gnuplot_i_h.html#a10">gnuplot_plot_xy</a>(handle, x, y, n, title); 00602 } 00603 printf(<font class="stringliteral">"press ENTER to continue\n"</font>); 00604 <font class="keywordflow">while</font> (getchar()!=<font class="charliteral">'\n'</font>) {} 00605 <a class="code" href="gnuplot_i_h.html#a3">gnuplot_close</a>(handle); 00606 <font class="keywordflow">return</font> ; 00607 } 00608 00609 00610 00611 00612 <font class="comment">/*-------------------------------------------------------------------------*/</font> 00637 <font class="comment">/*--------------------------------------------------------------------------*/</font> 00638 00639 <a name="l00640"></a><a class="code" href="gnuplot_i_c.html#a12">00640</a> <font class="keywordtype">void</font> <a class="code" href="gnuplot_i_h.html#a12">gnuplot_plot_slope</a>( 00641 <a class="code" href="struct__GNUPLOT_CTRL_.html">gnuplot_ctrl</a> * handle, 00642 <font class="keywordtype">double</font> a, 00643 <font class="keywordtype">double</font> b, 00644 <font class="keywordtype">char</font> * title 00645 )<font class="keyword"></font> 00646 <font class="keyword"></font>{ 00647 <font class="keywordtype">char</font> stitle[GP_TITLE_SIZE] ; 00648 <font class="keywordtype">char</font> cmd[GP_CMD_SIZE] ; 00649 00650 <font class="keywordflow">if</font> (title == NULL) { 00651 strcpy(stitle, <font class="stringliteral">"no title"</font>) ; 00652 } <font class="keywordflow">else</font> { 00653 strcpy(stitle, title) ; 00654 } 00655 00656 <font class="keywordflow">if</font> (handle->nplots > 0) { 00657 sprintf(cmd, <font class="stringliteral">"replot %g * x + %g title \"%s\" with %s"</font>, 00658 a, b, title, handle->pstyle) ; 00659 } <font class="keywordflow">else</font> { 00660 sprintf(cmd, <font class="stringliteral">"plot %g * x + %g title \"%s\" with %s"</font>, 00661 a, b, title, handle->pstyle) ; 00662 } 00663 <a class="code" href="gnuplot_i_h.html#a4">gnuplot_cmd</a>(handle, cmd) ; 00664 handle->nplots++ ; 00665 <font class="keywordflow">return</font> ; 00666 } 00667 00668 00669 <font class="comment">/*-------------------------------------------------------------------------*/</font> 00692 <font class="comment">/*--------------------------------------------------------------------------*/</font> 00693 <a name="l00694"></a><a class="code" href="gnuplot_i_c.html#a13">00694</a> <font class="keywordtype">void</font> <a class="code" href="gnuplot_i_h.html#a13">gnuplot_plot_equation</a>( 00695 <a class="code" href="struct__GNUPLOT_CTRL_.html">gnuplot_ctrl</a> * h, 00696 <font class="keywordtype">char</font> * equation, 00697 <font class="keywordtype">char</font> * title 00698 )<font class="keyword"></font> 00699 <font class="keyword"></font>{ 00700 <font class="keywordtype">char</font> cmd[GP_CMD_SIZE]; 00701 <font class="keywordtype">char</font> plot_str[GP_EQ_SIZE] ; 00702 <font class="keywordtype">char</font> title_str[GP_TITLE_SIZE] ; 00703 00704 <font class="keywordflow">if</font> (title == NULL) { 00705 strcpy(title_str, <font class="stringliteral">"no title"</font>) ; 00706 } <font class="keywordflow">else</font> { 00707 strcpy(title_str, title) ; 00708 } 00709 <font class="keywordflow">if</font> (h->nplots > 0) { 00710 strcpy(plot_str, <font class="stringliteral">"replot"</font>) ; 00711 } <font class="keywordflow">else</font> { 00712 strcpy(plot_str, <font class="stringliteral">"plot"</font>) ; 00713 } 00714 00715 sprintf(cmd, <font class="stringliteral">"%s %s title \"%s\" with %s"</font>, 00716 plot_str, equation, title_str, h->pstyle) ; 00717 <a class="code" href="gnuplot_i_h.html#a4">gnuplot_cmd</a>(h, cmd) ; 00718 h->nplots++ ; 00719 <font class="keywordflow">return</font> ; 00720 } 00721 </div></pre> <hr> Last modified: Tue Oct 23 15:29:10 2001 </hr> </body> </html> --- NEW FILE: gnuplot_i_c.html --- <html> <head> <meta name="author" content="nde...@fr..."> <meta name="editor" content="nde...@fr..."> <meta name="maintainer" content="nde...@fr..."> <meta name="keywords" content="gnuplot, interface, ANSI C"> <link href="doxygen.css" rel="stylesheet" type="text/css"> <title>gnuplot_i 2.x</title> </head> <body text="#000000" bgcolor="#ffffff"> <!-- Generated by Doxygen 1.2.5 on Tue Oct 23 15:29:10 2001 --> <h1>gnuplot_i.c File Reference</h1>C interface to gnuplot. <a href="#_details">More...</a> <p> <p> <a href="gnuplot_i_c-source.html">Go to the source code of this file.</a><table border=0 cellpadding=0 cellspacing=0> <tr><td colspan=2><br><h2>Functions</h2></td></tr> <tr><td nowrap align=right valign=top>char* </td><td valign=bottom><a class="el" href="gnuplot_i_c.html#a0">gnuplot_get_program_path</a> (char *pname)</td></tr> <tr><td> </td><td><font size=-1><em>Find out where a command lives in your PATH.</em> <a href="#a0">More...</a><em></em></font><br><br></td></tr> <tr><td nowrap align=right valign=top><a class="el" href="gnuplot_i_h.html#a0">gnuplot_ctrl</a>* </td><td valign=bottom><a class="el" href="gnuplot_i_c.html#a1">gnuplot_init</a> (void)</td></tr> <tr><td> </td><td><font size=-1><em>Opens up a gnuplot session, ready to receive commands.</em> <a href="#a1">More...</a><em></em></font><br><br></td></tr> <tr><td nowrap align=right valign=top>void </td><td valign=bottom><a class="el" href="gnuplot_i_c.html#a2">gnuplot_close</a> (<a class="el" href="gnuplot_i_h.html#a0">gnuplot_ctrl</a> *handle)</td></tr> <tr><td> </td><td><font size=-1><em>Closes a gnuplot session previously opened by <a class="el" href="gnuplot_i_c.html#a1">gnuplot_init</a>().</em> <a href="#a2">More...</a><em></em></font><br><br></td></tr> <tr><td nowrap align=right valign=top>void </td><td valign=bottom><a class="el" href="gnuplot_i_c.html#a3">gnuplot_cmd</a> (<a class="el" href="gnuplot_i_h.html#a0">gnuplot_ctrl</a> *handle, char *cmd,...)</td></tr> <tr><td> </td><td><font size=-1><em>Sends a command to an active gnuplot session.</em> <a href="#a3">More...</a><em></em></font><br><br></td></tr> <tr><td nowrap align=right valign=top>void </td><td valign=bottom><a class="el" href="gnuplot_i_c.html#a4">gnuplot_setstyle</a> (<a class="el" href="gnuplot_i_h.html#a0">gnuplot_ctrl</a> *h, char *plot_style)</td></tr> <tr><td> </td><td><font size=-1><em>Change the plotting style of a gnuplot session.</em> <a href="#a4">More...</a><em></em></font><br><br></td></tr> <tr><td nowrap align=right valign=top>void </td><td valign=bottom><a class="el" href="gnuplot_i_c.html#a5">gnuplot_set_xlabel</a> (<a class="el" href="gnuplot_i_h.html#a0">gnuplot_ctrl</a> *h, char *label)</td></tr> <tr><td> </td><td><font size=-1><em>Sets the x label of a gnuplot session.</em> <a href="#a5">More...</a><em></em></font><br><br></td></tr> <tr><td nowrap align=right valign=top>void </td><td valign=bottom><a class="el" href="gnuplot_i_c.html#a6">gnuplot_set_ylabel</a> (<a class="el" href="gnuplot_i_h.html#a0">gnuplot_ctrl</a> *h, char *label)</td></tr> <tr><td> </td><td><font size=-1><em>Sets the y label of a gnuplot session.</em> <a href="#a6">More...</a><em></em></font><br><br></td></tr> <tr><td nowrap align=right valign=top>void </td><td valign=bottom><a class="el" href="gnuplot_i_c.html#a7">gnuplot_resetplot</a> (<a class="el" href="gnuplot_i_h.html#a0">gnuplot_ctrl</a> *h)</td></tr> <tr><td> </td><td><font size=-1><em>Resets a gnuplot session (next plot will erase previous ones).</em> <a href="#a7">More...</a><em></em></font><br><br></td></tr> <tr><td nowrap align=right valign=top>void </td><td valign=bottom><a class="el" href="gnuplot_i_c.html#a8">gnuplot_plot_x</a> (<a class="el" href="gnuplot_i_h.html#a0">gnuplot_ctrl</a> *handle, double *d, int n, char *title)</td></tr> <tr><td> </td><td><font size=-1><em>Plots a 2d graph from a list of doubles.</em> <a href="#a8">More...</a><em></em></font><br><br></td></tr> <tr><td nowrap align=right valign=top>void </td><td valign=bottom><a class="el" href="gnuplot_i_c.html#a9">gnuplot_plot_xy</a> (<a class="el" href="gnuplot_i_h.html#a0">gnuplot_ctrl</a> *handle, double *x, double *y, int n, char *title)</td></tr> <tr><td> </td><td><font size=-1><em>Plot a 2d graph from a list of points.</em> <a href="#a9">More...</a><em></em></font><br><br></td></tr> <tr><td nowrap align=right valign=top>void </td><td valign=bottom><a class="el" href="gnuplot_i_c.html#a10">gnuplot_plot_once</a> (char *title, char *style, char *label_x, char *label_y, double *x, double *y, int n)</td></tr> <tr><td> </td><td><font size=-1><em>Open a new session, plot a signal, close the session.</em> <a href="#a10">More...</a><em></em></font><br><br></td></tr> <tr><td nowrap align=right valign=top>void </td><td valign=bottom><a class="el" href="gnuplot_i_c.html#a11">gnuplot_plot_slope</a> (<a class="el" href="gnuplot_i_h.html#a0">gnuplot_ctrl</a> *handle, double a, double b, char *title)</td></tr> <tr><td> </td><td><font size=-1><em>Plot a slope on a gnuplot session.</em> <a href="#a11">More...</a><em></em></font><br><br></td></tr> <tr><td nowrap align=right valign=top>void </td><td valign=bottom><a class="el" href="gnuplot_i_c.html#a12">gnuplot_plot_equation</a> (<a class="el" href="gnuplot_i_h.html#a0">gnuplot_ctrl</a> *h, char *equation, char *title)</td></tr> <tr><td> </td><td><font size=-1><em>Plot a curve of given equation y=f(x).</em> <a href="#a12">More...</a><em></em></font><br><br></td></tr> </table> <hr><a name="_details"></a><h2>Detailed Description</h2> C interface to gnuplot. <p> <p> <dl compact><dt> <b>Author(s): </b><dd> N. Devillard </dl><dl compact><dt> <b>Date: </b><dd> Sep 1998 </dl><dl compact><dt> <b>Version: </b><dd> </dl><dl compact><dt> <b>Revision: </b><dd> 2.6 </dl> <p> gnuplot is a freely available, command-driven graphical display tool for Unix. It compiles and works quite well on a number of Unix flavours as well as other operating systems. The following module enables sending display requests to gnuplot through simple C calls. <p> <p> Definition in file <a class="el" href="gnuplot_i_c-source.html">gnuplot_i.c</a>.<hr><h2>Function Documentation</h2> <a name="a2" doxytag="gnuplot_i.c::gnuplot_close"></a><p> <table width="100%" cellpadding="2" cellspacing="0" border="0"> <tr> <td class="md"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td nowrap valign="top"><b> void gnuplot_close ( </b></td> <td valign="bottom"><b> <a class="el" href="gnuplot_i_h.html#a0">gnuplot_ctrl</a> * <em>handle</em> ) </b></td> </tr> </table> </td> </tr> </table> <table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td> <p> Closes a gnuplot session previously opened by <a class="el" href="gnuplot_i_c.html#a1">gnuplot_init</a>(). <p> <dl compact><dt> <b>Parameters: </b><dd> <table border=0 cellspacing=2 cellpadding=0> <tr><td valign=top><em>handle</em> </td><td> Gnuplot session control handle. </td></tr> </table> </dl><dl compact><dt> <b>Returns: </b><dd> void <p> </dl>Kills the child PID and deletes all opened temporary files. It is mandatory to call this function to close the handle, otherwise temporary files are not cleaned and child process might survive. <p> Definition at line <a class="el" href="gnuplot_i_c-source.html#l00188">188</a> of file <a class="el" href="gnuplot_i_c-source.html">gnuplot_i.c</a>. </td> </tr> </table> <a name="a3" doxytag="gnuplot_i.c::gnuplot_cmd"></a><p> <table width="100%" cellpadding="2" cellspacing="0" border="0"> <tr> <td class="md"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td nowrap valign="top"><b> void gnuplot_cmd ( </b></td> <td valign="bottom"><b> <a class="el" href="gnuplot_i_h.html#a0">gnuplot_ctrl</a> * <em>handle</em>, </b></td> </tr> <tr> <td></td> <td><b> char * <em>cmd</em>, </b></td> </tr> <tr> <td></td> <td><b> ... ) </b></td> </tr> </table> </td> </tr> </table> <table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td> <p> Sends a command to an active gnuplot session. <p> <dl compact><dt> <b>Parameters: </b><dd> <table border=0 cellspacing=2 cellpadding=0> <tr><td valign=top><em>handle</em> </td><td> Gnuplot session control handle </td></tr> <tr><td valign=top><em>cmd</em> </td><td> Command to send, same as a printf statement. <p> </td></tr> </table> </dl>This sends a string to an active gnuplot session, to be executed. There is strictly no way to know if the command has been successfully executed or not. The command syntax is the same as printf. <p> Examples: <p> <div class="fragment"><pre> <a class="code" href="gnuplot_i_c.html#a3">gnuplot_cmd</a>(g, <font class="stringliteral">"plot %d*x"</font>, 23.0); <a class="code" href="gnuplot_i_c.html#a3">gnuplot_cmd</a>(g, <font class="stringliteral">"plot %g * cos(%g * x)"</font>, 32.0, -3.0);</div></pre> <p> Since the communication to the gnuplot process is run through a standard Unix pipe, it is only unidirectional. This means that it is not possible for this interface to query an error status back from gnuplot. <p> Definition at line <a class="el" href="gnuplot_i_c-source.html#l00231">231</a> of file <a class="el" href="gnuplot_i_c-source.html">gnuplot_i.c</a>. </td> </tr> </table> <a name="a0" doxytag="gnuplot_i.c::gnuplot_get_program_path"></a><p> <table width="100%" cellpadding="2" cellspacing="0" border="0"> <tr> <td class="md"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td nowrap valign="top"><b> char * gnuplot_get_program_path ( </b></td> <td valign="bottom"><b> char * <em>pname</em> ) </b></td> </tr> </table> </td> </tr> </table> <table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td> <p> Find out where a command lives in your PATH. <p> <dl compact><dt> <b>Parameters: </b><dd> <table border=0 cellspacing=2 cellpadding=0> <tr><td valign=top><em>pname</em> </td><td> Name of the program to look for. </td></tr> </table> </dl><dl compact><dt> <b>Returns: </b><dd> pointer to statically allocated character string. <p> </dl>This is the C equivalent to the 'which' command in Unix. It parses out your PATH environment variable to find out where a command lives. The returned character string is statically allocated within this function, i.e. there is no need to free it. Beware that the contents of this string will change from one call to the next, though (as all static variables in a function). <p> The input character string must be the name of a command without prefixing path of any kind, i.e. only the command name. The returned string is the path in which a command matching the same name was found. <p> Examples (assuming there is a prog named 'hello' in the cwd): <p> <div class="fragment"><pre> gnuplot_get_program_path("hello") returns "." gnuplot_get_program_path("ls") returns "/bin" gnuplot_get_program_path("csh") returns "/usr/bin" gnuplot_get_program_path("/bin/ls") returns NULL </div></pre> <p> Definition at line <a class="el" href="gnuplot_i_c-source.html#l00084">84</a> of file <a class="el" href="gnuplot_i_c-source.html">gnuplot_i.c</a>. </td> </tr> </table> <a name="a1" doxytag="gnuplot_i.c::gnuplot_init"></a><p> <table width="100%" cellpadding="2" cellspacing="0" border="0"> <tr> <td class="md"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td nowrap valign="top"><b> <a class="el" href="gnuplot_i_h.html#a0">gnuplot_ctrl</a> * gnuplot_init ( </b></td> <td valign="bottom"><b> void ) </b></td> </tr> </table> </td> </tr> </table> <table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td> <p> Opens up a gnuplot session, ready to receive commands. <p> <dl compact><dt> <b>Returns: </b><dd> Newly allocated gnuplot control structure. <p> </dl>This opens up a new gnuplot session, ready for input. The struct controlling a gnuplot session should remain opaque and only be accessed through the provided functions. <p> The session must be closed using <a class="el" href="gnuplot_i_c.html#a2">gnuplot_close</a>(). <p> Definition at line <a class="el" href="gnuplot_i_c-source.html#l00145">145</a> of file <a class="el" href="gnuplot_i_c-source.html">gnuplot_i.c</a>. <p> Referenced by <a class="el" href="gnuplot_i_c-source.html#l00568">gnuplot_plot_once</a>(). </td> </tr> </table> <a name="a12" doxytag="gnuplot_i.c::gnuplot_plot_equation"></a><p> <table width="100%" cellpadding="2" cellspacing="0" border="0"> <tr> <td class="md"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td nowrap valign="top"><b> void gnuplot_plot_equation ( </b></td> <td valign="bottom"><b> <a class="el" href="gnuplot_i_h.html#a0">gnuplot_ctrl</a> * <em>h</em>, </b></td> </tr> <tr> <td></td> <td><b> char * <em>equation</em>, </b></td> </tr> <tr> <td></td> <td><b> char * <em>title</em> ) </b></td> </tr> </table> </td> </tr> </table> <table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td> <p> Plot a curve of given equation y=f(x). <p> <dl compact><dt> <b>Parameters: </b><dd> <table border=0 cellspacing=2 cellpadding=0> <tr><td valign=top><em>h</em> </td><td> Gnuplot session control handle. </td></tr> <tr><td valign=top><em>equation</em> </td><td> Equation to plot. </td></tr> <tr><td valign=top><em>title</em> </td><td> Title of the plot. </td></tr> </table> </dl><dl compact><dt> <b>Returns: </b><dd> void <p> </dl>Plots out a curve of given equation. The general form of the equation is y=f(x), you only provide the f(x) side of the equation. <p> Example: <p> <div class="fragment"><pre> <a class="code" href="struct__GNUPLOT_CTRL_.html">gnuplot_ctrl</a> *h ; <font class="keywordtype">char</font> eq[80] ; h = <a class="code" href="gnuplot_i_c.html#a1">gnuplot_init</a>() ; strcpy(eq, <font class="stringliteral">"sin(x) * cos(2*x)"</font>) ; <a class="code" href="gnuplot_i_c.html#a12">gnuplot_plot_equation</a>(h, eq, <font class="stringliteral">"sine wave"</font>, normal) ; <a class="code" href="gnuplot_i_c.html#a2">gnuplot_close</a>(h) ;</div></pre> <p> Definition at line <a class="el" href="gnuplot_i_c-source.html#l00694">694</a> of file <a class="el" href="gnuplot_i_c-source.html">gnuplot_i.c</a>. </td> </tr> </table> <a name="a10" doxytag="gnuplot_i.c::gnuplot_plot_once"></a><p> <table width="100%" cellpadding="2" cellspacing="0" border="0"> <tr> <td class="md"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td nowrap valign="top"><b> void gnuplot_plot_once ( </b></td> <td valign="bottom"><b> char * <em>title</em>, </b></td> </tr> <tr> <td></td> <td><b> char * <em>style</em>, </b></td> </tr> <tr> <td></td> <td><b> char * <em>label_x</em>, </b></td> </tr> <tr> <td></td> <td><b> char * <em>label_y</em>, </b></td> </tr> <tr> <td></td> <td><b> double * <em>x</em>, </b></td> </tr> <tr> <td></td> <td><b> double * <em>y</em>, </b></td> </tr> <tr> <td></td> <td><b> int <em>n</em> ) </b></td> </tr> </table> </td> </tr> </table> <table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td> <p> Open a new session, plot a signal, close the session. <p> <dl compact><dt> <b>Parameters: </b><dd> <table border=0 cellspacing=2 cellpadding=0> <tr><td valign=top><em>title</em> </td><td> Plot title </td></tr> <tr><td valign=top><em>style</em> </td><td> Plot style </td></tr> <tr><td valign=top><em>label_x</em> </td><td> Label for X </td></tr> <tr><td valign=top><em>label_y</em> </td><td> Label for Y </td></tr> <tr><td valign=top><em>x</em> </td><td> Array of X coordinates </td></tr> <tr><td valign=top><em>y</em> </td><td> Array of Y coordinates (can be NULL) </td></tr> <tr><td valign=top><em>n</em> </td><td> Number of values in x and y. </td></tr> </table> </dl><dl compact><dt> <b>Returns: </b><dd> <p> </dl>This function opens a new gnuplot session, plots the provided signal as an X or XY signal depending on a provided y, waits for a carriage return on stdin and closes the session. <p> It is Ok to provide an empty title, empty style, or empty labels for X and Y. Defaults are provided in this case. <p> Definition at line <a class="el" href="gnuplot_i_c-source.html#l00568">568</a> of file <a class="el" href="gnuplot_i_c-source.html">gnuplot_i.c</a>. </td> </tr> </table> <a name="a11" doxytag="gnuplot_i.c::gnuplot_plot_slope"></a><p> <table width="100%" cellpadding="2" cellspacing="0" border="0"> <tr> <td class="md"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td nowrap valign="top"><b> void gnuplot_plot_slope ( </b></td> <td valign="bottom"><b> <a class="el" href="gnuplot_i_h.html#a0">gnuplot_ctrl</a> * <em>handle</em>, </b></td> </tr> <tr> <td></td> <td><b> double <em>a</em>, </b></td> </tr> <tr> <td></td> <td><b> double <em>b</em>, </b></td> </tr> <tr> <td></td> <td><b> char * <em>title</em> ) </b></td> </tr> </table> </td> </tr> </table> <table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td> <p> Plot a slope on a gnuplot session. <p> <dl compact><dt> <b>Parameters: </b><dd> <table border=0 cellspacing=2 cellpadding=0> <tr><td valign=top><em>handle</em> </td><td> Gnuplot session control handle. </td></tr> <tr><td valign=top><em>a</em> </td><td> Slope. </td></tr> <tr><td valign=top><em>b</em> </td><td> Intercept. </td></tr> <tr><td valign=top><em>title</em> </td><td> Title of the plot. </td></tr> </table> </dl><dl compact><dt> <b>Returns: </b><dd> void @doc <p> </dl>Plot a slope on a gnuplot session. The provided slope has an equation of the form y=ax+b <p> Example: <p> <div class="fragment"><pre> <a class="code" href="struct__GNUPLOT_CTRL_.html">gnuplot_ctrl</a> * h ; <font class="keywordtype">double</font> a, b ; h = <a class="code" href="gnuplot_i_c.html#a1">gnuplot_init</a>() ; <a class="code" href="gnuplot_i_c.html#a11">gnuplot_plot_slope</a>(h, 1.0, 0.0, <font class="stringliteral">"unity slope"</font>) ; sleep(2) ; <a class="code" href="gnuplot_i_c.html#a2">gnuplot_close</a>(h) ;</div></pre> <p> Definition at line <a class="el" href="gnuplot_i_c-source.html#l00640">640</a> of file <a class="el" href="gnuplot_i_c-source.html">gnuplot_i.c</a>. </td> </tr> </table> <a name="a8" doxytag="gnuplot_i.c::gnuplot_plot_x"></a><p> <table width="100%" cellpadding="2" cellspacing="0" border="0"> <tr> <td class="md"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td nowrap valign="top"><b> void gnuplot_plot_x ( </b></td> <td valign="bottom"><b> <a class="el" href="gnuplot_i_h.html#a0">gnuplot_ctrl</a> * <em>handle</em>, </b></td> </tr> <tr> <td></td> <td><b> double * <em>d</em>, </b></td> </tr> <tr> <td></td> <td><b> int <em>n</em>, </b></td> </tr> <tr> <td></td> <td><b> char * <em>title</em> ) </b></td> </tr> </table> </td> </tr> </table> <table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td> <p> Plots a 2d graph from a list of doubles. <p> <dl compact><dt> <b>Parameters: </b><dd> <table border=0 cellspacing=2 cellpadding=0> <tr><td valign=top><em>handle</em> </td><td> Gnuplot session control handle. </td></tr> <tr><td valign=top><em>d</em> </td><td> Array of doubles. </td></tr> <tr><td valign=top><em>n</em> </td><td> Number of values in the passed array. </td></tr> <tr><td valign=top><em>title</em> </td><td> Title of the plot. </td></tr> </table> </dl><dl compact><dt> <b>Returns: </b><dd> void <p> </dl>Plots out a 2d graph from a list of doubles. The x-coordinate is the index of the double in the list, the y coordinate is the double in the list. <p> Example: <p> <div class="fragment"><pre> <a class="code" href="struct__GNUPLOT_CTRL_.html">gnuplot_ctrl</a> *h ; <font class="keywordtype">double</font> d[50] ; <font class="keywordtype">int</font> i ; h = <a class="code" href="gnuplot_i_c.html#a1">gnuplot_init</a>() ; <font class="keywordflow">for</font> (i=0 ; i<50 ; i++) { d[i] = (<font class="keywordtype">double</font>)(i*i) ; } <a class="code" href="gnuplot_i_c.html#a8">gnuplot_plot_x</a>(h, d, 50, <font class="stringliteral">"parabola"</font>) ; sleep(2) ; <a class="code" href="gnuplot_i_c.html#a2">gnuplot_close</a>(h) ;</div></pre> <p> Definition at line <a class="el" href="gnuplot_i_c-source.html#l00389">389</a> of file <a class="el" href="gnuplot_i_c-source.html">gnuplot_i.c</a>. </td> </tr> </table> <a name="a9" doxytag="gnuplot_i.c::gnuplot_plot_xy"></a><p> <table width="100%" cellpadding="2" cellspacing="0" border="0"> <tr> <td class="md"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td nowrap valign="top"><b> void gnuplot_plot_xy ( </b></td> <td valign="bottom"><b> <a class="el" href="gnuplot_i_h.html#a0">gnuplot_ctrl</a> * <em>handle</em>, </b></td> </tr> <tr> <td></td> <td><b> double * <em>x</em>, </b></td> </tr> <tr> <td></td> <td><b> double * <em>y</em>, </b></td> </tr> <tr> <td></td> <td><b> int <em>n</em>, </b></td> </tr> <tr> <td></td> <td><b> char * <em>title</em> ) </b></td> </tr> </table> </td> </tr> </table> <table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td> <p> Plot a 2d graph from a list of points. <p> <dl compact><dt> <b>Parameters: </b><dd> <table border=0 cellspacing=2 cellpadding=0> <tr><td valign=top><em>handle</em> </td><td> Gnuplot session control handle. </td></tr> <tr><td valign=top><em>x</em> </td><td> Pointer to a list of x coordinates. </td></tr> <tr><td valign=top><em>y</em> </td><td> Pointer to a list of y coordinates. </td></tr> <tr><td valign=top><em>n</em> </td><td> Number of doubles in x (assumed the same as in y). </td></tr> <tr><td valign=top><em>title</em> </td><td> Title of the plot. </td></tr> </table> </dl><dl compact><dt> <b>Returns: </b><dd> void <p> </dl>Plots out a 2d graph from a list of points. Provide points through a list of x and a list of y coordinates. Both provided arrays are assumed to contain the same number of values. <p> <div class="fragment"><pre> <a class="code" href="struct__GNUPLOT_CTRL_.html">gnuplot_ctrl</a> *h ; <font class="keywordtype">double</font> x[50] ; <font class="keywordtype">double</font> y[50] ; <font class="keywordtype">int</font> i ; h = <a class="code" href="gnuplot_i_c.html#a1">gnuplot_init</a>() ; <font class="keywordflow">for</font> (i=0 ; i<50 ; i++) { x[i] = (<font class="keywordtype">double</font>)(i)/10.0 ; y[i] = x[i] * x[i] ; } gnuplot_plot1_xy(h, x, y, 50, <font class="stringliteral">"parabola"</font>) ; sleep(2) ; <a class="code" href="gnuplot_i_c.html#a2">gnuplot_close</a>(h) ;</div></pre> <p> Definition at line <a class="el" href="gnuplot_i_c-source.html#l00484">484</a> of file <a class="el" href="gnuplot_i_c-source.html">gnuplot_i.c</a>. </td> </tr> </table> <a name="a7" doxytag="gnuplot_i.c::gnuplot_resetplot"></a><p> <table width="100%" cellpadding="2" cellspacing="0" border="0"> <tr> <td class="md"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td nowrap valign="top"><b> void gnuplot_resetplot ( </b></td> <td valign="bottom"><b> <a class="el" href="gnuplot_i_h.html#a0">gnuplot_ctrl</a> * <em>h</em> ) </b></td> </tr> </table> </td> </tr> </table> <table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td> <p> Resets a gnuplot session (next plot will erase previous ones). <p> <dl compact><dt> <b>Parameters: </b><dd> <table border=0 cellspacing=2 cellpadding=0> <tr><td valign=top><em>h</em> </td><td> Gnuplot session control handle. </td></tr> </table> </dl><dl compact><dt> <b>Returns: </b><dd> void <p> </dl>Resets a gnuplot session, i.e. the next plot will erase all previous ones. <p> Definition at line <a class="el" href="gnuplot_i_c-source.html#l00343">343</a> of file <a class="el" href="gnuplot_i_c-source.html">gnuplot_i.c</a>. </td> </tr> </table> <a name="a5" doxytag="gnuplot_i.c::gnuplot_set_xlabel"></a><p> <table width="100%" cellpadding="2" cellspacing="0" border="0"> <tr> <td class="md"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td nowrap valign="top"><b> void gnuplot_set_xlabel ( </b></td> <td valign="bottom"><b> <a class="el" href="gnuplot_i_h.html#a0">gnuplot_ctrl</a> * <em>h</em>, </b></td> </tr> <tr> <td></td> <td><b> char * <em>label</em> ) </b></td> </tr> </table> </td> </tr> </table> <table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td> <p> Sets the x label of a gnuplot session. <p> <dl compact><dt> <b>Parameters: </b><dd> <table border=0 cellspacing=2 cellpadding=0> <tr><td valign=top><em>h</em> </td><td> Gnuplot session control handle. </td></tr> <tr><td valign=top><em>label</em> </td><td> Character string to use for X label. </td></tr> </table> </dl><dl compact><dt> <b>Returns: </b><dd> void <p> </dl>Sets the x label for a gnuplot session. <p> Definition at line <a class="el" href="gnuplot_i_c-source.html#l00301">301</a> of file <a class="el" href="gnuplot_i_c-source.html">gnuplot_i.c</a>. </td> </tr> </table> <a name="a6" doxytag="gnuplot_i.c::gnuplot_set_ylabel"></a><p> <table width="100%" cellpadding="2" cellspacing="0" border="0"> <tr> <td class="md"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td nowrap valign="top"><b> void gnuplot_set_ylabel ( </b></td> <td valign="bottom"><b> <a class="el" href="gnuplot_i_h.html#a0">gnuplot_ctrl</a> * <em>h</em>, </b></td> </tr> <tr> <td></td> <td><b> char * <em>label</em> ) </b></td> </tr> </table> </td> </tr> </table> <table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td> <p> Sets the y label of a gnuplot session. <p> <dl compact><dt> <b>Parameters: </b><dd> <table border=0 cellspacing=2 cellpadding=0> <tr><td valign=top><em>h</em> </td><td> Gnuplot session control handle. </td></tr> <tr><td valign=top><em>label</em> </td><td> Character string to use for Y label. </td></tr> </table> </dl><dl compact><dt> <b>Returns: </b><dd> void <p> </dl>Sets the y label for a gnuplot session. <p> Definition at line <a class="el" href="gnuplot_i_c-source.html#l00322">322</a> of file <a class="el" href="gnuplot_i_c-source.html">gnuplot_i.c</a>. </td> </tr> </table> <a name="a4" doxytag="gnuplot_i.c::gnuplot_setstyle"></a><p> <table width="100%" cellpadding="2" cellspacing="0" border="0"> <tr> <td class="md"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td nowrap valign="top"><b> void gnuplot_setstyle ( </b></td> <td valign="bottom"><b> <a class="el" href="gnuplot_i_h.html#a0">gnuplot_ctrl</a> * <em>h</em>, </b></td> </tr> <tr> <td></td> <td><b> char * <em>plot_style</em> ) </b></td> </tr> </table> </td> </tr> </table> <table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td> <p> Change the plotting style of a gnuplot session. <p> <dl compact><dt> <b>Parameters: </b><dd> <table border=0 cellspacing=2 cellpadding=0> <tr><td valign=top><em>h</em> </td><td> Gnuplot session control handle </td></tr> <tr><td valign=top><em>plot_style</em> </td><td> Plotting-style to use (character string) </td></tr> </table> </dl><dl compact><dt> <b>Returns: </b><dd> void <p> </dl>The provided plotting style is a character string. It must be one of the following: <p> <ul> <li>lines<li>points<li>linespoints<li>impulses<li>dots<li>steps<li>errorbars<li>boxes<li>boxeserrorbars </ul> <p> Definition at line <a class="el" href="gnuplot_i_c-source.html#l00270">270</a> of file <a class="el" href="gnu... [truncated message content] |
From: <tr...@us...> - 2002-08-31 11:04:55
|
Update of /cvsroot/basedb/basedb/exec/source/pca In directory usw-pr-cvs1:/tmp/cvs-serv28128 Added Files: Makefile PCA_README PCA_v01.c TestBig.txt TestSmall.txt Log Message: Added PCA plugin from Greg Voronin --- NEW FILE: Makefile --- FILES = pca FLAGS = -c -O3 -Wall -march=i686 -Ignuplot_i-2.6/src/ C = gcc CC = g++ LDFLAGS = -lgsl -lgslcblas SOURCE = PCA_v01.c gnuplot_i-2.6/src/gnuplot_i.c OBJ_PCA = PCA_v01.o gnuplot_i-2.6/src/gnuplot_i.o OBJ_ALL = Makedep.rule $(OBJ_PCA) all: $(FILES) .cc.o: $(CC) $(FLAGS) -o $@ $< .c.o: $(C) $(FLAGS) -o $@ $< clean: rm -f $(OBJ_ALL) $(FILES) *~ touch -d20020101 Makedep.rule depend: $(CC) $(FLAGS) -MM $(SOURCE) >Makedep.rule Makedep.rule: Makefile @echo "The makefile has changed since the last 'make depend'." install: cp $(FILES) ../../apps # Dependencies for executables pca: $(OBJ_PCA) $(C) $(LDFLAGS) -o $@ $+ # Dependencies for object files include Makedep.rule --- NEW FILE: PCA_README --- Principal Components Analysis Plug-In Tool version 0.01 8/26/02 ----------------------------------------------- Contents: ------- 1) Acknowledgement of Support 2) Introduction and Credits 3) Program Outline 4) System Parameters 5) Package List 6) Compilation, Linking Running 5) Test Runs 7) Integration with BASE 8) To Do List 9) References 1) Acknowledgement of Support: ------------------------ Creation of this software and documentation was supported by a grant from the New Jersey Commission on Spinal Cord Research. Support is also acknowledged from the Spinal Cord Injury Project of the W.M. Keck Center for Collaborative Neuroscience of Rutgers University. Authors: Gregory O. Voronin go...@ya... Ronald P. Hart rh...@an... Neuroscience Gene Expression Laboratory( www.ngelab.org ), W.M. Keck Center Center for Collaborative Neuroscience Rutgers University Piscataway, NJ 08854 2) Introduction and Credits: -------------------- We are releasing this PCA tool as an open source package under the GNU General Public Liscense. A copy of this liscense is provided in the archive file.Please feel free to use, modify and improve this code. It free to use and incorporate into your own projects. If you use this code, remember to credit us for its use. This project could not have been completed with the following projects: a) GNU Gnu Scientific Library - A comprehensive set of tools for numerical analysis of a broad range of problems. As a testimonial to the usefulness of this package, I was able to get the PCA calculation component coded, debugged and tested against real data sets in 1 and 1/2 days of leisurlely programming. This package can be found at: http://www.gnu.org/software/gsl/ b) Nicolas Devillard's gnuplot_i - This package allows you to call and use gnuplot directly from your C program. Compile and run his example programs then look at his code to see how easy it is to incorporate gnuplot funtionality into your code. This can be found at: http://ndevilla.free.fr/gnuplot/ We also include it as part of the PCA download package. 3) Program Outline: -------------- Detailed descriptions of Principal Components Analysis(PCA) can be found in the reference list. The following is an outline of our program: PCA is a multivariate statistics method at reducing data set dimensionality. The calculation of the PCA for a given data set is straight forward, however, the interpretation can be challenging. The reference list, your own judgement and the biology of your experiment should all be used to interpret the results of PCA. This program calculates the PCA of the sample variance-covariance matrix of your data set: a) Data is parsed from a lowess transformed data set in serial BASE file format. b) The natural logarithm of the ratio of expression intensity 1 to expression intensity 2 is then calculated. c) The data matrix of the ln transformed date is then created. Rows correspond to genes and columns correspond to experimental variates. d) The average value of each column is calcuated and a second matrix, called the average matrix is then created. For each column of the average matrix, the row value is equal to the column average of the corresponding column. e) The average matrix is then subtracted from the data matrix. This produces the difference matrix. f) The variance-covariance matrix is calcuated from the product of the transpose of the difference matrix times the difference matrix itself. The resulting marix is a symmetric matrix with all positive real values. Multiplying the entire matrix by ( 1/rows -1 ) yields the final sample variance-covariance matrix. g) The eigenvalues and eigenvectors of the sample variance-covariance matrix are then calculated. The combination of eigenvalues and eigenvectors for a given matrix can be termed the eignensytem of that matrix. The eigensystem is then sorted by the value of the eigenvalue of the system. h) The variance-covariance matrix and the eigensystem( which is stored in a linked list) are used to generate the output files, currently: covariance.html, eigensystem.html, Scree.png and CoeffieicentPlot.png. Some notes: 1) We did not reinvent the wheel when it comes to finding the eigensystem of a matrix. We used the Gnu Scientific Library. In their documentation, GNU Scientific Library Reference Manual Edition 1.2, for GSL Version 1.2 15 July 2002, the developers state: "This chapter describes functions for computing eigenvalues and eigenvectors of matrices. There are routines for real symmetric and complex hermitian matrices, and eigenvalues can be computed with or without eigenvectors. The algorithms used are symmetric bidiagonalization followed by QR reduction. These routines are intended for "small" systems where simple algorithms are acceptable. Anyone interested finding eigenvalues and eigenvectors of large matrices will want to use the sophisticated routines found in LAPACK. The Fortran version of LAPACK is recommended as the standard package for linear algebra. " Always, always check your work. We have tested this our code with a 5000 gene by 5 variate data set. We then compared the eigensystems generated with GeneSpring's PCA and PCA we implemented on Mathcad Plus 6.0 from Mathsoft Inc. with the same data set. The results provided by these three idependent implementations on the same data set were essentially the same. But you must confirm your own results. You are welcome to determine what is meant by a "small" system and report back to us. Lest you think we are lazy in not implementing our own eigensystem routines, we rely on the wisdom of authors of Numerical Recipes in C: The Art of Scientific Computing: "You have probably gathered by now that the solution of eigensystems is a fairly complicated business. It is. It is one of the few subjects covered in this book for which we do not recommend that you avoid canned routines." 2) A Scree plot shows the ordered eigen values against their ordinal number. This can be used to estimate the number of "true" components or rank of your data set. 3) The coefficient plot displays the value of the coeffiecent of a given principal component on the Y axis. Each princiapl component is plotted in a different color. TheX axis corresponds the data set or column to which that coefficient corresponds. 4) System parameters: ----------------- We can confirm succesful compilation and operation on the following system(s): RedHat Linux 7.3 ( 2.4.18 kernel, gcc 2.96-RH, glibc 2.2.4, XFree86 4.2.0 ) BASE 1.0.6 gcc version 2.96 20000731 ( RedHat Linux 7.3 2.96 ) gsl 1.1.1 gnuplot linux version 3.7.1 gnuplot_i-2.6 Gnuplot must be installed and working on your system. On our RedHat 7.3 installation, gnuplot was installed and gsl was provided as an RPM. 5) Package list: ----------- The following files should be present in the tarred and gzipped archive called PCA_v01.tar.gz 1) PCA_v01.c source code 2) PCA_v01 executable 3) gnuplot_i-2.6 N. Devillard's open source c interface to gnuplot 4) TestSmall.txt serial BASEfile fromat test data file 5) TestBig.txt serial BASEfile format test data file 6) PCA_README this file 6) Compilation, Linking and Running: --------------------------- A) Create a directory on your system called /usr/PCA. This will serve as the working directory prior to integrating the plug-in with BASE. Copy the gzipped archive to /usr/PCA then unzip and untar the archive PCA_v01.tar.gz: > mkdir /usr/PCA > cp ./PCA_v01/tar/gz /usr/PCA > gunzip PCA_v01.tar.gz > tar xvf PCA_v01.tar This will extract the files listed in section 4) Package List. B) Try a test run of the executable file PCA_v01 first. If this works on your system, then you won't to go through the compilation and linking procedure( Steps C - ). a) Test to ensure the program is executtable by running the directory command and seeing the that the executable parameter is set: > ls -al The console output of this command should somewhat like the following: drwxrwxr-x 5 1183 root gnuplot_i-2.6 -rw-r--r-- 1 root root PCA_README -rwxr-xr-x 1 root root PCA_v01 -rw-r--r-- 1 root root PCA_v01.c -rw-r--r-- 1 root root PCA_v01.tar -rw-r--r-- 1 root root TestBig.txt -rw-r--r-- 1 root root TestSmall.txt As you can see from the above, the x's are set for PCA_v01. If this is not the case for your output, issue the following command: > chmod 777 PCA_v01 b) To execute the program type the following: > PCA_v01 < TestSmall.txt You should see the following output: The variance-covariance matrix: 0.625100 0.004427 -0.001474 0.004427 0.140561 -0.005588 -0.001474 -0.005588 0.170664 PCA calculations completed. Point your web browser to your current working directory and bring up the following files: Covariance.html Eigensystem.html Scree.png CoefficientPlot.png The four files you see listed can be viewed in your browser by pointing to the working directory where they are created and then clicking on them from the browser window. The working directory is simply the directory in which you run the program. If the above steps work and give the desired output, you do not need to recompile the PCA_v01 from the source code. You can proceed the Section 6, Integrating with BASE. C) To compile from the source code: a) Test the steps from B) once again to be sure you didn't miss anything. b) Since you followed all the steps in B, you have a working directory /usr/PCA. Move to this directory and descend into the subdirectory callled gnuplot_i-2.6: > cd /usr/PCA > cd gnuplot_i-2.6 c) Please consult the instructions in the gnuplot_1-2.6 documentation prior to completing this step. Additionally you should create the example programs provided in with the gnuplot_i-2.6 package. The are very interesting and the source code is sort and easy to read. While in the gnuplot_i-2.6 subdirectory issue the make command: > make To compile and link the Nicolas Devillard's example programs: > make tests f) A file called gnuplot_i.o should exist in the directory /usr/PCA/gnuplot_i-2.6. Copy this file to the directory containing the PCA plug-in source code. This assumes we are using /usr/PCA as our working directory: > cd /usr/PCA/gnuplot_i-2.6 > cp ./gnuplot_i.o /usr/PCA Now descend into the src directory in the gnuplot_i-2.6 sub-directory and copy the header file gnuplot_i.h to the PCA working directory: > cd /usr/PCA/gnuplot_i-2.6/src > cp ./gnuplot_i.h /usr/PCA g) Now you can compile and link the PCA source code in one fell swoop: > gcc -O3 -I/usr/include -lgsl -lgslcblas -lm -o PCA_v01 PCA_v01.c gnuplot_i.o This will create the executable PCA_v01 in the working directory. h) Test the executable according to the instructions in B). 7) Integrating with BASE: ------------------ A) To integrate the executable with BASE, first copy the executable file to the exec/apps directory in the BASE directory tree. This will of course depend on the location of base in your directory tree, ( i.e the base home path ): > cp /usr/PCA/PCA_v01 /usr/local/base/exec/apps/ The execuatable file is now present in the correct directory. B) Now we can tell out BASE installation about the PCA plug-in: a) Log onto BASE as root b) Clickon the Analyze Data section. c) Click on Plug-ins d) Click on Add plug-in. This will bring up a page where you can specify the parameters for the plug-in: Fill in the following fields: Name: Analysis: PCA Name of executable: PCA_v01 Active: Check: On Data format Choose: Serial BASEfile( one section per assay ) Columns Check: postion and molecule Fields Check: intensity1 and intensity2 e) After you have entered the above options, click Accept The PCA Plug-in will now be active and usable: Choose and experiment to run this on. Run the Lowess plug-in. Choose to the [run app] option on the lowess transformed option line. Choose the Analysis: PCA plug-in. Remember that PCA is for multidimensional data that has been lowess transformed. It may take a while to run. Please be patient. 8) To Do List: ---------- 1) Improve parser efficiency, or integrate with Carl's C++ BASEfile parser 2) Provide postscript output file. 3) Resolve diminishing/truncated reporters list issue. 4) Component vs. Component 2D and 3D output with data. 5) Document use/parsing of stdin.txt 6) SQL script for uploading the plug-in definition 9) References: ----------- Principles of Multivariate Analysis: A User's Perspective. Krzanowski, WJ. Oxford University Press 1988. A User's Guide to Principal Components. Jackson, EJ. John Wiley & Sons, Inc. 1991 Principal Components Analysis to Summarize Microarray Experiments: Application to Sporulation Time Series. Raychaudhuri S, Stuart JM, Altman RB. Pacific Symposium on Biocomputing 2000. Honolulu, Hawaii, 452-463, 2000. --- NEW FILE: PCA_v01.c --- // // PCA Plug-In for BioArraySoftware Environment( BASE ) // homepage http://www.ngelab.org // BASE - homepage http://base.thep.lu.se/ // Copyright (C) 2002 Ron Hart, Greg Voronin(rhgv) // // Write to: See Below // This file is part of PCA_v01, a Principal Components Analysis Plug_In for BASE. // // PCA_v01 is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License // as published by the Free Software Foundation; either version 2 // of the License, or (at your option) any later version. // // PCA_v01 is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // // // Creation of this software and documentation was supported by a grant from the New Jersey Commission on Spinal Cord Research. // Support is also acknowledged from the Spinal Cord Injury Project of the W.M. Keck Center for Collaborative Neuroscience of Rutgers University. // // Authors: // // Gregory O. Voronin go...@ya... // Ronald P. Hart rh...@an... // Neuroscience Gene Expression Laboratory( www.ngelab.org ), // W.M. Keck Center Center for Collaborative Neuroscience // Rutgers University // Piscataway, NJ 08854 // /* ********************************************************************************* */ /* See the file PCA_README for a complete outline of the method */ /* used to perform PCA. Also consult the references cited therein. */ /* ********************************************************************************* */ #include <stdio.h> #include <stdlib.h> #include <math.h> #include <unistd.h> #include <gsl/gsl_matrix.h> #include <gsl/gsl_blas.h> #include <gsl/gsl_eigen.h> #include "gnuplot_i.h" /* **************************************************************************************** Link list structure for the data list. . . Since we know neither the number genes/rows/reporters nor the number of assays/experiments in a set prior to parsing the data file, a dynamic data strucutre seems to be called for. Similarly, eigensystem of the variance-covariance matrix will be stored in a linked list of elements of structure eigenRec. ***************************************************************************************** */ struct lowessRec { int row; int col; double intensity1; double intensity2; double ratio; char *tag; struct lowessRec *next; }; struct eigenRec { char *annotation; int cols; double eigenvalue; gsl_vector *eigenvector; struct eigenRec *next; }; /* ********************************************************************************** These typedefs will allow us to easily use the linked list representing the datalist and eigensystem throughout our code. ************************************************************************************ */ typedef struct lowessRec MYREC; typedef MYREC *LINK; typedef struct eigenRec EIGENREC; typedef EIGENREC *ELINK; /* Global variables used */ /* *********************************************************************************** matrix a is the data matrix representing the natural log transformed expression intensity ratios for the given experiments. Rows are are the genes and columns are the experiments. matrix s is the variance-covariance matrix. This is a symetrical col number X col number sized matrix. ************************************************************************************* */ gsl_matrix *a; gsl_matrix *s; /* ******************************************************************************* These are shared data tags which help to define the contents of a particular structure element in the linked list of data parsed in tjhe lowess transformed data file. ********************************************************************************** */ char *HEAD ="Head"; char *BEGIN = "Begin"; char *DATA = "Data"; LINK dataList, lowessHead; ELINK eigenList; /* ********************************************************************************************************** Function prototype headers *********************************************************************************************************** */ /* ***** data list linked list function protypes ***** */ LINK initializeList(); void addElement( int _row, int _col, double _intensity1, double _intensity2, int _code, LINK list ); void setRowsAndColumns( int maxRow, int maxCol, LINK list ); /* ************************************************************** */ /* ***** eigensystem list linked list function prototypes ***** */ ELINK initializeEList(); void addEigenLink( char *_annotation, ELINK _elist ); /* ******************************************************************** */ /* ***** parsing function prototype ****** */ void parse( LINK dList, ELINK eList ); /* ************************************************* */ /* ****** PCA calculation function prototypes ****** */ gsl_matrix listToMatrix( LINK list, gsl_matrix *m ); void createCovarianceMatrix(gsl_matrix *m, gsl_matrix *sm, ELINK eList ); void calculateEigenSystem( gsl_matrix *m, ELINK eList ); /* ******************************************************************* */ /* ***** output function protoypes ***** */ void outputCovarMatrix( ELINK eList, gsl_matrix *m ); void outputEigenSystem( ELINK eList ); void outputScreePNG( ELINK eList, int cols ); /* *********************************************************************************************************** */ /* ***** Begin Program Function Implementations Here ****** */ /* **************************************************************************************** main method: 1) parse the lowess transformed BASEfile into the into the linked list for data 2) use the now known col and row length parameters here to create the matrices for PCA 3) convert the data linked list to the data matrix 4) perform the PCA calculations 5) output the results of the eigensystem of the variance-covariance matrix. ****************************************************************************************** */ int main( void ) { dataList = initializeList(); eigenList = initializeEList(); parse( dataList, eigenList ); a = gsl_matrix_alloc( dataList->row, dataList->col ); s = gsl_matrix_alloc( dataList->col, dataList->col ); listToMatrix( dataList, a ); createCovarianceMatrix( a, s, eigenList ); calculateEigenSystem( s, eigenList ); outputCovarMatrix( eigenList, s ); outputEigenSystem( eigenList ); outputScreePNG( eigenList, s->size1 ); printf( "PCA calculations completed. Point your web browser to your\n" ); printf( "current working directory and bring up the following files: \n\n" ); printf( "\tCovariance.html\n" ); printf( "\tEigensystem.html\n" ); printf( "\tScree.png\n" ); printf( "\tCoefficientPlot.png\n\n" ); return 0; } void parse( LINK dList, ELINK eList ) { /* jobController.php prepares a tab-delimited text file from the information to it from the database tables Program and ProgramParameter. A text file in the BASEfile format is then created. This file is called stdin.txt jobController then calls your program and redirects the stdin iostream from the console/keyboard to the file stdin.txt. This allows you to look at stdin.txt as a set of strings entered by the user at the keyboard. The parser parses this BASEfile( stdin.txt ) as such. It uses a combination of scanf() and fgets() to do this. The parser keeps track of its position in the BASEfile as it marches through the various sections by means of a set of state variables. These can be viewed as series of boolean on/off switches. The switches are set and reset as the parser changes state. */ /* stand text strings used in the BASEfile format. */ char *SECTION = "section"; char *SPOTS = "spots"; char *COUNT = "count"; char *PERCENT = "%"; char line[100]; char *token; char *delimiters; char inten1[15]; char inten2[15]; char columnTitle[30]; int col; int i; int index = 0; double data, fi1, fi2; /* ****************************************************** The following are parser state variables: 0 = false; 1 = true; They represent the 'states' the parser is in while working its way through the lowess transformed BASEfile ( serial format ). ******************************************************** */ int inSection = 0; int inSpots = 0; int inPercent = 0; int inData = 0; int inCount = 0; int inAnnotation = 0; int rowCount = 0; scanf( "%s", line ); while( line != NULL && !feof( stdin ) ) { if ( line != NULL ) { if ( strcmp( line, SECTION ) == 0 ) { // printf( "in a section\n" ); inSection = 1; inPercent = 0; inData = 0; } if (inSection && strcmp( line, COUNT ) == 0 ) { scanf( "%d", &col ); inSection = 0; inCount = 1; } if( inCount && strcmp( line, PERCENT ) == 0 ) { inCount = 0; inAnnotation = 1; } if ( inAnnotation ) { /* ignore this first line */ fgets( columnTitle, 100, stdin ); for ( i = 0; i < col; i++ ) { fgets( columnTitle, 100, stdin ); addEigenLink( columnTitle, eList ); } inAnnotation = 0; } if ( inSection && strcmp( line, SPOTS ) == 0 ) { /* Oh yeah, were getting close to the data! */ inCount = 0; inSection = 0; inSpots = 1; } if ( inSpots && strcmp( line, PERCENT ) == 0 ) { /* Yeah baby, yeah baby this must be it! */ inPercent = 1; inData = 1; inSpots = 0; } if ( inData ) { if ( strcmp( line, PERCENT ) == 0 ) { /* This element indicates the beginning of a new replicate */ rowCount = 0; addElement( 0, 0, 0.0, 0.0, 1, dList ); } else if ( strcmp( line, SECTION ) == 0 ) { /* a new section of data, no doubt */ inData = 0; // inSection = 1; } else { if ( index == 0 ) { index = index + 1; } else if ( index == 1 ) { index = index + 1; } else if ( index == 2 ) { /* This is the lowess transformed intensity 1. It is being converted from a string to a number. */ fi1 = atof( line ); index = index + 1; } else { /* This is the lowess transformed intensity 1. It is being converted from a string to a number. */ fi2 = atof( line ); rowCount = rowCount + 1; // printf( "The intensities are 1: %f 2: %f\n", fi1, fi2 ); addElement( 0, 0, fi1, fi2, 0, dList ); index = 0; } } } } /* end of first if line != NULL */ scanf( "%s", line ); } /* end of outer most while loop */ setRowsAndColumns( rowCount, col, dList ); } /* The implementation of the linked list for the data list follows. This is a standard linked list implementation available in numerous code cookbooks and data strcutures and algorithm's course text books. */ LINK initializeList() { lowessHead = (LINK)malloc( sizeof( MYREC ) ); if ( lowessHead == NULL ) { printf( "failure to allocate space for the data list\n" ); exit( 1 ); } lowessHead->tag = HEAD; lowessHead->next = NULL; return lowessHead; } void addElement( int _row, int _col, double _intensity1, double _intensity2, int _code, LINK list ) { int rowCount; double r; struct lowessRec *newRec; newRec = (LINK)malloc ( sizeof( MYREC ) ); if ( newRec == NULL ) { printf( "shit!\n" ); exit( 1 ); } /* initialize the new rec values here */ newRec->row = _row; newRec ->col = _col; newRec->intensity1 = _intensity1; newRec->intensity2 = _intensity2; if ( _code == 1 ) { newRec->tag = BEGIN; rowCount = 0; } else if ( _code == 0 ) { newRec->tag = DATA; rowCount = rowCount + 1; r = log( _intensity1 / _intensity2 ); newRec->ratio = r; } newRec->next = NULL; /* walk to the end of the list, but don't fall off! */ while( list->next != NULL ) { list = list->next; } /* add the newRec to the end of the list */ list->next = newRec; } void setRowsAndColumns( int maxRow, int maxCol, LINK list ) { list->row = maxRow; list->col = maxCol; } /* The implementation of the linked list for the eigensystem follows. This is a standard linked list implementation available in numerous code cookbooks and data structures and algorithm's course text books. The annotation string's location does not imply a particular attachment to the eigen vector or eigenvalue value in the linked list. It is a merely a convienent place to store this information and use a later time for output. */ ELINK initializeEList() { ELINK eigenHead; eigenHead = (ELINK)malloc( sizeof( EIGENREC ) ); if ( eigenHead == NULL ) { printf( "failure to allocate space for head of eigen system list\n" ); exit( 1 ); } eigenHead->next = NULL; return eigenHead; } void addEigenLink( char *_annotation, ELINK _elist ) { EIGENREC *newRec; if ( _elist == NULL ) { _elist = (ELINK)malloc( sizeof( EIGENREC ) ); // printf( "allocating a new list\n" ); } newRec = (ELINK)malloc( sizeof( EIGENREC ) ); if ( newRec == NULL ) { printf( "Falied to alloc space for an EIGENREC.\n" ); exit( 1 ); } newRec->annotation = ( char *)malloc( strlen( _annotation ) + 1 ); strcpy( newRec->annotation, _annotation ); while( _elist->next != NULL ) { _elist = _elist->next; } _elist->next = newRec; } /* This function converts the data list linked list into a data matrix, which then can be manpulated by gsl functions */ gsl_matrix listToMatrix( LINK list, gsl_matrix *m ) { int matrixRows = 0; int matrixCols = 0; int currentRow = 0; int currentCol = -1; int rows, cols; int i, j; int index; matrixRows = list->row; matrixCols = list->col; while( list != NULL ) { if ( strcmp( list->tag, BEGIN ) == 0 ) { currentCol = currentCol + 1; currentRow = 0; } if ( strcmp( list->tag, DATA ) == 0 ) { if ( currentRow < matrixRows ) { gsl_matrix_set( m, currentRow, currentCol, list->ratio ); } currentRow = currentRow + 1; } if ( list !=NULL ) { list = list->next; } } /* end traversal outer while */ return *m; } /* The following functions perform the PCA calculation. */ void createCovarianceMatrix( gsl_matrix *m, gsl_matrix *sm, ELINK eList ) { /* calculating the difference matrix, requires first the matrix of column means */ int i, j, index, maxR, maxC; double columnSum, columnAvg, scaling; FILE *fp; ELINK workingList; gsl_matrix *am; gsl_matrix *at; int maxRow = m->size1; int maxCol = m->size2; am = gsl_matrix_alloc( maxRow, maxCol ); columnSum = 0; columnAvg = 0; for ( i = 0; i < maxCol; i++ ) { for ( j = 0; j < maxRow; j++ ) { columnSum = columnSum + gsl_matrix_get( m, j, i ); } columnAvg = columnSum / ( m->size1 ); for ( j = 0; j< maxRow; j++ ) { gsl_matrix_set( am, j, i, columnAvg ); } columnSum = 0; columnAvg = 0; } /* the matrix m will now be turned into the diffrerence matrix */ gsl_matrix_sub( m, am ); scaling = 1.0 / ( m->size1 - 1 ); at = gsl_matrix_alloc( m->size2, m->size1 ); gsl_matrix_transpose_memcpy( at, m ); gsl_blas_dgemm( CblasNoTrans, CblasNoTrans, 1.0, at, m, 0.0, sm ); gsl_matrix_scale( sm, scaling ); printf( "The variance-covariance matrix:\n" ); for ( i = 0; i < sm->size1; i++ ) { for ( j = 0; j < sm->size2; j++ ) { printf( " %f ", gsl_matrix_get( sm, i, j ) ); } printf( "\n" ); } printf( "\n" ); /* the matrix s is now the variance-covariance matrix */ gsl_matrix_free( m ); gsl_matrix_free( am ); gsl_matrix_free( at ); } void calculateEigenSystem( gsl_matrix *m, ELINK eList ) { int i, j, index; gsl_vector *eigenValues; gsl_matrix *working_m, *eigenVectors; gsl_eigen_symmv_workspace *w; eigenValues = gsl_vector_alloc( m->size2 ); working_m = gsl_matrix_alloc( m->size1, m->size2 ); gsl_matrix_memcpy( working_m, m ); eigenVectors = gsl_matrix_alloc( m->size2, m->size2 ); w = gsl_eigen_symmv_alloc( m->size2 ); gsl_eigen_symmv( working_m, eigenValues, eigenVectors, w ); gsl_eigen_symmv_free( w ); gsl_eigen_symmv_sort( eigenValues, eigenVectors, GSL_EIGEN_SORT_VAL_DESC ); /* assign the eigensystem list to the appropriate values */ eList = eList->next; index = 0; while ( eList != NULL && index < eigenValues->size ) { eList->eigenvalue = gsl_vector_get( eigenValues, index ); eList->cols = eigenValues->size; eList->eigenvector = gsl_vector_alloc( eigenValues->size ); gsl_matrix_get_col( eList->eigenvector, eigenVectors, index ); index = index + 1; eList = eList->next; } } /* The following functions create the HTML and text files displaying the results of the PCA computation. */ void outputCovarMatrix( ELINK eList, gsl_matrix *m ) { int i, j, col, row; ELINK head = eList; /* maintain a pointer to the head of the list */ FILE *fp1 = fopen( "Covariance.html", "w" ); if ( fp1 != NULL ) { /* Begin of html output of the variance-covariance matrix */ fprintf( fp1, "<html>" ); fprintf( fp1, "<table border=\"3\" cellpadding=\"3\" cellspacing=\"1\">" ); fprintf( fp1, "<caption><b>Variance-Covariance Matrix of the Data</b></caption>" ); fprintf( fp1, "<tr><td></td>" ); /* Place experiment names across the top of the table */ /* Skip the head of the list */ eList = eList->next; while( eList != NULL ) { fprintf( fp1, "<td align=\"center\"><font color=\"blue\">%s</font></td>", eList->annotation ); eList = eList->next; } fprintf( fp1, "</tr>" ); /* Begin the rows and columns of the variance-covariance matrix by returning to the head of the list to obtain experiment names and used the variance-covariance matrix to display the results */ eList = head; eList = eList->next; row = 0; while ( eList != NULL ) { fprintf( fp1, "</tr>" ); fprintf( fp1, "<td align=\"center\"><font color=\"blue\">%s</font></td>", eList->annotation ); for (col = 0; col<m->size2; col++ ) { fprintf( fp1, "<td align=\"center\">%f</td>", gsl_matrix_get( m, row, col ) ); } eList = eList->next; row = row + 1; fprintf( fp1, "<tr>" ); } /* End of the html output of the variance-covariance matrix */ fprintf( fp1, "</table>" ); fprintf( fp1, "</html>" ); fclose( fp1 ); } } void outputEigenSystem( ELINK eList ) { int i, index; ELINK head; FILE *fp1 = fopen( "Eigensystem.html", "w" ); head = eList; if ( fp1 != NULL ) { /* The files have both been created and can be written too */ /* write to the HTML file */ fprintf( fp1, "<html><head>" ); fprintf( fp1, "<body><Br></Br>" ); eList = eList->next; /* Skip the head of the list */ fprintf( fp1, "<table border=\"3\" cellpadding=\"3\" cellspacing=\"1\">" ); fprintf( fp1, "<caption><b>Principal Components Table</b></caption>" ); fprintf( fp1, "<tr>" ); fprintf( fp1, "<td align=\"center\"><font color=\"red\">Eigenvalue</font></td>" ); fprintf( fp1, "</tr>" ); eList = head; eList = eList->next; index = 1; while ( eList != NULL ) { fprintf( fp1, "<tr>" ); fprintf( fp1, "<td align=\"center\"><font color=\"red\">%f</font></td>", eList->eigenvalue ); fprintf( fp1, "<td align=\"center\"><font color=\"blue\">principal component %d</td>", index ); for ( i = 0; i<eList->cols; i++ ) { fprintf( fp1, "<td align=\"center\">%f</font></td>", gsl_vector_get( eList->eigenvector, i ) ); } fprintf( fp1, "</tr>" ); eList = eList->next; index = index + 1; } fprintf( fp1, "</table>" ); fclose( fp1 ); } } void outputScreePNG( ELINK eList, int cols ) { int i, j; /* component label variables */ int size = 30; int count = 1; char *label = (char *)malloc( size ); double index[ cols ]; double eigenvalues[ cols ]; double coefficients[ cols ]; ELINK head; /* initialize gnuplot sessions */ gnuplot_ctrl *session1 = gnuplot_init(); gnuplot_ctrl *session2 = gnuplot_init(); head = eList; /* Maintain a pointer to the head of the list */ eList = eList->next; i = 0; while ( eList != NULL ) { eigenvalues[ i ] = eList->eigenvalue; index[ i ] = ( double )i; eList = eList->next; i = i + 1; } gnuplot_cmd( session1, "set terminal png color" ); gnuplot_cmd( session1, "set output \"Scree.png\""); gnuplot_setstyle( session1, "linespoints" ); gnuplot_set_xlabel( session1, "Ordinal Position of Eigenvalue" ); gnuplot_set_ylabel( session1, "Eigenvalue" ); gnuplot_plot_xy( session1, index, eigenvalues, cols, "" ); /* close the gnuplot session 1 */ gnuplot_close( session1 ); /* begin output form gnuplot session 2 */ gnuplot_cmd( session2, "set terminal png color" ); gnuplot_setstyle( session2, "linespoints" ); gnuplot_set_xlabel( session2, "Experimental Conditions" ); gnuplot_set_ylabel( session2, "Coefficient Value" ); eList = head; /* Maintain a pointer to the head of the list */ eList = eList->next; while ( eList != NULL ) { for ( j = 0; j < cols; j++ ) { coefficients[ j ] = gsl_vector_get(eList->eigenvector, j ); } snprintf( label, size, "Principal Component %d ", count ); gnuplot_cmd( session2, "set output \"CoefficientPlot.png\""); gnuplot_plot_x( session2, coefficients, cols, label ); count = count + 1; eList = eList->next; } /* close the gnuplot session 2 */ gnuplot_close( session2 ); } --- NEW FILE: TestBig.txt --- BASEfile fit_fraction 0.33 min_x_step 0.1 n_iter 4 section lowess settings % section assays count 3 columns id name Hrs Rx Test Tx annotationColumns Hrs Rx Test Tx % 4 Test Set 1 5 Test Set 2 6 Test Set 3 section spots columns position molecule assayData assayFields intensity1 intensity2 [...2566 lines suppressed...] 2573 336 239.187 261.954 990 5205 320.577 195.822 597 2074 206.474 304.039 636 2231 260.801 240.736 4270 3451 247.211 253.993 977 3823 282.499 222.359 932 1229 191.449 328.474 150 2255 244.294 257.886 2698 343 249.614 252.838 274 2114 215.69 292.656 3512 3034 292.825 216.129 216 1034 248.059 255.254 547 1841 260.216 243.49 87 4955 238.531 265.626 1566 918 287.291 220.641 898 4502 327.925 193.349 2278 3695 192.366 329.964 1480 2246 256.007 248.055 506 1996 265.489 239.196 3800 2461 283.063 224.459 --- NEW FILE: TestSmall.txt --- BASEfile fit_fraction 0.33 min_x_step 0.1 n_iter 4 section lowess settings % section assays count 3 columns id name Hrs Rx Test Tx annotationColumns Hrs Rx Test Tx % 4 Test Set 1 5 Test Set 2 6 Test Set 3 section spots columns position molecule assayData assayFields intensity1 intensity2 assays 4 % 4705 1876 0.182727772 0.639442747 3361 3490 0.178550103 0.734521416 2017 1092 0.75188986 0.946157646 673 4443 0.52163883 0.425572287 4706 4393 0.226277593 0.75675317 3362 4517 0.483571184 0.284209255 2018 4223 0.363921297 0.430420856 674 1501 0.282386944 0.374558038 4707 4540 0.53350036 0.745814532 3363 3266 0.718361323 0.855847816 section spots columns position molecule assayData assayFields intensity1 intensity2 assays 4 % 4705 1876 0.956653582 0.144926138 3361 3490 0.530925839 0.154646906 2017 1092 0.433994784 0.998590057 673 4443 0.474103618 0.36427883 4706 4393 0.382959597 0.793716884 3362 4517 0.257531312 0.304847628 2018 4223 0.426341693 0.119879148 674 1501 0.31309046 0.544443088 4707 4540 0.072738575 0.186893687 3363 3266 0.576870571 0.694229354 section spots columns position molecule assayData assayFields intensity1 intensity2 assays 4 % 4705 1876 0.116390925 0.643916614 3361 3490 0.791205844 0.630646561 2017 1092 0.769312628 0.557026574 673 4443 0.986900081 0.447894876 4706 4393 0.755242497 0.031620397 3362 4517 0.133165695 0.222270832 2018 4223 0.533144379 0.171807537 674 1501 0.252414263 0.34161909 4707 4540 0.422475338 0.672763583 3363 3266 0.68490596 0.375773707 |
From: <tr...@us...> - 2002-08-31 11:04:55
|
Update of /cvsroot/basedb/basedb/exec/source/pca/gnuplot_i-2.6/src In directory usw-pr-cvs1:/tmp/cvs-serv28128/gnuplot_i-2.6/src Added Files: gnuplot_i.c gnuplot_i.h Log Message: Added PCA plugin from Greg Voronin --- NEW FILE: gnuplot_i.c --- /*-------------------------------------------------------------------------*/ /** @file gnuplot_i.c @author N. Devillard @date Sep 1998 @version $Revision: 1.1 $ @brief C interface to gnuplot. gnuplot is a freely available, command-driven graphical display tool for Unix. It compiles and works quite well on a number of Unix flavours as well as other operating systems. The following module enables sending display requests to gnuplot through simple C calls. */ /*--------------------------------------------------------------------------*/ /* $Id: gnuplot_i.c,v 1.1 2002/08/31 11:04:52 troein Exp $ $Author: troein $ $Date: 2002/08/31 11:04:52 $ $Revision: 1.1 $ */ /*--------------------------------------------------------------------------- Includes ---------------------------------------------------------------------------*/ #include "gnuplot_i.h" /*--------------------------------------------------------------------------- Defines ---------------------------------------------------------------------------*/ /** Maximal size of a gnuplot command */ #define GP_CMD_SIZE 2048 /** Maximal size of a plot title */ #define GP_TITLE_SIZE 80 /** Maximal size for an equation */ #define GP_EQ_SIZE 512 /** Maximal size of a name in the PATH */ #define PATH_MAXNAMESZ 4096 /** Define P_tmpdir if not defined (this is normally a POSIX symbol) */ #ifndef P_tmpdir #define P_tmpdir "." #endif /*--------------------------------------------------------------------------- Function codes ---------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/ /** @brief Find out where a command lives in your PATH. @param pname Name of the program to look for. @return pointer to statically allocated character string. This is the C equivalent to the 'which' command in Unix. It parses out your PATH environment variable to find out where a command lives. The returned character string is statically allocated within this function, i.e. there is no need to free it. Beware that the contents of this string will change from one call to the next, though (as all static variables in a function). The input character string must be the name of a command without prefixing path of any kind, i.e. only the command name. The returned string is the path in which a command matching the same name was found. Examples (assuming there is a prog named 'hello' in the cwd): @verbatim gnuplot_get_program_path("hello") returns "." gnuplot_get_program_path("ls") returns "/bin" gnuplot_get_program_path("csh") returns "/usr/bin" gnuplot_get_program_path("/bin/ls") returns NULL @endverbatim */ /*-------------------------------------------------------------------------*/ char * gnuplot_get_program_path(char * pname) { int i, j, lg; char * path; static char buf[PATH_MAXNAMESZ]; /* Trivial case: try in CWD */ sprintf(buf, "./%s", pname) ; if (access(buf, X_OK)==0) { sprintf(buf, "."); return buf ; } /* Try out in all paths given in the PATH variable */ buf[0] = 0; path = getenv("PATH") ; if (path!=NULL) { for (i=0; path[i]; ) { for (j=i ; (path[j]) && (path[j]!=':') ; j++); lg = j - i; strncpy(buf, path + i, lg); if (lg == 0) buf[lg++] = '.'; buf[lg++] = '/'; strcpy(buf + lg, pname); if (access(buf, X_OK) == 0) { /* Found it! */ break ; } buf[0] = 0; i = j; if (path[i] == ':') i++ ; } } else { fprintf(stderr, "PATH variable not set\n"); } /* If the buffer is still empty, the command was not found */ if (buf[0] == 0) return NULL ; /* Otherwise truncate the command name to yield path only */ lg = strlen(buf) - 1 ; while (buf[lg]!='/') { buf[lg]=0 ; lg -- ; } buf[lg] = 0; return buf ; } /*-------------------------------------------------------------------------*/ /** @brief Opens up a gnuplot session, ready to receive commands. @return Newly allocated gnuplot control structure. This opens up a new gnuplot session, ready for input. The struct controlling a gnuplot session should remain opaque and only be accessed through the provided functions. The session must be closed using gnuplot_close(). */ /*--------------------------------------------------------------------------*/ gnuplot_ctrl * gnuplot_init(void) { gnuplot_ctrl * handle ; if (getenv("DISPLAY") == NULL) { fprintf(stderr, "cannot find DISPLAY variable: is it set?\n") ; } if (gnuplot_get_program_path("gnuplot")==NULL) { fprintf(stderr, "cannot find gnuplot in your PATH"); return NULL ; } /* * Structure initialization: */ handle = (gnuplot_ctrl*)malloc(sizeof(gnuplot_ctrl)) ; handle->nplots = 0 ; gnuplot_setstyle(handle, "points") ; handle->ntmp = 0 ; handle->gnucmd = popen("gnuplot", "w") ; if (handle->gnucmd == NULL) { fprintf(stderr, "error starting gnuplot\n") ; free(handle) ; return NULL ; } return handle; } /*-------------------------------------------------------------------------*/ /** @brief Closes a gnuplot session previously opened by gnuplot_init() @param handle Gnuplot session control handle. @return void Kills the child PID and deletes all opened temporary files. It is mandatory to call this function to close the handle, otherwise temporary files are not cleaned and child process might survive. */ /*--------------------------------------------------------------------------*/ void gnuplot_close(gnuplot_ctrl * handle) { int i ; if (pclose(handle->gnucmd) == -1) { fprintf(stderr, "problem closing communication to gnuplot\n") ; return ; } if (handle->ntmp) { for (i=0 ; i<handle->ntmp ; i++) { remove(handle->to_delete[i]) ; } } free(handle) ; return ; } /*-------------------------------------------------------------------------*/ /** @brief Sends a command to an active gnuplot session. @param handle Gnuplot session control handle @param cmd Command to send, same as a printf statement. This sends a string to an active gnuplot session, to be executed. There is strictly no way to know if the command has been successfully executed or not. The command syntax is the same as printf. Examples: @code gnuplot_cmd(g, "plot %d*x", 23.0); gnuplot_cmd(g, "plot %g * cos(%g * x)", 32.0, -3.0); @endcode Since the communication to the gnuplot process is run through a standard Unix pipe, it is only unidirectional. This means that it is not possible for this interface to query an error status back from gnuplot. */ /*--------------------------------------------------------------------------*/ void gnuplot_cmd(gnuplot_ctrl * handle, char * cmd, ...) { va_list ap ; char local_cmd[GP_CMD_SIZE]; va_start(ap, cmd); vsprintf(local_cmd, cmd, ap); va_end(ap); strcat(local_cmd, "\n"); fputs(local_cmd, handle->gnucmd) ; fflush(handle->gnucmd) ; return ; } /*-------------------------------------------------------------------------*/ /** @brief Change the plotting style of a gnuplot session. @param h Gnuplot session control handle @param plot_style Plotting-style to use (character string) @return void The provided plotting style is a character string. It must be one of the following: - lines - points - linespoints - impulses - dots - steps - errorbars - boxes - boxeserrorbars */ /*--------------------------------------------------------------------------*/ void gnuplot_setstyle(gnuplot_ctrl * h, char * plot_style) { if (strcmp(plot_style, "lines") && strcmp(plot_style, "points") && strcmp(plot_style, "linespoints") && strcmp(plot_style, "impulses") && strcmp(plot_style, "dots") && strcmp(plot_style, "steps") && strcmp(plot_style, "errorbars") && strcmp(plot_style, "boxes") && strcmp(plot_style, "boxerrorbars")) { fprintf(stderr, "warning: unknown requested style: using points\n") ; strcpy(h->pstyle, "points") ; } else { strcpy(h->pstyle, plot_style) ; } return ; } /*-------------------------------------------------------------------------*/ /** @brief Sets the x label of a gnuplot session. @param h Gnuplot session control handle. @param label Character string to use for X label. @return void Sets the x label for a gnuplot session. */ /*--------------------------------------------------------------------------*/ void gnuplot_set_xlabel(gnuplot_ctrl * h, char * label) { char cmd[GP_CMD_SIZE] ; sprintf(cmd, "set xlabel \"%s\"", label) ; gnuplot_cmd(h, cmd) ; return ; } /*-------------------------------------------------------------------------*/ /** @brief Sets the y label of a gnuplot session. @param h Gnuplot session control handle. @param label Character string to use for Y label. @return void Sets the y label for a gnuplot session. */ /*--------------------------------------------------------------------------*/ void gnuplot_set_ylabel(gnuplot_ctrl * h, char * label) { char cmd[GP_CMD_SIZE] ; sprintf(cmd, "set ylabel \"%s\"", label) ; gnuplot_cmd(h, cmd) ; return ; } /*-------------------------------------------------------------------------*/ /** @brief Resets a gnuplot session (next plot will erase previous ones). @param h Gnuplot session control handle. @return void Resets a gnuplot session, i.e. the next plot will erase all previous ones. */ /*--------------------------------------------------------------------------*/ void gnuplot_resetplot(gnuplot_ctrl * h) { int i ; if (h->ntmp) { for (i=0 ; i<h->ntmp ; i++) { remove(h->to_delete[i]) ; } } h->ntmp = 0 ; h->nplots = 0 ; return ; } /*-------------------------------------------------------------------------*/ /** @brief Plots a 2d graph from a list of doubles. @param handle Gnuplot session control handle. @param d Array of doubles. @param n Number of values in the passed array. @param title Title of the plot. @return void Plots out a 2d graph from a list of doubles. The x-coordinate is the index of the double in the list, the y coordinate is the double in the list. Example: @code gnuplot_ctrl *h ; double d[50] ; int i ; h = gnuplot_init() ; for (i=0 ; i<50 ; i++) { d[i] = (double)(i*i) ; } gnuplot_plot_x(h, d, 50, "parabola") ; sleep(2) ; gnuplot_close(h) ; @endcode */ /*--------------------------------------------------------------------------*/ void gnuplot_plot_x( gnuplot_ctrl * handle, double * d, int n, char * title ) { int i ; int tmpfd ; char name[128] ; char cmd[GP_CMD_SIZE] ; char line[GP_CMD_SIZE] ; if (handle==NULL || d==NULL || (n<1)) return ; /* Open one more temporary file? */ if (handle->ntmp == GP_MAX_TMP_FILES - 1) { fprintf(stderr, "maximum # of temporary files reached (%d): cannot open more", GP_MAX_TMP_FILES) ; return ; } /* Open temporary file for output */ sprintf(name, "%s/gnuplot-i-XXXXXX", P_tmpdir); if ((tmpfd=mkstemp(name))==-1) { fprintf(stderr,"cannot create temporary file: exiting plot") ; return ; } /* Store file name in array for future deletion */ strcpy(handle->to_delete[handle->ntmp], name) ; handle->ntmp ++ ; /* Write data to this file */ for (i=0 ; i<n ; i++) { sprintf(line, "%g\n", d[i]); write(tmpfd, line, strlen(line)); } close(tmpfd) ; /* Command to be sent to gnuplot */ if (handle->nplots > 0) { strcpy(cmd, "replot") ; } else { strcpy(cmd, "plot") ; } if (title == NULL) { sprintf(line, "%s \"%s\" with %s", cmd, name, handle->pstyle) ; } else { sprintf(line, "%s \"%s\" title \"%s\" with %s", cmd, name, title, handle->pstyle) ; } /* send command to gnuplot */ gnuplot_cmd(handle, line) ; handle->nplots++ ; return ; } /*-------------------------------------------------------------------------*/ /** @brief Plot a 2d graph from a list of points. @param handle Gnuplot session control handle. @param x Pointer to a list of x coordinates. @param y Pointer to a list of y coordinates. @param n Number of doubles in x (assumed the same as in y). @param title Title of the plot. @return void Plots out a 2d graph from a list of points. Provide points through a list of x and a list of y coordinates. Both provided arrays are assumed to contain the same number of values. @code gnuplot_ctrl *h ; double x[50] ; double y[50] ; int i ; h = gnuplot_init() ; for (i=0 ; i<50 ; i++) { x[i] = (double)(i)/10.0 ; y[i] = x[i] * x[i] ; } gnuplot_plot1_xy(h, x, y, 50, "parabola") ; sleep(2) ; gnuplot_close(h) ; @endcode */ /*--------------------------------------------------------------------------*/ void gnuplot_plot_xy( gnuplot_ctrl * handle, double * x, double * y, int n, char * title ) { int i ; int tmpfd ; char name[128] ; char cmd[GP_CMD_SIZE] ; char line[GP_CMD_SIZE] ; if (handle==NULL || x==NULL || y==NULL || (n<1)) return ; /* Open one more temporary file? */ if (handle->ntmp == GP_MAX_TMP_FILES - 1) { fprintf(stderr, "maximum # of temporary files reached (%d): cannot open more", GP_MAX_TMP_FILES) ; return ; } /* Open temporary file for output */ sprintf(name, "%s/gnuplot-i-XXXXXX", P_tmpdir); if ((tmpfd=mkstemp(name))==-1) { fprintf(stderr,"cannot create temporary file: exiting plot") ; return ; } /* Store file name in array for future deletion */ strcpy(handle->to_delete[handle->ntmp], name) ; handle->ntmp ++ ; /* Write data to this file */ for (i=0 ; i<n; i++) { sprintf(line, "%g %g\n", x[i], y[i]) ; write(tmpfd, line, strlen(line)); } close(tmpfd) ; /* Command to be sent to gnuplot */ if (handle->nplots > 0) { strcpy(cmd, "replot") ; } else { strcpy(cmd, "plot") ; } if (title == NULL) { sprintf(line, "%s \"%s\" with %s", cmd, name, handle->pstyle) ; } else { sprintf(line, "%s \"%s\" title \"%s\" with %s", cmd, name, title, handle->pstyle) ; } /* send command to gnuplot */ gnuplot_cmd(handle, line) ; handle->nplots++ ; return ; } /*-------------------------------------------------------------------------*/ /** @brief Open a new session, plot a signal, close the session. @param title Plot title @param style Plot style @param label_x Label for X @param label_y Label for Y @param x Array of X coordinates @param y Array of Y coordinates (can be NULL) @param n Number of values in x and y. @return This function opens a new gnuplot session, plots the provided signal as an X or XY signal depending on a provided y, waits for a carriage return on stdin and closes the session. It is Ok to provide an empty title, empty style, or empty labels for X and Y. Defaults are provided in this case. */ /*--------------------------------------------------------------------------*/ void gnuplot_plot_once( char * title, char * style, char * label_x, char * label_y, double * x, double * y, int n ) { gnuplot_ctrl * handle ; if (x==NULL || n<1) return ; handle = gnuplot_init(); if (style!=NULL) { gnuplot_setstyle(handle, style); } else { gnuplot_setstyle(handle, "lines"); } if (label_x!=NULL) { gnuplot_set_xlabel(handle, label_x); } else { gnuplot_set_xlabel(handle, "X"); } if (label_y!=NULL) { gnuplot_set_ylabel(handle, label_y); } else { gnuplot_set_ylabel(handle, "Y"); } if (y==NULL) { gnuplot_plot_x(handle, x, n, title); } else { gnuplot_plot_xy(handle, x, y, n, title); } printf("press ENTER to continue\n"); while (getchar()!='\n') {} gnuplot_close(handle); return ; } /*-------------------------------------------------------------------------*/ /** @brief Plot a slope on a gnuplot session. @param handle Gnuplot session control handle. @param a Slope. @param b Intercept. @param title Title of the plot. @return void @doc Plot a slope on a gnuplot session. The provided slope has an equation of the form y=ax+b Example: @code gnuplot_ctrl * h ; double a, b ; h = gnuplot_init() ; gnuplot_plot_slope(h, 1.0, 0.0, "unity slope") ; sleep(2) ; gnuplot_close(h) ; @endcode */ /*--------------------------------------------------------------------------*/ void gnuplot_plot_slope( gnuplot_ctrl * handle, double a, double b, char * title ) { char stitle[GP_TITLE_SIZE] ; char cmd[GP_CMD_SIZE] ; if (title == NULL) { strcpy(stitle, "no title") ; } else { strcpy(stitle, title) ; } if (handle->nplots > 0) { sprintf(cmd, "replot %g * x + %g title \"%s\" with %s", a, b, title, handle->pstyle) ; } else { sprintf(cmd, "plot %g * x + %g title \"%s\" with %s", a, b, title, handle->pstyle) ; } gnuplot_cmd(handle, cmd) ; handle->nplots++ ; return ; } /*-------------------------------------------------------------------------*/ /** @brief Plot a curve of given equation y=f(x). @param h Gnuplot session control handle. @param equation Equation to plot. @param title Title of the plot. @return void Plots out a curve of given equation. The general form of the equation is y=f(x), you only provide the f(x) side of the equation. Example: @code gnuplot_ctrl *h ; char eq[80] ; h = gnuplot_init() ; strcpy(eq, "sin(x) * cos(2*x)") ; gnuplot_plot_equation(h, eq, "sine wave", normal) ; gnuplot_close(h) ; @endcode */ /*--------------------------------------------------------------------------*/ void gnuplot_plot_equation( gnuplot_ctrl * h, char * equation, char * title ) { char cmd[GP_CMD_SIZE]; char plot_str[GP_EQ_SIZE] ; char title_str[GP_TITLE_SIZE] ; if (title == NULL) { strcpy(title_str, "no title") ; } else { strcpy(title_str, title) ; } if (h->nplots > 0) { strcpy(plot_str, "replot") ; } else { strcpy(plot_str, "plot") ; } sprintf(cmd, "%s %s title \"%s\" with %s", plot_str, equation, title_str, h->pstyle) ; gnuplot_cmd(h, cmd) ; h->nplots++ ; return ; } --- NEW FILE: gnuplot_i.h --- /*-------------------------------------------------------------------------*/ /** @file gnuplot_i.h @author N. Devillard @date Sep 1998 @version $Revision: 1.1 $ @brief C interface to gnuplot. gnuplot is a freely available, command-driven graphical display tool for Unix. It compiles and works quite well on a number of Unix flavours as well as other operating systems. The following module enables sending display requests to gnuplot through simple C calls. */ /*--------------------------------------------------------------------------*/ /* $Id: gnuplot_i.h,v 1.1 2002/08/31 11:04:52 troein Exp $ $Author: troein $ $Date: 2002/08/31 11:04:52 $ $Revision: 1.1 $ */ #ifndef _GNUPLOT_PIPES_H_ #define _GNUPLOT_PIPES_H_ /*--------------------------------------------------------------------------- Includes ---------------------------------------------------------------------------*/ #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include <stdarg.h> /** Maximal number of simultaneous temporary files */ #define GP_MAX_TMP_FILES 64 /** Maximal size of a temporary file name */ #define GP_TMP_NAME_SIZE 512 /*--------------------------------------------------------------------------- New Types ---------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/ /** @typedef gnuplot_ctrl @brief gnuplot session handle (opaque type). This structure holds all necessary information to talk to a gnuplot session. It is built and returned by gnuplot_init() and later used by all functions in this module to communicate with the session, then meant to be closed by gnuplot_close(). This structure is meant to remain opaque, you normally do not need to know what is contained in there. */ /*-------------------------------------------------------------------------*/ typedef struct _GNUPLOT_CTRL_ { /** Pipe to gnuplot process */ FILE * gnucmd ; /** Number of currently active plots */ int nplots ; /** Current plotting style */ char pstyle[32] ; /** Name of temporary files */ char to_delete[GP_MAX_TMP_FILES][GP_TMP_NAME_SIZE] ; /** Number of temporary files */ int ntmp ; } gnuplot_ctrl ; /*--------------------------------------------------------------------------- Function ANSI C prototypes ---------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/ /** @brief Find out where a command lives in your PATH. @param pname Name of the program to look for. @return pointer to statically allocated character string. This is the C equivalent to the 'which' command in Unix. It parses out your PATH environment variable to find out where a command lives. The returned character string is statically allocated within this function, i.e. there is no need to free it. Beware that the contents of this string will change from one call to the next, though (as all static variables in a function). The input character string must be the name of a command without prefixing path of any kind, i.e. only the command name. The returned string is the path in which a command matching the same name was found. Examples (assuming there is a prog named 'hello' in the cwd): @verbatim gnuplot_get_program_path("hello") returns "." gnuplot_get_program_path("ls") returns "/bin" gnuplot_get_program_path("csh") returns "/usr/bin" gnuplot_get_program_path("/bin/ls") returns NULL @endverbatim */ /*-------------------------------------------------------------------------*/ char * gnuplot_get_program_path(char * pname); /*-------------------------------------------------------------------------*/ /** @brief Opens up a gnuplot session, ready to receive commands. @return Newly allocated gnuplot control structure. This opens up a new gnuplot session, ready for input. The struct controlling a gnuplot session should remain opaque and only be accessed through the provided functions. The session must be closed using gnuplot_close(). */ /*--------------------------------------------------------------------------*/ gnuplot_ctrl * gnuplot_init(void); /*-------------------------------------------------------------------------*/ /** @brief Closes a gnuplot session previously opened by gnuplot_init() @param handle Gnuplot session control handle. @return void Kills the child PID and deletes all opened temporary files. It is mandatory to call this function to close the handle, otherwise temporary files are not cleaned and child process might survive. */ /*--------------------------------------------------------------------------*/ void gnuplot_close(gnuplot_ctrl * handle); /*-------------------------------------------------------------------------*/ /** @brief Sends a command to an active gnuplot session. @param handle Gnuplot session control handle @param cmd Command to send, same as a printf statement. This sends a string to an active gnuplot session, to be executed. There is strictly no way to know if the command has been successfully executed or not. The command syntax is the same as printf. Examples: @code gnuplot_cmd(g, "plot %d*x", 23.0); gnuplot_cmd(g, "plot %g * cos(%g * x)", 32.0, -3.0); @endcode Since the communication to the gnuplot process is run through a standard Unix pipe, it is only unidirectional. This means that it is not possible for this interface to query an error status back from gnuplot. */ /*--------------------------------------------------------------------------*/ void gnuplot_cmd(gnuplot_ctrl * handle, char * cmd, ...); /*-------------------------------------------------------------------------*/ /** @brief Change the plotting style of a gnuplot session. @param h Gnuplot session control handle @param plot_style Plotting-style to use (character string) @return void The provided plotting style is a character string. It must be one of the following: - lines - points - linespoints - impulses - dots - steps - errorbars - boxes - boxeserrorbars */ /*--------------------------------------------------------------------------*/ void gnuplot_setstyle(gnuplot_ctrl * h, char * plot_style); /*-------------------------------------------------------------------------*/ /** @brief Sets the x label of a gnuplot session. @param h Gnuplot session control handle. @param label Character string to use for X label. @return void Sets the x label for a gnuplot session. */ /*--------------------------------------------------------------------------*/ void gnuplot_set_xlabel(gnuplot_ctrl * h, char * label); /*-------------------------------------------------------------------------*/ /** @brief Sets the y label of a gnuplot session. @param h Gnuplot session control handle. @param label Character string to use for Y label. @return void Sets the y label for a gnuplot session. */ /*--------------------------------------------------------------------------*/ void gnuplot_set_ylabel(gnuplot_ctrl * h, char * label); /*-------------------------------------------------------------------------*/ /** @brief Resets a gnuplot session (next plot will erase previous ones). @param h Gnuplot session control handle. @return void Resets a gnuplot session, i.e. the next plot will erase all previous ones. */ /*--------------------------------------------------------------------------*/ void gnuplot_resetplot(gnuplot_ctrl * h); /*-------------------------------------------------------------------------*/ /** @brief Plots a 2d graph from a list of doubles. @param handle Gnuplot session control handle. @param d Array of doubles. @param n Number of values in the passed array. @param title Title of the plot. @return void Plots out a 2d graph from a list of doubles. The x-coordinate is the index of the double in the list, the y coordinate is the double in the list. Example: @code gnuplot_ctrl *h ; double d[50] ; int i ; h = gnuplot_init() ; for (i=0 ; i<50 ; i++) { d[i] = (double)(i*i) ; } gnuplot_plot_x(h, d, 50, "parabola") ; sleep(2) ; gnuplot_close(h) ; @endcode */ /*--------------------------------------------------------------------------*/ void gnuplot_plot_x(gnuplot_ctrl * handle, double * d, int n, char * title); /*-------------------------------------------------------------------------*/ /** @brief Plot a 2d graph from a list of points. @param handle Gnuplot session control handle. @param x Pointer to a list of x coordinates. @param y Pointer to a list of y coordinates. @param n Number of doubles in x (assumed the same as in y). @param title Title of the plot. @return void Plots out a 2d graph from a list of points. Provide points through a list of x and a list of y coordinates. Both provided arrays are assumed to contain the same number of values. @code gnuplot_ctrl *h ; double x[50] ; double y[50] ; int i ; h = gnuplot_init() ; for (i=0 ; i<50 ; i++) { x[i] = (double)(i)/10.0 ; y[i] = x[i] * x[i] ; } gnuplot_plot1_xy(h, x, y, 50, "parabola") ; sleep(2) ; gnuplot_close(h) ; @endcode */ /*--------------------------------------------------------------------------*/ void gnuplot_plot_xy( gnuplot_ctrl * handle, double * x, double * y, int n, char * title ) ; /*-------------------------------------------------------------------------*/ /** @brief Open a new session, plot a signal, close the session. @param title Plot title @param style Plot style @param label_x Label for X @param label_y Label for Y @param x Array of X coordinates @param y Array of Y coordinates (can be NULL) @param n Number of values in x and y. @return This function opens a new gnuplot session, plots the provided signal as an X or XY signal depending on a provided y, waits for a carriage return on stdin and closes the session. It is Ok to provide an empty title, empty style, or empty labels for X and Y. Defaults are provided in this case. */ /*--------------------------------------------------------------------------*/ void gnuplot_plot_once( char * title, char * style, char * label_x, char * label_y, double * x, double * y, int n ); /*-------------------------------------------------------------------------*/ /** @brief Plot a slope on a gnuplot session. @param handle Gnuplot session control handle. @param a Slope. @param b Intercept. @param title Title of the plot. @return void @doc Plot a slope on a gnuplot session. The provided slope has an equation of the form y=ax+b Example: @code gnuplot_ctrl * h ; double a, b ; h = gnuplot_init() ; gnuplot_plot_slope(h, 1.0, 0.0, "unity slope") ; sleep(2) ; gnuplot_close(h) ; @endcode */ /*--------------------------------------------------------------------------*/ void gnuplot_plot_slope( gnuplot_ctrl * handle, double a, double b, char * title ) ; /*-------------------------------------------------------------------------*/ /** @brief Plot a curve of given equation y=f(x). @param h Gnuplot session control handle. @param equation Equation to plot. @param title Title of the plot. @return void Plots out a curve of given equation. The general form of the equation is y=f(x), you only provide the f(x) side of the equation. Example: @code gnuplot_ctrl *h ; char eq[80] ; h = gnuplot_init() ; strcpy(eq, "sin(x) * cos(2*x)") ; gnuplot_plot_equation(h, eq, "sine wave", normal) ; gnuplot_close(h) ; @endcode */ /*--------------------------------------------------------------------------*/ void gnuplot_plot_equation(gnuplot_ctrl * h, char * equation, char * title) ; #endif |
From: <tr...@us...> - 2002-08-31 11:04:55
|
Update of /cvsroot/basedb/basedb/exec/source/pca/gnuplot_i-2.6/test In directory usw-pr-cvs1:/tmp/cvs-serv28128/gnuplot_i-2.6/test Added Files: anim.c example.c sinepng.c Log Message: Added PCA plugin from Greg Voronin --- NEW FILE: anim.c --- /* * Examples of gnuplot_i.c usage */ #include <stdio.h> #include <stdlib.h> #include "gnuplot_i.h" #define SLEEP_LGTH 1 int main(int argc, char *argv[]) { gnuplot_ctrl * h1; double phase ; printf("*** example of gnuplot control through C ***\n") ; h1 = gnuplot_init() ; for (phase=0.1 ; phase<10 ; phase +=0.1) { gnuplot_resetplot(h1) ; gnuplot_cmd(h1, "plot sin(x+%g)", phase) ; } for (phase=10 ; phase>=0.1 ; phase -=0.1) { gnuplot_resetplot(h1) ; gnuplot_cmd(h1, "plot sin(x+%g)", phase) ; } gnuplot_close(h1) ; return 0 ; } --- NEW FILE: example.c --- /* * Examples of gnuplot_i.c usage */ #include <stdio.h> #include <stdlib.h> #include "gnuplot_i.h" #define SLEEP_LGTH 2 #define NPOINTS 50 int main(int argc, char *argv[]) { gnuplot_ctrl * h1, * h2, * h3, * h4 ; double x[NPOINTS] ; double y[NPOINTS] ; int i ; /* * Initialize the gnuplot handle */ printf("*** example of gnuplot control through C ***\n") ; h1 = gnuplot_init() ; /* * Slopes */ gnuplot_setstyle(h1, "lines") ; printf("*** plotting slopes\n") ; printf("y = x\n") ; gnuplot_plot_slope(h1, 1.0, 0.0, "unity slope") ; sleep(SLEEP_LGTH) ; printf("y = 2*x\n") ; gnuplot_plot_slope(h1, 2.0, 0.0, "y=2x") ; sleep(SLEEP_LGTH) ; printf("y = -x\n") ; gnuplot_plot_slope(h1, -1.0, 0.0, "y=-x") ; sleep(SLEEP_LGTH) ; /* * Equations */ gnuplot_resetplot(h1) ; printf("\n\n") ; printf("*** various equations\n") ; printf("y = sin(x)\n") ; gnuplot_plot_equation(h1, "sin(x)", "sine") ; sleep(SLEEP_LGTH) ; printf("y = log(x)\n") ; gnuplot_plot_equation(h1, "log(x)", "logarithm") ; sleep(SLEEP_LGTH) ; printf("y = sin(x)*cos(2*x)\n") ; gnuplot_plot_equation(h1, "sin(x)*cos(2*x)", "sine product") ; sleep(SLEEP_LGTH) ; /* * Styles */ gnuplot_resetplot(h1) ; printf("\n\n") ; printf("*** showing styles\n") ; printf("sine in points\n") ; gnuplot_setstyle(h1, "points") ; gnuplot_plot_equation(h1, "sin(x)", "sine") ; sleep(SLEEP_LGTH) ; printf("sine in impulses\n") ; gnuplot_setstyle(h1, "impulses") ; gnuplot_plot_equation(h1, "sin(x)", "sine") ; sleep(SLEEP_LGTH) ; printf("sine in steps\n") ; gnuplot_setstyle(h1, "steps") ; gnuplot_plot_equation(h1, "sin(x)", "sine") ; sleep(SLEEP_LGTH) ; /* * User defined 1d and 2d point sets */ gnuplot_resetplot(h1) ; gnuplot_setstyle(h1, "impulses") ; printf("\n\n") ; printf("*** user-defined lists of doubles\n") ; for (i=0 ; i<NPOINTS ; i++) { x[i] = (double)i*i ; } gnuplot_plot_x(h1, x, NPOINTS, "user-defined doubles") ; sleep(SLEEP_LGTH) ; printf("*** user-defined lists of points\n"); for (i=0 ; i<NPOINTS ; i++) { x[i] = (double)i ; y[i] = (double)i * (double)i ; } gnuplot_resetplot(h1) ; gnuplot_setstyle(h1, "points") ; gnuplot_plot_xy(h1, x, y, NPOINTS, "user-defined points") ; sleep(SLEEP_LGTH) ; /* * Multiple output screens */ printf("\n\n") ; printf("*** multiple output windows\n") ; gnuplot_resetplot(h1) ; gnuplot_setstyle(h1, "lines") ; h2 = gnuplot_init() ; gnuplot_setstyle(h2, "lines") ; h3 = gnuplot_init() ; gnuplot_setstyle(h3, "lines") ; h4 = gnuplot_init() ; gnuplot_setstyle(h4, "lines") ; printf("window 1: sin(x)\n") ; gnuplot_plot_equation(h1, "sin(x)", "sin(x)") ; sleep(SLEEP_LGTH) ; printf("window 2: x*sin(x)\n") ; gnuplot_plot_equation(h2, "x*sin(x)", "x*sin(x)") ; sleep(SLEEP_LGTH) ; printf("window 3: log(x)/x\n") ; gnuplot_plot_equation(h3, "log(x)/x", "log(x)/x"); sleep(SLEEP_LGTH) ; printf("window 4: sin(x)/x\n") ; gnuplot_plot_equation(h4, "sin(x)/x", "sin(x)/x") ; sleep(SLEEP_LGTH) ; /* * close gnuplot handles */ printf("\n\n") ; printf("*** end of gnuplot example\n") ; gnuplot_close(h1) ; gnuplot_close(h2) ; gnuplot_close(h3) ; gnuplot_close(h4) ; return 0 ; } --- NEW FILE: sinepng.c --- #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include "gnuplot_i.h" int main(int argc, char * argv[]) { gnuplot_ctrl * g = gnuplot_init(); gnuplot_cmd(g, "set terminal png"); gnuplot_cmd(g, "set output \"sine.png\""); gnuplot_plot_equation(g, "sin(x)", "Sine wave"); gnuplot_close(g); return 0 ; } |
From: <tr...@us...> - 2002-08-31 11:04:55
|
Update of /cvsroot/basedb/basedb/exec/source/pca/gnuplot_i-2.6 In directory usw-pr-cvs1:/tmp/cvs-serv28128/gnuplot_i-2.6 Added Files: LICENSE Makefile README Log Message: Added PCA plugin from Greg Voronin --- NEW FILE: LICENSE --- The gnuplot_i module is released in the public domain. You are free to edit, re-distribute, modify, delete, send me cash, print it on T-shirts, sing it, learn the code, port it to another language, make money out of it (although I seriously doubt you could). Enjoy! N. Devillard Tue Apr 3 17:24:33 CEST 2001 --- NEW FILE: Makefile --- CC = gcc CFLAGS = -O3 -I./src RM = rm -f default: gnuplot_i.o gnuplot_i.o: src/gnuplot_i.c src/gnuplot_i.h $(CC) $(CFLAGS) -c -o gnuplot_i.o src/gnuplot_i.c tests: test/anim test/example test/sinepng test/anim: test/anim.c gnuplot_i.o $(CC) $(CFLAGS) -o test/anim test/anim.c gnuplot_i.o test/example: test/example.c gnuplot_i.o $(CC) $(CFLAGS) -o test/example test/example.c gnuplot_i.o test/sinepng: test/sinepng.c gnuplot_i.o $(CC) $(CFLAGS) -o test/sinepng test/sinepng.c gnuplot_i.o clean: $(RM) gnuplot_i.o test/anim test/example test/sinepng --- NEW FILE: README --- gnuplot_i: a short documentation ------------------------------------ gnuplot_i (formerly known as gnuplot_pipes) is yet another attempt to provide a programmer-friendly set of routines to use gnuplot as a data displayer from a C program. The procedure to follow to display graphics in a gnuplot session is: 1. Open a new gnuplot session, referenced by a handle of type (pointer to) gnuplot_ctrl. This is done by calling gnuplot_init(): gnuplot_ctrl * h ; h = gnuplot_init() ; h will be used as the handle to the gnuplot session which was just opened, by all further functions. 2. Send optionally display configuration orders. The following functions are available: gnuplot_setstyle(handle, style) sets the plotting style of the next plots gnuplot_set_xlabel(handle, label) sets the X label for the next plots gnuplot_set_ylabel(handle, label) sets the Y label for the next plots Examples: gnuplot_setstyle(h, "impulses") ; gnuplot_set_xlabel(h, "my X label") ; gnuplot_set_xlabel(h, "my Y label") ; The most useful routine is probably gnuplot_cmd(), which allows you to send character strings to gnuplot as though they were typed in by a user. This routine works in a printf fashion, accepting the same kind of format string and variable number of arguments. The prototype is: gnuplot_cmd(handle, command, ...) Example: char myfile[] = "/data/file_in.dat" ; int i ; gnuplot_cmd(handle, "plot '%s'", myfile); for (i=0 ; i<10 ; i++) { gnuplot_cmd (handle, "plot y=%d*x", i); } The following commands request the output to be done to a postscript file named 'curve.ps': gnuplot_cmd(h, "set terminal postscript") ; gnuplot_cmd(h, "set output \"curve.ps\"") ; Using gnuplot_cmd(), it should be fairly easy to add up some more configuration-related functions whenever needed. 3. Send some display orders: either functions or doubles, or double points. The following functions are available: gnuplot_plot_slope() to display a slope gnuplot_plot_equation() to display an equation gnuplot_plot_x() to display user-defined 1d data with a single variable. Input is a list of values, assumed regularly spaced on the X-axis. gnuplot_plot_xy() to display user-defined 1d data with two variables. Input is two lists of point coordinates. gnuplot_resetplot() states that the current gnuplot display will be cleared before next display is done. 4. Close the gnuplot handle. This is very important, since otherwise all temporary files will NOT be cleaned for /tmp and /var/tmp. gnuplot_close(h) ; See examples of gnuplot_i use in the provided files 'example.c' and 'anim.c'. Some more points before you start using gnuplot_i ------------------------------------------------- gnuplot_i is completely free software. Use it for whatever you want to do with it without any fee, and do not hesitate to send feedback to me if you wish: <nde...@fr...> If you can do it, I would appreciate a mention somewhere that you are using 'gnuplot_i' in your application. Something like: "This software uses the gnuplot_i library written by N.Devillard <nde...@fr...> If you are using gnuplot_i for a web-based application, you can also add a link to the gnuplot home page: http://ndevilla.free.fr/gnuplot/ If you are so happy about this piece of code that you would like to fund more stuff like that, do not hesitate to send me cash :-) Notice that it is possible to open several gnuplot sessions from the same program. Just be careful then to which session you are talking when using functions. Example: h1 = gnuplot_init() ; h2 = gnuplot_init() ; gnuplot_plot_equation(h1, "sin(x)", "sine on first session"); gnuplot_plot_equation(h2, "log(x)", "log on second session") ; sleep(3) ; gnuplot_close(h1) ; gnuplot_close(h2) ; Never forget to close opened sessions! This would leave some temporary files. Hopefully, your temporary directories should be cleaned automatically every now and then, but best is simply not to forget to close all windows before leaving the house. User interactions are not part of gnuplot_i. Feel free to use your own. No timing mechanisms are provided to leave the outputs on screen until e.g. a key is pressed. I leave it up to gnuplot_i users to provide that kind of functionality in their own application, depending on the kind of interaction they need. No programming so far of 'splot' related commands. Should you implement some, I would recommend making use of the 'plot' related commands as a canvas. To compile and run the examples ------------------------------- You can use the provided Makefile, or compile by hand: To compile the gnuplot_i module: % cc -I. -c gnuplot_i.c To compile both examples: % cc -o example example.c gnuplot_i.o % cc -o anim anim.c gnuplot_i.o To compile if you want to use the Makefile: % make % make tests Try it out to see if it works: % test/anim -- Will show an animated sine wave % test/example -- Will show various functions in use % test/sinepng -- Will generate a PNG file with a sine wave The latter test requires gnuplot to have been compiled with PNG support. This should be the case if you are using a pre-packaged gnuplot under Linux (RPM). Of course, you must have gnuplot installed and working on your machine, accessible from the user account you are using. Nicolas Devillard -- June 2001 |