This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Perl script to retrieve species name from Swissprot

I want to query uniprot/KB by accesion number to retrieve species names only.I have write this script:

#!/usr/bin/perl
use strict; use warnings; use Bio::Seq; use Bio::DB::SwissProt; use SWISS::Entry;

print "Please enter the accession number ... "; $_ = <STDIN>; my $db_obj = Bio::DB::SwissProt->new; my $seq_obj = $db_obj->get_Seq_by_acc($_); if( defined $seq->species ) { print "Sequence coming from ",$species->binomial," [",$species->common_name,"]\n"; } exit 0;

but it throws me this error
Name of the protein: Bio::Species=HASH(0x3bb03d8)

Can you help me understand what doesn't work ? Thanks you.

bioperl swissprot
 #!/usr/bin/perl  

use strict;   
use warnings;  
use Bio::Seq;  
use Bio::DB::SwissProt;  
use SWISS::Entry;  

print "Please enter the accession number ... ";  
$_ = <STDIN>;  

my $db_obj = Bio::DB::SwissProt->new;   
my $seq_obj = $db_obj->get_Seq_by_acc($_);  

if( defined $seq->species ) {
        print "Sequence coming from ",$species->binomial," [",$species->common_name,"]\n";
        }  

exit 0;

I added code markup to your post for increased readability. You can do this by selecting the text and clicking the 101010 button. When you compose or edit a post that button is in your toolbar, see image below:

101010 Button

Where is the error message ?

Name of the protein: Bio::Species=HASH(0x3bb03d8)

This doesn't look like an error message but like a variable that wasn't properly dereferenced.

1 answer

This doesn't really answer your question, but you could also have a look at the Swissknife PERL package, http://swissknife.sourceforge.net/docs/

I think the OP is already using it (isn't the module SWISS::Entry part of swissknife ?)

Log in to answer this question.