[Bioperl-l] More on ACC NR -> Species name
Ewan Birney
birney at ebi.ac.uk
Wed Feb 19 14:36:29 EST 2003
On 19 Feb 2003, Henrik Nilsson wrote:
> Thanks everyone for your kind input on the matter!
>
> >You can get the seq from genbank via
> >Bio::DB::GenBank, and then ask for the species with
> >$seq->species() [this will return a Bio::Species object]
>
> Yes, this would be exactly what I am looking for. My being a bioperl
> newcomer, I'm not sure how to implement your elegant solution. The
> following code, for example, doesn't really do the trick:
>
> -----------------------
> #!/usr/bin/perl -w
> use strict;
> use Bio::Perl;
> use IO::String;
> use Bio::Perl qw( get_sequence );
> use Bio::DB::GenBank;
> use Bio::Species;
> use Bio::Root::Root;
>
> my ($seq_object, $seq_id, $seq_as_string, $species);
>
> $seq_object = get_sequence('genbank',"AF429427");
> $seq_id = $seq_object->display_id;
> $seq_as_string = $seq_object->seq();
> $species = $seq_object->species();
>
Go for
$species = $seq_object->species()->binomial()
(altnernatives to binomial are genus() species() common_name()
and classification() gives you the classification as an array)
Check out Bio::Species for more info with
perldoc Bio::Species
> print "seq_id: $seq_id\n";
> print "sequence: $seq_as_string\n";
> print "species: $species\n";
> exit;
> ----------------------
>
> although it does output
>
> seq_id: AF429427
> sequence: TTGTAGCTGGCCGTAAACT ...
> species: Bio::Species=HASH(0x8658bf0)
>
> i.e. it does fetch the sequence and seq_id, but not the species.
>
> What am I doing wrong?
>
> Yours gratefully,
>
> Henrik N
>
> _______________________________________________
> Bioperl-l mailing list
> Bioperl-l at bioperl.org
> http://bioperl.org/mailman/listinfo/bioperl-l
>
More information about the Bioperl-l
mailing list