Author: Michael R. Crusoe Description: skip broken samtools version parsing code that can't handle version 1.10+ --- bio-tradis.orig/lib/Bio/Tradis/Samtools.pm +++ bio-tradis/lib/Bio/Tradis/Samtools.pm @@ -8,40 +8,6 @@ has 'exec' => ( is => 'ro', isa => 'Str', default => 'samtools' ); has 'threads' => ( is => 'ro', isa => 'Int', default => 1 ); -has 'exec_version' => ( is => 'ro', isa => 'Str', lazy => 1, builder => '_build_exec_version' ); - -sub _build_exec_version { - my ($self) = @_; - - my $fp = $self->find_exe($self->exec); - if(!$fp) - { - exit("ERROR: Can't find required ".$self->exec." in your \$PATH"); - } - my $cmd_version = $self->exec." 2>&1 | grep Version"; - my ($version_string) = qx($cmd_version); - - if(defined($version_string)) - { - #Version: 0.1.19-44428cd - #Version: 1.2 (using htslib 1.2) - # we dont use 3rd number in version so just look for 0.1, 1.2 - if($version_string =~ /Version:[\t\s]+(\d+)\.(\d+)/) - { - return $1.'.'.$2; - } - else - { - print STDERR "ERROR: Couldn't identify samtools version"; - } - } - else - { - print STDERR "ERROR: Couldn't identify samtools version"; - } - # reasonable fallback - return '0.1'; -} sub find_exe { my ( $self, $bin ) = @_; @@ -52,29 +18,12 @@ return; } -sub _is_version_less_than_1 { - my ($self) = @_; - if($self->exec_version < 1.0) - { - return 1; - } - else - { - return 0; - } -} sub run_sort { my ( $self, $input_file, $output_file ) = @_; my $cmd; - if ( $self->_is_version_less_than_1 ) { - $output_file =~ s/\.bam//i; - $cmd = join( ' ', ( $self->exec, 'sort', $input_file, $output_file) ); - } - else { - $cmd = join( ' ', ( $self->exec, 'sort', '-@', $self->threads, '-O', 'bam', '-T', $input_file.'.tmp', '-o', $output_file, $input_file ) ); - } + $cmd = join( ' ', ( $self->exec, 'sort', '-@', $self->threads, '-O', 'bam', '-T', $input_file.'.tmp', '-o', $output_file, $input_file ) ); system($cmd); }