Commit f7fe4373 authored by Roy Storey's avatar Roy Storey
Browse files

always write the sequence to the current seqio - fix for creating lots of empty output files

parent c0381e5c
...@@ -127,14 +127,14 @@ sub write_output { ...@@ -127,14 +127,14 @@ sub write_output {
my $chunk_size = 0; # number of sequences in the current chunk my $chunk_size = 0; # number of sequences in the current chunk
my $chunk_name = $output_prefix.$chunk_number.$output_suffix; my $chunk_name = $output_prefix.$chunk_number.$output_suffix;
my $chunk_seqio = Bio::SeqIO->new(-file => '>'.$chunk_name, -format => 'fasta'); my $chunk_seqio = Bio::SeqIO->new(-file => '>'.$chunk_name, -format => 'fasta');
while (my $seq_object = $input_seqio->next_seq) { while (my $seq_object = $input_seqio->next_seq) {
$chunk_seqio->write_seq( $seq_object );
if((my $seq_length = $seq_object->length()) + $chunk_length <= $max_chunk_length) { if((my $seq_length = $seq_object->length()) + $chunk_length <= $max_chunk_length) {
# add to the current chunk:
$chunk_seqio->write_seq( $seq_object );
$chunk_length += $seq_length; $chunk_length += $seq_length;
$chunk_size += 1; $chunk_size += 1;
} else { } else {
# dataflow the current chunk: # dataflow the current chunk:
...@@ -162,6 +162,8 @@ sub write_output { ...@@ -162,6 +162,8 @@ sub write_output {
'chunk_length' => $chunk_length, 'chunk_length' => $chunk_length,
'chunk_size' => $chunk_size 'chunk_size' => $chunk_size
}, 2); }, 2);
} else {
unlink $chunk_name unless (stat($chunk_name))[7];
} }
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment