From: preecej Date: Mon, 11 Oct 2010 17:11:18 +0000 (+0000) Subject: Switched from Bio::OntologyIO module to GO::Parser (go-perl) X-Git-Url: http://gitweb.planteome.org/?a=commitdiff_plain;h=49d172338943c26fbab176e6e65019a291deebc5;p=old-jaiswallab-svn%2F.git Switched from Bio::OntologyIO module to GO::Parser (go-perl) svn path=/; revision=63 --- diff --git a/preecej/perl_singletons/reactome_chebi_mapping/reactome_chebi_mapping.pl b/preecej/perl_singletons/reactome_chebi_mapping/reactome_chebi_mapping.pl index 5d01cd7..4ef2a36 100755 --- a/preecej/perl_singletons/reactome_chebi_mapping/reactome_chebi_mapping.pl +++ b/preecej/perl_singletons/reactome_chebi_mapping/reactome_chebi_mapping.pl @@ -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;