line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# |
2
|
|
|
|
|
|
|
# BioPerl module for Bio::Tools::Run::Samtools |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
# Please direct questions and support issues to |
5
|
|
|
|
|
|
|
# |
6
|
|
|
|
|
|
|
# Cared for by Mark A. Jensen |
7
|
|
|
|
|
|
|
# |
8
|
|
|
|
|
|
|
# Copyright Mark A. Jensen |
9
|
|
|
|
|
|
|
# |
10
|
|
|
|
|
|
|
# You may distribute this module under the same terms as perl itself |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
# POD documentation - main docs before the code |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head1 NAME |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
Bio::Tools::Run::Samtools - a run wrapper for the samtools suite *BETA* |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head1 SYNOPSIS |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
# convert a sam to a bam |
21
|
|
|
|
|
|
|
$samt = Bio::Tools::Run::Samtools( -command => 'view', |
22
|
|
|
|
|
|
|
-sam_input => 1, |
23
|
|
|
|
|
|
|
-bam_output => 1 ); |
24
|
|
|
|
|
|
|
$samt->run( -bam => "mysam.sam", -out => "mysam.bam" ); |
25
|
|
|
|
|
|
|
# sort it |
26
|
|
|
|
|
|
|
$samt = Bio::Tools::Run::Samtools( -command => 'sort' ); |
27
|
|
|
|
|
|
|
$samt->run( -bam => "mysam.bam", -pfx => "mysam.srt" ); |
28
|
|
|
|
|
|
|
# now create an assembly |
29
|
|
|
|
|
|
|
$assy = Bio::IO::Assembly->new( -file => "mysam.srt.bam", |
30
|
|
|
|
|
|
|
-refdb => "myref.fas" ); |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=head1 DESCRIPTION |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
This is a wrapper for running samtools, a suite of large-alignment |
35
|
|
|
|
|
|
|
reading and manipulation programs available at |
36
|
|
|
|
|
|
|
L. |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=head1 RUNNING COMMANDS |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
To run a C |
41
|
|
|
|
|
|
|
command, construct a run factory, specifying the desired command using |
42
|
|
|
|
|
|
|
the C<-command> argument in the factory constructor, along with |
43
|
|
|
|
|
|
|
options specific to that command (see L): |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
$samt = Bio::Tools::Run::Samtools->new( -command => 'view', |
46
|
|
|
|
|
|
|
-sam_input => 1, |
47
|
|
|
|
|
|
|
-bam_output => 1); |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
To execute, use the C method. Input and output files are |
50
|
|
|
|
|
|
|
specified in the arguments of C (see L): |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
$samt->run( -bam => "mysam.sam", -out => "mysam.bam" ); |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=head1 OPTIONS |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
C is complex, with many subprograms (commands) and command-line |
57
|
|
|
|
|
|
|
options and file specs for each. This module attempts to provide |
58
|
|
|
|
|
|
|
commands and options comprehensively. You can browse the choices like so: |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
$samt = Bio::Tools::Run::Samtools->new( -command => 'pileup' ); |
61
|
|
|
|
|
|
|
# all samtools commands |
62
|
|
|
|
|
|
|
@all_commands = $samt->available_parameters('commands'); |
63
|
|
|
|
|
|
|
@all_commands = $samt->available_commands; # alias |
64
|
|
|
|
|
|
|
# just for pileup |
65
|
|
|
|
|
|
|
@pup_params = $samt->available_parameters('params'); |
66
|
|
|
|
|
|
|
@pup_switches = $samt->available_parameters('switches'); |
67
|
|
|
|
|
|
|
@pup_all_options = $samt->available_parameters(); |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
Reasonably mnemonic names have been assigned to the single-letter |
70
|
|
|
|
|
|
|
command line options. These are the names returned by |
71
|
|
|
|
|
|
|
C, and can be used in the factory constructor |
72
|
|
|
|
|
|
|
like typical BioPerl named parameters. |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
See L for the gory details. |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=head1 FILES |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
When a command requires filenames, these are provided to the |
79
|
|
|
|
|
|
|
C method, not the constructor (C). To see the set of |
80
|
|
|
|
|
|
|
files required by a command, use C |
81
|
|
|
|
|
|
|
or the alias C: |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
$samt = Bio::Tools::Run::Samtools->new( -command => 'view' ); |
84
|
|
|
|
|
|
|
@filespec = $samt->filespec; |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
This example returns the following array: |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
bam |
89
|
|
|
|
|
|
|
>out |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
This indicates that the bam/sam file (bam) and the output file (out) |
92
|
|
|
|
|
|
|
MUST be specified in the C argument list: |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
$samt->run( -bam => 'mysam.sam', -out => 'mysam.cvt' ); |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
If files are not specified per the filespec, text sent to STDOUT and |
97
|
|
|
|
|
|
|
STDERR is saved and is accessible with C<$bwafac->stdout()> and |
98
|
|
|
|
|
|
|
C<$bwafac->stderr()>. |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=head1 FEEDBACK |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=head2 Mailing Lists |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
User feedback is an integral part of the evolution of this and other |
105
|
|
|
|
|
|
|
Bioperl modules. Send your comments and suggestions preferably to |
106
|
|
|
|
|
|
|
the Bioperl mailing list. Your participation is much appreciated. |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
bioperl-l@bioperl.org - General discussion |
109
|
|
|
|
|
|
|
http://bioperl.org/wiki/Mailing_lists - About the mailing lists |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=head2 Support |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
Please direct usage questions or support issues to the mailing list: |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
L |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
rather than to the module maintainer directly. Many experienced and |
118
|
|
|
|
|
|
|
reponsive experts will be able look at the problem and quickly |
119
|
|
|
|
|
|
|
address it. Please include a thorough description of the problem |
120
|
|
|
|
|
|
|
with code and data examples if at all possible. |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=head2 Reporting Bugs |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
Report bugs to the Bioperl bug tracking system to help us keep track |
125
|
|
|
|
|
|
|
of the bugs and their resolution. Bug reports can be submitted via |
126
|
|
|
|
|
|
|
the web: |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
http://redmine.open-bio.org/projects/bioperl/ |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=head1 AUTHOR - Mark A. Jensen |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
Email maj -at- fortinbras -dot- us |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=head1 APPENDIX |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
The rest of the documentation details each of the object methods. |
137
|
|
|
|
|
|
|
Internal methods are usually preceded with a _ |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=cut |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
# Let the code begin... |
142
|
|
|
|
|
|
|
package Bio::Tools::Run::Samtools; |
143
|
3
|
|
|
3
|
|
125039
|
use strict; |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
69
|
|
144
|
3
|
|
|
3
|
|
9
|
use warnings; |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
69
|
|
145
|
3
|
|
|
3
|
|
843
|
use Bio::Root::Root; |
|
3
|
|
|
|
|
35623
|
|
|
3
|
|
|
|
|
29
|
|
146
|
3
|
|
|
3
|
|
1190
|
use Bio::Tools::Run::Samtools::Config; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
323
|
|
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
# currently an AssemblerBase object, but the methods we need from |
149
|
|
|
|
|
|
|
# there should really go in an updated WrapperBase.../maj |
150
|
|
|
|
|
|
|
|
151
|
3
|
|
|
3
|
|
12
|
use base qw(Bio::Tools::Run::WrapperBase Bio::Root::Root); |
|
3
|
|
|
|
|
3
|
|
|
3
|
|
|
|
|
805
|
|
152
|
3
|
|
|
3
|
|
998
|
use Bio::Tools::Run::WrapperBase::CommandExts; |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
19
|
|
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
our $program_name = 'samtools'; |
155
|
|
|
|
|
|
|
our $use_dash = 1; |
156
|
|
|
|
|
|
|
our $join = ' '; |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
=head2 new |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
Title : new |
161
|
|
|
|
|
|
|
Usage : my $obj = new Bio::Tools::Run::Samtools(); |
162
|
|
|
|
|
|
|
Function: Builds a new Bio::Tools::Run::Samtools object |
163
|
|
|
|
|
|
|
Returns : an instance of Bio::Tools::Run::Samtools |
164
|
|
|
|
|
|
|
Args : |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
=cut |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
sub new { |
169
|
1
|
|
|
1
|
1
|
85
|
my ($class, @args) = @_; |
170
|
1
|
|
33
|
|
|
7
|
$program_dir ||= $ENV{SAMTOOLSDIR}; |
171
|
1
|
|
|
|
|
9
|
my $self = $class->SUPER::new(@args); |
172
|
1
|
|
|
|
|
5
|
return $self; |
173
|
|
|
|
|
|
|
} |
174
|
|
|
|
|
|
|
|
175
|
0
|
|
|
0
|
1
|
|
sub run { shift->_run(@_) } |
176
|
|
|
|
|
|
|
1; |