Difference between revisions of "BamUtil: trimBam"

From Genome Analysis Wiki
Jump to navigationJump to search
Line 30: Line 30:
 
Returns the SamStatus for the reads/writes.  0 on success.
 
Returns the SamStatus for the reads/writes.  0 on success.
  
= Example Output =
+
= Examples =
  
If the number to trim from each side is the same:
+
==Trim the same number of bases from each side==
 +
Example Input, trimming 2 bases:
 +
<pre>
 +
./bin trimBam testFiles/testSam.sam results/trimSam.sam 2
 +
</pre>
 +
Example Output:
 
<pre>
 
<pre>
 
Arguments in effect:  
 
Arguments in effect:  
Line 43: Line 48:
 
</pre>
 
</pre>
  
If the number to trim from each side is different (but left/right is the same for forward/reverse):
+
==Trim different bases from each side, but treat forward & reverse the same==
 +
Example Input, trimming 1 base from the left and 2 bases from the right:
 +
<pre>
 +
./bin trimBam testFiles/testSam.sam results/trimSam.sam -L 1 -R 2
 +
</pre>
 +
Example Output:
 
<pre>
 
<pre>
 
Arguments in effect:  
 
Arguments in effect:  
Line 58: Line 68:
  
  
If the number to trim from each side is different and the reverse option is used(left/right is opposite for reverse):
+
==Trim different bases from each side, but treat reverse strands the opposite==
 +
Example Input, trimming 1 base from the left and 2 bases from the right for forward strands and do the opposite for reverse strands:
 +
<pre>
 +
./bin trimBam testFiles/testSam.sam results/trimSam.sam -L 1 -R 2 --reverse
 +
</pre>
 +
Example Output:
 
<pre>
 
<pre>
 
Arguments in effect:  
 
Arguments in effect:  

Revision as of 16:01, 14 November 2012

Overview of the trimBam function of bamUtil

The trimBam option on the bamUtil executable trims the end of reads in a SAM/BAM file, changing read ends to ‘N’ and quality to ‘!’.


Usage

./bam trimBam [inFile] [outFile] [num-bases-to-trim-on-each-side]

Version 1.0.6 and later:

Alternately, the number of bases from each side can be specified (either or both -L/-R (--left/--right) can be specified):

./bam trimBam [inFile] [outFile] -L [num-bases-to-trim-from-left] -R [num-bases-to-trim-from-right]

By default Left/Right is as the reads are in the SAM/BAM file.

Optionally --reverse/-r can be specified to reverse the left/right for reverse reads

trimBam will modify the sequences to 'N', and the quality string to '!'

Parameters

    Required Parameters:
        inFile  : the SAM/BAM file to be read
        outFile : the SAM/BAM file to be written
        num-bases-to-trim-on-each-side : the number of bases/qualities to trim from each side
    Instead of num-bases-to-trim-on-each-side, -L/-R (or --left/--right) can be specified to indicate the number of bases to trim from the left/right
    Optional Parameters:
        --reverse : reverse the left/right for reverse reads

Return Value

Returns the SamStatus for the reads/writes. 0 on success.

Examples

Trim the same number of bases from each side

Example Input, trimming 2 bases:

./bin trimBam testFiles/testSam.sam results/trimSam.sam 2

Example Output:

Arguments in effect: 
	Input file : testFiles/testSam.sam
	Output file : results/trimSam.sam
	#Bases to trim from each side : 2

Number of records read = 10
Number of records written = 10

Trim different bases from each side, but treat forward & reverse the same

Example Input, trimming 1 base from the left and 2 bases from the right:

./bin trimBam testFiles/testSam.sam results/trimSam.sam -L 1 -R 2

Example Output:

Arguments in effect: 
	Input file : testFiles/testSam.sam
	Output file : results/trimSam.sam
	#Bases to trim from the left of forward strands : 1
	#Bases to trim from the right of forward strands: 2
	#Bases to trim from the left of reverse strands : 1
	#Bases to trim from the right of reverse strands : 2

Number of records read = 10
Number of records written = 10


Trim different bases from each side, but treat reverse strands the opposite

Example Input, trimming 1 base from the left and 2 bases from the right for forward strands and do the opposite for reverse strands:

./bin trimBam testFiles/testSam.sam results/trimSam.sam -L 1 -R 2 --reverse

Example Output:

Arguments in effect: 
	Input file : testFiles/testSam.sam
	Output file : results/trimSam.sam
	#Bases to trim from the left of forward strands : 1
	#Bases to trim from the right of forward strands: 2
	#Bases to trim from the left of reverse strands : 2
	#Bases to trim from the right of reverse strands : 1

Number of records read = 10
Number of records written = 10