[Bio] / FigKernelPackages / FIG.pm Repository:
ViewVC logotype

Diff of /FigKernelPackages/FIG.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.645, Thu Dec 6 13:47:40 2007 UTC revision 1.646, Thu Dec 6 15:44:05 2007 UTC
# Line 43  Line 43 
43  use SOAP::Lite;  use SOAP::Lite;
44  use File::Path;  use File::Path;
45  use LWP::UserAgent;  use LWP::UserAgent;
46    use LWP::Simple; # for ncbi connection - get genetic code
47    
48  use DBrtns;  use DBrtns;
49  use Sim;  use Sim;
# Line 2941  Line 2942 
2942      }      }
2943  }  }
2944    
2945    
2946    =head3 get_organism_info_from_ncbi
2947    
2948    C<< my $code = FIG::get_organism_info_from_ncbi( $taxonomyID ); >>
2949    
2950    For a given taxonomy ID returns a hash containing scientific name , genetic code , synonyms and lineage
2951    
2952    =cut
2953    # Andreas
2954    sub get_organism_info_from_ncbi{
2955      my ($self , $tax_id) = @_;
2956    
2957      my $overview = {};
2958    
2959      #query url
2960      my $url="http://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?db=taxonomy&report=xml&id=". $tax_id;
2961    
2962      my $content = get($url);
2963    
2964      # get genetic code
2965      my $genetic_code = "";
2966      if ($content =~ /\&lt\;GCId\&gt\;(.*)\&lt\;\/GCId\&gt\;/) {
2967        $genetic_code = $1;
2968        $overview->{genetic_code} = $genetic_code;
2969      }
2970    
2971      #get lineage
2972      my $lineage = "";
2973      if ($content =~ /\&lt\;Lineage\&gt\;cellular organisms; (.*)\&lt\;\/Lineage\&gt\;/) {
2974        $lineage = $1;
2975        $overview->{ lineage } = $lineage;
2976      }
2977    
2978      # set genus
2979      my $genus = "";
2980      if ($content =~ /\&lt\;ScientificName\&gt\;(.*)\&lt\;\/ScientificName\&gt\;(\W*)\&lt\;Rank\&gt\;genus\&lt\;\/Rank\&gt\;/) {
2981        $genus = $1;
2982        $overview->{ genus } = $genus ;
2983      }
2984    
2985      # set species
2986      my $species = "";
2987      if ($content =~ /\&lt\;ScientificName\&gt\;(.*)\&lt\;\/ScientificName\&gt\;(\W*)\&lt\;Rank\&gt\;species\&lt\;\/Rank\&gt\;/) {
2988        $species = $1;
2989        $species =~ s/$genus\s//;
2990        $species =~ s/ii$/i/;
2991        $species =~ s/ae$/a/;
2992    
2993        $overview->{ species } = $species ;
2994      }
2995    
2996      # set strain
2997      my $strain = "";
2998      if ($content =~ /\&lt\;ScientificName\&gt\;(.*)\&lt\;\/ScientificName\&gt\;(\W*)\&lt\;OtherNames\&gt\;/) {
2999        $strain = $1;
3000        $strain =~ s/$genus\s//;
3001        $strain =~ s/$species\s//;
3002    
3003        $overview->{ strain } = $strain;
3004      }
3005    
3006      # set scientific name and synonyms
3007      my $scientific_name = "";
3008      my $names = {};
3009      foreach my $line (split ("\n", $content) )  {
3010        $names->{$1} = 1 if ( $line =~ /\&lt\;Synonym\&gt\;(.*)\&lt\;\/Synonym\&gt\;/);
3011        $names->{$1} = 1 if ( $line =~ /\&lt\;EquivalentName\&gt\;(.*)\&lt\;\/EquivalentName\&gt\;/);
3012        $scientific_name = $1 if ($content =~ /\&lt\;ScientificName\&gt\;(.*)\&lt\;\/ScientificName\&gt\;/ and !$scientific_name );
3013      }
3014    
3015      $overview->{ synonyms } = $names;
3016      $overview->{ scientific_name } = $scientific_name;
3017    
3018    
3019    
3020      return $overview;
3021    }
3022    
3023    
3024    
3025    
3026  =head3 standard_genetic_code  =head3 standard_genetic_code
3027    
3028      my $code = FIG::standard_genetic_code();      my $code = FIG::standard_genetic_code();

Legend:
Removed from v.1.645  
changed lines
  Added in v.1.646

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3