# 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
# --------------------------------------------------------------------
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);
# --------------------------------------------------------------------
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";
- #}
+ }
}
}
# --------------------------------------------------------------------
init;
-#test_inputs;
-perform_map;
+test_inputs;
+#perform_map;
create_mapfile;
exit;