Beispiel #1
0
 function process()
 {
     $refseq_record_str = "";
     while ($aLine = $this->getReadFile()->Read(40960)) {
         preg_match("/^\\/\\/\$/", $aLine, $matches);
         if (!count($matches)) {
             preg_match("/^\n\$/", $aLine, $matches);
             if (count($matches) == 0) {
                 $refseq_record_str .= $aLine . PHP_EOL;
             }
             continue;
         } else {
             //now remove the header if it is there
             $refseq_record_str = $this->removeHeader($refseq_record_str);
             $sectionsRaw = $this->parseGenbankRaw($refseq_record_str);
             /**
              * SECTIONS being parsed:
              * locus, definition, accession, version, keywords, source
              * features
              **/
             //get the locus section
             $locus = $this->retrieveSections("LOCUS", $sectionsRaw);
             $parsed_locus_arr = $this->parseLocus($locus);
             //get the definition
             $definition = $this->retrieveSections("DEFINITION", $sectionsRaw);
             $parsed_definition_arr = $this->parseDefinition($definition);
             //get the accession
             $accessions = $this->retrieveSections("ACCESSION", $sectionsRaw);
             $parsed_accession_arr = $this->parseAccession($accessions);
             //get the version
             $versions = $this->retrieveSections("VERSION", $sectionsRaw);
             $parsed_version_arr = $this->parseVersion($versions);
             //get the keywords
             $keywords = $this->retrieveSections("KEYWORDS", $sectionsRaw);
             $parsed_keyword_arr = $this->parseKeywords($keywords);
             //get the reference section
             $references = $this->retrieveSections("REFERENCE", $sectionsRaw);
             $parsed_refs_arr = $this->parseReferences($references);
             //get the source section
             $source = $this->retrieveSections("SOURCE", $sectionsRaw);
             $parsed_source_arr = $this->parseSource($source);
             //get the features
             $features = $this->retrieveSections("FEATURES", $sectionsRaw);
             $parsed_features_arr = $this->parseFeatures($features);
             //lets make some rdf
             $refseq_res = $this->getNamespace() . $parsed_version_arr['versioned_accession'];
             $refseq_label = utf8_encode(htmlspecialchars($parsed_definition_arr[0]));
             parent::AddRDF(parent::describeIndividual($refseq_res, $refseq_label, $this->getVoc() . 'refseq-record') . parent::triplifyString($refseq_res, $this->getVoc() . 'sequence-length', $parsed_locus_arr[0]['sequence_length']) . parent::triplifyString($refseq_res, $this->getVoc() . 'chromosome-shape', $parsed_locus_arr[0]['chromosome_shape']) . parent::triplifyString($refseq_res, $this->getVoc() . 'date-of-entry', $parsed_locus_arr[0]['date']) . parent::triplifyString($refseq_res, $this->getVoc() . 'source', utf8_encode($parsed_source_arr[0])) . parent::triplify($refseq_res, $this->getVoc() . 'fasta-seq', 'https://www.ncbi.nlm.nih.gov/sviewer/viewer.cgi?sendto=on&db=nucest&dopt=fasta&val=' . $parsed_version_arr['gi']) . parent::triplify('https://www.ncbi.nlm.nih.gov/sviewer/viewer.cgi?sendto=on&db=nucest&dopt=fasta&val=' . $parsed_version_arr['gi'], "rdf:type", $this->getVoc() . 'fasta-sequence'));
             //add the features to the rdf
             foreach ($parsed_features_arr as $aFeature) {
                 $type = $aFeature['type'];
                 $feat_desc = $this->getFeatures($type);
                 $label = $type;
                 $def = '';
                 if (isset($feat_desc['definition'])) {
                     $def = preg_replace('/\\s\\s*/', ' ', $feat_desc['definition']);
                 }
                 $comment = null;
                 //					$value = $aFeature['value'];
                 $value = str_replace("UniProtKB/Swiss-Prot", "UniProt", $aFeature['value']);
                 // imperfect solution.
                 $value_arr = explode("/", $value);
                 $location = preg_replace('/\\n/', '', $value_arr[0]);
                 $class_id = parent::getVoc() . md5($type);
                 $feat_res = parent::getRes() . md5($type . $location . $refseq_res);
                 $feat_label = utf8_encode($type . " " . $location . " for " . $refseq_res);
                 if (isset($feat_desc['comment'])) {
                     $comment = $feat_desc['comment'];
                     $comment = preg_replace('/\\s\\s*/', ' ', $comment);
                     $label .= " " . $comment;
                 }
                 parent::AddRDF(parent::describeClass($class_id, $label, parent::getVoc() . "Feature", $label, $def) . parent::describeIndividual($feat_res, $feat_label, $class_id) . parent::triplify($refseq_res, $this->getVoc() . "has-feature", $feat_res));
                 foreach ($value_arr as $aL) {
                     //check if aL has an equals in it
                     $p = "/(\\S+)\\=(.*)/";
                     preg_match($p, $aL, $m);
                     if (count($m)) {
                         if ($m[1] == "db_xref") {
                             parent::AddRDF(parent::triplify($feat_res, "rdfs:seeAlso", str_replace("\"", "", $m[2])));
                         } else {
                             parent::AddRDF(parent::triplifyString($feat_res, $this->getVoc() . $m[1], utf8_encode(str_replace("\"", "", $m[2]))));
                         }
                     }
                 }
             }
             //add the accession
             foreach ($parsed_accession_arr[0] as $acc) {
                 parent::AddRDF(parent::triplifyString($refseq_res, $this->getVoc() . "accession", $acc));
             }
             //versioned accession
             if (isset($parsed_version_arr['versioned_accession'])) {
                 parent::AddRDF(parent::triplifyString($refseq_res, $this->getVoc() . "versioned-accession", $parsed_version_arr['versioned_accession']));
             }
             //keywords
             foreach ($parsed_keyword_arr as $akw) {
                 parent::AddRDF(parent::triplifyString($refseq_res, $this->getVoc() . "keyword", $akw));
             }
             //references
             foreach ($parsed_refs_arr as $aRef) {
                 $r = rand();
                 $ref_res = $this->getRes() . md5($r);
                 $ref_label = "reference for " . $refseq_res;
                 if (isset($aRef['TITLE'])) {
                     parent::AddRDF(parent::describeIndividual($ref_res, $ref_label, $this->getVoc() . "reference") . parent::triplifyString($ref_res, $this->getVoc() . "title", $aRef['TITLE']));
                 }
                 if (isset($aRef['PUBMED'])) {
                     parent::AddRDF(parent::triplify($ref_res, $this->getVoc() . "x-pubmed", 'pubmed:' . $aRef['PUBMED']));
                 }
                 if (isset($aRef['AUTHORS'])) {
                     parent::AddRDF(parent::triplifyString($ref_res, $this->getVoc() . "authors", $aRef['AUTHORS']));
                 }
                 if (isset($aRef['COORDINATES'])) {
                     parent::AddRDF(parent::triplify($refseq_res, $this->getVoc() . "reference", $ref_res) . parent::triplifyString($ref_res, $this->getVoc() . "coordinates", $aRef['COORDINATES']) . parent::triplifyString($ref_res, $this->getVoc() . "citation", $aRef['JOURNAL']));
                 } else {
                     parent::AddRDF(parent::triplify($refseq_res, $this->getVoc() . "reference", $ref_res) . parent::triplifyString($ref_res, $this->getVoc() . "citation", $aRef['JOURNAL']));
                 }
             }
             $refseq_record_str = "";
             $this->WriteRDFBufferToWriteFile();
             continue;
         }
     }
     //while
 }
