This is a test version of Biostars. For the public version, visit https://www.biostars.org.
How to retrieve record from Uniprot with BioPerl

Hello

I am new here and I face a problem about retrieving data from Uniprot. I use bioperl and I want to retrieve a specific fasta sequence by id from uniprot. I tried the classic code like get_seq_by_id or use BIO::DB::SwissProt but it doesn't work. Any advice?

bioperl uniprot

Can you show us the code? This type of thing is very hard to solve without seeing the IDs, the database(s) you are trying to query and the actual syntax you are using.

Of course. As i read in some Perl's tutorials the code have to be like this: script1: $gb = new Bio::DB::SwissProt(); $seq = $gb->get_Seq_by_id('Q6GZW6'); script2: use Bio::DB::Fasta; use strict; my $seqobj = $db->get_Seq_by_id($Q6GZW6);

I have to compine the 2 scripts to retrieve the fasta form of this protein. *i have to mention that i am new on Perl Scripting. Maybe there are more available scripts.

#!/usr/bin/perl

use strict;
use warnings;
use Bio::DB::SwissProt; 

my $gb = new Bio::DB::SwissProt(); 
# Retrieve Bio::Seq object
my $seq = $gb->get_Seq_by_id('Q6GZW6');
# Output FASTA
print ">Q6GZW6\n",$seq->seq(),"\n";

It shows an error: "Stack top level". Could it be an erron in my Bio Library? and if yes, should i reinstall the packages?

Do you have the full error message ? Stack top level doesn't mean much.

Stack Bio::DB::WevDBSeqI::get_Seq_by_id C:/Perl/site/lib/Bio/DV/WevDBSeqI.pm

Do you need the whole script? Because there are more after that. It is a homework about my University: "you have to insert an ID (protein, gene etc) and returns back a file which contains the places of the sequence where take place a motif".

This is still only a small part of the error message. Read the whole error message, it will tell you what doesn't work. Most likely it is a connection issue, i.e. you'll see something like "Can't connect to www.ebi.ac.uk:80".

Excuse me for my delay but this site restricts new members to 6 posts. I sent an e-mail to you but you did not respond. I get this message-error when i run the script: "--------------EXCEPTION-------------- MSG: WebDBSeqI Error - check query sequences! STACK Bio::DB::WebDBSeqI::get_seq_stream C:/Perl/site/lib/Bio/DB/WebDBSeqI.pm:50 STACK Bio::DB::WebDBSeqI::get_Stream_by_id C:/Perl/site/lib/Bio/DB/WebDBSeqI.pm:289 STACK Bio::DB::WebDBSeqI::get_Seq_by_id C:/Perl/site/lib/Bio/DB/WebDBSeqI.pm:159 STACK toplevel filename.pl:40"

I sometimes sleep at night ;) The error seems to come from a failed request. First make sure that you're using the latest version of Bioperl. Then check that it's querying the right URL and database. You can get this info using

my $gb = new Bio::DB::SwissProt(-verbose=>1);

Show us the whole thing. We can't help you if you keep on only showing bits of info.

request is POST http://www.ebi.ac.uk/cgi-bin/dbfetch Content-Length: 49 Content-Type: application/x-www-form-urlencoded

style=raw&id=Q6GZW6&format=swissprot&db=UniProtKB content is --------------EXCEPTION-------------- MSG: WebDBSeqI Error - check query sequences! STACK Bio::DB::WebDBSeqI::get_seq_stream C:/Perl/site/lib/Bio/DB/WebDBSeqI.pm:50 STACK Bio::DB::WebDBSeqI::get_Stream_by_id C:/Perl/site/lib/Bio/DB/WebDBSeqI.pm:289 STACK Bio::DB::WebDBSeqI::get_Seq_by_id C:/Perl/site/lib/Bio/DB/WebDBSeqI.pm:159 STACK toplevel filename.pl:7

when i type it in the browser it shows the motif. and the places where the motif exists. so my script has access in uniprot db and the problem is in the rest script?

You shouldn't get a motif, you should get the entire Uniprot record for accession Q6GZW6, a text page that starts like this:

ID 009L_FRG3G Reviewed; 948 AA.
AC Q6GZW6;
DT 28-JUN-2011, integrated into UniProtKB/Swiss-Prot.
DT 19-JUL-2004, sequence version 1.
DT 14-OCT-2015, entry version 47.
DE RecName: Full=Putative helicase 009L;
DE EC=3.6.4.-;
GN ORFNames=FV3-009L;
OS Frog virus 3 (isolate Goorha) (FV-3).
OC Viruses; dsDNA viruses, no RNA stage; Iridoviridae; Ranavirus.
....

yes i get the entire record. My problem is that i must make a script that has access in Uniprot, find the specific ID and then creates a file which contains the places where the motif exists. I just cannot figure out why it stops there and shows me those messages.

I suspect the problem is in your script then. Do you use strict and use warnings ? If not please do, this will catch a number of mistakes including most typos. Also please try the example code I gave above.

1 answer

i use it in every sub-script that i have in my script but i get the same errors. Nevermind, i will reiinstall Perl and packages and see what happens. Dear Heriche i would like to highlight my gratidute for your help and time spent on my case.

Log in to answer this question.