Beispiel #1
0
 function phenotype()
 {
     /** get the ontology terms **/
     $apofile = $this->GetParameterValue('ncbo_download_dir') . "apo.obo";
     if (!file_exists($apofile)) {
         GetLatestNCBOOntology('1222', $this->GetParameterValue('ncbo_api_key'), $apofile);
     }
     $apoin = fopen($apofile, "r");
     if ($apoin === FALSE) {
         trigger_error("Unable to open {$apofile}");
         exit;
     }
     $terms = OBOParser($apoin);
     fclose($apoin);
     BuildNamespaceSearchList($terms, $searchlist);
     while ($l = $this->GetReadFile()->Read(96000)) {
         if (trim($l) == '') {
             continue;
         }
         $a = explode("\t", $l);
         $eid = md5($a[3] . $a[5] . $a[6] . $a[9]);
         $label = "{$a['0']} - {$a['5']} experiment with {$a['6']} resulting in phenotype of {$a['9']}";
         $this->AddRDF($this->QQuadL("sgd_resource:{$eid}", "rdfs:label", "{$label} [sgd_resource:{$eid}]"));
         $this->AddRDF($this->QQuad("sgd_resource:{$eid}", "void:inDataset", $this->GetDatasetURI()));
         $this->AddRDF($this->QQuad("sgd_resource:{$eid}", "rdf:type", "sgd_vocabulary:Phenotype_Experiment"));
         $this->AddRDF($this->QQuad("sgd_resource:{$eid}", "sgd_vocabulary:has-participant", "sgd:{$a['3']}"));
         // reference
         // PMID: 12140549|SGD_REF: S000071347
         $b = explode("|", $a[4]);
         foreach ($b as $c) {
             $d = explode(" ", $c);
             if ($d[0] == "PMID:") {
                 $ns = "pubmed";
             } else {
                 $ns = "sgd";
             }
             $this->AddRDF($this->QQuad("sgd_resource:{$eid}", "sgd_vocabulary:article", "{$ns}:" . $d[1]));
         }
         // experiment type [5]
         $p = strpos($a[5], '(');
         if ($p !== FALSE) {
             $label = substr($a[5], 0, $p - 1);
             $details = substr($a[5], $p + 1);
             $this->AddRDF($this->QQuadL("sgd_resource:{$eid}", "dc:description", "{$details}"));
         } else {
             $label = $a[5];
         }
         $id = array_search($label, $searchlist['experiment_type']);
         if ($id !== FALSE) {
             $this->AddRDF($this->QQuad("sgd_resource:{$eid}", "sgd_vocabulary:experiment-type", strtolower($id)));
         } else {
             trigger_error("No match for experiment type {$label}");
         }
         // mutant type [6]
         $id = array_search($a[6], $searchlist['mutant_type']);
         if ($id !== FALSE) {
             $this->AddRDF($this->QQuad("sgd_resource:{$eid}", "sgd_vocabulary:mutant-type", strtolower($id)));
         }
         // phenotype  [9]
         // presented as observable: qualifier
         $b = explode(": ", $a[9]);
         $id = array_search($b[0], $searchlist['observable']);
         if ($id !== FALSE) {
             $this->AddRDF($this->QQuad("sgd_resource:{$eid}", "sgd_vocabulary:observable", strtolower($id)));
         }
         if (!empty($b[1])) {
             $id = array_search($b[1], $searchlist['qualifier']);
             if ($id !== FALSE) {
                 $this->AddRDF($this->QQuad("sgd_resource:{$eid}", "sgd_vocabulary:qualifier", strtolower($id)));
             }
         }
         /*
         7) Allele (Optional)    			-Allele name and description, if applicable
         8) Strain Background (Optional) 		-Genetic background in which the phenotype was analyzed
         10) Chemical (Optional) 			-Any chemicals relevant to the phenotype
         11) Condition (Optional)        		-Condition under which the phenotype was observed
         12) Details (Optional)  			-Details about the phenotype
         13) Reporter (Optional) 			-The protein(s) or RNA(s) used in an experiment to track a process 
         */
         if (trim($a[7]) != '') {
             $this->AddRDF($this->QQuadL("sgd_resource:{$eid}", "sgd_vocabulary:allele", $a[7]));
         }
         if (trim($a[8]) != '') {
             $this->AddRDF($this->QQuadL("sgd_resource:{$eid}", "sgd_vocabulary:background", $a[8]));
         }
         if (trim($a[10]) != '') {
             $this->AddRDF($this->QQuadL("sgd_resource:{$eid}", "sgd_vocabulary:chemical", $a[10]));
         }
         if (trim($a[11]) != '') {
             $this->AddRDF($this->QQuadL("sgd_resource:{$eid}", "sgd_vocabulary:condition", $a[11]));
         }
         if (trim($a[12]) != '') {
             $this->AddRDF($this->QQuadL("sgd_resource:{$eid}", "sgd_vocabulary:details", str_replace('"', '\\"', $a[12])));
         }
         //if($a[13] != '') $buf .= "sgd:$eid sgd_vocabulary:reporter \"$a[13]\".".PHP_EOL;
     }
     //while
     return TRUE;
 }