Beispiel #2
0
 private function process()
 {
     $z = 0;
     $y = 1;
     while ($l = $this->getReadFile()->Read(200000)) {
         if ($z++ % 1000000 == 0) {
             echo $z . PHP_EOL;
             $odir = parent::getParameterValue('outdir');
             $ofile = 'iproclass.' . $y++ . "." . parent::getParameterValue('output_format');
             $gz = strstr(parent::getParameterValue('output_format'), "gz") ? true : false;
             if (parent::getWriteFile() != null) {
                 parent::getWriteFile()->close();
                 parent::clear();
             }
             // generate a new file
             parent::setWriteFile($odir . $ofile, $gz);
         }
         $fields = explode("\t", $l);
         @($uniprot_acc = $fields[0]);
         @($uniprot = $fields[1]);
         @($gene = $fields[2]);
         @($refseq = $fields[3]);
         @($gi = $fields[4]);
         @($pdb = $fields[5]);
         @($pfam = $fields[6]);
         @($go = $fields[7]);
         @($pirsf = $fields[8]);
         @($ipi = $fields[9]);
         @($uniref_100 = $fields[10]);
         @($uniref_90 = $fields[11]);
         @($uniref_50 = $fields[12]);
         @($uniparc = $fields[13]);
         //skipping pir-psd because db no longer maintained
         @($ncbi_taxonomy = $fields[15]);
         @($mim = $fields[16]);
         @($unigene = $fields[17]);
         @($ensembl = $fields[18]);
         @($pubmed = $fields[19]);
         @($embl_genbank_ddbj = $fields[20]);
         @($embl_protein = trim($fields[21]));
         $id = $uniprot_acc;
         $id_res = $this->getNamespace() . $id;
         $id_label = "iproclass entry for uniprot:{$uniprot_acc}";
         parent::addRDF(parent::triplify($id_res, $this->getVoc() . "x-uniprot", "uniprot:" . $uniprot_acc));
         if (!empty($uniprot)) {
             $uniprot_ids = explode("; ", $uniprot);
             foreach ($uniprot_ids as $uniprot_id) {
                 parent::AddRDF(parent::triplify($id_res, $this->getVoc() . "x-uniprot", "uniprot:" . $uniprot_id));
             }
         }
         if (!empty($gene)) {
             $gene_ids = explode("; ", $gene);
             foreach ($gene_ids as $gene_id) {
                 parent::AddRDF(parent::triplify($id_res, $this->getVoc() . "x-ncbigene", "geneid:" . $gene_id));
             }
         }
         if (!empty($refseq)) {
             $refseq_ids = explode("; ", $refseq);
             foreach ($refseq_ids as $refseq_id) {
                 parent::AddRDF(parent::triplify($id_res, $this->getVoc() . "x-refseq", "refseq:" . $refseq_id));
             }
         }
         if (!empty($gi)) {
             $gi_ids = explode("; ", $gi);
             foreach ($gi_ids as $gi_id) {
                 parent::AddRDF(parent::triplify($id_res, $this->getVoc() . "x-gi", "gi:" . $gi_id));
             }
         }
         if (!empty($pdb)) {
             $pdb_ids = explode("; ", $pdb);
             foreach ($pdb_ids as $pdb_id) {
                 parent::AddRDF(parent::triplify($id_res, $this->getVoc() . "x-pdb", "pdb:" . $pdb_id));
             }
         }
         if (!empty($pfam)) {
             $pfam_ids = explode("; ", $pfam);
             foreach ($pfam_ids as $pfam_id) {
                 parent::AddRDF(parent::triplify($id_res, $this->getVoc() . "x-pfam", "pfam:" . $pfam_id));
             }
         }
         if (!empty($go)) {
             $go_ids = explode("; ", $go);
             foreach ($go_ids as $go_id) {
                 $go_id = substr($go_id, 3);
                 parent::AddRDF(parent::triplify($id_res, $this->getVoc() . "x-go", "go:" . $go_id));
             }
         }
         if (!empty($pirsf)) {
             $pirsf_ids = explode("; ", $pirsf);
             foreach ($pirsf_ids as $pirsf_id) {
                 parent::AddRDF(parent::triplify($id_res, $this->getVoc() . "x-pirsf", "pirsf:" . $pirsf_id));
             }
         }
         if (!empty($ipi)) {
             $ipi_ids = explode("; ", $ipi);
             foreach ($ipi_ids as $ipi_id) {
                 parent::AddRDF(parent::triplify($id_res, $this->getVoc() . "x-ipi", "ipi:" . $ipi_id));
             }
         }
         if (!empty($uniref_100)) {
             $uniref_100_ids = explode("; ", $uniref_100);
             foreach ($uniref_100_ids as $uniref_100_id) {
                 parent::AddRDF(parent::QQuadO_URL($id_res, "rdfs:seeAlso", "http://uniprot.org/uniref/" . $uniref_100_id));
             }
         }
         if (!empty($uniref_90)) {
             $uniref_90_ids = explode("; ", $uniref_90);
             foreach ($uniref_90_ids as $uniref_90_id) {
                 parent::AddRDF(parent::QQuadO_URL($id_res, "rdfs:seeAlso", "http://uniprot.org/uniref/" . $uniref_90_id));
             }
         }
         if (!empty($uniref_50)) {
             $uniref_50_ids = explode("; ", $uniref_50);
             foreach ($uniref_50_ids as $uniref_50_id) {
                 parent::AddRDF(parent::QQuadO_URL($id_res, "rdfs:seeAlso", "http://uniprot.org/uniref/" . $uniref_50_id));
             }
         }
         if (!empty($uniparc)) {
             $uniparc_ids = explode("; ", $uniparc);
             foreach ($uniparc_ids as $uniparc_id) {
                 parent::AddRDF(parent::triplify($id_res, $this->getVoc() . "x-uniparc", "uniparc:" . $uniparc_id) . parent::QQuadO_URL($id_res, "rdfs:seeAlso", "http://uniprot.org/uniparc/" . $uniparc_id));
             }
         }
         if (!empty($ncbi_taxonomy)) {
             $taxonomy_ids = explode("; ", $ncbi_taxonomy);
             foreach ($taxonomy_ids as $taxonomy_id) {
                 parent::AddRDF(parent::triplify($id_res, $this->getVoc() . "x-taxon", "taxon:" . $taxonomy_id));
             }
         }
         if (!empty($mim)) {
             $mim_ids = explode("; ", $mim);
             foreach ($mim_ids as $mim_id) {
                 parent::AddRDF(parent::triplify($id_res, $this->getVoc() . "x-omim", "omim:" . $mim_id));
             }
         }
         if (!empty($unigene)) {
             $unigene_ids = explode("; ", $unigene);
             foreach ($unigene_ids as $unigene_id) {
                 parent::AddRDF(parent::triplify($id_res, $this->getVoc() . "x-unigene", "unigene:" . $unigene_id));
             }
         }
         if (!empty($ensembl)) {
             $ensembl_ids = explode("; ", $ensembl);
             foreach ($ensembl_ids as $ensembl_id) {
                 parent::AddRDF(parent::triplify($id_res, $this->getVoc() . "x-ensembl", "ensembl:" . $ensembl_id));
             }
         }
         if (!empty($pubmed)) {
             $pubmed_ids = explode("; ", $pubmed);
             foreach ($pubmed_ids as $pubmed_id) {
                 parent::AddRDF(parent::triplify($id_res, $this->getVoc() . "x-pubmed", "pubmed:" . $pubmed_id));
             }
         }
         if (!empty($embl_genbank_ddbj)) {
             $genbank_ids = explode("; ", $embl_genbank_ddbj);
             foreach ($genbank_ids as $genbank_id) {
                 parent::AddRDF(parent::triplify($id_res, $this->getVoc() . "x-genbank", "genbank:" . $genbank_id));
             }
         }
         if (!empty($embl_protein)) {
             $embl_protein_ids = explode(";", $embl_protein);
             foreach ($embl_protein_ids as $embl_protein_id) {
                 parent::AddRDF(parent::triplify($id_res, $this->getVoc() . "x-genbank", "genbank:" . $embl_protein_id));
             }
         }
         //write rdf to file
         $this->WriteRDFBufferToWriteFile();
     }
     //while
 }
