[Bioperl-l] newbie question

Jason Stajich jason@chg.mc.duke.edu
Mon, 19 Feb 2001 16:51:28 -0500 (EST)


Use bioperl for this if you like.  bioperl-0.7 supports the following
code.  Bioperl 0.6 should as well as I tried to maintain backwards
compatibility.  

If you are unsure about the Bio::SeqIO module or Bio::DB::GenBank modules
check out the perldoc for them.

If you want to retrieve just via the web look up info on Batch Entrez at
the NCBI site.

#!/usr/local/bin/perl -w
use Bio::DB::GenBank;
use Bio::SeqIO;
my $gb = new Bio::DB::GenBank;

# the output stream for your seqs, this can be a file
# instead or STDOUT, see the Bio::SeqIO module for info

my $seqout = new Bio::SeqIO(-fh => \*STDOUT, -format => 'fasta');

# if you want a single seq
my $seq = $gb->get_Seq_by_id('MUSIGHBA1');
$seqout->write_seq($seq);
# or by accession
$seq = $gb->get_Seq_by_acc('AF303112');

$seqout->write_seq($seq);

# if you want to get a bunch of sequences use the batch method
my $seqio = $gb->get_Stream_by_batch([ qw(J00522 AF303112 2981014)]); 

while( defined ($seq = $seqio->next_seq )) {
	$seqout->write_seq($seq);
}

On Mon, 19 Feb 2001, Joel Sevinsky wrote:

> Could anyone direct me towards some sample code in perl that would send a
> query to Genbank containing only an accession number and returning a fasta
> file?  Anything close would be appreciated.  Can't seem to find this
> information at NCBI.  If you know the site address at NCBI that would give
> this information that would work also.  Thanks.
> 
> Joel
> 
> _______________________________________________
> Bioperl-l mailing list
> Bioperl-l@bioperl.org
> http://bioperl.org/mailman/listinfo/bioperl-l
> 

Jason Stajich
jason@chg.mc.duke.edu
Center for Human Genetics
Duke University Medical Center 
http://www.chg.duke.edu/