2 # Author: Jason Stajich <jason@bioperl.org>
3 # Purpose: Retrieve the NCBI Taxa ID for organism(s)
5 # TODO: add rest of POD
15 my $USAGE = "taxid4species: [-v] [-p] \"Genus1 species1\" \"Genus2 species2\"";
17 GetOptions('v|verbose' => \$verbose,
20 die("$USAGE\n") if $help;
22 my $ua = new LWP::UserAgent();
24 my $urlbase = 'http://www.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi?db=taxonomy&term=';
26 my (@organisms) = @ARGV;
27 die("must provide valid organism") unless @organisms;
28 my $organismstr = join(" OR ", @organisms);
29 $organismstr =~ s/\s/\+/g;
31 my $response = $ua->get($urlbase.$organismstr);
32 my $t = XML::Twig->new();
33 print $response->content,"\n"if($verbose);
34 $t->parse($response->content);
36 my $list = $root->first_child('IdList');
38 foreach my $child ($list->children('Id') ) {
39 push @data, $child->text;
40 if( $plain ) { print $child->text, "\n" }
43 $list = $root->first_child('TranslationStack');
44 foreach my $set ($list->children('TermSet') ) {
45 foreach my $term ( $set->children('Term') ) {
46 print "\"",$term->text(), "\", ", shift @data, "\n";
53 taxid4species - simple script which returns the NCBI Taxonomic id for a requested species
57 taxid4species [-v] [-p] [-h] "Genus1 species1" "Genus2 species2"
66 This simple script shows how to get the taxa id from NCBI Entrez and
67 will return a list of taxa ids for requested organisms.
73 User feedback is an integral part of the evolution of this and other
74 Bioperl modules. Send your comments and suggestions preferably to
75 the Bioperl mailing list. Your participation is much appreciated.
77 bioperl-l@bioperl.org - General discussion
78 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
82 Report bugs to the Bioperl bug tracking system to help us keep track
83 of the bugs and their resolution. Bug reports can be submitted via the
86 http://bugzilla.open-bio.org/
90 Jason Stajich jason-at-bioperl-dot-org