Beispiel #3
0
 private function process()
 {
     //read the file into a string
     $xml_str = '';
     while ($l = $this->getReadFile()->Read(4096)) {
         $xml_str .= $l;
     }
     $xml = new SimpleXMLElement($xml_str);
     foreach ($xml->{'sts'} as $sts) {
         $uid = (string) $sts->uid;
         $uid_res = $this->getNamespace() . $uid;
         $name = (string) $sts->name;
         $uid_label = $name;
         parent::AddRDF(parent::describeIndividual($uid_res, $uid_label, $this->getVoc() . "sequence_tagged_site"));
         //split by semicolon
         $genbank_accession_arr = explode(";", (string) $sts->gbacc);
         foreach ($genbank_accession_arr as $gb) {
             parent::AddRDF(parent::triplify($uid_res, $this->getVoc() . 'x-genbank', 'genbank:' . $gb));
         }
         //split by semicolon
         $gi_arr = explode(';', (string) $sts->gi);
         foreach ($gi_arr as $gi) {
             parent::AddRDF(parent::triplify($uid_res, $this->getVoc() . 'x-gi', 'gi:' . $gi));
         }
         $links = (string) $sts->links;
         if (isset($links)) {
             parent::AddRDF(parent::triplifyString($uid_res, $this->getVoc() . 'links', utf8_encode($links)));
         }
         $forward_primer = (string) $sts->pcrfor;
         if (isset($forward_primer)) {
             parent::AddRDF(parent::triplifyString($uid_res, $this->getVoc() . 'forward-primer', $forward_primer));
         }
         $reverse_primer = (string) $sts->pcrrev;
         if (isset($reverse_primer)) {
             parent::AddRDF(parent::triplifyString($uid_res, $this->getVoc() . 'reverse-primer', $reverse_primer));
         }
         $epcr_summary = (string) $sts->EPCR_Summary;
         if (isset($epcr_summary)) {
             parent::AddRDF(parent::triplifyString($uid_res, $this->getVoc() . 'epcr-summary', $epcr_summary));
         }
         $dbsts = (string) $sts->dbsts;
         if (isset($dbsts)) {
             parent::AddRDF(parent::triplifyString($uid_res, $this->getVoc() . 'dbsts', $dbsts));
         }
         foreach ($sts->{'Map_Gene_Summary_List'} as $gsl) {
             foreach ($gsl->{'Map_Gene_Summary'} as $mgs) {
                 $r = rand();
                 $org = (string) $mgs->Org;
                 $taxid = (string) $mgs->taxid;
                 $chromosome = (string) $mgs->Chr;
                 $locus = (string) $mgs->Locus;
                 $polymorphic = (string) $mgs->Polymorphic;
                 $lbl = "map gene summary for :" . $org . " " . $taxid;
                 $u_res = $this->getRes() . md5($r . $org);
                 parent::AddRDF(parent::describeIndividual($u_res, $lbl, $this->getVoc() . "map-gene-summary") . parent::triplify($uid_res, $this->getVoc() . "has-map-gene-summary", $u_res));
                 if (isset($polymorphic)) {
                     parent::AddRDF(parent::triplifyString($u_res, $this->getVoc() . "polymorphic", $polymorphic));
                 }
                 if (isset($locus)) {
                     parent::AddRDF(parent::triplifyString($u_res, $this->getVoc() . "locus", $locus));
                 }
                 if (isset($chromosome)) {
                     parent::AddRDF(parent::triplifyString($u_res, $this->getVoc() . "chromosome", $chromosome));
                 }
                 if (isset($taxid)) {
                     parent::AddRDF(parent::triplify($u_res, $this->getVoc() . "x-taxonomy", "taxon:" . $taxid));
                 }
                 if (isset($org)) {
                     parent::AddRDF(parent::triplifyString($u_res, $this->getVoc() . "org-name", $org));
                 }
             }
         }
         foreach ($sts->{'org'} as $anOrg) {
             $r = rand();
             $taxname = (string) $anOrg->taxname;
             $taxid = (string) $anOrg->taxid;
             $name = (string) $anOrg->name;
             $keyword = (string) $anOrg->keyword;
             $alias = (string) $anOrg->alias;
             $polymorphic = (string) $anOrg->polymorphic;
             $dseg = (string) $anOrg->dseg;
             $gdb = (string) $anOrg->gdb;
             $rgd = (string) $anOrg->rgd;
             $mgd = (string) $anOrg->mgd;
             $zfin = (string) $anOrg->zfin;
             $pcrsize = (string) $anOrg->pcrsize;
             $dbsnp = (string) $anOrg->dbsnp;
             $warn = (string) $anOrg->warn;
             $wloc = (string) $anOrg->wloc;
             $wmap = (string) $anOrg->wmap;
             $wctg = (string) $anOrg->wctg;
             $wdrift = (string) $anOrg->wdrift;
             $mapview = (string) $anOrg->mapview;
             $u_res = $this->getRes() . md5($r . $taxname . $taxid);
             $u_lbl = "org entry for " . $taxname . " " . $taxid;
             parent::AddRDF(parent::describeIndividual($u_res, $u_lbl, $this->getVoc() . "organism") . parent::triplify($uid_res, $this->getVoc() . "has-organism", $u_res));
             if (isset($mapview) && strlen($mapview)) {
                 parent::AddRDF(parent::triplifyString($u_res, $this->getVoc() . "mapview", $mapview));
             }
             if (isset($wdrift) && strlen($wdrift)) {
                 parent::AddRDF(parent::triplifyString($u_res, $this->getVoc() . "wdrift", $wdrift));
             }
             if (isset($wctg) && strlen($wctg)) {
                 parent::AddRDF(parent::triplifyString($u_res, $this->getVoc() . "wctg", $wctg));
             }
             if (isset($wmap) && strlen($wmap)) {
                 parent::AddRDF(parent::triplifyString($u_res, $this->getVoc() . "wmap", $wmap));
             }
             if (isset($wloc) && strlen($wloc)) {
                 parent::AddRDF(parent::triplifyString($u_res, $this->getVoc() . "wloc", $wloc));
             }
             if (isset($warn) && strlen($warn)) {
                 parent::AddRDF(parent::triplifyString($u_res, $this->getVoc() . "warn", $warn));
             }
             if (isset($taxname) && strlen($taxname)) {
                 parent::AddRDF(parent::triplifyString($u_res, $this->getVoc() . "taxname", $taxname));
             }
             if (isset($name)) {
                 parent::AddRDF(parent::triplifyString($u_res, $this->getVoc() . "name", $name));
             }
             if (isset($keyword) && strlen($keyword)) {
                 parent::AddRDF(parent::triplifyString($u_res, $this->getVoc() . "keyword", $keyword));
             }
             if (isset($alias) && strlen($alias)) {
                 parent::AddRDF(parent::triplifyString($u_res, $this->getVoc() . "alias", $alias));
             }
             if (isset($polymorphic) && strlen($polymorphic)) {
                 parent::AddRDF(parent::triplifyString($u_res, $this->getVoc() . "polymorphic", $polymorphic));
             }
             if (isset($dseg) && strlen($dseg)) {
                 parent::AddRDF(parent::triplifyString($u_res, $this->getVoc() . "dseg", $dseg));
             }
             if (isset($gdb) && strlen($gdb)) {
                 parent::AddRDF(parent::triplifyString($u_res, $this->getVoc() . "gdb", $gdb));
             }
             if (isset($rgd) && strlen($rgd)) {
                 parent::AddRDF(parent::triplifyString($u_res, $this->getVoc() . "rgd", $rgd));
             }
             if (isset($mgd) && strlen($mgd)) {
                 parent::AddRDF(parent::triplifyString($u_res, $this->getVoc() . "mgd", $mgd));
             }
             if (isset($zfin) && strlen($zfin)) {
                 parent::AddRDF(parent::triplifyString($u_res, $this->getVoc() . "zfin", $zfin));
             }
             if (isset($pcrsize) && strlen($pcrsize)) {
                 parent::AddRDF(parent::triplifyString($u_res, $this->getVoc() . "pcrsize", $pcrsize));
             }
             if (isset($dbsnp) && strlen($dbsnp)) {
                 parent::AddRDF(parent::triplifyString($u_res, $this->getVoc() . "dbsnp", $dbsnp));
             }
             foreach ($anOrg->{'rhdb'} as $rh) {
                 $id = (string) $rh->id;
                 $panel = (string) $rh->panel;
                 $r = rand();
                 $u_res = $this->getRes() . md5($r . $id . $panel);
                 $u_label = "rhdb for " . $id . " " . $panel;
                 parent::AddRDF(parent::describeIndividual($u_res, $u_label, $this->getVoc() . "rhdb") . parent::triplify($uid_res, $this->getVoc() . 'has-rhdb', $u_res) . parent::triplifyString($u_res, $this->getVoc() . 'id', $id) . parent::triplifyString($u_res, $this->getVoc() . 'panel', $panel));
             }
             foreach ($anOrg->{'unigene'} as $u) {
                 $ugid = (string) $u->unigene;
                 $ugname = (string) $u->ugname;
                 $r = rand();
                 $u_res = $this->getRes() . md5($r . $ugid . $ugname);
                 $u_label = "unigene for " . $ugid . " " . $ugname;
                 if (strlen($ugid) > 0 && strlen($ugname) > 0) {
                     parent::AddRDF(parent::describeIndividual($u_res, $u_label, $this->getVoc() . "unigene") . parent::triplify($uid_res, $this->getVoc() . 'has-unigene', $u_res) . parent::triplify($u_res, $this->getVoc() . 'x-unigene', $ugid) . parent::triplifyString($u_res, $this->getVoc() . 'ugname', $ugname));
                 }
             }
             foreach ($anOrg->{'locus'} as $aLocus) {
                 $lid = (string) $aLocus->lid;
                 $lsymbol = (string) $aLocus->lsymbol;
                 $lname = (string) $aLocus->lname;
                 $lcyto = (string) $aLocus->lcyto;
                 $ltype = (string) $aLocus->ltype;
                 $r = rand();
                 $u_res = $this->getRes() . md5($r . $lid);
                 $u_label = "locus for " . $lid . " " . $lname . " " . $lsymbol;
                 parent::AddRDF(parent::describeIndividual($u_res, $u_label, $this->getVoc() . "locus") . parent::triplify($uid_res, $this->getVoc() . 'has-locus', $u_res));
                 if (isset($lcyto) && strlen($lcyto)) {
                     parent::AddRDF(parent::triplifyString($u_res, $this->getVoc() . 'cyto', $lcyto));
                 }
                 if (isset($ltype) && strlen($ltype)) {
                     parent::AddRDF(parent::triplifyString($u_res, $this->getVoc() . 'ltype', $ltype));
                 }
                 if (isset($lname) && strlen($lname)) {
                     parent::AddRDF(parent::triplifyString($u_res, $this->getVoc() . 'name', $lname));
                 }
             }
             foreach ($anOrg->{'mappos'} as $aMapPos) {
                 $map = (string) $aMapPos->map;
                 $marker = (string) $aMapPos->marker;
                 $chr = (string) $aMapPos->chr;
                 $chrpos = (string) $aMapPos->chrpos;
                 $ctg = (string) $aMapPos->ctg;
                 $ctgpos = (string) $aMapPos->ctgpos;
                 $coord = (string) $aMapPos->coord;
                 $lod = (string) $aMapPos->lod;
                 $bin = (string) $aMapPos->bin;
                 $binpos = (string) $aMapPos->binpos;
                 $het = (string) $aMapPos->het;
                 $lab = (string) $aMapPos->lab;
                 $unit = (string) $aMapPos->unit;
                 $r = rand();
                 $u_res = $this->getRes() . md5($r . $map);
                 $u_label = "locus for " . $map . " " . $marker . " " . $chr;
                 parent::AddRDF(parent::describeIndividual($u_res, $u_label, $this->getVoc() . "mappos") . parent::triplify($uid_res, $this->getVoc() . 'has-mappos', $u_res));
                 if (isset($unit) && strlen($unit)) {
                     parent::AddRDF(parent::triplifyString($u_res, $this->getVoc() . 'unit', $unit));
                 }
                 if (isset($lab) && strlen($lab)) {
                     parent::AddRDF(parent::triplifyString($u_res, $this->getVoc() . 'lab', $lab));
                 }
                 if (isset($het) && strlen($het)) {
                     parent::AddRDF(parent::triplifyString($u_res, $this->getVoc() . 'het', $het));
                 }
                 if (isset($binpos) && strlen($binpos)) {
                     parent::AddRDF(parent::triplifyString($u_res, $this->getVoc() . 'binpos', $binpos));
                 }
                 if (isset($bin) && strlen($bin)) {
                     parent::AddRDF(parent::triplifyString($u_res, $this->getVoc() . 'bin', $bin));
                 }
                 if (isset($lod) && strlen($lod)) {
                     parent::AddRDF(parent::triplifyString($u_res, $this->getVoc() . 'lod', $lod));
                 }
                 if (isset($coord) && strlen($coord)) {
                     parent::AddRDF(parent::triplifyString($u_res, $this->getVoc() . 'coord', $coord));
                 }
                 if (isset($ctgpos) && strlen($ctgpos)) {
                     parent::AddRDF(parent::triplifyString($u_res, $this->getVoc() . 'ctgpos', $ctgpos));
                 }
                 if (isset($ctg) && strlen($ctg)) {
                     parent::AddRDF(parent::triplifyString($u_res, $this->getVoc() . 'ctg', $ctg));
                 }
                 if (isset($chrpos) && strlen($chrpos)) {
                     parent::AddRDF(parent::triplifyString($u_res, $this->getVoc() . 'chrpos', $chrpos));
                 }
                 if (isset($chr) && strlen($chr)) {
                     parent::AddRDF(parent::triplifyString($u_res, $this->getVoc() . 'chr', $chr));
                 }
                 if (isset($marker) && strlen($marker)) {
                     parent::AddRDF(parent::triplifyString($u_res, $this->getVoc() . 'marker', $marker));
                 }
             }
             foreach ($anOrg->{'epcr'} as $aEpcr) {
                 $seqType = (string) $aEpcr->seqtype;
                 $acc = (string) $aEpcr->acc;
                 $gi = (string) $aEpcr->gi;
                 $pos1 = (string) $aEpcr->pos1;
                 $pos2 = (string) $aEpcr->pos2;
                 $epcr_size = (string) $aEpcr->epcrsize;
                 $r = rand();
                 $u_res = $this->getRes() . md5($r . $gi . $pos1);
                 $u_label = "epcr for " . $pos1 . " " . $pos2;
                 parent::AddRDF(parent::describeIndividual($u_res, $u_label, $this->getVoc() . "epcr") . parent::triplify($uid_res, $this->getVoc() . 'has-epcr', $u_res));
                 if (isset($seqtype) && strlen($seqtype)) {
                     parent::AddRDF(parent::triplifyString($u_res, $this->getVoc() . 'seqtype', $seqtype));
                 }
                 if (isset($acc) && strlen($acc)) {
                     parent::AddRDF(parent::triplify($u_res, $this->getVoc() . 'x-genbank', 'genbank:' . $acc));
                 }
                 if (isset($gi) && strlen($gi)) {
                     parent::AddRDF(parent::triplify($u_res, $this->getVoc() . 'x-gi', 'gi:' . $gi));
                 }
                 if (isset($pos1) && strlen($pos1)) {
                     parent::AddRDF(parent::triplifyString($u_res, $this->getVoc() . 'pos1', $pos1));
                 }
                 if (isset($pos2) && strlen($pos2)) {
                     parent::AddRDF(parent::triplifyString($u_res, $this->getVoc() . 'pos2', $pos2));
                 }
                 if (isset($epcr_size) && strlen($epcr_size)) {
                     parent::AddRDF(parent::triplifyString($u_res, $this->getVoc() . 'epcr_size', $epcr_size));
                 }
             }
         }
         $this->WriteRDFBufferToWriteFile();
     }
 }
