~ubuntu-branches/ubuntu/trusty/bioperl/trusty

« back to all changes in this revision

Viewing changes to scripts/taxa/bp_query_entrez_taxa.pl

  • Committer: Package Import Robot
  • Author(s): Charles Plessy
  • Date: 2013-09-22 13:39:48 UTC
  • mfrom: (3.1.11 sid)
  • Revision ID: package-import@ubuntu.com-20130922133948-c6z62zegjyp7ztou
Tags: 1.6.922-1
* New upstream release.
* Replaces and Breaks grinder (<< 0.5.3-3~) because of overlaping contents.
  Closes: #722910
* Stop Replacing and Breaking bioperl ( << 1.6.9 ): not needed anymore. 

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/perl
 
2
# This is a -*-Perl-* file (make my emacs happy)
 
3
 
 
4
=head1 NAME
 
5
 
 
6
bp_query_entrez_taxa - query Entrez taxonomy database and print out information 
 
7
 
 
8
=head1 USAGE
 
9
 
 
10
bp_query_entrez_taxa "Homo sapiens" "Saccharomyces cerevisiae" Rhizopus Metazoa
 
11
bp_query_entrez_taxa -gi 28800981 -gi 54301680 -db nucleotide
 
12
bp_query_entrez_taxa -gi 71836523 -db protein
 
13
 
 
14
 Provide the genus and species name in quotes, you can also query for
 
15
 a non-species node like Family or Order
 
16
 
 
17
Command-line options:
 
18
   -v or --verbose  : print verbose debugging info
 
19
   -gi              : one or many GI numbers to lookup taxon id for
 
20
   -db              : the sequence db (nucleotide or protein) the GI is for
 
21
 
 
22
   other arguments are assumed to be species names to lookup in taxonomy db
 
23
 
 
24
 
 
25
=head1 AUTHOR
 
26
 
 
27
Jason Stajich jason-at-bioperl-dot-org
 
28
 
 
29
=cut
 
30
 
 
31
use strict;
 
32
use warnings;
 
33
use Bio::DB::Taxonomy;
 
34
use Getopt::Long;
 
35
 
 
36
my $verbose = 0;
 
37
my (@gi, $dbname);
 
38
GetOptions('v|verbose' => \$verbose,
 
39
           'gi:i'      => \@gi,
 
40
           'db:s'      => \$dbname);
 
41
 
 
42
my $db = new Bio::DB::Taxonomy(-source => 'entrez', -verbose => $verbose);
 
43
if( @gi ) {
 
44
    my @nodes= $db->get_Taxonomy_Node(-gi => \@gi,
 
45
                                      -db => $dbname);
 
46
    for my $node ( @nodes ) {
 
47
        my $gi = shift @gi;
 
48
        print " for gi $gi:\n";
 
49
        print " taxonid is ",$node->ncbi_taxid,"\n";    
 
50
        print " node is ", join(", ",$node->classification), "\n";
 
51
        print " species is ", $node->species,"\n";
 
52
        print " parent is ", $node->parent_id, "\n";
 
53
        print " rank is ", $node->rank, "\n";
 
54
        print " genetic_code  ", $node->genetic_code, "\n";
 
55
        print " mito_genetic_code  ", $node->mitochondrial_genetic_code, "\n";
 
56
        print " scientfic name is ", $node->binomial, "\n";
 
57
    }   
 
58
}
 
59
 
 
60
print "\n\n";
 
61
for my $name ( @ARGV ) {
 
62
    my $taxonid = $db->get_taxonid($name);
 
63
    my $node   = $db->get_Taxonomy_Node(-taxonid => $taxonid);
 
64
    print "taxonid is $taxonid\n";
 
65
 
 
66
    print " node is ", join(", ",$node->classification), "\n";
 
67
    print " species is ", $node->species,"\n";
 
68
    print " parent is ", $node->parent_id, "\n";
 
69
    print " rank is ", $node->rank, "\n";
 
70
    print " genetic_code  ", $node->genetic_code, "\n";
 
71
    print " mito_genetic_code  ", $node->mitochondrial_genetic_code, "\n";
 
72
    print " scientfic name is ", $node->binomial, "\n";
 
73
    print " common name is ", $node->common_name, "\n";
 
74
    print " create date is ", $node->create_date, "\n";
 
75
    print " update date is ", $node->update_date, "\n";
 
76
    print " pub date is ", ($node->pub_date || ''), "\n";
 
77
    print " variant is ", $node->variant, "\n";
 
78
    print " sub_species is ", $node->sub_species, "\n";
 
79
    print " organelle is ", $node->organelle, "\n";
 
80
    print " division is ", $node->division, "\n";
 
81
}