Created

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist

Get the full FASTA header or Full GenPept record for retrieval

View GenPept retrieval
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
#!/usr/bin/perl -w
# Jason Stajich jason<at>bioperl.org
use strict;
use Bio::DB::GenPept;
use Bio::DB::GenBank;
use Bio::SeqIO;
 
# get the FASTA formatted header for BLAST database
my $db = Bio::DB::GenBank->new(-format => 'fasta');
my $out = Bio::SeqIO->new(-format => 'fasta');
 
my $seq = $db->get_Seq_by_id('NP_006959.1');
$out->write_seq($seq);
 
 
# get the full GenPept record
$db = Bio::DB::GenBank->new(-format => 'gp');
$out = Bio::SeqIO->new(-format => 'genbank');
 
$seq = $db->get_Seq_by_id('NP_006959.1');
$out->write_seq($seq);
 
# works when you use the wrong DB (genbank)
eval {
$db = Bio::DB::GenBank->new(-format => 'gb');
$out = Bio::SeqIO->new(-format => 'genbank');
$seq = $db->get_Seq_by_id('NP_006959.1');
$out->write_seq($seq);
};
if($@) {
# should never get here
warn("couldn't request a protein record from GenBank\n");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.