Beispiel #4
0
 function process()
 {
     $header = $this->GetReadFile()->Read(200000);
     $header_arr = explode("\t", $header);
     $n = 41;
     $c = count($header_arr);
     if ($c != $n) {
         echo PHP_EOL;
         print_r($header_arr);
         trigger_error("Expected {$n} columns, found {$c} . please update the script", E_USER_ERROR);
         exit;
     }
     while ($l = $this->GetReadFile()->Read(4096)) {
         $fields = explode("\t", $l);
         $id = strtolower($fields[0]);
         $approved_symbol = $fields[1];
         $approved_name = $fields[2];
         $status = $fields[3];
         $locus_type = $fields[4];
         $locus_group = $fields[5];
         $previous_symbols = $fields[6];
         $previous_names = $fields[7];
         $synonyms = $fields[8];
         $name_synonyms = $fields[9];
         $chromosome = $fields[10];
         $date_approved = $fields[11];
         $date_modified = $fields[12];
         $date_symbol_changed = $fields[13];
         $date_name_changed = $fields[14];
         $accession_numbers = $fields[15];
         $enzyme_ids = $fields[16];
         $entrez_gene_id = $fields[17];
         $ensembl_gene_id = $fields[18];
         $mouse_genome_database_id = $fields[19];
         $specialist_database_links = $fields[20];
         $specialist_database_ids = $fields[21];
         $pubmed_ids = $fields[22];
         $refseq_ids = $fields[23];
         $gene_family_tag = $fields[24];
         $gene_family_description = $fields[25];
         $record_type = $fields[26];
         $primary_ids = $fields[27];
         $secondary_ids = $fields[28];
         $ccd_ids = $fields[29];
         $vega_ids = $fields[30];
         $locus_specific_databases = $fields[31];
         $entrez_gene_id_mappeddatasuppliedbyNCBI = $fields[32];
         $omim_id_mappeddatasuppliedbyNCBI = $fields[33];
         $refseq_mappeddatasuppliedbyNCBI = $fields[34];
         $uniprot_id_mappeddatasuppliedbyUniProt = $fields[35];
         $ensembl_id_mappeddatasuppliedbyEnsembl = $fields[36];
         $vega_id_mappeddatasuppliedbyVega = $fields[37];
         $ucsc_id_mappeddatasuppliedbyUCSC = $fields[38];
         $mouse_genome_database_id_mappeddatasuppliedbyMGI = $fields[39];
         $rat_genome_database_id_mappeddatasuppliedbyRGD = $fields[40];
         $id_res = $id;
         $id_label = "Gene Symbol for " . $approved_symbol;
         parent::AddRDF(parent::triplify($id_res, "rdf:type", $this->getVoc() . "Gene-Symbol") . parent::describeIndividual($id_res, $id_label, $this->getVoc() . "Gene-Symbol") . parent::describeClass($this->getVoc() . "Gene-Symbol", "HGNC Official Gene Symbol"));
         if (!empty($approved_symbol)) {
             $s = "hgnc.symbol:" . $approved_symbol;
             parent::AddRDF(parent::triplifyString($id_res, $this->getVoc() . "approved-symbol", utf8_encode(htmlspecialchars($approved_symbol))) . parent::describeProperty($this->getVoc() . "approved-symbol", "HGNC approved gene symbol", "The official gene symbol that has been approved by the HGNC and is publicly available. Symbols are approved based on specific HGNC nomenclature guidelines. In the HTML results page this ID links to the HGNC Symbol Report for that gene") . parent::describeIndividual($s, $approved_symbol, parent::getVoc() . "Approved-Gene-Symbol") . parent::describeClass(parent::getVoc() . "Approved-Gene-Symbol", "Approved Gene Symbol") . parent::triplify($id_res, parent::getVoc() . "has-approved-symbol", $s) . parent::triplify($s, parent::getVoc() . "is-approved-symbol-of", $id_res));
         }
         if (!empty($approved_name)) {
             parent::AddRDF(parent::triplifyString($id_res, $this->getVoc() . "approved-name", utf8_encode(htmlspecialchars($approved_name))) . parent::describeProperty($this->getVoc() . "approved-name", "HGNC approved name", "The official gene name that has been approved by the HGNC and is publicly available. Names are approved based on specific HGNC nomenclature guidelines."));
         }
         if (!empty($status)) {
             $s = $this->getVoc() . str_replace(" ", "-", $status);
             parent::AddRDF(parent::triplify($id_res, $this->getVoc() . "status", $s) . parent::describeProperty($this->getVoc() . "status", "HGNC status", "Indicates whether the gene is classified as: Approved - these genes have HGNC-approved gene symbols. Entry withdrawn - these previously approved genes are no longer thought to exist. Symbol withdrawn - a previously approved record that has since been merged into a another record.") . parent::describeClass($s, $status, $this->getVoc() . "Status"));
         }
         if (!empty($locus_id)) {
             $locus_res = $this->getRes() . $id . "_LOCUS";
             parent::AddRDF(parent::triplify($id_res, $this->getVoc() . "locus", $locus_res) . parent::triplifyString($locus_res, $this->getVoc() . "locus-type", utf8_encode(htmlspecialchars($locus_type))) . parent::triplifyString($locus_res, $this->getVoc() . "locus-group", utf8_encode(htmlspecialchars($locus_group))) . parent::describeProperty($this->getVoc() . "locus-type", "locus type", "Specifies the type of locus described by the given entry") . parent::describeProperty($this->getVoc() . "locus-group", "locus group", "Groups locus types together into related sets. Below is a list of groups and the locus types within the group"));
         }
         if (!empty($previous_symbols)) {
             $previous_symbols = explode(", ", $previous_symbols);
             foreach ($previous_symbols as $previous_symbol) {
                 $previous_symbol_uri = "hgnc.symbol:" . $previous_symbol;
                 parent::AddRDF(parent::describeIndividual($previous_symbol_uri, $previous_symbol, parent::getVoc() . "Previous-Symbol") . parent::describeClass(parent::getVoc() . "Previous-Symbol", "Previous Symbol") . parent::triplify($id_res, $this->getVoc() . "previous-symbol", $previous_symbol_uri) . parent::describeProperty($this->getVoc() . "previous-symbol", "HGNC previous symbol", "Symbols previously approved by the HGNC for this gene"));
             }
         }
         if (!empty($previous_names)) {
             $previous_names = explode(", ", $previous_names);
             foreach ($previous_names as $previous_name) {
                 $previous_name = str_replace("\"", "", $previous_name);
                 parent::AddRDF(parent::triplifyString($id_res, $this->getVoc() . "previous-name", utf8_encode(htmlspecialchars($previous_name))) . parent::describeProperty($this->getVoc() . "previous-name", "HGNC previous name", "Gene names previously approved by the HGNC for this gene"));
             }
         }
         if (!empty($synonyms)) {
             $synonyms = explode(", ", $synonyms);
             foreach ($synonyms as $synonym) {
                 parent::AddRDF(parent::triplifyString($id_res, $this->getVoc() . "synonym", utf8_encode(htmlspecialchars($synonym))) . parent::describeProperty($this->getVoc() . "synonym", "synonym", "Other symbols used to refer to this gene"));
             }
         }
         if (!empty($name_synonyms)) {
             $name_synonyms = explode(", ", $name_synonyms);
             foreach ($name_synonyms as $name_synonym) {
                 $name_synonym = str_replace("\"", "", $name_synonym);
                 parent::AddRDF(parent::triplifyString($id_res, $this->getVoc() . "name-synonym", utf8_encode(htmlspecialchars($name_synonym))) . parent::describeProperty($this->getVoc() . "name-synonym", "name synonym", "Other names used to refer to this gene"));
             }
         }
         if (!empty($chromosome)) {
             parent::AddRDF(parent::triplifyString($id_res, $this->getVoc() . "chromosome", utf8_encode(htmlspecialchars($chromosome))) . parent::describeProperty($this->getVoc() . "chromosome", "chromosome", "Indicates the location of the gene or region on the chromosome"));
         }
         if (!empty($date_approved)) {
             parent::AddRDF(parent::triplifyString($id_res, $this->getVoc() . "date-approved", $date_approved, "xsd:date") . parent::describeProperty($this->getVoc() . "date-approved", "date approved", "Date the gene symbol and name were approved by the HGNC"));
         }
         if (!empty($date_modified)) {
             parent::AddRDF(parent::triplifyString($id_res, $this->getVoc() . "date-modified", $date_modified, "xsd:date") . parent::describeProperty($this->getVoc() . "date-modified", "date modified", "the date the entry was modified by the HGNC"));
         }
         if (!empty($date_symbol_changed)) {
             parent::AddRDF(parent::triplifyString($id_res, $this->getVoc() . "date-symbol-changed", $date_symbol_changed, "xsd:date") . parent::describeProperty($this->getVoc() . "date-symbol-changed", "date symbol changed", "The date the gene symbol was last changed by the HGNC from a previously approved symbol. Many genes receive approved symbols and names which are viewed as temporary (eg C2orf#) or are non-ideal when considered in the light of subsequent information. In the case of individual genes a change to the name (and subsequently the symbol) is only made if the original name is seriously misleading"));
         }
         if (!empty($date_name_changed)) {
             parent::AddRDF(parent::triplifyString($id_res, $this->getVoc() . "date-name-changed", $date_name_changed, "xsd:date") . parent::describeProperty($this->getVoc() . "date-name-changed", "date name changed", "The date the gene name was last changed by the HGNC from a previously approved name"));
         }
         if (!empty($accession_numbers)) {
             $accession_numbers = explode(", ", $accession_numbers);
             foreach ($accession_numbers as $accession_number) {
                 parent::AddRDF(parent::triplifyString($id_res, $this->getVoc() . "accession", utf8_encode(htmlspecialchars($accession_number))) . parent::describeProperty($this->getVoc() . "accession", "accession number", "Accession numbers for each entry selected by the HGNC"));
             }
         }
         if (!empty($enzyme_ids)) {
             $enzyme_ids = explode(", ", $enzyme_ids);
             foreach ($enzyme_ids as $enzyme_id) {
                 parent::AddRDF(parent::triplifyString($id_res, $this->getVoc() . "x-ec", utf8_encode(htmlspecialchars($enzyme_id))) . parent::describeProperty($this->getVoc() . "x-ec", "Enzyme Commission (EC) number", "Enzyme entries have Enzyme Commission (EC) numbers associated with them that indicate the hierarchical functional classes to which they belong"));
             }
         }
         if (!empty($entrez_gene_id)) {
             parent::AddRDF(parent::triplify($id_res, $this->getVoc() . "x-ncbigene", "ncbigene:{$entrez_gene_id}") . parent::describeProperty($this->getVoc() . "x-ncbigene", "NCBI Gene", "NCBI Gene provides curated sequence and descriptive information about genetic loci including official nomenclature, synonyms, sequence accessions, phenotypes, EC numbers, MIM numbers, UniGene clusters, homology, map locations, and related web sites"));
         }
         if (!empty($ensembl_gene_id)) {
             parent::AddRDF(parent::triplify($id_res, $this->getVoc() . "x-ensembl", "ensembl:{$ensembl_gene_id}") . parent::describeProperty($this->getVoc() . "x-ensembl", "Ensembl Gene"));
         }
         if (!empty($mouse_genome_database_id)) {
             if (strpos($mouse_genome_database_id, "MGI:") !== FALSE) {
                 $mouse_genome_database_id = substr($mouse_genome_database_id, 4);
                 parent::AddRDF(parent::triplify($id_res, $this->getVoc() . "x-mgi", "mgi:{$mouse_genome_database_id}") . parent::describeProperty($this->getVoc() . "x-mgi", "MGI entry"));
             }
         }
         if (!empty($specialist_database_links)) {
             $specialist_database_links = explode(", ", $specialist_database_links);
             foreach ($specialist_database_links as $specialist_database_link) {
                 preg_match('/href="(\\S+)"/', $specialist_database_link, $matches);
                 if (!empty($matches[1])) {
                     parent::AddRDF(parent::QQuadO_URL($id_res, $this->getVoc() . "xref", $matches[1]) . parent::describeProperty($this->getVoc() . "xref", "Specialist database references."));
                 }
             }
         }
         if (!empty($pubmed_ids)) {
             $pubmed_ids = explode(", ", $pubmed_ids);
             foreach ($pubmed_ids as $pubmed_id) {
                 parent::AddRDF(parent::triplify($id_res, $this->getVoc() . "x-pubmed", "pubmed:" . trim($pubmed_id)) . parent::describeProperty($this->getVoc() . "x-pubmed", "NCBI PubMed entry", "Identifier that links to published articles relevant to the entry in the NCBI's PubMed database."));
             }
         }
         if (!empty($refseq_ids)) {
             $refseq_ids = explode(", ", $refseq_ids);
             foreach ($refseq_ids as $refseq_id) {
                 parent::AddRDF(parent::triplify($id_res, $this->getVoc() . "x-refseq", "refseq:" . trim($refseq_id)) . parent::describeProperty($this->getVoc() . "x-refseq", "NCBI Refseq entry", "The Reference Sequence (RefSeq) identifier for that entry, provided by the NCBI. As we do not aim to curate all variants of a gene only one selected RefSeq is displayed per gene report. RefSeq aims to provide a comprehensive, integrated, non-redundant set of sequences, including genomic DNA, transcript (RNA), and protein products. RefSeq identifiers are designed to provide a stable reference for gene identification and characterization, mutation analysis, expression studies, polymorphism discovery, and comparative analyses. In the HTML results page this ID links to the RefSeq page for that entry."));
             }
         }
         if (!empty($gene_family_tag)) {
             parent::AddRDF(parent::triplifyString($id_res, $this->getVoc() . "gene-family-tag", utf8_encode(htmlspecialchars($gene_family_tag))) . parent::describeProperty($this->getVoc() . "gene-family-tag", "Gene Family Tag", "Tag used to designate a gene family or group the gene has been assigned to, according to either sequence similarity or information from publications, specialist advisors for that family or other databases. Families/groups may be either structural or functional, therefore a gene may belong to more than one family/group. These tags are used to generate gene family or grouping specific pages at genenames.org and do not necessarily reflect an official nomenclature. Each gene family has an associated gene family tag and gene family description. If a particular gene is a member of more than one gene family, the tags and the descriptions will be shown in the same order."));
         }
         if (!empty($gene_family_description)) {
             $gene_family_description = str_replace("\"", "", $gene_family_description);
             parent::AddRDF(parent::triplifyString($id_res, $this->getVoc() . "gene-family-description", utf8_encode(htmlspecialchars($gene_family_description))) . parent::describeProperty($this->getVoc() . "gene-family-description", "gene family name", "Name given to a particular gene family. The gene family description has an associated gene family tag. Gene families are used to group genes according to either sequence similarity or information from publications, specialist advisors for that family or other databases. Families/groups may be either structural or functional, therefore a gene may belong to more than one family/group."));
         }
         if (!empty($record_type)) {
             parent::AddRDF(parent::triplifyString($id_res, $this->getVoc() . "record-type", utf8_encode(htmlspecialchars($record_type))));
         }
         if (!empty($primary_ids)) {
             $primary_ids = explode(", ", $primary_ids);
             foreach ($primary_ids as $primary_id) {
                 parent::AddRDF(parent::triplifyString($id_res, $this->getVoc() . "primary-id", utf8_encode(htmlspecialchars($primary_id))) . parent::describeProperty($this->getVoc() . "primary-id", "primary identifier"));
             }
         }
         if (!empty($secondary_ids)) {
             $secondary_ids = explode(", ", $secondary_ids);
             foreach ($secondary_ids as $secondary_id) {
                 parent::AddRDF(parent::triplifyString($id_res, $this->getVoc() . "secondary-id", utf8_encode(htmlspecialchars($secondary_id))) . parent::describeProperty($this->getVoc() . "secondary-id", "secondary identifier"));
             }
         }
         if (!empty($ccd_ids)) {
             $ccd_ids = explode(", ", $ccd_ids);
             foreach ($ccd_ids as $ccd_id) {
                 parent::AddRDF(parent::triplify($id_res, $this->getVoc() . "x-ccds", "ccds:" . trim($ccd_id)) . parent::describeProperty($this->getVoc() . "x-ccds", "consensus CDS entry", "The Consensus CDS (CCDS) project is a collaborative effort to identify a core set of human and mouse protein coding regions that are consistently annotated and of high quality. The long term goal is to support convergence towards a standard set of gene annotations."));
             }
         }
         if (!empty($vega_ids)) {
             $vega_ids = explode(", ", $vega_ids);
             foreach ($vega_ids as $vega_id) {
                 parent::AddRDF(parent::triplify($id_res, $this->getVoc() . "x-vega", "vega:" . trim($vega_id)) . parent::describeProperty($this->getVoc() . "x-vega", "VEGA gene entry"));
             }
         }
         if (!empty($locus_specific_databases)) {
             parent::AddRDF(parent::triplifyString($id_res, $this->getVoc() . "locus-specific-xref", utf8_encode(htmlspecialchars($locus_specific_databases))) . parent::describeProperty($this->getVoc() . "locus-specific-xref", "locus specific xref", "This contains a list of links to databases or database entries pertinent to the gene"));
         }
         if (!empty($entrez_gene_id_mappeddatasuppliedbyNCBI)) {
             $entrez_gene_id_mappeddatasuppliedbyNCBI = explode(", ", $entrez_gene_id_mappeddatasuppliedbyNCBI);
             foreach ($entrez_gene_id_mappeddatasuppliedbyNCBI as $gene_id) {
                 if (strstr($gene_id, ":") !== FALSE) {
                     $a = explode(":", $gene_id);
                     $gene_id = $a[1];
                 }
                 parent::AddRDF(parent::triplify($id_res, $this->getVoc() . "x-ncbigene", "ncbigene:" . trim($gene_id)) . parent::describeProperty($this->getVoc() . "x-ncbigene", "NCBI Gene entry"));
             }
         }
         if (!empty($omim_id_mappeddatasuppliedbyNCBI)) {
             $omim_id_mappeddatasuppliedbyNCBI = explode(", ", $omim_id_mappeddatasuppliedbyNCBI);
             foreach ($omim_id_mappeddatasuppliedbyNCBI as $omim_id) {
                 parent::AddRDF(parent::triplify($id_res, $this->getVoc() . "x-omim", "omim:" . trim($omim_id)) . parent::describeProperty($this->getVoc() . "x-omim", "OMIM entry", "Identifier provided by Online Mendelian Inheritance in Man (OMIM) at the NCBI. This database is described as a catalog of human genes and genetic disorders containing textual information and links to MEDLINE and sequence records in the Entrez system, and links to additional related resources at NCBI and elsewhere. In the HTML results page this ID links to the OMIM page for that entry."));
             }
         }
         if (!empty($refseq_mappeddatasuppliedbyNCBI)) {
             $refseq_mappeddatasuppliedbyNCBI = explode(", ", $refseq_mappeddatasuppliedbyNCBI);
             foreach ($refseq_mappeddatasuppliedbyNCBI as $refseq_id) {
                 parent::AddRDF(parent::triplify($id_res, $this->getVoc() . "x-refseq", "refseq:" . trim($refseq_id)) . parent::describeProperty($this->getVoc() . "x-refseq", "NCBI Refseq entry", "The Reference Sequence (RefSeq) identifier for that entry, provided by the NCBI. As we do not aim to curate all variants of a gene only one selected RefSeq is displayed per gene report. RefSeq aims to provide a comprehensive, integrated, non-redundant set of sequences, including genomic DNA, transcript (RNA), and protein products. RefSeq identifiers are designed to provide a stable reference for gene identification and characterization, mutation analysis, expression studies, polymorphism discovery, and comparative analyses. In the HTML results page this ID links to the RefSeq page for that entry."));
             }
         }
         if (!empty($uniprot_id_mappeddatasuppliedbyUniProt)) {
             $uniprot_id_mappeddatasuppliedbyUniProt = explode(", ", $uniprot_id_mappeddatasuppliedbyUniProt);
             foreach ($uniprot_id_mappeddatasuppliedbyUniProt as $uniprot_id) {
                 parent::AddRDF(parent::triplify($id_res, $this->getVoc() . "x-uniprot", "uniprot:" . trim($uniprot_id)) . parent::describeProperty($this->getVoc() . "x-uniprot", "Uniprot entry", "The UniProt identifier, provided by the EBI. The UniProt Protein Knowledgebase is described as a curated protein sequence database that provides a high level of annotation, a minimal level of redundancy and high level of integration with other databases. In the HTML results page this ID links to the UniProt page for that entry."));
             }
         }
         if (!empty($ensembl_id_mappeddatasuppliedbyEnsembl)) {
             $ensembl_id_mappeddatasuppliedbyEnsembl = explode(", ", $ensembl_id_mappeddatasuppliedbyEnsembl);
             foreach ($ensembl_id_mappeddatasuppliedbyEnsembl as $ensembl_id) {
                 parent::AddRDF(parent::triplify($id_res, $this->getVoc() . "x-ensembl", "ensembl:" . trim($refseq_id)) . parent::describeProperty($this->getVoc() . "x-ensembl", "Ensembl entry", "The Ensembl ID is derived from the current build of the Ensembl database and provided by the Ensembl team."));
             }
         }
         if (!empty($ucsc_id_mappeddatasuppliedbyVega)) {
             $ucsc_id_mappeddatasuppliedbyVega = explode(", ", $ucsc_id_mappeddatasuppliedbyVega);
             foreach ($ucsc_id_mappeddatasuppliedbyVega as $vega_id) {
                 parent::AddRDF(parent::triplify($id_res, $this->getVoc() . "x-vega", "vega:" . trim($vega_id)) . parent::describeProperty($this->getVoc() . "x-vega", "Vega entry"));
             }
         }
         if (!empty($ucsc_id_mappeddatasuppliedbyUCSC)) {
             $ucsc_id_mappeddatasuppliedbyUCSC = explode(", ", $ucsc_id_mappeddatasuppliedbyUCSC);
             foreach ($ucsc_id_mappeddatasuppliedbyUCSC as $ucsc_id) {
                 parent::AddRDF(parent::triplify($id_res, $this->getVoc() . "x-ucsc", "ucsc:" . trim($ucsc_id)) . parent::describeProperty($this->getVoc() . "x-ucsc", "UCSC entry"));
             }
         }
         if (!empty($mouse_genome_database_id_mappeddatasuppliedbyMGI)) {
             $mouse_genome_database_id_mappeddatasuppliedbyMGI = explode(", ", $mouse_genome_database_id_mappeddatasuppliedbyMGI);
             foreach ($mouse_genome_database_id_mappeddatasuppliedbyMGI as $mgi_id) {
                 if (strpos($mgi_id, "MGI:") !== FALSE) {
                     $mgi_id = substr($mgi_id, 4);
                 }
                 parent::AddRDF(parent::triplify($id_res, $this->getVoc() . "x-mgi", "mgi:" . trim($mgi_id)) . parent::describeProperty($this->getVoc() . "x-mgi", "MGI entry"));
             }
         }
         if (!empty($rat_genome_database_id_mappeddatasuppliedbyRGD)) {
             $rat_genome_database_id_mappeddatasuppliedbyRGD = explode(", ", trim($rat_genome_database_id_mappeddatasuppliedbyRGD));
             foreach ($rat_genome_database_id_mappeddatasuppliedbyRGD as $rgd_id) {
                 $rgd_id = trim($rgd_id);
                 if (!empty($rgd_id)) {
                     parent::AddRDF(parent::triplify($id_res, $this->getVoc() . "x-rgd", trim($rgd_id)) . parent::describeProperty($this->getVoc() . "x-rgd", "RGD entry"));
                 }
             }
         }
         //write RDF to file
         $this->WriteRDFBufferToWriteFile();
     }
     //while
 }
