From 989fe550e8720e4bd2b05aaf8e632809c725f4f4 Mon Sep 17 00:00:00 2001 From: preecej Date: Fri, 8 Oct 2010 19:30:50 +0000 Subject: [PATCH] hash loads of CAS, LIGAND, RiceCyc svn path=/; revision=60 --- .../reactome_chebi_mapping.pl | 73 ++++++++++++------- 1 file changed, 46 insertions(+), 27 deletions(-) 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 cc12279..4ff66d9 100755 --- a/preecej/perl_singletons/reactome_chebi_mapping/reactome_chebi_mapping.pl +++ b/preecej/perl_singletons/reactome_chebi_mapping/reactome_chebi_mapping.pl @@ -77,36 +77,41 @@ sub init chomp $line; my @reactome_entry = split(/\t/, $line); # break up our tab-del line + # load up this reactome entry's ID, CAS, LIGAND, and RiceCyc values + my $reactome_id = $reactome_entry[0]; + my $CAS_id = $reactome_entry[2]; + my $LIGAND_id = $reactome_entry[3]; + my $RiceCyc_term = $reactome_entry[4]; + # There is a possibility that a single CAS, LIGAND, or RiceCyc # identifier may appear in more than one reactome entry. This - # temp array allows each hash match to hold more than - # ReactomeID, if necessary. - my @temp_ary = (); + # temp array allows each matched hash value to hold more than + # one ReactomeID, if necessary. # --CAS Hash Load-- - # if this reactome entry is already in the hash, just - # append it to the hash's array - if(defined($reactome_CAS{$reactome_entry[2]})) + if ($CAS_id ne "-") # keep those "-" placeholders out + { + # build the CAS hash; each value may hold 1...n reactome + # ids (as an array) + push @{$reactome_CAS{$CAS_id}}, $reactome_id; + } + + # similarly... + + # --LIGAND Hash Load-- + if ($LIGAND_id ne "-") { - $reactome_CAS{push(@_,$reactome_entry[2])} = $reactome_entry[0]; - # otherwise, just add the reactome entry to the hash - } else { - @temp_ary = (); # clear it for re-use - if ($reactome_entry[2] != "-") # keep those "-" placeholders out - { - $reactome_CAS{$temp_ary[$reactome_entry[2]]} - = $reactome_entry[0]; - } + push @{$reactome_LIGAND{$LIGAND_id}}, $reactome_id; + } + + # --RiceCyc Hash Load-- + if ($RiceCyc_term ne "-") + { + push @{$reactome_RiceCyc{$RiceCyc_term}}, $reactome_id; } } close REACTOME_FILE; - - # read rice reactome file into array - #open(REACTOME_FILE,$data_path . $reactome_file); - #@reactome_ref_molecules = ; - #chomp(@reactome_ref_molecules); - #close REACTOME_FILE; } @@ -120,12 +125,29 @@ sub test_inputs 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()) { + #print $term->identifier() . "\n"; + #} + # show reactome hashes + my $k; my @v; print "\n[Reactome Hashes]\n"; print "\n--CAS Hash--\n"; - print "$_\n" foreach %reactome_CAS; - print "\n"; + for $k (keys %reactome_CAS) { + print "$k: @{$reactome_CAS{$k}}\n"; + } + print "\n--LIGAND Hash--\n"; + for $k (keys %reactome_LIGAND) { + print "$k: @{$reactome_LIGAND{$k}}\n"; + } + print "\n--RiceCyc Hash--\n"; + for $k (keys %reactome_RiceCyc) { + print "$k: @{$reactome_RiceCyc{$k}}\n"; + } + } @@ -143,9 +165,6 @@ sub perform_map # if match chebi to reactome hashes on CAS, LIGAND, and/or RiceCyc name; # write tab-del mapping string directly to results array for EACH type of match - foreach my $term (@chebi_obo_terms) { - print $term->identifier() . "\n"; - } } -- 2.34.1