質問

I'm trying to export aligned sequences to a fasta file one by one using Bio::SeqIO. The result is that the sequences are broken by a new line every 60 columns. How do I avoid that?
I'd like to have the sequences exported in a 'wide' format, i.e. no line breaks in the sequence.

My code is roughly:

use Bio::SeqIO;
my $seqin = Bio::SeqIO->new(-file => "<$fastaFile", '-format' => 'Fasta');
my $outname = fileparse($fastaFile, qr/\.[^\.]*$/) . "_sub.fasta";
my $seqout = Bio::SeqIO->new(-file => ">$outname", '-format' => 'Fasta');

while(my $seq = $seqin->next_seq){
      # do something with $seq
      $seqout->write_seq($seq);
}
役に立ちましたか?

解決

Bio::SeqIO::fasta provides a width method to specify how written FASTA records should be formatted:

while (my $seq = $seqin->next_seq) {
    $seqout->width($seq->length);
    $seqout->write_seq($seq);
}

Or of course if your sequences have some maximum size, you can just put a single

$seqout->width(5000);

or so in before the loop.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top