Beispiel #5
0
 /**
  * add an RDF representation of the incoming param to the model.
  * @$qual_record_arr is an assoc array with the contents of one qualifier record
  */
 private function makeQualifierRecordRDF($qual_record_arr)
 {
     //get the UI of the qualifier record
     $qr_ui = $qual_record_arr["UI"][0];
     $qr_res = $this->getNamespace() . $qr_ui;
     $qr_label = $qual_record_arr['SH'][0];
     parent::AddRDF(parent::describeIndividual($qr_res, $qr_label, $this->getVoc() . "Qualifier-Descriptor", $qr_label) . parent::describeClass($this->getVoc() . "Qualifier-Descriptor", "MeSH Qualifier Descriptor"));
     //now get the descriptor_data_elements
     $qde = $this->getQualifierDataElements();
     //iterate over the properties
     foreach ($qual_record_arr as $k => $v) {
         if (array_key_exists($k, $qde)) {
             if ($k == "AN") {
                 foreach ($v as $kv => $vv) {
                     //explode by semicolon
                     $vvrar = explode(";", $vv);
                     foreach ($vvrar as $anAn) {
                         parent::AddRDF(parent::triplifyString($qr_res, $this->getVoc() . $qde["AN"], $anAn) . parent::describeProperty($this->getVoc() . $qde["AN"], "Relationship between a qualifier record and its annotation"));
                     }
                     //foreach
                 }
                 //foreach
             }
             //if
             if ($k == "DA") {
                 foreach ($v as $kv => $vv) {
                     parent::AddRDF(parent::triplifyString($qr_res, $this->getVoc() . $qde['DA'], $this->formatDate($vv), "xsd:date") . parent::describeProperty($this->getVoc() . $qde['DA'], "Relationship between a qualifier record and its date of entry"));
                 }
             }
             //if
             if ($k == "DQ") {
                 foreach ($v as $kv => $vv) {
                     parent::AddRDF(parent::triplifyString($qr_res, $this->getVoc() . $qde['DQ'], $this->formatDate($vv), "xsd:date") . parent::describeProperty($this->getVoc() . $qde['DQ'], "Relationship between a qualifier record and its date qualifier established"));
                 }
             }
             //if
             if ($k == "GM") {
                 foreach ($v as $kv => $vv) {
                     parent::AddRDF(parent::triplifyString($qr_res, $this->getVoc() . $qde['GM'], utf8_encode(htmlspecialchars($vv))) . parent::describeProperty($this->getVoc() . $qde['GM'], "Relationship between a qualifier record and its grateful med note"));
                 }
             }
             if ($k == "HN") {
                 foreach ($v as $kv => $vv) {
                     parent::AddRDF(parent::triplifyString($qr_res, $this->getVoc() . $qde['HN'], utf8_encode(htmlspecialchars($vv))) . parent::describeProperty($this->getVoc() . $qde['HN'], "Relationship between a qualifier record and its history note"));
                 }
             }
             if ($k == "HN") {
                 foreach ($v as $kv => $vv) {
                     parent::AddRDF(parent::triplifyString($qr_res, $this->getVoc() . $qde['HN'], utf8_encode(htmlspecialchars($vv))) . parent::describeProperty($this->getVoc() . $qde['HN'], "Relationship between a qualifier record and its history note"));
                 }
             }
             if ($k == "MED") {
                 foreach ($v as $kv => $vv) {
                     parent::AddRDF(parent::triplifyString($qr_res, $this->getVoc() . $qde['MED'], utf8_encode(htmlspecialchars($vv))) . parent::describeProperty($this->getVoc() . $qde['MED'], "Relationship between a qualifier record and its backfile postings"));
                 }
             }
             if ($k == "M94") {
                 foreach ($v as $kv => $vv) {
                     parent::AddRDF(parent::triplifyString($qr_res, $this->getVoc() . $qde['M94'], utf8_encode(htmlspecialchars($vv))) . parent::describeProperty($this->getVoc() . $qde['M94'], "Relationship between a qualifier record and its backfile postings"));
                 }
             }
             if ($k == "M90") {
                 foreach ($v as $kv => $vv) {
                     parent::AddRDF(parent::triplifyString($qr_res, $this->getVoc() . $qde['M90'], utf8_encode(htmlspecialchars($vv))) . parent::describeProperty($this->getVoc() . $qde['M90'], "Relationship between a qualifier record and its backfile postings"));
                 }
             }
             if ($k == "M85") {
                 foreach ($v as $kv => $vv) {
                     parent::AddRDF(parent::triplifyString($qr_res, $this->getVoc() . $qde['M85'], utf8_encode(htmlspecialchars($vv))) . parent::describeProperty($this->getVoc() . $qde['M85'], "Relationship between a qualifier record and its backfile postings"));
                 }
             }
             if ($k == "M80") {
                 foreach ($v as $kv => $vv) {
                     parent::AddRDF(parent::triplifyString($qr_res, $this->getVoc() . $qde['M80'], utf8_encode(htmlspecialchars($vv))) . parent::describeProperty($this->getVoc() . $qde['M80'], "Relationship between a qualifier record and its backfile postings"));
                 }
             }
             if ($k == "M75") {
                 foreach ($v as $kv => $vv) {
                     parent::AddRDF(parent::triplifyString($qr_res, $this->getVoc() . $qde['M75'], utf8_encode(htmlspecialchars($vv))) . parent::describeProperty($this->getVoc() . $qde['M75'], "Relationship between a qualifier record and its backfile postings"));
                 }
             }
             if ($k == "M66") {
                 foreach ($v as $kv => $vv) {
                     parent::AddRDF(parent::triplifyString($qr_res, $this->getVoc() . $qde['M66'], utf8_encode(htmlspecialchars($vv))) . parent::describeProperty($this->getVoc() . $qde['M66'], "Relationship between a qualifier record and its backfile postings"));
                 }
             }
             if ($k == "MR") {
                 foreach ($v as $kv => $vv) {
                     parent::AddRDF(parent::triplifyString($qr_res, $this->getVoc() . $qde['MR'], $this->formatDate($vv), "xsd:date") . parent::describeProperty($this->getVoc() . $qde['MR'], "Relationship between a qualifier record and its major revision date"));
                 }
             }
             //if
             if ($k == "MS") {
                 foreach ($v as $kv => $vv) {
                     parent::AddRDF(parent::triplifyString($qr_res, $this->getVoc() . $qde['MS'], utf8_encode(htmlspecialchars($vv))) . parent::describeProperty($this->getVoc() . $qde['MS'], "Relationship between a qualifier record and its MeSH scope note"));
                 }
             }
             if ($k == "OL") {
                 foreach ($v as $kv => $vv) {
                     parent::AddRDF(parent::triplifyString($qr_res, $this->getVoc() . $qde['OL'], utf8_encode(htmlspecialchars($vv))) . parent::describeProperty($this->getVoc() . $qde['OL'], "Relationship between a qualifier record and its online note"));
                 }
             }
             if ($k == "QA") {
                 foreach ($v as $kv => $vv) {
                     parent::AddRDF(parent::triplifyString($qr_res, $this->getVoc() . $qde['QA'], utf8_encode(htmlspecialchars($vv))) . parent::describeProperty($this->getVoc() . $qde['QA'], "Relationship between a qualifier record and its toplical qualifier abbreviation"));
                 }
             }
             if ($k == "QE") {
                 foreach ($v as $kv => $vv) {
                     parent::AddRDF(parent::triplifyString($qr_res, $this->getVoc() . $qde['QE'], utf8_encode(htmlspecialchars($vv))) . parent::describeProperty($this->getVoc() . $qde['QE'], "Relationship between a qualifier record and its qualifier entry version"));
                 }
             }
             if ($k == "QS") {
                 foreach ($v as $kv => $vv) {
                     parent::AddRDF(parent::triplifyString($qr_res, $this->getVoc() . $qde['QS'], utf8_encode(htmlspecialchars($vv))) . parent::describeProperty($this->getVoc() . $qde['QS'], "Relationship between a qualifier record and its qualifier sort version"));
                 }
             }
             if ($k == "QT") {
                 foreach ($v as $kv => $vv) {
                     parent::AddRDF(parent::triplifyString($qr_res, $this->getVoc() . $qde['QT'], utf8_encode(htmlspecialchars($vv))) . parent::describeProperty($this->getVoc() . $qde['QT'], "Relationship between a qualifier record and its qualifier type"));
                 }
             }
             if ($k == "QX") {
                 foreach ($v as $kv => $vv) {
                     parent::AddRDF(parent::triplifyString($qr_res, $this->getVoc() . $qde['QX'], utf8_encode(htmlspecialchars($vv))) . parent::describeProperty($this->getVoc() . $qde['QX'], "Relationship between a qualifier record and its qualifier cross reference"));
                 }
             }
             if ($k == "RECTYPE") {
                 foreach ($v as $kv => $vv) {
                     parent::AddRDF(parent::triplifyString($qr_res, $this->getVoc() . $qde['RECTYPE'], utf8_encode(htmlspecialchars($vv))) . parent::describeProperty($this->getVoc() . $qde['RECTYPE'], "Relationship between a qualifier record and its record type"));
                 }
             }
             if ($k == "SH") {
                 foreach ($v as $kv => $vv) {
                     parent::AddRDF(parent::triplifyString($qr_res, $this->getVoc() . $qde['SH'], utf8_encode(htmlspecialchars($vv))) . parent::describeProperty($this->getVoc() . $qde['SH'], "Relationship between a qualifier record and its subheading"));
                 }
             }
             if ($k == "TN") {
                 foreach ($v as $kv => $vv) {
                     parent::AddRDF(parent::triplifyString($qr_res, $this->getVoc() . $qde['TN'], utf8_encode(htmlspecialchars($vv))) . parent::describeProperty($this->getVoc() . $qde['TN'], "Relationship between a qualifier record and its tree node allowed"));
                 }
             }
         } else {
             trigger_error("Please add key to qualifier record map: " . $k . PHP_EOL, E_USER_ERROR);
         }
         //else
         $this->WriteRDFBufferToWriteFile();
     }
     //foreach
     $this->WriteRDFBufferToWriteFile();
 }
