Permalink
Browse files

Fixing a bug that caused the first sequence in a ##FASTA section to b…

…e lost; the problem was that Bio::SeqIO::fasta sets \n> as the line separator, but during processing, Bio::FeatureIO::gff swallowed the \n before sending the filehandle to SeqIO. Now when fasta_mode is set, it rewinds the filehandle to get the preceeding line's \n.

svn path=/bioperl-live/trunk/; revision=16465
  • Loading branch information...
1 parent 87b2474 commit 1d146f6444565bfa1c93dbfeaa6ee107c1c9eb6e scain committed with carandraug Dec 16, 2009
Showing with 8 additions and 0 deletions.
  1. +8 −0 Bio/FeatureIO/gff.pm
@@ -298,12 +298,20 @@ sub write_feature {
Returns : value of fasta_mode (a scalar)
Args : on set, new value (a scalar or undef, optional)
+Side effect: rewind the file handle a little bit to get the last carriage return
+that was swallowed when the previous line was processed.
=cut
sub fasta_mode {
my($self,$val) = @_;
+
$self->{'fasta_mode'} = $val if defined($val);
+
+ if ($val == 1) {
+ seek $self->_fh(), -1, 1; #rewind 1 byte to get the previous line's \n
+ }
+
return $self->{'fasta_mode'};
}

0 comments on commit 1d146f6

Please sign in to comment.