Created
November 30, 2010 02:11
-
-
Save hyphaltip/721012 to your computer and use it in GitHub Desktop.
Get the full FASTA header or Full GenPept record for retrieval
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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