Beispiel #6
0
 function process()
 {
     $gb_record_str = "";
     while ($aLine = $this->getReadFile()->Read(4096)) {
         preg_match("/^\\/\\/\$/", $aLine, $matches);
         if (count($matches)) {
             //now remove the header if it is there
             $gb_record_str = $this->removeHeader($gb_record_str);
             $sectionsRaw = $this->parseGenbankRaw($gb_record_str);
             /**
              * SECTIONS being parsed:
              * locus, definition, accession, version, keywords, segment, source, reference, features
              */
             //get locus section(s)
             $locus = $this->retrieveSections("LOCUS", $sectionsRaw);
             $parsed_locus_arr = $this->parseLocus($locus);
             //get the definition section
             $definition = $this->retrieveSections("DEFINITION", $sectionsRaw);
             $parsed_definition_arr = $this->parseDefinition($definition);
             //get the accession
             $accessions = $this->retrieveSections("ACCESSION", $sectionsRaw);
             $parsed_accession_arr = $this->parseAccession($accessions);
             //get the version
             $versions = $this->retrieveSections("VERSION", $sectionsRaw);
             $parsed_version_arr = $this->parseVersion($versions);
             //get the keywords
             $keywords = $this->retrieveSections("KEYWORDS", $sectionsRaw);
             $parsed_keyword_arr = $this->parseKeywords($keywords);
             //may not be any segment section
             $segments = $this->retrieveSections("SEGMENT", $sectionsRaw);
             if (!empty($segments)) {
                 $parsed_segments_arr = $this->parseSegment($segments);
             }
             $features = $this->retrieveSections("FEATURES", $sectionsRaw);
             $parsed_features_arr = $this->parseFeatures($features);
             //get the source section
             $source = $this->retrieveSections("SOURCE", $sectionsRaw);
             $parsed_source_arr = $this->parseSource($source);
             $contig = $this->retrieveSections("CONTIG", $sectionsRaw);
             if (!empty($contig)) {
                 $parsed_contig_arr = $this->parseContig($contig);
             }
             //get the reference section
             $references = $this->retrieveSections("REFERENCE", $sectionsRaw);
             $parsed_refs_arr = $this->parseReferences($references);
             $gb_res = "gi:" . $parsed_version_arr['gi'];
             $gb_label = utf8_encode(htmlspecialchars($parsed_definition_arr[0]));
             parent::AddRDF(parent::describeIndividual($gb_res, $gb_label, $this->getVoc() . "genbank-record") . parent::triplifyString($gb_res, $this->getVoc() . 'sequence-length', $parsed_locus_arr[0]['sequence_length']) . parent::triplifyString($gb_res, $this->getVoc() . 'strandedness', $parsed_locus_arr[0]['strandedness']) . parent::triplify($gb_res, "rdf:type", $this->getRes() . $parsed_locus_arr[0]['mol_type']) . parent::triplifyString($gb_res, $this->getVoc() . 'chromosome-shape', $parsed_locus_arr[0]['chromosome_shape']) . parent::triplifyString($gb_res, $this->getVoc() . 'division-name', $parsed_locus_arr[0]['division_name']) . parent::triplifyString($gb_res, $this->getVoc() . 'date-of-entry', $parsed_locus_arr[0]['date']) . parent::triplifyString($gb_res, $this->getVoc() . 'source', utf8_encode($parsed_source_arr[0])) . parent::QQuadO_URL($gb_res, $this->getVoc() . 'fasta-seq', 'https://www.ncbi.nlm.nih.gov/sviewer/viewer.cgi?sendto=on&db=nucest&dopt=fasta&val=' . $parsed_version_arr['gi']));
             foreach ($parsed_features_arr as $aFeature) {
                 //getFeatures
                 $type = $aFeature['type'];
                 $feat_desc = $this->getFeatures($type);
                 $label = preg_replace('/\\s\\s*/', ' ', $feat_desc['definition']);
                 $comment = null;
                 $value = $aFeature['value'];
                 $value_arr = explode("/", $value);
                 $location = preg_replace('/\\n/', '', $value_arr[0]);
                 $class_id = parent::getVoc() . md5($type);
                 $feat_res = parent::getRes() . md5($type . $location . $gb_res);
                 $feat_label = utf8_encode($type . " " . $location . " for " . $gb_res);
                 if (isset($feat_desc['comment'])) {
                     $comment = $feat_desc['comment'];
                     $comment = preg_replace('/\\s\\s*/', ' ', $comment);
                     $label .= " " . $comment;
                 }
                 parent::AddRDF(parent::describeClass($class_id, $label, parent::getVoc() . "Feature") . parent::describeIndividual($feat_res, $feat_label, $class_id) . parent::triplify($gb_res, $this->getVoc() . "has-feature", $feat_res));
                 foreach ($value_arr as $aL) {
                     //check if aL has an equals in it
                     $p = "/(\\S+)\\=(.*)/";
                     preg_match($p, $aL, $m);
                     if (count($m)) {
                         if ($m[1] == "db_xref") {
                             parent::AddRDF(parent::triplify($feat_res, "rdfs:seeAlso", str_replace("\"", "", $m[2])));
                         } else {
                             parent::AddRDF(parent::triplifyString($feat_res, $this->getVoc() . $m[1], utf8_encode(str_replace("\"", "", $m[2]))));
                         }
                     }
                 }
             }
             foreach ($parsed_accession_arr[0] as $acc) {
                 parent::AddRDF(parent::triplifyString($gb_res, $this->getVoc() . "accession", $acc));
             }
             if (isset($parsed_version_arr['versioned_accession'])) {
                 parent::AddRDF(parent::triplifyString($gb_res, $this->getVoc() . "versioned-accession", $parsed_version_arr['versioned_accession']));
             }
             if (isset($parsed_contig_arr)) {
                 foreach ($parsed_contig_arr as $aContig) {
                     parent::AddRDF(parent::triplifyString($gb_res, $this->getVoc() . "contig", parent::safeLiteral($aContig)));
                 }
             }
             foreach ($parsed_keyword_arr as $akw) {
                 parent::AddRDF(parent::triplifyString($gb_res, $this->getVoc() . "keyword", $akw));
             }
             if (isset($parsed_segments_arr)) {
                 foreach ($parsed_segments_arr as $aSeg) {
                     parent::AddRDF(parent::triplifyString($gb_res, $this->getVoc() . "segment-number", $aSeg['segment_number']) . parent::triplifyString($gb_res, $this->getVoc() . "total-segments", $aSeg['total_segments']));
                 }
             }
             foreach ($parsed_refs_arr as $aRef) {
                 $r = rand();
                 $ref_res = $this->getRes() . md5($r);
                 $ref_label = "reference for " . $gb_res;
                 if (isset($aRef['TITLE'])) {
                     parent::AddRDF(parent::describeIndividual($ref_res, $ref_label, $this->getVoc() . "reference") . parent::triplifyString($ref_res, $this->getVoc() . "title", $aRef['TITLE']));
                 }
                 if (isset($aRef['PUBMED'])) {
                     parent::AddRDF(parent::triplify($ref_res, $this->getVoc() . "x-pubmed", 'pubmed:' . $aRef['PUBMED']));
                 }
                 if (isset($aRef['AUTHORS'])) {
                     parent::AddRDF(parent::triplifyString($ref_res, $this->getVoc() . "authors", $aRef['AUTHORS']));
                 }
                 parent::AddRDF(parent::triplify($gb_res, $this->getVoc() . "reference", $ref_res) . parent::triplifyString($ref_res, $this->getVoc() . "coordinates", $aRef['COORDINATES']) . parent::triplifyString($ref_res, $this->getVoc() . "citation", $aRef['JOURNAL']));
             }
             $gb_record_str = "";
             $this->WriteRDFBufferToWriteFile();
             continue;
         }
         preg_match("/^\n\$/", $aLine, $matches);
         if (count($matches) == 0) {
             $gb_record_str .= $aLine;
         }
     }
     //while
 }
