[Bioperl-l] Fetching Fasta seqs from GenBank - Help request

Sean Davis sdavis2 at mail.nih.gov
Thu Mar 25 09:12:23 EST 2004


Alberto,

This code will output your sequences in fasta to a file called outfile.fa.

Sean

#!/usr/local/bin/perl -w
use lib "/usr/local/bioperl14";
use Bio::DB::BioFetch;
use strict;
use Bio::DB::WebDBSeqI;
use HTTP::Request::Common 'POST';
my $format_type='fasta';my $stream;
my $bf = new Bio::DB::BioFetch(-format        =>$format_type,
                   -retrievaltype =>'tempfile',
                   -db            =>'EMBL');
#open a seqio handle for writing to outfile.fa
my $seqio = new Bio::SeqIO(-format=>'fasta',
               -file=>'>outfile.fa');

$stream = $bf->get_Stream_by_id(['BUM','J00231']);
while (my $s = $stream->next_seq) {
  print $s->seq,"\n\n\n";
#write the fasta
  $seqio->write_seq($s);
}




On 3/25/04 7:40 AM, "Alberto Davila" <davila at ioc.fiocruz.br> wrote:

> Thanks Jason,
> 
> I installed the IO::String, then it is working fine now. However I have
> a doubt, the "get_Stream_by_id" is returning me more than the "sequence
> per se", what is it ? My script and results are listed below. Finally I
> would like to save (in my local disk) the retrieved sequences as fasta
> files... is there any argument for that ?
> 
> Thanks again, Alberto
> 
> 
> #!/usr/local/bin/perl -w
> 
> use lib "/usr/local/bioperl14";
> use Bio::DB::BioFetch;
> use strict;
> use Bio::DB::WebDBSeqI;
> use HTTP::Request::Common 'POST';
> 
> my $format_type='fasta';
> my $stream;
> 
> 
> my $bf = new Bio::DB::BioFetch(-format        =>$format_type,
>                              -retrievaltype =>'tempfile',
>       -db            =>'EMBL');
>  
> $stream = $bf->get_Stream_by_id(['BUM','J00231']);
> while (my $s = $stream->next_seq) {
>   print $s->seq,"\n\n\n";
> }              
>  
>  
>  exit;
> 
> 
> 
> 
> [davila at tryps script]$ perl gb-fetch-1.pl
> agtagtgtactaccaagtatagataacgtttaaatattaaagttttggatcaaagccaaagatgattcgcat
> gctggtgctgattgtagttacagctgcaagcccagtgtatcagagatgtttccaagatggggctatagtgaa
> gcaaaacccatccaaagaggcagtcacagaagtgtccctaaaagatgatgttagca
>                  
>                  
> cctggacctcctgtgcaagaacatgaaacanctgtggttcttccttctcctggtggcagctcccagatgggt
> cctgtcccaggtgcacctgcaggagtcgggcccaggactggggaagcctccagagctcaaaaccccacttgg
> tgacacaactcacacatgcccacggtgcccagagcccaaatcttgtgacacacctcccccgtgcccacggtg
> cccagagcccaaatcttgtgacacacctcccccatgcccacggtgcccagagcccaaatcttgtgacacacc
> tcccccgtgcccnnngtgcccagcacctgaactcttgggaggaccgtcagtcttcctcttccccccaaaacc
> caaggatacccttatgatttcccggacccctgaggtcacgtgcgtggtggtggacgtgagccacgaagaccc
> nnnngtccagttcaagtggtacgtggacggcgtggaggtgcataatgccaagacaaagctgcgggaggagca
> gtacaacagcacgttccgtgtggtcagcgtcctcaccgtcctgcaccaggactggctgaacggcaaggagta
> caagtgcaaggtctccaacaaagccctcccagcccccatcgagaaaaccatctccaaagccaaaggacagcc
> cnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnngaggagatgaccaagaaccaagtcagcctgacctg
> cctggtcaaaggcttctaccccagcgacatcgccgtggagtgggagagcaatgggcagccggagaacaacta
> caacaccacgcctcccatgctggactccgacggctccttcttcctctacagcaagctcaccgtggacaagag
> caggtggcagcaggggaacatcttctcatgctccgtgatgcatgaggctctgcacaaccgctacacgcagaa
> gagcctctccctgtctccgggtaaatgagtgccatggccggcaagcccccgctccccgggctctcggggtcg
> cgcgaggatgcttggcacgtaccccgtgtacatacttcccaggcacccagcatggaaataaagcacccagcg
> ctgccctgg
> 
> 
> 
> 
> On Tue, 2004-03-23 at 22:44, Jason Stajich wrote:
>> You need an additional perl module.
>> 
>> 
>> install IO::String from CPAN
>> 
>> There is a section on how to install additional perl modules in the
>> INSTALL document.
>> 
>> -j
>> 
>> On Tue, 23 Mar 2004, Alberto Davila wrote:
>> 
>>> Hi,
>>> 
>>> May I ask for some help ?
>>> 
>>> I am trying to use the BioFetch module in order to download several seqs
>>> (from specific Organisms) from GenBank in fasta format, but looks like I
>>> am missing "IO/String.pm" and other things.. should I install additional
>>> bioperl modules (I have the Bioperl Core 1.4 installed) ? or use a
>>> different module for my purpose ?
>>> 
>>> My script and error msg are listed below.
>>> 
>>> Thanks and besr regards,
>>> 
>>> Alberto
>>> 
>>> ****
>>> 
>>> #!/usr/local/bin/perl -w
>>> 
>>> use lib "/usr/local/bioperl14";
>>> package Bio::DB::BioFetch;
>>> use strict;
>>> use Bio::DB::WebDBSeqI;
>>> use HTTP::Request::Common 'POST';
>>> 
>>> my $format_type='fasta';
>>> my $stream;
>>> 
>>> 
>>> my $bf = new Bio::DB::BioFetch(-format        =>$format_type',
>>>                                -retrievaltype =>'tempfile',
>>>                                -db            =>'EMBL');
>>> 
>>>  $stream = $bf->get_Stream_by_id(['BUM','J00231']);
>>>  while (my $s = $stream->next_seq) {
>>>     print $s->seq,"\n";
>>>         }
>>> 
>>> 
>>>           exit;
>>> 
>>> 
>>> [davila at tryps script]$ perl gb-fetch-1.pl
>>> Can't locate IO/String.pm in @INC (@INC contains:
>>> /usr/local/bioperl14/i386-linux-thread-multi /usr/local/bioperl14
>>> /usr/lib/perl5/5.8.3/i386-linux-thread-multi /usr/lib/perl5/5.8.3
>>> /usr/lib/perl5/site_perl/5.8.3/i386-linux-thread-multi
>>> /usr/lib/perl5/site_perl/5.8.2/i386-linux-thread-multi
>>> /usr/lib/perl5/site_perl/5.8.1/i386-linux-thread-multi
>>> /usr/lib/perl5/site_perl/5.8.0/i386-linux-thread-multi
>>> /usr/lib/perl5/site_perl/5.8.3 /usr/lib/perl5/site_perl/5.8.2
>>> /usr/lib/perl5/site_perl/5.8.1 /usr/lib/perl5/site_perl/5.8.0
>>> /usr/lib/perl5/site_perl
>>> /usr/lib/perl5/vendor_perl/5.8.3/i386-linux-thread-multi
>>> /usr/lib/perl5/vendor_perl/5.8.2/i386-linux-thread-multi
>>> /usr/lib/perl5/vendor_perl/5.8.1/i386-linux-thread-multi
>>> /usr/lib/perl5/vendor_perl/5.8.0/i386-linux-thread-multi
>>> /usr/lib/perl5/vendor_perl/5.8.3 /usr/lib/perl5/vendor_perl/5.8.2
>>> /usr/lib/perl5/vendor_perl/5.8.1 /usr/lib/perl5/vendor_perl/5.8.0
>>> /usr/lib/perl5/vendor_perl .) at
>>> /usr/local/bioperl14/Bio/DB/WebDBSeqI.pm line 90.
>>> BEGIN failed--compilation aborted at
>>> /usr/local/bioperl14/Bio/DB/WebDBSeqI.pm line 90.
>>> Compilation failed in require at gb-fetch-1.pl line 6.
>>> BEGIN failed--compilation aborted at gb-fetch-1.pl line 6.
> 
> 
> _______________________________________________
> Bioperl-l mailing list
> Bioperl-l at portal.open-bio.org
> http://portal.open-bio.org/mailman/listinfo/bioperl-l
> 



More information about the Bioperl-l mailing list