1.

I Would Like To Make My Own Custom Fasta Header - How Do I Do This?

Answer»

You want to use the method preferred_id_type().

Here's some example code:

use Bio::SeqIO;
my $seqin = Bio::SeqIO->new(-FILE => $file,
-format => 'genbank');
my $seqout = Bio::SeqIO->new(-fh => *STDOUT,
-format => 'fasta');
# From Bio::SeqIO::fasta
$seqout->preferred_id_type('display');
my $count = 1;
while (my $seq = $seqin->next_seq) {
# override the regular display_id with your own
$seq->display_id('foo'.$count);
$seqout->write_seq($seq);
$count++;
}
You can pass one of the following values to preferred_id_type: "accession", "accession.version", "display", "primary". The DESCRIPTION line is automatically appended to the PREFERRED ID type but this can also be set, like so:
$seq->DESC($some_string);

You want to use the method preferred_id_type().

Here's some example code:

use Bio::SeqIO;
my $seqin = Bio::SeqIO->new(-file => $file,
-format => 'genbank');
my $seqout = Bio::SeqIO->new(-fh => *STDOUT,
-format => 'fasta');
# From Bio::SeqIO::fasta
$seqout->preferred_id_type('display');
my $count = 1;
while (my $seq = $seqin->next_seq) {
# override the regular display_id with your own
$seq->display_id('foo'.$count);
$seqout->write_seq($seq);
$count++;
}
You can pass one of the following values to preferred_id_type: "accession", "accession.version", "display", "primary". The description line is automatically appended to the preferred id type but this can also be set, like so:
$seq->desc($some_string);



Discussion

No Comment Found