Beispiel #7
0
 function process()
 {
     while ($aLine = $this->GetReadFile()->Read(200000)) {
         $parsed_line = $this->parse_homologene_tab_line($aLine);
         $hid = "homologene:" . $parsed_line["hid"];
         $hid_label = "homologene group " . $parsed_line['hid'];
         parent::AddRDF(parent::describeIndividual($hid, $hid_label, $this->getVoc() . "Homologene-Group") . parent::describeClass($this->getVoc() . "Homologene-Group", "Homologene Group"));
         $geneid = "ncbigene:" . $parsed_line["geneid"];
         $taxid = "taxid:" . $parsed_line["taxid"];
         $gi = "gi:" . $parsed_line["gi"];
         $genesymbol = str_replace("\\", "", $parsed_line["genesymbol"]);
         $refseq = "refseq:" . $parsed_line["refseq"];
         parent::AddRDF(parent::triplify($hid, $this->getVoc() . "x-taxid", $taxid) . parent::describeProperty($this->getVoc() . "x-taxid", "Link to NCBI taxonomy"));
         parent::AddRDF(parent::triplify($hid, $this->getVoc() . "x-ncbigene", $geneid) . parent::describeProperty($this->getVoc() . "x-ncbigene", "Link to NCBI GeneId"));
         parent::AddRDF(parent::triplifyString($hid, $this->getVoc() . "gene-symbol", utf8_encode(htmlspecialchars($genesymbol)), "xsd:string") . parent::describeProperty($this->getVoc() . "gene-symbol", "Link to gene symbol"));
         parent::AddRDF(parent::triplify($hid, $this->getVoc() . "x-gi", $gi) . parent::describeProperty($this->getVoc() . "x-gi", "Link to NCBI GI"));
         parent::AddRDF(parent::triplify($hid, $this->getVoc() . "x-refseq", $refseq) . parent::describeProperty($this->getVoc() . "x-refseq", "Link to NCBI Refseq"));
         $this->WriteRDFBufferToWriteFile();
     }
 }
