~ubuntu-branches/ubuntu/saucy/bioperl/saucy-proposed

« back to all changes in this revision

Viewing changes to Bio/SeqIO/fasta.pm

  • Committer: Bazaar Package Importer
  • Author(s): Charles Plessy
  • Date: 2009-03-10 07:19:11 UTC
  • mfrom: (1.2.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20090310071911-fukqzw54pyb1f0bd
Tags: 1.6.0-2
* Removed patch system (not used):
  - removed instuctions in debian/rules;
  - removed quilt from Build-Depends in debian/control.
* Re-enabled tests:
  - uncommented test command in debian/rules;
  - uncommented previously missing build-dependencies in debian/control.
  - Re-enabled tests and uncommented build-dependencies accordingly.
* Removed libmodule-build-perl and libtest-harness-perl from
  Build-Depends-Indep (provided by perl-modules).
* Better cleaning of empty directories using find -type d -empty -delete
  instead of rmdir in debian/rules (LP: #324001).

Show diffs side-by-side

added added

removed removed

Lines of Context:
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
3
3
#
4
4
# Cared for by Ewan Birney <birney@ebi.ac.uk>
178
178
                $self->throw("Did not provide a valid Bio::PrimarySeqI object") 
179
179
                  unless defined $seq && ref($seq) && $seq->isa('Bio::PrimarySeqI');
180
180
 
181
 
                my $str = $seq->seq;
182
181
                my $top;
183
182
 
184
183
                # Allow for different ids 
203
202
                        $desc =~ s/\n//g;
204
203
                        $top .= " $desc";
205
204
                }
206
 
                if(defined $str && length($str) > 0) {
207
 
                        $str =~ s/(.{1,$width})/$1\n/g;
 
205
                
 
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
 
211
                  my $buff_max = 2000;
 
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);
 
219
                    if($buff) {
 
220
                      $buff =~ s/(.{1,$width})/$1\n/g;
 
221
                      $self->_print($buff);
 
222
                    } else {
 
223
                      $self->_print("\n");
 
224
                    }
 
225
                  }
208
226
                } else {
209
 
                        $str = "\n";
 
227
                  my $str = $seq->seq;
 
228
                  if(defined $str && length($str) > 0) {
 
229
                    $str =~ s/(.{1,$width})/$1\n/g;
 
230
                  } else {
 
231
                    $str = "\n";
 
232
                  }
 
233
                  $self->_print (">",$top,"\n",$str) or return;
210
234
                }
211
 
                $self->_print (">",$top,"\n",$str) or return;
212
235
   }
213
236
 
214
237
   $self->flush if $self->_flush_on_write && defined $self->_fh;