File: Samtools.pm

package info (click to toggle)
bio-tradis 1.4.5%2Bdfsg2-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye
  • size: 13,652 kB
  • sloc: perl: 4,312; xml: 1,731; sh: 123; makefile: 18
file content (77 lines) | stat: -rw-r--r-- 1,502 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
package Bio::Tradis::Samtools;
$Bio::Tradis::Samtools::VERSION = '1.4.5';
# ABSTRACT: Change samtools syntax depending on version found


use Moose;
use File::Spec;

has 'exec'         => ( is => 'ro', isa => 'Str', default => 'samtools' );
has 'threads'      => ( is => 'ro', isa => 'Int', default => 1 );

sub find_exe {
    my ( $self, $bin ) = @_;
    for my $dir ( File::Spec->path ) {
        my $exe = File::Spec->catfile( $dir, $bin );
        return $exe if -x $exe;
    }
    return;
}


sub run_sort {
    my ( $self, $input_file, $output_file ) = @_;

    my $cmd;
    $cmd = join( ' ', ( $self->exec, 'sort', '-@', $self->threads, '-O', 'bam', '-T', $input_file.'.tmp',  '-o', $output_file, $input_file ) );
    system($cmd);
}

sub run_index {
    my ( $self, $input_file ) = @_;
    system( $self->exec . " index $input_file" );
}

no Moose;
__PACKAGE__->meta->make_immutable;

1;

__END__

=pod

=encoding UTF-8

=head1 NAME

Bio::Tradis::Samtools - Change samtools syntax depending on version found

=head1 VERSION

version 1.4.5

=head1 SYNOPSIS

Change samtools syntax depending on version found
   use Bio::Tradis::Samtools;

   my $obj = Bio::Tradis::Samtools->new(
      exec => 'samtools'
     );

   $obj->run_sort();

=head1 AUTHOR

Carla Cummins <path-help@sanger.ac.uk>

=head1 COPYRIGHT AND LICENSE

This software is Copyright (c) 2013 by Wellcome Trust Sanger Institute.

This is free software, licensed under:

  The GNU General Public License, Version 3, June 2007

=cut