Hello!

To see the file structure, click on "tree".

Note that updates take place every 10 minutes, commits may not be seen immediately.
Switched from Bio::OntologyIO module to GO::Parser (go-perl)
authorpreecej <preecej@localhost>
Mon, 11 Oct 2010 17:11:18 +0000 (17:11 +0000)
committerpreecej <preecej@localhost>
Mon, 11 Oct 2010 17:11:18 +0000 (17:11 +0000)
svn path=/; revision=63

preecej/perl_singletons/reactome_chebi_mapping/reactome_chebi_mapping.pl

index 5d01cd72c5a439d74e71f2a1bf0a1a14d287e0be..4ef2a36b9bf5e234153933d2e2e71109bd6bcf77 100755 (executable)
@@ -26,16 +26,16 @@ use strict;
 # modules
 # --------------------------------------------------------------------
 
-use Bio::OntologyIO;
+use GO::Parser;
 
 # --------------------------------------------------------------------
 # declarations
 # --------------------------------------------------------------------
 
 # set paths to data files
-my $data_path = "/home/preecej/Documents/Projects/Reactome/";
+my $data_path = "/Users/cindypreece/Desktop/jaiswal_lab/projects/reactome/";
 my $chebi_obo_file = "chebi_sample.obo";
-my $reactome_file = "RiceReferenceMolecules_sample.txt";
+my $reactome_file = "RiceReferenceMolecules.txt";
 my $mapped_output_file = "reactome_chebi_mapping.txt";
 
 my $ont; # chebi ontology
@@ -56,14 +56,18 @@ my @map_results = (); # successful mappings between chebi and reactome
 # --------------------------------------------------------------------
 sub init
 {
-    # init ontology parser
-    my $parser = Bio::OntologyIO->new (
-        -format => "obo",
-        -file => $data_path . $chebi_obo_file);
+    # init ontology parser and ontology
+    my $parser = GO::Parser->new({handler=>'obj'});
+    $parser->parse($data_path . $chebi_obo_file);
+    $ont = $parser->handler->graph;
+      
+#    my $parser = Bio::OntologyIO->new (
+#        -format => "obo",
+#        -file => $data_path . $chebi_obo_file);
 
     # init ontology
-    $ont = $parser->next_ontology();
-    $parser->close();
+#    $ont = $parser->next_ontology();
+#    $parser->close();
 
     # read rice reactome file into 3 separate hashes
     open(REACTOME_FILE,$data_path . $reactome_file);
@@ -117,55 +121,76 @@ sub init
 # --------------------------------------------------------------------
 sub test_inputs
 {
+       # output new GO version of parsed ontology
+       my $terms = $ont->get_all_terms;
+       foreach my $term (@$terms) {
+               print "\n" . $term->acc . " " . $term->name . "\n[SYNONYMS]\n";
+
+               my $synonyms = $term->synonym_list;
+               foreach my $synonym (@$synonyms) {
+                       print $synonym . "\n";
+               }
+               
+               print "[XREFS]\n";
+               my $xrefs = $term->dbxref_list;
+               foreach my $xref (@$xrefs) {
+                       print $xref->xref_key . ",",
+                               $xref->xref_keytype . ",",
+                               $xref->xref_dbname . ",",
+                               $xref->xref_desc . "\n";
+               }
+               print "\n";
+       }
+
     # output basic stats on chebi ontology
-    print "\n[Ontology Stats]\n";
-    print "read ontology ",$ont->name()," with ",
-        scalar($ont->get_root_terms)," root terms, and ",
-        scalar($ont->get_all_terms)," total terms, and ",
-        scalar($ont->get_leaf_terms)," leaf terms\n";
+#    print "\n[Ontology Stats]\n";
+#    print "read ontology ",$ont->name()," with ",
+#        scalar($ont->get_root_terms)," root terms, and ",
+#        scalar($ont->get_all_terms)," total terms, and ",
+#        scalar($ont->get_leaf_terms)," leaf terms\n";
 
     # all chebi terms in the ontology
-    print "\n[CHEBI Term List from \$ont]\n";
-    foreach my $term ($ont->get_all_terms) {
-        my @synonyms = $term->get_synonyms;
-        my @xrefs = $term->get_dbxrefs;
-
-        print $term->identifier;
-        print " \|NAME\| ";
-        if (defined($term->name)) {
-            print $term->name;
-        }
-        print " \|SYNONYMS\| ";
-        print "$_," foreach @synonyms;
-        print " \|XREFS\| ";
-        print "$_" foreach @xrefs;
-        foreach my $xref (@xrefs) {
-            print $xref->primary_id;
-        }
-        print "\n\n";
-    }
+#    print "\n[CHEBI Term List from \$ont]\n";
+#    foreach my $term ($ont->get_all_terms) {
+#        my @synonyms = $term->get_synonyms;
+#        my @xrefs = $term->get_dbxrefs;
+
+#        print $term->identifier;
+#        print " \|NAME\| ";
+#        if (defined($term->name)) {
+#            print $term->name;
+#        }
+#        print " \|SYNONYMS\| ";
+#        print "$_," foreach @synonyms;
+#        print " \|XREFS\| ";
+#        print "$_" foreach @xrefs;
+#        foreach my $xref (@xrefs) {
+#            print $xref->primary_id;
+#        }
+#        print "\n\n";
+#    }
 
     # show reactome hashes - this is important, give >1 dupes to Pankaj
     # for manual reference
     my $k; my @v;
-    print "\n[Reactome Hashes]\n";
+    print "\n[Reactome Hashes - Dupes]\n";
     print "\n--CAS Hash--\n";
     for $k (keys %reactome_CAS) {
-        #if (@{$reactome_CAS{$k}} > 1) {
+        if (@{$reactome_CAS{$k}} > 1) {
             print "$k: @{$reactome_CAS{$k}}\n";
-        #}
+        }
     }
     print "\n--LIGAND Hash--\n";
     for $k (keys %reactome_LIGAND) {
-        #if (@{$reactome_LIGAND{$k}} > 1) {
+        if (@{$reactome_LIGAND{$k}} > 1) {
             print "$k: @{$reactome_LIGAND{$k}}\n";
-        #}
+        }
     }
     print "\n--RiceCyc Hash--\n";
     for $k (keys %reactome_RiceCyc) {
-        #if (@{$reactome_RiceCyc{$k}} > 1) {
+        if (@{$reactome_RiceCyc{$k}} > 1) {
             print "$k: @{$reactome_RiceCyc{$k}}\n";
-        #}
+        }
     }
 }
 
@@ -241,8 +266,8 @@ sub create_mapfile
 # --------------------------------------------------------------------
 
 init;
-#test_inputs;
-perform_map;
+test_inputs;
+#perform_map;
 create_mapfile;
 
 exit;