Bio::Tools::Run::Samtools(3) a run wrapper for the samtools suite *BETA*


# convert a sam to a bam
$samt = Bio::Tools::Run::Samtools( -command => 'view',
-sam_input => 1,
-bam_output => 1 );
$samt->run( -bam => "mysam.sam", -out => "mysam.bam" );
# sort it
$samt = Bio::Tools::Run::Samtools( -command => 'sort' );
$samt->run( -bam => "mysam.bam", -pfx => "" );
# now create an assembly
$assy = Bio::IO::Assembly->new( -file => "",
-refdb => "myref.fas" );


This is a wrapper for running samtools, a suite of large-alignment reading and manipulation programs available at <>.


To run a "samtools" command, construct a run factory, specifying the desired command using the "-command" argument in the factory constructor, along with options specific to that command (see ``OPTIONS''):

 $samt = Bio::Tools::Run::Samtools->new( -command => 'view',
                                         -sam_input => 1,
                                         -bam_output => 1);

To execute, use the "run()" method. Input and output files are specified in the arguments of "run()" (see ``FILES''):

 $samt->run( -bam => "mysam.sam", -out => "mysam.bam" );


"samtools" is complex, with many subprograms (commands) and command-line options and file specs for each. This module attempts to provide commands and options comprehensively. You can browse the choices like so:

 $samt = Bio::Tools::Run::Samtools->new( -command => 'pileup' );
 # all samtools commands
 @all_commands = $samt->available_parameters('commands'); 
 @all_commands = $samt->available_commands; # alias
 # just for pileup
 @pup_params = $samt->available_parameters('params');
 @pup_switches = $samt->available_parameters('switches');
 @pup_all_options = $samt->available_parameters();

Reasonably mnemonic names have been assigned to the single-letter command line options. These are the names returned by "available_parameters", and can be used in the factory constructor like typical BioPerl named parameters.

See <> for the gory details.


When a command requires filenames, these are provided to the "run()" method, not the constructor ("new()"). To see the set of files required by a command, use "available_parameters('filespec')" or the alias "filespec()":

  $samt = Bio::Tools::Run::Samtools->new( -command => 'view' );
  @filespec = $samt->filespec;

This example returns the following array:


This indicates that the bam/sam file (bam) and the output file (out) MUST be specified in the "run()" argument list:

 $samt->run( -bam => 'mysam.sam', -out => 'mysam.cvt' );

If files are not specified per the filespec, text sent to STDOUT and STDERR is saved and is accessible with "$bwafac-"stdout()> and "$bwafac-"stderr()>.


Mailing Lists

User feedback is an integral part of the evolution of this and other Bioperl modules. Send your comments and suggestions preferably to the Bioperl mailing list. Your participation is much appreciated.

  [email protected]                  - General discussion  - About the mailing lists


Please direct usage questions or support issues to the mailing list:

[email protected]

rather than to the module maintainer directly. Many experienced and reponsive experts will be able look at the problem and quickly address it. Please include a thorough description of the problem with code and data examples if at all possible.

Reporting Bugs

Report bugs to the Bioperl bug tracking system to help us keep track of the bugs and their resolution. Bug reports can be submitted via the web:

AUTHOR - Mark A. Jensen

Email maj -at- fortinbras -dot- us


The rest of the documentation details each of the object methods. Internal methods are usually preceded with a _


 Title   : new
 Usage   : my $obj = new Bio::Tools::Run::Samtools();
 Function: Builds a new Bio::Tools::Run::Samtools object
 Returns : an instance of Bio::Tools::Run::Samtools
 Args    :