| 1 | # | ||||||||||||||||||||
| 2 | # BioPerl module for Bio::Tools::Run::Samtools | ||||||||||||||||||||
| 3 | # | ||||||||||||||||||||
| 4 | # Please direct questions and support issues to <bioperl-l@bioperl.org> | ||||||||||||||||||||
| 5 | # | ||||||||||||||||||||
| 6 | # Cared for by Mark A. Jensen <maj -at- fortinbras -dot- us> | ||||||||||||||||||||
| 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<http://samtools.sourceforge.net/>. | ||||||||||||||||||||
| 37 | |||||||||||||||||||||
| 38 | =head1 RUNNING COMMANDS | ||||||||||||||||||||
| 39 | |||||||||||||||||||||
| 40 | To run a C<samtools> | ||||||||||||||||||||
| 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</OPTIONS>): | ||||||||||||||||||||
| 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<run()> method. Input and output files are | ||||||||||||||||||||
| 50 | specified in the arguments of C<run()> (see L</FILES>): | ||||||||||||||||||||
| 51 | |||||||||||||||||||||
| 52 | $samt->run( -bam => "mysam.sam", -out => "mysam.bam" ); | ||||||||||||||||||||
| 53 | |||||||||||||||||||||
| 54 | =head1 OPTIONS | ||||||||||||||||||||
| 55 | |||||||||||||||||||||
| 56 | C<samtools> 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<available_parameters>, and can be used in the factory constructor | ||||||||||||||||||||
| 72 | like typical BioPerl named parameters. | ||||||||||||||||||||
| 73 | |||||||||||||||||||||
| 74 | See L<http://samtools.sourceforge.net/samtools.shtml> for the gory details. | ||||||||||||||||||||
| 75 | |||||||||||||||||||||
| 76 | =head1 FILES | ||||||||||||||||||||
| 77 | |||||||||||||||||||||
| 78 | When a command requires filenames, these are provided to the | ||||||||||||||||||||
| 79 | C<run()> method, not the constructor (C<new()>). To see the set of | ||||||||||||||||||||
| 80 | files required by a command, use C<available_parameters('filespec')> | ||||||||||||||||||||
| 81 | or the alias C<filespec()>: | ||||||||||||||||||||
| 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<run()> 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<bioperl-l@bioperl.org> | ||||||||||||||||||||
| 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 | 1 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 144 | 1 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 145 | 1 | ▶ | use Bio::Root::Root; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 146 | 1 | ▶ | use Bio::Tools::Run::Samtools::Config; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 147 | |||||||||||||||||||||
| 148 | # currently an AssemblerBase object, but the methods we need from | ||||||||||||||||||||
| 149 | # there should really go in an updated WrapperBase.../maj | ||||||||||||||||||||
| 150 | |||||||||||||||||||||
| 151 | 1 | ▶ | use base qw(Bio::Tools::Run::WrapperBase Bio::Root::Root); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 152 | 1 | ▶ | use Bio::Tools::Run::WrapperBase::CommandExts; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 153 | |||||||||||||||||||||
| 154 | 1 | our $program_name = 'samtools'; | |||||||||||||||||||
| 155 | 1 | our $use_dash = 1; | |||||||||||||||||||
| 156 | 1 | 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 | 1 | ▶ | sub new { | ||||||||||||||||||
|
Subroutine
new: called CC=2 SCAR=7.4
Pod
documented
| |||||||||||||||||||||
| 169 | 1 | my ($class, @args) = @_; | |||||||||||||||||||
| 170 | 1 | ▶ | $program_dir ||= $ENV{SAMTOOLSDIR}; | ||||||||||||||||||
|
Condition33%1/3
$Bio::Tools::Run::Samtools::program_dir ||= $ENV{"SAMTOOLSDIR"}
MC/DC0%0/2
$Bio::Tools::Run::Samtools::program_dir ||= $ENV{"SAMTOOLSDIR"}
$Bio::Tools::Run::Samtools::program_dir
$ENV{"SAMTOOLSDIR"}
Truth table33%1/3
A ||= B
A= $Bio::Tools::Run::Samtools::program_dirB= $ENV{"SAMTOOLSDIR"}
| |||||||||||||||||||||
| 171 | 1 | my $self = $class->SUPER::new(@args); | |||||||||||||||||||
| 172 | 1 | return $self; | |||||||||||||||||||
| 173 | } | ||||||||||||||||||||
| 174 | |||||||||||||||||||||
| 175 | 0 | ▶ | sub run { shift->_run(@_) } | ||||||||||||||||||
|
Subroutine
run: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 176 | 1 | 1; | |||||||||||||||||||