Difference between revisions of "BamUtil: trimBam"
Line 10: | Line 10: | ||
Alternately, the number of bases from each side can be specified (either or both -L/-R (--left/--right) can be specified): | 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] | ./bam trimBam [inFile] [outFile] -L [num-bases-to-trim-from-left] -R [num-bases-to-trim-from-right] | ||
− | |||
− | Optionally -- | + | By default reverse strands are reversed and then the left & right are trimmed. |
+ | |||
+ | This means that --left actually trims from the right of the read in the SAM/BAM for reverse reads. | ||
+ | |||
+ | Optionally --ignoreStrand/-i can be specified to ignore the strand information and treat forward/reverse the same. | ||
trimBam will modify the sequences to 'N', and the quality string to '!' | trimBam will modify the sequences to 'N', and the quality string to '!' | ||
+ | |||
= Parameters = | = Parameters = | ||
Line 22: | Line 26: | ||
outFile : the SAM/BAM file to be written | 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 | 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 | + | 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 (left/right are reversed for reverse strands) |
Optional Parameters: | Optional Parameters: | ||
− | -- | + | --ignoreStrand : ignore strand information - do not reverse left/right for reverse reads |
</pre> | </pre> | ||
Line 48: | Line 52: | ||
</pre> | </pre> | ||
− | ==Trim different bases from each side, but treat | + | |
− | Example Input, trimming 1 base from the left and 2 bases from the right: | + | ==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> | <pre> | ||
./bin trimBam testFiles/testSam.sam results/trimSam.sam -L 1 -R 2 | ./bin trimBam testFiles/testSam.sam results/trimSam.sam -L 1 -R 2 | ||
Line 60: | Line 65: | ||
#Bases to trim from the left of forward strands : 1 | #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 right of forward strands: 2 | ||
− | #Bases to trim from the left of reverse strands : | + | #Bases to trim from the left of reverse strands : 2 |
− | #Bases to trim from the right of reverse strands : | + | #Bases to trim from the right of reverse strands : 1 |
Number of records read = 10 | Number of records read = 10 | ||
Line 68: | Line 73: | ||
− | ==Trim different bases from each side, but treat 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 | + | Example Input, trimming 1 base from the left and 2 bases from the right ignoring strand information: |
<pre> | <pre> | ||
− | ./bin trimBam testFiles/testSam.sam results/trimSam.sam -L 1 -R 2 -- | + | ./bin trimBam testFiles/testSam.sam results/trimSam.sam -L 1 -R 2 --ignoreStrand |
</pre> | </pre> | ||
Example Output: | Example Output: | ||
Line 80: | Line 85: | ||
#Bases to trim from the left of forward strands : 1 | #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 right of forward strands: 2 | ||
− | #Bases to trim from the left of reverse strands : | + | #Bases to trim from the left of reverse strands : 1 |
− | #Bases to trim from the right of reverse strands : | + | #Bases to trim from the right of reverse strands : 2 |
Number of records read = 10 | Number of records read = 10 | ||
Number of records written = 10 | Number of records written = 10 | ||
</pre> | </pre> | ||
+ | |||
Revision as of 18:49, 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 reverse strands are reversed and then the left & right are trimmed.
This means that --left actually trims from the right of the read in the SAM/BAM for reverse reads.
Optionally --ignoreStrand/-i can be specified to ignore the strand information and treat forward/reverse the same.
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 (left/right are reversed for reverse strands) Optional Parameters: --ignoreStrand : ignore strand information - do not reverse 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 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
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
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 ignoring strand information:
./bin trimBam testFiles/testSam.sam results/trimSam.sam -L 1 -R 2 --ignoreStrand
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