tag fourth (and hopefully last) alpha
[bioperl-live.git] / branch-1-6 / examples / db / getGenBank.pl
blobe3482f34b299944810edc980e25457bc02b2f6c5
1 #!/usr/local/bin/perl -w
3 # How to retrieve GenBank entries over the Web
5 # by Jason Stajich
7 use Bio::DB::GenBank;
8 use Bio::SeqIO;
9 my $gb = new Bio::DB::GenBank;
11 # the output stream for your seqs, this can be a file
12 # instead or STDOUT, see the Bio::SeqIO module for info
14 my $seqout = new Bio::SeqIO(-fh => \*STDOUT, -format => 'fasta');
16 # if you want a single seq
17 my $seq = $gb->get_Seq_by_id('MUSIGHBA1');
18 $seqout->write_seq($seq);
19 # or by accession
20 $seq = $gb->get_Seq_by_acc('AF303112');
22 $seqout->write_seq($seq);
24 # feel free to pull multiple sequences...
25 # if you want to get a bunch of sequences use the get_Stream_by_id/acc methods
26 my $seqio = $gb->get_Stream_by_id([ qw(J00522 AF303112 2981014)]);
28 while( defined ($seq = $seqio->next_seq )) {
29 $seqout->write_seq($seq);