[Bioperl-l] Converting Genbank to fasta via SeqIO

Wes Barris wes.barris at csiro.au
Mon Jul 21 16:36:00 EDT 2003


I am using the following code to convert a genbank file into a fasta

my $seq_in = Bio::SeqIO->new('-file' => "<$infile", '-format' => 'genbank');
my $seq_out = Bio::SeqIO->new('-file' => ">$outfile", '-format' => 'fasta');

while ( my $inseq = $seq_in->next_seq ) {
    if ($seq->accession =~ '_') {

The genbank entry (NM_174198) results in the following defline
in the fasta file:

 >TLR4 Bos taurus toll-like receptor 4 (TLR4), mRNA.

However, I prefer to have a defline containing the accession number similar to
what is shown at the NCBI site:

 >gi|31342611|ref|NM_174198.2| Bos taurus toll-like receptor 4 (TLR4), mRNA

Is there a way to have the SeqIO routines do this?

Wes Barris
E-Mail: Wes.Barris at csiro.au

More information about the Bioperl-l mailing list