[Bioperl-l] More on ACC NR -> Species name
Wiepert, Mathieu
Wiepert.Mathieu at mayo.edu
Wed Feb 19 08:26:14 EST 2003
Hi,
The problem you see is that $species is an object, not just the name of the species. As such, there are many things you can do with it. Check out the documentation for the Species at http://doc.bioperl.org/bioperl-live/
Should work if you add
my $taxid = $species->ncbi_taxid();
my $common_name = $species->common_name();
print "species: $common_name\n";
print "species: $taxid\n";
Or close to it anyway...
-mat
-----Original Message-----
From: Henrik Nilsson [mailto:henrik.nilsson at botany.gu.se]
Sent: Wednesday, February 19, 2003 7:40 AM
To: bioperl-l at bioperl.org
Subject: [Bioperl-l] More on ACC NR -> Species name
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();
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