[Bioperl-l] remote db retrieval

Jason Stajich jason@cgt.mc.duke.edu
Wed, 20 Nov 2002 08:35:50 -0500 (EST)


On Wed, 20 Nov 2002, Mikaela Ilinca Gabrielli wrote:

> Can somebody help me?
> I'd like to retrieve sequences from a remote database in FASTA format. I
> cannot find how to do so allthough there should be a simple way.
>
> Here's my code:
>




>
> #! /usr/bin/perl
> use Bio::SeqIO;
> use Bio::DB::RefSeq;
>
# It is more sensible if you initialize the db handle once at the
# begining rather than each iteration of the loop

my $db = new Bio::DB::RefSeq(-format=>'fasta');

# Note you didn't have to specify -format => 'fasta'
# (this tells the webserver how to return the data, but
# we can reformat it in bioperl.  It *should*
# result in slightly faster performance, you may just want
# to omit that option though as the header desc line
# seems to get weirdly formatted and I don't know if it is on our end
# or the EMBL srv end.

$db->proxy(['http', 'ftp'],'http://fw.lundbeck.com:8080');

# initialize a sequence writer which writes in fasta format
my $seqout = new Bio::SeqIO(-format => 'fasta', -file => '>myseqs.fa');

>
# don't provide the version number the EMBL refseq db doesn't respond
my @acc=('NP_061843', 'NP_110411', 'NP_072093');

# try it the simple way without a subroutine
 foreach my $ACC(@acc){
  my $seq= $db->get_Seq_by_acc($ACC);
  if( ! $seq ) { print STDERR "could not get seq for $ACC\n"; next;}
  $seqout->write_seq($seq);
 }

-jason

>
>
> --Thanks!
> /Mikaela
> _______________________________________________
> Bioperl-l mailing list
> Bioperl-l@bioperl.org
> http://bioperl.org/mailman/listinfo/bioperl-l
>

-- 
Jason Stajich
Duke University
jason at cgt.mc.duke.edu