Beispiel #8
0
 private function gi_taxid_nucl()
 {
     while ($aLine = $this->GetReadFile()->Read(200000)) {
         $a = explode("\t", $aLine);
         $gi = trim($a[0]);
         $txid = trim($a[1]);
         parent::AddRDF(parent::triplify("gi" . $gi, $this->getVoc() . "x-taxonomy", $this->GetNamespace() . $txid));
         $this->WriteRDFBufferToWriteFile();
     }
     //while
 }
Beispiel #9
0
 private function species_xrefs()
 {
     while ($aLine = $this->getReadFile()->Read(4096)) {
         $tLine = explode("\t", $aLine);
         //get the Database from which master entry of this IPI entry has been taken.
         $master_db = null;
         //key is code, value is bio2rdf namespace
         if ($tLine[0] == "SP" || $tLine[0] == "REFSEQ_REVIEWED" || $tLine[0] == "TR" || $tLine[0] == "ENSEMBL" || $tLine[0] == "ENSEMBL_HAVANA" || $tLine[0] == "REFSEQ_STATUS" || $tLine[0] == "VEGA" || $tLine[0] == "TAIR" || $tLine[0] == "HINV") {
             if ($tLine[0] == "SP") {
                 $master_db["SP"] = "swissprot";
             }
             if ($tLine[0] == "TR") {
                 $master_db["TR"] = "uniprot";
             }
             if ($tLine[0] == "ENSEMBL") {
                 $master_db["ENSEMBL"] = "ensembl";
             }
             if ($tLine[0] == "ENSEMBL_HAVANA") {
                 $master_db["ENSEMBL_HAVANA"] = "ensembl";
             }
             if ($tLine[0] == "REFSEQ_STATUS") {
                 $master_db["REFSEQ_STATUS"] = "refseq";
             }
             if ($tLine[0] == "VEGA") {
                 $master_db["VEGA"] = "vega";
             }
             if ($tLine[0] == "TAIR") {
                 $master_db["TAIR"] = "tair";
             }
             if ($tLine[0] == "HINV") {
                 $master_db["HINV"] = "hinv";
             }
         }
         $ipi_id = null;
         $sup_uniprots_sps = array();
         $uniprotkb_id = null;
         $sup_uniprots_tre = array();
         $sup_ensembl = array();
         $sup_refseq = array();
         $sup_tair = array();
         $sup_hinv = array();
         $xref_embl_genbank_ddbj = array();
         $hgnc_ids = array();
         $ncbi_ids = array();
         $uniparc_ids = array();
         $unigene_ids = array();
         $ccds_ids = array();
         $refseq_gis = array();
         $vega_ids = array();
         //UniProtKB accession number or Vega ID or Ensembl ID or RefSeq ID or TAIR Protein ID or H-InvDB ID
         if (count(isset($tLine[1]))) {
             @($uniprotkb_id = $this->getFirstId($tLine[1]));
         }
         //ipi id
         if (count(isset($tLine[2]))) {
             @($ipi_id = $tLine[2]);
         }
         //Supplementary UniProtKB/Swiss-Prot entries associated with this IPI entry.
         if (count(isset($tLine[3]))) {
             @($sup_uniprots_sps = $this->readIdentifiers($tLine[3]));
         }
         //Supplementary UniProtKB/TrEMBL entries associated with this IPI entry.
         if (count(isset($tLine[4]))) {
             @($sup_uniprots_tre = $this->readIdentifiers($tLine[4]));
         }
         //Supplementary Ensembl entries associated with this IPI entry. Havana curated transcripts preceeded by the key HAVANA: (e.g. HAVANA:ENSP00000237305;ENSP00000356824;).
         if (count(isset($tLine[5]))) {
             @($sup_ensembl = $this->readIdentifiers($tLine[5]));
         }
         //Supplementary list of RefSeq STATUS:ID couples (separated by a semi-colon ';') associated with this IPI entry (RefSeq entry revision status details).
         if (count(isset($tLine[6]))) {
             @($sup_refseq = $this->readIdentifiers($tLine[6]));
         }
         //Supplementary TAIR Protein entries associated with this IPI entry.
         if (count(isset($tLine[7]))) {
             @($sup_tair = $this->readIdentifiers($tLine[7]));
         }
         //Supplementary H-Inv Protein entries associated with this IPI entry.
         if (count(isset($tLine[8]))) {
             @($sup_hinv = $this->readIdentifiers($tLine[8]));
         }
         //Protein identifiers (cross reference to EMBL/Genbank/DDBJ nucleotide databases).
         if (count(isset($tLine[9]))) {
             @($xref_embl_genbank_ddbj = $this->readIdentifiers($tLine[9]));
         }
         //List of HGNC number, HGNC official gene symbol couples (separated by by a semi-colon ';') associated with this IPI entry.
         if (count(isset($tLine[10]))) {
             @($hgnc_ids = $this->readIdentifiers($tLine[10]));
         }
         ////List of NCBI Entrez Gene gene number, Entrez Gene Default Gene Symbol couples (separated by a semi-colon ';') associated with this IPI entry.
         if (count(isset($tLine[11]))) {
             @($ncbi_ids = $this->readIdentifiers($tLine[11]));
         }
         //UNIPARC identifier associated with the sequence of this IPI entry.
         if (count(isset($tLine[12]))) {
             @($uniparc_ids = $this->readIdentifiers($tLine[12]));
         }
         //UniGene identifiers associated with this IPI entry.
         if (count(isset($tLine[13]))) {
             @($unigene_ids = $this->readIdentifiers($tLine[13]));
         }
         //CCDS identifiers associated with this IPI entry.
         if (count(isset($tLine[14]))) {
             @($ccds_ids = $this->readIdentifiers($tLine[14]));
         }
         //RefSeq GI protein identifiers associated with this IPI entry.
         if (count(isset($tLine[15]))) {
             @($refseq_gis = $this->readIdentifiers($tLine[15]));
         }
         //Supplementary Vega entries associated with this IPI entry.
         if (count(isset($tLine[16]))) {
             @($vega_ids = $this->readIdentifiers($tLine[16]));
         }
         //lets make some rdf!
         if (strlen($ipi_id)) {
             $ipi_res = $this->getNamespace() . $ipi_id;
             if (count($sup_refseq)) {
                 foreach ($sup_refseq as $r) {
                     if ($r != "" && $r != "\n") {
                         parent::AddRDF(parent::triplify($ipi_res, $this->getVoc() . "x-refseq", "refseq:" . $r));
                     }
                 }
             }
         }
         if ($uniprotkb_id != "" && $uniprotkb_id != "\n" && count($uniprotkb_id) > 1 && isset($uniprotkb_id)) {
             parent::AddRDF(parent::triplify($ipi_res, $this->getVoc() . "x-uniprot", "uniprot:" . $r));
         }
         if (count($sup_uniprots_sps)) {
             foreach ($sup_uniprots_sps as $r) {
                 if ($r != "" && $r != "\n" && count($r) > 1 && isset($r)) {
                     parent::AddRDF(parent::triplify($ipi_res, $this->getVoc() . "x-uniprot", "uniprot:" . $r));
                 }
             }
         }
         if (count($sup_uniprots_tre)) {
             foreach ($sup_uniprots_tre as $r) {
                 if ($r != "" && $r != "\n" && count($r) > 1 && isset($r)) {
                     parent::AddRDF(parent::triplify($ipi_res, $this->getVoc() . "x-uniprot", "uniprot:" . $r));
                 }
             }
         }
         if (count($sup_ensembl)) {
             foreach ($sup_ensembl as $r) {
                 if ($r != "" && $r != "\n" && count($r) > 1 && isset($r)) {
                     parent::AddRDF(parent::triplify($ipi_res, $this->getVoc() . "x-ensembl", "uniprot:" . $r));
                 }
             }
         }
         if (count($sup_tair)) {
             foreach ($sup_tair as $r) {
                 if ($r != "" && $r != "\n" && count($r) > 1 && isset($r)) {
                     parent::AddRDF(parent::triplify($ipi_res, $this->getVoc() . "x-tair", "tair:" . $r));
                 }
             }
         }
         if (count($sup_hinv)) {
             foreach ($sup_hinv as $r) {
                 if ($r != "" && $r != "\n" && count($r) > 1 && isset($r)) {
                     parent::AddRDF(parent::triplify($ipi_res, $this->getVoc() . "x-hinv", "hinv:" . $r));
                 }
             }
         }
         if (count($xref_embl_genbank_ddbj)) {
             foreach ($xref_embl_genbank_ddbj as $r) {
                 if ($r != "" && $r != "\n" && count($r) > 1 && isset($r)) {
                     parent::AddRDF(parent::triplify($ipi_res, $this->getVoc() . "x-embl", "embl:" . $r));
                 }
             }
         }
         if (count($hgnc_ids)) {
             foreach ($hgnc_ids as $r) {
                 if ($r != "" && $r != "\n" && count($r) > 1 && isset($r)) {
                     parent::AddRDF(parent::triplify($ipi_res, $this->getVoc() . "x-hgnc", "hgnc:" . $r));
                 }
             }
         }
         if (count($ncbi_ids)) {
             foreach ($ncbi as $r) {
                 if ($r != "" && $r != "\n" && count($r) > 1 && isset($r)) {
                     parent::AddRDF(parent::triplify($ipi_res, $this->getVoc() . "x-ncbi-gene", "geneid:" . $r));
                 }
             }
         }
         if (count($uniparc_ids)) {
             foreach ($uniparc_ids as $r) {
                 if ($r != "" && $r != "\n" && count($r) > 1 && isset($r)) {
                     parent::AddRDF(parent::triplify($ipi_res, $this->getVoc() . "x-uniparc", "uniparc:" . $r));
                 }
             }
         }
         if (count($unigene_ids)) {
             foreach ($unigene_ids as $r) {
                 if ($r != "" && $r != "\n" && count($r) > 1 && isset($r)) {
                     parent::AddRDF(parent::triplify($ipi_res, $this->getVoc() . "x-unigene", "unigene:" . $r));
                 }
             }
         }
         if (count($ccds_ids)) {
             foreach ($ccds_ids as $r) {
                 if ($r != "" && $r != "\n" && count($r) > 1 && isset($r)) {
                     parent::AddRDF(parent::triplify($ipi_res, $this->getVoc() . "x-ccds", "ccds:" . $r));
                 }
             }
         }
         if (count($refseq_gis)) {
             foreach ($refseq_gis as $r) {
                 if ($r != "" && $r != "\n" && count($r) > 1 && isset($r)) {
                     parent::AddRDF(parent::triplify($ipi_res, $this->getVoc() . "x-ncbi-gene", "geneid:" . $r));
                 }
             }
         }
         if (count($vega_ids)) {
             foreach ($vega_ids as $r) {
                 if ($r != "" && $r != "\n" && count($r) > 1 && isset($r)) {
                     parent::AddRDF(parent::triplify($ipi_res, $this->getVoc() . "x-vega", "vega:" . $r));
                 }
             }
         }
         $this->WriteRDFBufferToWriteFile();
     }
     //while
 }