Beispiel #2
0
 function phenotype()
 {
     /** get the ontology terms **/
     $apofile = $this->GetParameterValue('ncbo_download_dir') . "apo.obo";
     if (!file_exists($apofile)) {
         GetLatestNCBOOntology('APO', $this->GetParameterValue('ncbo_api_key'), $apofile);
     }
     $apoin = fopen($apofile, "r");
     if ($apoin === FALSE) {
         trigger_error("Unable to open {$apofile}", E_USER_ERROR);
         exit;
     }
     $terms = OBOParser($apoin);
     fclose($apoin);
     BuildNamespaceSearchList($terms, $searchlist);
     while ($l = $this->GetReadFile()->Read(96000)) {
         if (trim($l) == '') {
             continue;
         }
         $a = explode("\t", $l);
         $eid = md5($a[3] . $a[5] . $a[6] . $a[9]);
         $label = "{$a['0']} - {$a['5']} experiment with {$a['6']} resulting in phenotype of {$a['9']}";
         $this->AddRDF(parent::triplify($this->getRes() . $eid, $this->getVoc() . "has-participant", $this->getNamespace() . $a[3]) . parent::describeClass($this->getVoc() . "Phenotype_Experiment", "SGD phenotype experiment [" . $this->getVoc() . "Phenotype_Experiment]") . parent::describeProperty($this->getVoc() . "has-participant", "Relationship between an SGD entity and its participant"));
         // reference
         // PMID: 12140549|SGD_REF: S000071347
         $b = explode("|", $a[4]);
         foreach ($b as $c) {
             $d = explode(" ", $c);
             if ($d[0] == "PMID:") {
                 $ns = "pubmed";
             } else {
                 $ns = "sgd";
             }
             $this->AddRDF(parent::triplify($this->getRes() . $eid, $this->getVoc() . "article", $ns . ":" . $d[1]));
         }
         // experiment type [5]
         $details = null;
         $p = strpos($a[5], '(');
         if ($p !== FALSE) {
             $label = substr($a[5], 0, $p - 1);
             $details = substr($a[5], $p + 1);
         } else {
             $label = $a[5];
         }
         $this->AddRDF(parent::describeIndividual($this->getRes() . $eid, $label, $this->getVoc() . "Phenotype_Experiment", null, $details, null));
         $id = array_search($label, $searchlist['experiment_type']);
         if ($id !== FALSE) {
             $this->AddRDF(parent::triplify($this->getRes() . $eid, $this->getVoc() . "experiment-type", strtolower($id)) . parent::describeProperty($this->getVoc() . "experiment-type", "Relationship between an SGD experiment and the experiment type"));
         } else {
             trigger_error("No match for experiment type {$label}", E_USER_WARNING);
         }
         // mutant type [6]
         $id = array_search($a[6], $searchlist['mutant_type']);
         if ($id !== FALSE) {
             $this->AddRDF(parent::triplify($this->getRes() . $eid, $this->getVoc() . "mutant-type", strtolower($id)) . parent::describeProperty($this->getVoc() . "mutant-type", "Relationship between an SGD experiment and the mutant type"));
         }
         // phenotype  [9]
         // presented as observable: qualifier
         $b = explode(": ", $a[9]);
         $id = array_search($b[0], $searchlist['observable']);
         if ($id !== FALSE) {
             $this->AddRDF(parent::triplify($this->getRes() . $eid, $this->getVoc() . "observable", strtolower($id)) . parent::describeProperty($this->getVoc() . "observable", "Relationship between an SGD entity and its observable qualifier"));
         }
         if (!empty($b[1])) {
             $id = array_search($b[1], $searchlist['qualifier']);
             if ($id !== FALSE) {
                 $this->AddRDF(parent::triplify($this->getRes() . $eid, $this->getVoc() . "qualifier", strtolower($id)));
             }
         }
         /*
         7) Allele (Optional)    			-Allele name and description, if applicable
         8) Strain Background (Optional) 		-Genetic background in which the phenotype was analyzed
         10) Chemical (Optional) 			-Any chemicals relevant to the phenotype
         11) Condition (Optional)        		-Condition under which the phenotype was observed
         12) Details (Optional)  			-Details about the phenotype
         13) Reporter (Optional) 			-The protein(s) or RNA(s) used in an experiment to track a process 
         */
         if (trim($a[7]) != '') {
             $this->AddRDF(parent::triplifyString($this->getRes() . $eid, $this->getVoc() . "allele", $a[7]) . parent::describeProperty($this->getVoc() . "allele", "Relationship between an SGD experiment and an allele"));
         }
         if (trim($a[8]) != '') {
             $this->AddRDF(parent::triplifyString($this->getRes() . $eid, $this->getVoc() . "background", $a[8]) . parent::describeProperty($this->getVoc() . "background", "Relationship betweeen an SGD experiment and its background"));
         }
         if (trim($a[10]) != '') {
             $this->AddRDF(parent::triplifyString($this->getRes() . $eid, $this->getVoc() . "chemical", $a[10]) . parent::describeProperty($this->getVoc() . "chemical", "Relationship between an SGD experiment and a chemical"));
         }
         if (trim($a[11]) != '') {
             $this->AddRDF(parent::triplifyString($this->getRes() . $eid, $this->getVoc() . "condition", $a[11]) . parent::describeProperty($this->getVoc() . "condition", "Relationship between an SGD experiment and a condition"));
         }
         if (trim($a[12]) != '') {
             $this->AddRDF(parent::triplifyString($this->getRes() . $eid, $this->getVoc() . "details", str_replace('"', '\\"', $a[12])) . parent::describeProperty($this->getVoc() . "details", "Relationship between an SGD experiment and its details"));
         }
         parent::writeRDFBufferToWriteFile();
     }
     //while
     return TRUE;
 }