1
# $Id: fasta.pm,v 1.58.4.1 2006/10/02 23:10:29 sendu Exp $
1
# $Id: fasta.pm 14669 2008-04-22 21:03:23Z cjfields $
2
2
# BioPerl module for Bio::SeqIO::fasta
4
4
# Cared for by Ewan Birney <birney@ebi.ac.uk>
203
202
$desc =~ s/\n//g;
204
203
$top .= " $desc";
206
if(defined $str && length($str) > 0) {
207
$str =~ s/(.{1,$width})/$1\n/g;
206
if( $seq->isa('Bio::Seq::LargeSeqI') ) {
207
$self->_print(">$top\n");
208
# for large seqs, don't call seq(), it defeats the
209
# purpose of the largeseq functionality. instead get
210
# chunks of the seq, $width at a time
212
my $buff_size = int($buff_max/$width)*$width; #< buffer is even multiple of widths
213
my $seq_length = $seq->length;
214
my $num_chunks = int($seq_length/$buff_size+1);
215
for( my $c = 0; $c < $num_chunks; $c++ ) {
216
my $buff_end = $buff_size*($c+1);
217
$buff_end = $seq_length if $buff_end > $seq_length;
218
my $buff = $seq->subseq($buff_size*$c+1,$buff_end);
220
$buff =~ s/(.{1,$width})/$1\n/g;
221
$self->_print($buff);
228
if(defined $str && length($str) > 0) {
229
$str =~ s/(.{1,$width})/$1\n/g;
233
$self->_print (">",$top,"\n",$str) or return;
211
$self->_print (">",$top,"\n",$str) or return;
214
237
$self->flush if $self->_flush_on_write && defined $self->_fh;