<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>http://genome.sph.umich.edu/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Mktrost</id>
	<title>Genome Analysis Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="http://genome.sph.umich.edu/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Mktrost"/>
	<link rel="alternate" type="text/html" href="http://genome.sph.umich.edu/wiki/Special:Contributions/Mktrost"/>
	<updated>2026-09-24T06:02:00Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.43.1</generator>
	<entry>
		<id>http://genome.sph.umich.edu/w/index.php?title=BamUtil:_recab&amp;diff=15104</id>
		<title>BamUtil: recab</title>
		<link rel="alternate" type="text/html" href="http://genome.sph.umich.edu/w/index.php?title=BamUtil:_recab&amp;diff=15104"/>
		<updated>2019-04-20T03:01:33Z</updated>

		<summary type="html">&lt;p&gt;Mktrost: /* Required Generic Parameters */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:BamUtil|validate]]&lt;br /&gt;
[[Category:BAM Software]]&lt;br /&gt;
[[Category:Software]]&lt;br /&gt;
&lt;br /&gt;
= Overview of the &amp;lt;code&amp;gt;recab&amp;lt;/code&amp;gt; function of &amp;lt;code&amp;gt;[[bamUtil]]&amp;lt;/code&amp;gt; =&lt;br /&gt;
The &amp;lt;code&amp;gt;recab&amp;lt;/code&amp;gt; option of [[bamUtil]] recalibrates a SAM/BAM file. &lt;br /&gt;
&lt;br /&gt;
Recalibration can also be called as an option of [[bamUtil: dedup]].  This will perform the recalibration and  the deduping in the same set of steps, increasing processing speed.&lt;br /&gt;
&lt;br /&gt;
==Handling Recalibration/Implementation Notes==&lt;br /&gt;
&lt;br /&gt;
Recalibration is a 2-step process that loops through the file twice (stdin is not support as input):&lt;br /&gt;
# Build Recalibration Table&lt;br /&gt;
# Apply Recalibration Table&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Recalibration Table groups bases based on a set of covariates:&lt;br /&gt;
* Read Group&lt;br /&gt;
* Quality (either from the quality string or [[#Read the quality from a tag (--qualField)|from a tag]])&lt;br /&gt;
* Cycle (reverse complement for reverse strands)&lt;br /&gt;
* 1st/2nd read in pair&lt;br /&gt;
* Previous Cycle&#039;s Base (reverse complement for reverse strands)&lt;br /&gt;
* This Cycle&#039;s Base (reverse complement for reverse strands)&lt;br /&gt;
&lt;br /&gt;
The Recalibration Table tracks the number of matches/mismatches for each set of covariates.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Only bases meeting all of the following criteria are used to Build the Recalibration Table:&lt;br /&gt;
* Read criteria&lt;br /&gt;
** not a duplicate&lt;br /&gt;
** mapped&lt;br /&gt;
** mapping quality != 0&lt;br /&gt;
** mapping quality != 255&lt;br /&gt;
* Base criteria&lt;br /&gt;
** match/mismatch (not an insertion/deletion/skip/clip)&lt;br /&gt;
** not a [[#DBSNP File (--dbsnp)|dbSNP position]]&lt;br /&gt;
** base quality &amp;gt; [[#Minimum Recalibration Base Quality (--minBaseQual)|minBaseQual (5 by default)]]&lt;br /&gt;
* Additional criteria for cycle != 1 (can be turned off via flags)&lt;br /&gt;
** previous base is a CIGAR Match/Mismatch (Use [[#Allow Previous Base Non-Match/Mismatch (--keepPrevNonAdjacent)|&amp;lt;code&amp;gt;--keepPrevNonAdjacent&amp;lt;/code&amp;gt;]] to disable)&lt;br /&gt;
** previous base position is not a [[#DBSNP File (--dbsnp)|dbSNP position]] (Use [[#Allow Previous Base DBSNP (--keepPrevDbsnp)|&amp;lt;code&amp;gt;--keepPrevDbsnp&amp;lt;/code&amp;gt;]] to disable)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Recalibration Table is applied to all bases meeting all of the following criteria (even if they were not used for creating the table):&lt;br /&gt;
* base quality &amp;gt; [[#Minimum Recalibration Base Quality (--minBaseQual)|minBaseQual (5 by default)]]&lt;br /&gt;
* at least 1 match or mismatch for the set of covariates&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Recalibrated Quality is: &amp;lt;math&amp;gt;-10 * \log \frac{mismatches + 1}{mismatches + matches + 1}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Alternatively, [[#Logistic Regression (--useLogReg)|logistic regression]] can be used for calculating the new quality.&lt;br /&gt;
&lt;br /&gt;
If the Recalibrated Quality is greater than [[#Maximum Recalibration Base Quality (--maxBaseQual)|maxBaseQual]], the updated quality is set to maxBaseQual.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Optionally, the previous quality can be [[#Store the original quality (--storeQualTag)|stored in a tag]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The current recalibration logic was designed for recalibrating ILLUMINA data.&lt;br /&gt;
&lt;br /&gt;
NOTE: GATK ignores/skips adapters, but our logic does not.&lt;br /&gt;
&lt;br /&gt;
== How to use it ==&lt;br /&gt;
&lt;br /&gt;
When &amp;lt;code&amp;gt;recab&amp;lt;/code&amp;gt; is invoked without any arguments the usage information is displayed as described below under [[#Usage|Usage]].&lt;br /&gt;
&lt;br /&gt;
The input SAM/BAM file ([[#input File (--in)|--in]]), the output SAM/BAM file ([[#output File (--out)|--out]]), and the reference file ([[#Reference File (--refFile)|--refFile]]) are required inputs.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Recommended usage with Deduper: &lt;br /&gt;
&lt;br /&gt;
 /usr/cluster/bin/bam dedup --recab --in ${INPUT}.bam --out ${OUTPUT}.bam --force --refFile ${REF} --dbsnp ${DBSNP} --oneChrom --storeQualTag OQ --maxBaseQual 40&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Recommended usage without Deduper: &lt;br /&gt;
&lt;br /&gt;
 /usr/cluster/bin/bam recab --in ${INPUT}.bam --out ${OUTPUT}.bam --refFile ${REF} --dbsnp ${DBSNP} --storeQualTag OQ --maxBaseQual 40&lt;br /&gt;
&lt;br /&gt;
= Usage =&lt;br /&gt;
 ./bam recab (options) --in &amp;lt;InputBamFile&amp;gt; --out &amp;lt;OutputFile&amp;gt; [--log &amp;lt;logFile&amp;gt;] [--verbose] [--noeof] [--params] --refFile &amp;lt;ReferenceFile&amp;gt; [--dbsnp &amp;lt;dbsnpFile&amp;gt;] [--minBaseQual &amp;lt;minBaseQual&amp;gt;] [--maxBaseQual &amp;lt;maxBaseQual&amp;gt;] [--blended &amp;lt;weight&amp;gt;] [--fitModel] [--fast] [--keepPrevDbsnp] [--keepPrevNonAdjacent] [--useLogReg] [--qualField &amp;lt;tag&amp;gt;] [--storeQualTag &amp;lt;tag&amp;gt;] [--buildExcludeFlags &amp;lt;flag&amp;gt;] [--applyExcludeFlags &amp;lt;flag&amp;gt;]&lt;br /&gt;
&lt;br /&gt;
= Parameters =&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Required General Parameters :&lt;br /&gt;
        --in &amp;lt;infile&amp;gt;   : input BAM file name&lt;br /&gt;
        --out &amp;lt;outfile&amp;gt; : output recalibration file name&lt;br /&gt;
Optional General Parameters :&lt;br /&gt;
        --log &amp;lt;logfile&amp;gt; : log and summary statistics (default: [outfile].log)&lt;br /&gt;
        --verbose       : Turn on verbose mode&lt;br /&gt;
        --noeof         : do not expect an EOF block on a bam file.&lt;br /&gt;
        --params        : print the parameter settings&lt;br /&gt;
&lt;br /&gt;
Recab Specific Required Parameters&lt;br /&gt;
        --refFile &amp;lt;reference file&amp;gt;    : reference file name&lt;br /&gt;
Recab Specific Optional Parameters :&lt;br /&gt;
        --dbsnp &amp;lt;known variance file&amp;gt; : dbsnp file of positions&lt;br /&gt;
        --minBaseQual &amp;lt;minBaseQual&amp;gt;   : minimum base quality of bases to recalibrate (default: 5)&lt;br /&gt;
        --maxBaseQual &amp;lt;maxBaseQual&amp;gt;   : maximum recalibrated base quality (default: 50)&lt;br /&gt;
                                        qualities over this value will be set to this value.&lt;br /&gt;
                                        This setting is applied after binning (if applicable).&lt;br /&gt;
        --blended &amp;lt;weight&amp;gt;            : blended model weight&lt;br /&gt;
        --fitModel                    : check if the logistic regression model fits the data&lt;br /&gt;
                                        overriden by fast, but automatically applied by useLogReg&lt;br /&gt;
        --fast                        : use a compact representation that only allows:&lt;br /&gt;
                                           * at most 256 Read Groups&lt;br /&gt;
                                           * maximum quality 63&lt;br /&gt;
                                           * at most 127 cycles&lt;br /&gt;
                                        overrides fitModel, but is overridden by useLogReg&lt;br /&gt;
                                        uses up to about 2.25G more memory than running without --fast.&lt;br /&gt;
        --keepPrevDbsnp               : do not exclude entries where the previous base is in dbsnp when&lt;br /&gt;
                                        building the recalibration table&lt;br /&gt;
                                        By default they are excluded from the table.&lt;br /&gt;
        --keepPrevNonAdjacent         : do not exclude entries where the previous base is not adjacent&lt;br /&gt;
                                        (not a Cigar M/X/=) when building the recalibration table&lt;br /&gt;
                                        By default they are excluded from the table (except the first cycle).&lt;br /&gt;
        --useLogReg                   : use logistic regression calculated quality for the new quality&lt;br /&gt;
                                        automatically applies fitModel and overrides fast.&lt;br /&gt;
        --qualField &amp;lt;quality tag&amp;gt;     : tag to get the starting base quality&lt;br /&gt;
                                        (default is to get it from the Quality field)&lt;br /&gt;
        --storeQualTag &amp;lt;quality tag&amp;gt;  : tag to store the previous quality into&lt;br /&gt;
        --buildExcludeFlags &amp;lt;flag&amp;gt;    : exclude reads with any of these flags set when building the&lt;br /&gt;
                                        recalibration table.  Default is 0xF04&lt;br /&gt;
        --applyExcludeFlags &amp;lt;flag&amp;gt;    : do not apply the recalibration table to any reads with any of these flags set&lt;br /&gt;
        Quality Binning Parameters (optional):&lt;br /&gt;
          Bin qualities by phred score, into the ranges specified by binQualS or binQualF (both cannot be used)&lt;br /&gt;
          Ranges are specified by comma separated minimum phred score for the bin, example: 1,17,20,30,40,50,70&lt;br /&gt;
          The first bin always starts at 0, so does not need to be specified.&lt;br /&gt;
          By default, the bin value is the low end of the range.&lt;br /&gt;
                --binQualS   : Bin the Qualities as specified (phred): minQualOfBin2, minQualofBin3...&lt;br /&gt;
                --binQualF   : Bin the Qualities based on the specified file&lt;br /&gt;
                --binMid     : Use the mid point of the quality bin range for the quality value of the bin.&lt;br /&gt;
                --binHigh    : Use the high end of the quality bin range for the quality value of the bin.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
{{PhoneHomeParamDesc}}&lt;br /&gt;
&lt;br /&gt;
== Required Generic Parameters ==&lt;br /&gt;
{{inBAMInputFile|noStdin=1}}&lt;br /&gt;
{{outBAMOutputFile}}&lt;br /&gt;
&lt;br /&gt;
== Optional Generic Parameters ==&lt;br /&gt;
=== Output log &amp;amp; Summary Statistics FileName (&amp;lt;code&amp;gt;--log&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
Output file name for writing logs &amp;amp; summary statistics.&lt;br /&gt;
&lt;br /&gt;
If this parameter is not specified, it will write to the output file specified in &amp;lt;code&amp;gt;--out&amp;lt;/code&amp;gt; + &amp;quot;.log&amp;quot;.  Or if the output bam is written to stdout (&amp;lt;code&amp;gt;--out&amp;lt;/code&amp;gt; starts with &#039;-&#039;), the logs will be written to stderr.  If the filename after --log starts with &#039;-&#039; it will write to stderr.&lt;br /&gt;
&lt;br /&gt;
=== Turn on Verbose Mode (&amp;lt;code&amp;gt;--verbose&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
Turn on verbose logging to get more log messages in the log and to stderr.&lt;br /&gt;
&lt;br /&gt;
{{noeofBGZFParameter}}&lt;br /&gt;
{{paramsParameter}}&lt;br /&gt;
&lt;br /&gt;
{{PhoneHomeParameters}}&lt;br /&gt;
&lt;br /&gt;
== Required Recalibration Parameters ==&lt;br /&gt;
=== Reference File (&amp;lt;code&amp;gt;--refFile&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
The reference file is a required parameter used for comparing read bases to the reference.&lt;br /&gt;
&lt;br /&gt;
== Optional Recalibration Parameters ==&lt;br /&gt;
&lt;br /&gt;
=== DBSNP File (&amp;lt;code&amp;gt;--dbsnp&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
The dbsnp file that specifies positions to skip recalibrating.  Tab delimited file with the chromosome in the first column and the 1-based position in the 2nd column.&lt;br /&gt;
&lt;br /&gt;
=== Minimum Recalibration Base Quality (&amp;lt;code&amp;gt;--minBaseQual&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
When recalibrating reads, only positions with a base quality greater than this minimum phred quality will be recalibrated.  If &amp;lt;code&amp;gt;--minBaseQual&amp;lt;/code&amp;gt; is not specified, it is defaulted to 5. &lt;br /&gt;
&lt;br /&gt;
The ILLUMINA specs indicate that any quality below 5 can be used as an error indicator so we do not want to recalibrate those.&lt;br /&gt;
&lt;br /&gt;
=== Maximum Recalibration Base Quality (&amp;lt;code&amp;gt;--maxBaseQual&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
This value sets the maximum phred base quality assigned to a base after recalibrating. Any qualities above this value will be set to this value.  It is defaulted to 50. &lt;br /&gt;
&lt;br /&gt;
=== Blended Model Weight (&amp;lt;code&amp;gt;--blended&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;TBD - this parameter is not yet implemented.&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Fit Model (&amp;lt;code&amp;gt;--fitModel&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
Check if the logistic regression model fits the data.&lt;br /&gt;
&lt;br /&gt;
This option does NOT set the new qualities to the logistic regression calculated qualities, it only checks the fit.  To apply the logistic regression qualities, see [[#Logistic Regression (--useLogReg)|&amp;lt;code&amp;gt;--useLogReg&amp;lt;/code&amp;gt;]].  &amp;lt;code&amp;gt;--fitModel&amp;lt;/code&amp;gt; is automatically applied when &amp;lt;code&amp;gt;--useLogReg&amp;lt;/code&amp;gt; is specified.&lt;br /&gt;
	                               &lt;br /&gt;
This option cannot be used in conjunction with [[#Fast Recalibration (--fast)|&amp;lt;code&amp;gt;--fast&amp;lt;/code&amp;gt;]] and is overriden by &amp;lt;code&amp;gt;--fast&amp;lt;/code&amp;gt;, but automatically applied by useLogReg&lt;br /&gt;
&lt;br /&gt;
=== Fast Recalibration (&amp;lt;code&amp;gt;--fast&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
Use a compact representation of the Recalibration Table that only allows:&lt;br /&gt;
* at most 256 Read Groups&lt;br /&gt;
* maximum quality 63&lt;br /&gt;
* at most 127 cycles&lt;br /&gt;
&lt;br /&gt;
This option will run faster than the default recalibration, but uses up to about 2.25G more memory than running without --fast.&lt;br /&gt;
&lt;br /&gt;
This option cannot be used in conjunction with [[#Fit Model (--fitModel)|&amp;lt;code&amp;gt;--fitModel&amp;lt;/code&amp;gt;]], or [[#Logistic Regression (--useLogReg)|&amp;lt;code&amp;gt;--useLogReg&amp;lt;/code&amp;gt;]] and overrides [[#Fit Model (--fitModel)|&amp;lt;code&amp;gt;--fitModel&amp;lt;/code&amp;gt;]], but is overridden by [[#Logistic Regression (--useLogReg)|&amp;lt;code&amp;gt;--useLogReg&amp;lt;/code&amp;gt;]].&lt;br /&gt;
&lt;br /&gt;
=== Allow Previous Base DBSNP (&amp;lt;code&amp;gt;--keepPrevDbsnp&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
By default bases where the previous base is in DBSNP are excluded from the Recalibration Table.&lt;br /&gt;
&lt;br /&gt;
This option includes these bases in the building of the Recalibration Table.&lt;br /&gt;
&lt;br /&gt;
=== Allow Previous Base Non-Match/Mismatch (&amp;lt;code&amp;gt;--keepPrevNonAdjacent&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
By default bases where the previous base is not a CIGAR Match/Mismatch are excluded from the Recalibration Table.&lt;br /&gt;
&lt;br /&gt;
This option includes these bases in the building of the Recalibration Table.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Logistic Regression (&amp;lt;code&amp;gt;--useLogReg&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
Use the logistic regression empirical qualities for setting the new base qualities instead of the default formula.&lt;br /&gt;
&lt;br /&gt;
This option automatically enables [[#Fit Model (--fitModel)|&amp;lt;code&amp;gt;--fitModel&amp;lt;/code&amp;gt;]] and disables [[#Fast Recalibration (--fast)|&amp;lt;code&amp;gt;--fast&amp;lt;/code&amp;gt;]].&lt;br /&gt;
&lt;br /&gt;
=== Read the quality from a tag (&amp;lt;code&amp;gt;--qualField&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
If this parameter is set, then read the quality string from the specified tag name.  If the tag is not found, the quality is read from the quality field.&lt;br /&gt;
&lt;br /&gt;
=== Store the original quality (&amp;lt;code&amp;gt;--storeQualTag&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
If this parameter is set, the original quality will be stored as a string in the specified tag.&lt;br /&gt;
&lt;br /&gt;
=== Skip Records with any of the Specified Flags (&amp;lt;code&amp;gt;--buildExcludeFlags&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;--applyExcludeFlags&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
Use &amp;lt;code&amp;gt;--buildExcludeFlags&amp;lt;/code&amp;gt; to skip records with any of the specified flags set when building the recalibration table, default 0xF04.&lt;br /&gt;
&lt;br /&gt;
By default, when building the recalibration table reads with any of the following flags set are skipped:&lt;br /&gt;
* unmapped&lt;br /&gt;
* secondary alignment&lt;br /&gt;
* fails QC checks&lt;br /&gt;
* duplicate&lt;br /&gt;
* supplementary alignment&lt;br /&gt;
&lt;br /&gt;
Use &amp;lt;code&amp;gt;--applyExcludeFlags&amp;lt;/code&amp;gt; to skip records with any of the specified flags set when applying the recalibration table.  The default value is 0x000, do not skip any reads.&lt;br /&gt;
&lt;br /&gt;
= Return Value =&lt;br /&gt;
&lt;br /&gt;
Returns -1 if input parameters are invalid.&lt;br /&gt;
&lt;br /&gt;
Returns the SamStatus for the reads/writes (0 on success, non-0 on failure).&lt;/div&gt;</summary>
		<author><name>Mktrost</name></author>
	</entry>
	<entry>
		<id>http://genome.sph.umich.edu/w/index.php?title=BamUtil:_recab&amp;diff=15103</id>
		<title>BamUtil: recab</title>
		<link rel="alternate" type="text/html" href="http://genome.sph.umich.edu/w/index.php?title=BamUtil:_recab&amp;diff=15103"/>
		<updated>2019-04-20T03:00:41Z</updated>

		<summary type="html">&lt;p&gt;Mktrost: /* Handling Recalibration/Implementation Notes */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:BamUtil|validate]]&lt;br /&gt;
[[Category:BAM Software]]&lt;br /&gt;
[[Category:Software]]&lt;br /&gt;
&lt;br /&gt;
= Overview of the &amp;lt;code&amp;gt;recab&amp;lt;/code&amp;gt; function of &amp;lt;code&amp;gt;[[bamUtil]]&amp;lt;/code&amp;gt; =&lt;br /&gt;
The &amp;lt;code&amp;gt;recab&amp;lt;/code&amp;gt; option of [[bamUtil]] recalibrates a SAM/BAM file. &lt;br /&gt;
&lt;br /&gt;
Recalibration can also be called as an option of [[bamUtil: dedup]].  This will perform the recalibration and  the deduping in the same set of steps, increasing processing speed.&lt;br /&gt;
&lt;br /&gt;
==Handling Recalibration/Implementation Notes==&lt;br /&gt;
&lt;br /&gt;
Recalibration is a 2-step process that loops through the file twice (stdin is not support as input):&lt;br /&gt;
# Build Recalibration Table&lt;br /&gt;
# Apply Recalibration Table&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Recalibration Table groups bases based on a set of covariates:&lt;br /&gt;
* Read Group&lt;br /&gt;
* Quality (either from the quality string or [[#Read the quality from a tag (--qualField)|from a tag]])&lt;br /&gt;
* Cycle (reverse complement for reverse strands)&lt;br /&gt;
* 1st/2nd read in pair&lt;br /&gt;
* Previous Cycle&#039;s Base (reverse complement for reverse strands)&lt;br /&gt;
* This Cycle&#039;s Base (reverse complement for reverse strands)&lt;br /&gt;
&lt;br /&gt;
The Recalibration Table tracks the number of matches/mismatches for each set of covariates.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Only bases meeting all of the following criteria are used to Build the Recalibration Table:&lt;br /&gt;
* Read criteria&lt;br /&gt;
** not a duplicate&lt;br /&gt;
** mapped&lt;br /&gt;
** mapping quality != 0&lt;br /&gt;
** mapping quality != 255&lt;br /&gt;
* Base criteria&lt;br /&gt;
** match/mismatch (not an insertion/deletion/skip/clip)&lt;br /&gt;
** not a [[#DBSNP File (--dbsnp)|dbSNP position]]&lt;br /&gt;
** base quality &amp;gt; [[#Minimum Recalibration Base Quality (--minBaseQual)|minBaseQual (5 by default)]]&lt;br /&gt;
* Additional criteria for cycle != 1 (can be turned off via flags)&lt;br /&gt;
** previous base is a CIGAR Match/Mismatch (Use [[#Allow Previous Base Non-Match/Mismatch (--keepPrevNonAdjacent)|&amp;lt;code&amp;gt;--keepPrevNonAdjacent&amp;lt;/code&amp;gt;]] to disable)&lt;br /&gt;
** previous base position is not a [[#DBSNP File (--dbsnp)|dbSNP position]] (Use [[#Allow Previous Base DBSNP (--keepPrevDbsnp)|&amp;lt;code&amp;gt;--keepPrevDbsnp&amp;lt;/code&amp;gt;]] to disable)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Recalibration Table is applied to all bases meeting all of the following criteria (even if they were not used for creating the table):&lt;br /&gt;
* base quality &amp;gt; [[#Minimum Recalibration Base Quality (--minBaseQual)|minBaseQual (5 by default)]]&lt;br /&gt;
* at least 1 match or mismatch for the set of covariates&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Recalibrated Quality is: &amp;lt;math&amp;gt;-10 * \log \frac{mismatches + 1}{mismatches + matches + 1}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Alternatively, [[#Logistic Regression (--useLogReg)|logistic regression]] can be used for calculating the new quality.&lt;br /&gt;
&lt;br /&gt;
If the Recalibrated Quality is greater than [[#Maximum Recalibration Base Quality (--maxBaseQual)|maxBaseQual]], the updated quality is set to maxBaseQual.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Optionally, the previous quality can be [[#Store the original quality (--storeQualTag)|stored in a tag]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The current recalibration logic was designed for recalibrating ILLUMINA data.&lt;br /&gt;
&lt;br /&gt;
NOTE: GATK ignores/skips adapters, but our logic does not.&lt;br /&gt;
&lt;br /&gt;
== How to use it ==&lt;br /&gt;
&lt;br /&gt;
When &amp;lt;code&amp;gt;recab&amp;lt;/code&amp;gt; is invoked without any arguments the usage information is displayed as described below under [[#Usage|Usage]].&lt;br /&gt;
&lt;br /&gt;
The input SAM/BAM file ([[#input File (--in)|--in]]), the output SAM/BAM file ([[#output File (--out)|--out]]), and the reference file ([[#Reference File (--refFile)|--refFile]]) are required inputs.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Recommended usage with Deduper: &lt;br /&gt;
&lt;br /&gt;
 /usr/cluster/bin/bam dedup --recab --in ${INPUT}.bam --out ${OUTPUT}.bam --force --refFile ${REF} --dbsnp ${DBSNP} --oneChrom --storeQualTag OQ --maxBaseQual 40&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Recommended usage without Deduper: &lt;br /&gt;
&lt;br /&gt;
 /usr/cluster/bin/bam recab --in ${INPUT}.bam --out ${OUTPUT}.bam --refFile ${REF} --dbsnp ${DBSNP} --storeQualTag OQ --maxBaseQual 40&lt;br /&gt;
&lt;br /&gt;
= Usage =&lt;br /&gt;
 ./bam recab (options) --in &amp;lt;InputBamFile&amp;gt; --out &amp;lt;OutputFile&amp;gt; [--log &amp;lt;logFile&amp;gt;] [--verbose] [--noeof] [--params] --refFile &amp;lt;ReferenceFile&amp;gt; [--dbsnp &amp;lt;dbsnpFile&amp;gt;] [--minBaseQual &amp;lt;minBaseQual&amp;gt;] [--maxBaseQual &amp;lt;maxBaseQual&amp;gt;] [--blended &amp;lt;weight&amp;gt;] [--fitModel] [--fast] [--keepPrevDbsnp] [--keepPrevNonAdjacent] [--useLogReg] [--qualField &amp;lt;tag&amp;gt;] [--storeQualTag &amp;lt;tag&amp;gt;] [--buildExcludeFlags &amp;lt;flag&amp;gt;] [--applyExcludeFlags &amp;lt;flag&amp;gt;]&lt;br /&gt;
&lt;br /&gt;
= Parameters =&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Required General Parameters :&lt;br /&gt;
        --in &amp;lt;infile&amp;gt;   : input BAM file name&lt;br /&gt;
        --out &amp;lt;outfile&amp;gt; : output recalibration file name&lt;br /&gt;
Optional General Parameters :&lt;br /&gt;
        --log &amp;lt;logfile&amp;gt; : log and summary statistics (default: [outfile].log)&lt;br /&gt;
        --verbose       : Turn on verbose mode&lt;br /&gt;
        --noeof         : do not expect an EOF block on a bam file.&lt;br /&gt;
        --params        : print the parameter settings&lt;br /&gt;
&lt;br /&gt;
Recab Specific Required Parameters&lt;br /&gt;
        --refFile &amp;lt;reference file&amp;gt;    : reference file name&lt;br /&gt;
Recab Specific Optional Parameters :&lt;br /&gt;
        --dbsnp &amp;lt;known variance file&amp;gt; : dbsnp file of positions&lt;br /&gt;
        --minBaseQual &amp;lt;minBaseQual&amp;gt;   : minimum base quality of bases to recalibrate (default: 5)&lt;br /&gt;
        --maxBaseQual &amp;lt;maxBaseQual&amp;gt;   : maximum recalibrated base quality (default: 50)&lt;br /&gt;
                                        qualities over this value will be set to this value.&lt;br /&gt;
                                        This setting is applied after binning (if applicable).&lt;br /&gt;
        --blended &amp;lt;weight&amp;gt;            : blended model weight&lt;br /&gt;
        --fitModel                    : check if the logistic regression model fits the data&lt;br /&gt;
                                        overriden by fast, but automatically applied by useLogReg&lt;br /&gt;
        --fast                        : use a compact representation that only allows:&lt;br /&gt;
                                           * at most 256 Read Groups&lt;br /&gt;
                                           * maximum quality 63&lt;br /&gt;
                                           * at most 127 cycles&lt;br /&gt;
                                        overrides fitModel, but is overridden by useLogReg&lt;br /&gt;
                                        uses up to about 2.25G more memory than running without --fast.&lt;br /&gt;
        --keepPrevDbsnp               : do not exclude entries where the previous base is in dbsnp when&lt;br /&gt;
                                        building the recalibration table&lt;br /&gt;
                                        By default they are excluded from the table.&lt;br /&gt;
        --keepPrevNonAdjacent         : do not exclude entries where the previous base is not adjacent&lt;br /&gt;
                                        (not a Cigar M/X/=) when building the recalibration table&lt;br /&gt;
                                        By default they are excluded from the table (except the first cycle).&lt;br /&gt;
        --useLogReg                   : use logistic regression calculated quality for the new quality&lt;br /&gt;
                                        automatically applies fitModel and overrides fast.&lt;br /&gt;
        --qualField &amp;lt;quality tag&amp;gt;     : tag to get the starting base quality&lt;br /&gt;
                                        (default is to get it from the Quality field)&lt;br /&gt;
        --storeQualTag &amp;lt;quality tag&amp;gt;  : tag to store the previous quality into&lt;br /&gt;
        --buildExcludeFlags &amp;lt;flag&amp;gt;    : exclude reads with any of these flags set when building the&lt;br /&gt;
                                        recalibration table.  Default is 0xF04&lt;br /&gt;
        --applyExcludeFlags &amp;lt;flag&amp;gt;    : do not apply the recalibration table to any reads with any of these flags set&lt;br /&gt;
        Quality Binning Parameters (optional):&lt;br /&gt;
          Bin qualities by phred score, into the ranges specified by binQualS or binQualF (both cannot be used)&lt;br /&gt;
          Ranges are specified by comma separated minimum phred score for the bin, example: 1,17,20,30,40,50,70&lt;br /&gt;
          The first bin always starts at 0, so does not need to be specified.&lt;br /&gt;
          By default, the bin value is the low end of the range.&lt;br /&gt;
                --binQualS   : Bin the Qualities as specified (phred): minQualOfBin2, minQualofBin3...&lt;br /&gt;
                --binQualF   : Bin the Qualities based on the specified file&lt;br /&gt;
                --binMid     : Use the mid point of the quality bin range for the quality value of the bin.&lt;br /&gt;
                --binHigh    : Use the high end of the quality bin range for the quality value of the bin.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
{{PhoneHomeParamDesc}}&lt;br /&gt;
&lt;br /&gt;
== Required Generic Parameters ==&lt;br /&gt;
{{inBAMInputFile}}&lt;br /&gt;
{{outBAMOutputFile}}&lt;br /&gt;
&lt;br /&gt;
== Optional Generic Parameters ==&lt;br /&gt;
=== Output log &amp;amp; Summary Statistics FileName (&amp;lt;code&amp;gt;--log&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
Output file name for writing logs &amp;amp; summary statistics.&lt;br /&gt;
&lt;br /&gt;
If this parameter is not specified, it will write to the output file specified in &amp;lt;code&amp;gt;--out&amp;lt;/code&amp;gt; + &amp;quot;.log&amp;quot;.  Or if the output bam is written to stdout (&amp;lt;code&amp;gt;--out&amp;lt;/code&amp;gt; starts with &#039;-&#039;), the logs will be written to stderr.  If the filename after --log starts with &#039;-&#039; it will write to stderr.&lt;br /&gt;
&lt;br /&gt;
=== Turn on Verbose Mode (&amp;lt;code&amp;gt;--verbose&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
Turn on verbose logging to get more log messages in the log and to stderr.&lt;br /&gt;
&lt;br /&gt;
{{noeofBGZFParameter}}&lt;br /&gt;
{{paramsParameter}}&lt;br /&gt;
&lt;br /&gt;
{{PhoneHomeParameters}}&lt;br /&gt;
&lt;br /&gt;
== Required Recalibration Parameters ==&lt;br /&gt;
=== Reference File (&amp;lt;code&amp;gt;--refFile&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
The reference file is a required parameter used for comparing read bases to the reference.&lt;br /&gt;
&lt;br /&gt;
== Optional Recalibration Parameters ==&lt;br /&gt;
&lt;br /&gt;
=== DBSNP File (&amp;lt;code&amp;gt;--dbsnp&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
The dbsnp file that specifies positions to skip recalibrating.  Tab delimited file with the chromosome in the first column and the 1-based position in the 2nd column.&lt;br /&gt;
&lt;br /&gt;
=== Minimum Recalibration Base Quality (&amp;lt;code&amp;gt;--minBaseQual&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
When recalibrating reads, only positions with a base quality greater than this minimum phred quality will be recalibrated.  If &amp;lt;code&amp;gt;--minBaseQual&amp;lt;/code&amp;gt; is not specified, it is defaulted to 5. &lt;br /&gt;
&lt;br /&gt;
The ILLUMINA specs indicate that any quality below 5 can be used as an error indicator so we do not want to recalibrate those.&lt;br /&gt;
&lt;br /&gt;
=== Maximum Recalibration Base Quality (&amp;lt;code&amp;gt;--maxBaseQual&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
This value sets the maximum phred base quality assigned to a base after recalibrating. Any qualities above this value will be set to this value.  It is defaulted to 50. &lt;br /&gt;
&lt;br /&gt;
=== Blended Model Weight (&amp;lt;code&amp;gt;--blended&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;TBD - this parameter is not yet implemented.&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Fit Model (&amp;lt;code&amp;gt;--fitModel&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
Check if the logistic regression model fits the data.&lt;br /&gt;
&lt;br /&gt;
This option does NOT set the new qualities to the logistic regression calculated qualities, it only checks the fit.  To apply the logistic regression qualities, see [[#Logistic Regression (--useLogReg)|&amp;lt;code&amp;gt;--useLogReg&amp;lt;/code&amp;gt;]].  &amp;lt;code&amp;gt;--fitModel&amp;lt;/code&amp;gt; is automatically applied when &amp;lt;code&amp;gt;--useLogReg&amp;lt;/code&amp;gt; is specified.&lt;br /&gt;
	                               &lt;br /&gt;
This option cannot be used in conjunction with [[#Fast Recalibration (--fast)|&amp;lt;code&amp;gt;--fast&amp;lt;/code&amp;gt;]] and is overriden by &amp;lt;code&amp;gt;--fast&amp;lt;/code&amp;gt;, but automatically applied by useLogReg&lt;br /&gt;
&lt;br /&gt;
=== Fast Recalibration (&amp;lt;code&amp;gt;--fast&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
Use a compact representation of the Recalibration Table that only allows:&lt;br /&gt;
* at most 256 Read Groups&lt;br /&gt;
* maximum quality 63&lt;br /&gt;
* at most 127 cycles&lt;br /&gt;
&lt;br /&gt;
This option will run faster than the default recalibration, but uses up to about 2.25G more memory than running without --fast.&lt;br /&gt;
&lt;br /&gt;
This option cannot be used in conjunction with [[#Fit Model (--fitModel)|&amp;lt;code&amp;gt;--fitModel&amp;lt;/code&amp;gt;]], or [[#Logistic Regression (--useLogReg)|&amp;lt;code&amp;gt;--useLogReg&amp;lt;/code&amp;gt;]] and overrides [[#Fit Model (--fitModel)|&amp;lt;code&amp;gt;--fitModel&amp;lt;/code&amp;gt;]], but is overridden by [[#Logistic Regression (--useLogReg)|&amp;lt;code&amp;gt;--useLogReg&amp;lt;/code&amp;gt;]].&lt;br /&gt;
&lt;br /&gt;
=== Allow Previous Base DBSNP (&amp;lt;code&amp;gt;--keepPrevDbsnp&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
By default bases where the previous base is in DBSNP are excluded from the Recalibration Table.&lt;br /&gt;
&lt;br /&gt;
This option includes these bases in the building of the Recalibration Table.&lt;br /&gt;
&lt;br /&gt;
=== Allow Previous Base Non-Match/Mismatch (&amp;lt;code&amp;gt;--keepPrevNonAdjacent&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
By default bases where the previous base is not a CIGAR Match/Mismatch are excluded from the Recalibration Table.&lt;br /&gt;
&lt;br /&gt;
This option includes these bases in the building of the Recalibration Table.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Logistic Regression (&amp;lt;code&amp;gt;--useLogReg&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
Use the logistic regression empirical qualities for setting the new base qualities instead of the default formula.&lt;br /&gt;
&lt;br /&gt;
This option automatically enables [[#Fit Model (--fitModel)|&amp;lt;code&amp;gt;--fitModel&amp;lt;/code&amp;gt;]] and disables [[#Fast Recalibration (--fast)|&amp;lt;code&amp;gt;--fast&amp;lt;/code&amp;gt;]].&lt;br /&gt;
&lt;br /&gt;
=== Read the quality from a tag (&amp;lt;code&amp;gt;--qualField&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
If this parameter is set, then read the quality string from the specified tag name.  If the tag is not found, the quality is read from the quality field.&lt;br /&gt;
&lt;br /&gt;
=== Store the original quality (&amp;lt;code&amp;gt;--storeQualTag&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
If this parameter is set, the original quality will be stored as a string in the specified tag.&lt;br /&gt;
&lt;br /&gt;
=== Skip Records with any of the Specified Flags (&amp;lt;code&amp;gt;--buildExcludeFlags&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;--applyExcludeFlags&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
Use &amp;lt;code&amp;gt;--buildExcludeFlags&amp;lt;/code&amp;gt; to skip records with any of the specified flags set when building the recalibration table, default 0xF04.&lt;br /&gt;
&lt;br /&gt;
By default, when building the recalibration table reads with any of the following flags set are skipped:&lt;br /&gt;
* unmapped&lt;br /&gt;
* secondary alignment&lt;br /&gt;
* fails QC checks&lt;br /&gt;
* duplicate&lt;br /&gt;
* supplementary alignment&lt;br /&gt;
&lt;br /&gt;
Use &amp;lt;code&amp;gt;--applyExcludeFlags&amp;lt;/code&amp;gt; to skip records with any of the specified flags set when applying the recalibration table.  The default value is 0x000, do not skip any reads.&lt;br /&gt;
&lt;br /&gt;
= Return Value =&lt;br /&gt;
&lt;br /&gt;
Returns -1 if input parameters are invalid.&lt;br /&gt;
&lt;br /&gt;
Returns the SamStatus for the reads/writes (0 on success, non-0 on failure).&lt;/div&gt;</summary>
		<author><name>Mktrost</name></author>
	</entry>
	<entry>
		<id>http://genome.sph.umich.edu/w/index.php?title=BamUtil:_dedup&amp;diff=15092</id>
		<title>BamUtil: dedup</title>
		<link rel="alternate" type="text/html" href="http://genome.sph.umich.edu/w/index.php?title=BamUtil:_dedup&amp;diff=15092"/>
		<updated>2019-04-09T02:31:36Z</updated>

		<summary type="html">&lt;p&gt;Mktrost: /* Required Parameters */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:BamUtil|validate]]&lt;br /&gt;
[[Category:BAM Software]]&lt;br /&gt;
[[Category:Software]]&lt;br /&gt;
&lt;br /&gt;
= Overview of the &amp;lt;code&amp;gt;dedup&amp;lt;/code&amp;gt; function of &amp;lt;code&amp;gt;[[bamUtil]]&amp;lt;/code&amp;gt; =&lt;br /&gt;
The &amp;lt;code&amp;gt;dedup&amp;lt;/code&amp;gt; option of [[bamUtil]] determines duplicates in a coordinate sorted SAM/BAM file. It either marks or removes the lower quality duplicates.&lt;br /&gt;
&lt;br /&gt;
This tool also contains the option to perform recalibration.&lt;br /&gt;
&lt;br /&gt;
NOTE: This tool does not properly work on templates that have more than 2 segments.  It does not properly match reads when more than 2 reads have the same read name.&lt;br /&gt;
&lt;br /&gt;
NOTE: Dedup cannot read from stdin since it reads the input file twice.&lt;br /&gt;
&lt;br /&gt;
Potential future features:&lt;br /&gt;
* Soft clip overlapping reads (for now, use: [[BamUtil: clipOverlap]])&lt;br /&gt;
&lt;br /&gt;
==Handling Duplicates==&lt;br /&gt;
&lt;br /&gt;
The deduper reads all the alignments in a coordinate-sorted SAM/BAM looking for duplicates, failing if the file is not coordinate-sorted.&lt;br /&gt;
&lt;br /&gt;
The deduper assumes that duplicates in the input BAM file are not marked.  When the deduper detects a marked duplicate in the input BAM file, it will throw an error and stop.  To override this behavior, use the [[#Ignore Previous Duplicate Marking (--force)|&amp;lt;code&amp;gt;--force&amp;lt;/code&amp;gt;]] option;  in this mode, alignments that are marked as duplicates in the input file are unmarked before the deduper begins its detection algorithm.  The result is that only duplicates detected by the deduper will be marked in or removed from the output file.&lt;br /&gt;
&lt;br /&gt;
The handling of paired-end reads assumes that the mate information in the SAM/BAM records is accurate.  If a mate is not found at the expected position, an error message is printed (once per file) indicating this error.  Paired-end reads whose mate cannot be found are not marked duplicate and are not used for duplicate marking of other paired-end reads.  Single-end reads with the same key as paired-end reads whose mate cannot be found are still marked as duplicate.  If this error is encountered, you may want to fix the mate information and reprocess the file through the deduper.  &lt;br /&gt;
&lt;br /&gt;
With the default settings this tool should produce similar results as Picard.&lt;br /&gt;
&lt;br /&gt;
Use the [[#Treat Reads with Mates On Different Chromosomes As Single-Ended (--oneChrom)|&amp;lt;code&amp;gt;--oneChrom&amp;lt;/code&amp;gt;]] option to treat reads with a mate on a different chromosome as single-ended.  This option is useful if you are running the deduper on just a single chromosome.  The code will use less memory with this option if mates are found on different chromosomes.  (Picard does not specially handle mates on different chromosomes, so the --oneChrom option may produce different results than Picard.)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Implementation Notes ===&lt;br /&gt;
Duplicates are determined by checking for matching keys.  &lt;br /&gt;
&lt;br /&gt;
The Key is comprised of:&lt;br /&gt;
# Chromosome&lt;br /&gt;
# Orientation (forward/reverse)&lt;br /&gt;
# Unclipped Start(forward)/End(reverse)&lt;br /&gt;
# Library&lt;br /&gt;
&lt;br /&gt;
Rules:&lt;br /&gt;
* Skip Unmapped Reads, they are not marked as duplicate&lt;br /&gt;
* Reads whose mate is unmapped are treated as single-end&lt;br /&gt;
* Mark a Single-End Read Duplicate (or remove it if configured to do so) if:&lt;br /&gt;
*# A paired-end record has the same key (even if the pair is not proper/the mate is not found)&amp;lt;br/&amp;gt;-OR-&lt;br /&gt;
*# A single-end record has the same key and a higher base quality sum (sum of all base qualities in the record above [[#Minimum Quality for Quality Calculations (--minQual)|&amp;lt;code&amp;gt;--minBaseQual&amp;lt;/code&amp;gt;]])&lt;br /&gt;
* Mark both Paired-End Reads Duplicate if:&lt;br /&gt;
# Another paired-end pair has the same set of keys and has a higher base quality sum (sum of all base qualities in the record above [[#Minimum Quality for Quality Calculations (--minQual)|&amp;lt;code&amp;gt;--minBaseQual&amp;lt;/code&amp;gt;]])&lt;br /&gt;
 &lt;br /&gt;
This code assumes that at most 1000 bases are clipped at the start of a read.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Deduping requires two passes through the file, so cannot read from stdin.&lt;br /&gt;
&lt;br /&gt;
==Handling Recalibration==&lt;br /&gt;
See [[BamUtil: recab]] for recalibration details.&lt;br /&gt;
&lt;br /&gt;
Recalibration parameters can be applied to deduping when --recab is specified.&lt;br /&gt;
&lt;br /&gt;
== How to use it ==&lt;br /&gt;
&lt;br /&gt;
When &amp;lt;code&amp;gt;dedup&amp;lt;/code&amp;gt; is invoked without any arguments the usage information is displayed as described below under [[#Usage|Usage]].&lt;br /&gt;
&lt;br /&gt;
The input SAM/BAM file is required, [[#input File (--in)|input File (--in)]], and must be sorted by coordinate.&lt;br /&gt;
&lt;br /&gt;
The output SAM/BAM file is also required, [[#output File (--out)|output File (--out)]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Recommended usage with Recalibrator: &lt;br /&gt;
&lt;br /&gt;
 /usr/cluster/bin/bam dedup --recab --in ${INPUT}.bam --out ${OUTPUT}.bam --force --refFile ${REF} --dbsnp ${DBSNP} --oneChrom --storeQualTag OQ --maxBaseQual 40&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Recommended usage without Recalibrator: &lt;br /&gt;
&lt;br /&gt;
 /usr/cluster/bin/bam dedup --in ${INPUT}.bam --out ${OUTPUT}.bam --force --oneChrom&lt;br /&gt;
&lt;br /&gt;
= Usage =&lt;br /&gt;
 ./bam dedup --in &amp;lt;InputBamFile&amp;gt; --out &amp;lt;OutputBamFile&amp;gt; [--minQual &amp;lt;minPhred&amp;gt;] [--log &amp;lt;logFile&amp;gt;] [--oneChrom] [--rmDups] [--force] [--excludeFlags &amp;lt;flag&amp;gt;] [--verbose] [--noeof] [--params] [--recab]&lt;br /&gt;
&lt;br /&gt;
Additional Recalibration Usage is documented at [[BamUtil: recab#Usage|BamUtil: recab -&amp;gt; Usage]]&lt;br /&gt;
&lt;br /&gt;
= Parameters =&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Required parameters :&lt;br /&gt;
	--in &amp;lt;infile&amp;gt;   : Input BAM file name (must be sorted)&lt;br /&gt;
	--out &amp;lt;outfile&amp;gt; : Output BAM file name (same order with original file)&lt;br /&gt;
Optional parameters : &lt;br /&gt;
	--minQual &amp;lt;int&amp;gt; : Only add scores over this phred quality when determining a read&#039;s quality (default: 15)&lt;br /&gt;
	--log &amp;lt;logfile&amp;gt; : Log and summary statistics (default: [outfile].log, or stderr if --out starts with &#039;-&#039;)&lt;br /&gt;
	--oneChrom      : Treat reads with mates on different chromosomes as single-ended.&lt;br /&gt;
	--rmDups        : Remove duplicates (default is to mark duplicates)&lt;br /&gt;
	--force         : Allow an already mark-duplicated BAM file, unmarking any previously marked &lt;br /&gt;
	                  duplicates and apply this duplicate marking logic.  Default is to throw errors&lt;br /&gt;
	                  and exit when trying to run on an already mark-duplicated BAM&lt;br /&gt;
	--excludeFlags &amp;lt;flag&amp;gt;    : exclude reads with any of these flags set when determining or marking duplicates&lt;br /&gt;
	                           by default (0xB04): exclude unmapped, secondary reads, QC failures, and supplementary reads&lt;br /&gt;
	--verbose       : Turn on verbose mode&lt;br /&gt;
	--noeof         : Do not expect an EOF block on a bam file.&lt;br /&gt;
	--params        : Print the parameter settings&lt;br /&gt;
	--recab         : Recalibrate in addition to deduping&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
{{PhoneHomeParamDesc}}&lt;br /&gt;
&lt;br /&gt;
Additional Recalibration Parameters are documented at [[BamUtil: recab#Parameters|BamUtil: recab -&amp;gt; Parameters]]&lt;br /&gt;
&lt;br /&gt;
== Required Parameters ==&lt;br /&gt;
{{inBAMInputFile|noStdin=1}}&lt;br /&gt;
&lt;br /&gt;
Note: The input file must be sorted by coordinate.&lt;br /&gt;
{{outBAMOutputFile}}&lt;br /&gt;
&lt;br /&gt;
== Optional Parameters==&lt;br /&gt;
=== Minimum Quality for Quality Calculations (&amp;lt;code&amp;gt;--minQual&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
When duplicate reads are encountered, the read with the highest quality is kept.&lt;br /&gt;
&lt;br /&gt;
To determine the quality of a read, all of the phred base quality scores above the &amp;lt;code&amp;gt;--minQual&amp;lt;/code&amp;gt; value are added together.  If &amp;lt;code&amp;gt;--minQual&amp;lt;/code&amp;gt; is not specified, it is defaulted to 15.&lt;br /&gt;
&lt;br /&gt;
=== Output log &amp;amp; Summary Statistics FileName (&amp;lt;code&amp;gt;--log&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
Output file name for writing logs &amp;amp; summary statistics.&lt;br /&gt;
&lt;br /&gt;
If this parameter is not specified, it will write to the output file specified in &amp;lt;code&amp;gt;--out&amp;lt;/code&amp;gt; + &amp;quot;.log&amp;quot;.  Or if the output bam is written to stdout (&amp;lt;code&amp;gt;--out&amp;lt;/code&amp;gt; starts with &#039;-&#039;), the logs will be written to stderr.  If the filename after --log starts with &#039;-&#039; it will write to stderr.&lt;br /&gt;
&lt;br /&gt;
=== Treat Reads with Mates On Different Chromosomes As Single-Ended (&amp;lt;code&amp;gt;--oneChrom&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
If a read&#039;s mate is not found it will not be used for duplicate marking.  If you are running on a single chromosome, all read&#039;s whose mates are on different chromosomes will not be used for duplicate marking.  The &amp;lt;code&amp;gt;--oneChrom&amp;lt;/code&amp;gt; option will treat reads with mates on a different chromosome as single-ended.&lt;br /&gt;
&lt;br /&gt;
=== Remove Duplicates (&amp;lt;code&amp;gt;--rmDups&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
Instead of marking a read as duplicate in the flag, the &amp;lt;code&amp;gt;--rmDups&amp;lt;/code&amp;gt; option will remove it from the output BAM file.  &lt;br /&gt;
&lt;br /&gt;
=== Ignore Previous Duplicate Marking (&amp;lt;code&amp;gt;--force&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
By default the deduper will throw an error and stop if a read is already marked as duplicate.  The &amp;lt;code&amp;gt;--force&amp;lt;/code&amp;gt; option will removes any previous duplicate marking and marks the reads from scratch.  The resulting output file will only have reads determined by the deduper marked as duplicates.&lt;br /&gt;
&lt;br /&gt;
=== Skip Records with any of the Specified Flags (&amp;lt;code&amp;gt;--excludeFlags&amp;lt;/code&amp;gt;)===&lt;br /&gt;
Skip records with any of the specified flags set, default 0xB04&lt;br /&gt;
&lt;br /&gt;
By default skips reads with any of the following flags set:&lt;br /&gt;
* unmapped&lt;br /&gt;
* secondary alignment&lt;br /&gt;
* fails QC checks&lt;br /&gt;
* supplementary reads&lt;br /&gt;
&lt;br /&gt;
Secondary (0x100) and Supplementary (0x800) reads currently must be excluded.&lt;br /&gt;
&lt;br /&gt;
=== Turn on Verbose Mode (&amp;lt;code&amp;gt;--verbose&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
Turn on verbose logging to get more log messages in the log and to stderr.&lt;br /&gt;
&lt;br /&gt;
{{noeofBGZFParameter}}&lt;br /&gt;
{{paramsParameter}}&lt;br /&gt;
&lt;br /&gt;
== Recalibrate (&amp;lt;code&amp;gt;--recab&amp;lt;/code&amp;gt;) ==&lt;br /&gt;
&lt;br /&gt;
This option will recalibrate the input file in addition to deduping.&lt;br /&gt;
&lt;br /&gt;
See [[BamUtil: recab]] for recalibration details.&lt;br /&gt;
&lt;br /&gt;
{{PhoneHomeParameters}}&lt;br /&gt;
&lt;br /&gt;
= Return Value =&lt;br /&gt;
&lt;br /&gt;
Returns -1 if input parameters are invalid.&lt;br /&gt;
&lt;br /&gt;
Returns the SamStatus for the reads/writes (0 on success, non-0 on failure).&lt;/div&gt;</summary>
		<author><name>Mktrost</name></author>
	</entry>
	<entry>
		<id>http://genome.sph.umich.edu/w/index.php?title=Template:InBAMInputFile&amp;diff=15091</id>
		<title>Template:InBAMInputFile</title>
		<link rel="alternate" type="text/html" href="http://genome.sph.umich.edu/w/index.php?title=Template:InBAMInputFile&amp;diff=15091"/>
		<updated>2019-04-09T02:31:23Z</updated>

		<summary type="html">&lt;p&gt;Mktrost: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{{hdr|===}}} Input File ({{#if: {{{noParam|}}} | {{{noParam}}} argument|&amp;lt;code&amp;gt;{{{param|--in}}}&amp;lt;/code&amp;gt;}}) {{{hdr|===}}}&lt;br /&gt;
&lt;br /&gt;
{{#if: {{{noParam|}}} | The {{{noParam}}} argument is the name of the input SAM/BAM file. |&lt;br /&gt;
Use &amp;lt;code&amp;gt;{{{param|--in}}}&amp;lt;/code&amp;gt; followed by your file name to specify the SAM/BAM input file.}}&lt;br /&gt;
&lt;br /&gt;
The program automatically determines if your input file is SAM/BAM/uncompressed BAM without any input other than a filename from the user{{#if: {{{noStdin|}}} |.|, unless your input file is stdin.}}&lt;br /&gt;
&lt;br /&gt;
{{#if: {{{noStdin|}}}|Note: This tool does not support input from stdin.|A &amp;lt;code&amp;gt;-&amp;lt;/code&amp;gt; is used to indicate to read from stdin and the extension is used to determine the file type (no extension indicates SAM).}}&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;1&amp;quot; cellspacing=&amp;quot;0&amp;quot; cellpadding=&amp;quot;2&amp;quot;&lt;br /&gt;
|SAM/BAM/Uncompressed BAM from file&lt;br /&gt;
| &amp;lt;code&amp;gt;{{#if: {{{noParam|}}} | |--in}} yourFileName&amp;lt;/code&amp;gt;&lt;br /&gt;
{{#if: {{{noStdin|}}} | |&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;SAM from stdin&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&amp;lt;code&amp;gt;{{#if: {{{noParam|}}} | |--in}} -&amp;lt;/code&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;BAM from stdin&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&amp;lt;code&amp;gt;{{#if: {{{noParam|}}} | |--in}} -.bam&amp;lt;/code&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;Uncompressed BAM from stdin&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&amp;lt;code&amp;gt;{{#if: {{{noParam|}}} | |--in}} -.ubam&amp;lt;/code&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;}}&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Note: Uncompressed BAM is compressed using compression level-0 (so it is not an entirely uncompressed file).  This matches the &amp;lt;code&amp;gt;samtools&amp;lt;/code&amp;gt; implementation so pipes between our tools and &amp;lt;code&amp;gt;samtools&amp;lt;/code&amp;gt; are supported.&lt;/div&gt;</summary>
		<author><name>Mktrost</name></author>
	</entry>
	<entry>
		<id>http://genome.sph.umich.edu/w/index.php?title=Template:InBAMInputFile&amp;diff=15090</id>
		<title>Template:InBAMInputFile</title>
		<link rel="alternate" type="text/html" href="http://genome.sph.umich.edu/w/index.php?title=Template:InBAMInputFile&amp;diff=15090"/>
		<updated>2019-04-09T02:30:41Z</updated>

		<summary type="html">&lt;p&gt;Mktrost: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{{hdr|===}}} Input File ({{#if: {{{noParam|}}} | {{{noParam}}} argument|&amp;lt;code&amp;gt;{{{param|--in}}}&amp;lt;/code&amp;gt;}}) {{{hdr|===}}}&lt;br /&gt;
&lt;br /&gt;
{{#if: {{{noParam|}}} | The {{{noParam}}} argument is the name of the input SAM/BAM file. |&lt;br /&gt;
Use &amp;lt;code&amp;gt;{{{param|--in}}}&amp;lt;/code&amp;gt; followed by your file name to specify the SAM/BAM input file.}}&lt;br /&gt;
&lt;br /&gt;
The program automatically determines if your input file is SAM/BAM/uncompressed BAM without any input other than a filename from the user{{#if: {{{noStdin|}}} |.|, unless your input file is stdin.}}&lt;br /&gt;
&lt;br /&gt;
{{#if: {{{noStdin|}}}|This tool does not support input from stdin.|A &amp;lt;code&amp;gt;-&amp;lt;/code&amp;gt; is used to indicate to read from stdin and the extension is used to determine the file type (no extension indicates SAM).}}&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;1&amp;quot; cellspacing=&amp;quot;0&amp;quot; cellpadding=&amp;quot;2&amp;quot;&lt;br /&gt;
|SAM/BAM/Uncompressed BAM from file&lt;br /&gt;
| &amp;lt;code&amp;gt;{{#if: {{{noParam|}}} | |--in}} yourFileName&amp;lt;/code&amp;gt;&lt;br /&gt;
{{#if: {{{noStdin|}}} | |&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;SAM from stdin&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&amp;lt;code&amp;gt;{{#if: {{{noParam|}}} | |--in}} -&amp;lt;/code&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;BAM from stdin&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&amp;lt;code&amp;gt;{{#if: {{{noParam|}}} | |--in}} -.bam&amp;lt;/code&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;Uncompressed BAM from stdin&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&amp;lt;code&amp;gt;{{#if: {{{noParam|}}} | |--in}} -.ubam&amp;lt;/code&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;}}&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Note: Uncompressed BAM is compressed using compression level-0 (so it is not an entirely uncompressed file).  This matches the &amp;lt;code&amp;gt;samtools&amp;lt;/code&amp;gt; implementation so pipes between our tools and &amp;lt;code&amp;gt;samtools&amp;lt;/code&amp;gt; are supported.&lt;/div&gt;</summary>
		<author><name>Mktrost</name></author>
	</entry>
	<entry>
		<id>http://genome.sph.umich.edu/w/index.php?title=Template:InBAMInputFile&amp;diff=15089</id>
		<title>Template:InBAMInputFile</title>
		<link rel="alternate" type="text/html" href="http://genome.sph.umich.edu/w/index.php?title=Template:InBAMInputFile&amp;diff=15089"/>
		<updated>2019-04-09T02:29:34Z</updated>

		<summary type="html">&lt;p&gt;Mktrost: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{{hdr|===}}} Input File ({{#if: {{{noParam|}}} | {{{noParam}}} argument|&amp;lt;code&amp;gt;{{{param|--in}}}&amp;lt;/code&amp;gt;}}) {{{hdr|===}}}&lt;br /&gt;
&lt;br /&gt;
{{#if: {{{noParam|}}} | The {{{noParam}}} argument is the name of the input SAM/BAM file. |&lt;br /&gt;
Use &amp;lt;code&amp;gt;{{{param|--in}}}&amp;lt;/code&amp;gt; followed by your file name to specify the SAM/BAM input file.}}&lt;br /&gt;
&lt;br /&gt;
The program automatically determines if your input file is SAM/BAM/uncompressed BAM without any input other than a filename from the user{{#if: {{{noStdin|}}} .|, unless your input file is stdin.}}&lt;br /&gt;
&lt;br /&gt;
{{#if: {{{noStdin|}}}|This tool does not support input from stdin.|A &amp;lt;code&amp;gt;-&amp;lt;/code&amp;gt; is used to indicate to read from stdin and the extension is used to determine the file type (no extension indicates SAM).}}&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;1&amp;quot; cellspacing=&amp;quot;0&amp;quot; cellpadding=&amp;quot;2&amp;quot;&lt;br /&gt;
|SAM/BAM/Uncompressed BAM from file&lt;br /&gt;
| &amp;lt;code&amp;gt;{{#if: {{{noParam|}}} | |--in}} yourFileName&amp;lt;/code&amp;gt;&lt;br /&gt;
{{#if: {{{noStdin|}}} | |&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;SAM from stdin&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&amp;lt;code&amp;gt;{{#if: {{{noParam|}}} | |--in}} -&amp;lt;/code&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;BAM from stdin&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&amp;lt;code&amp;gt;{{#if: {{{noParam|}}} | |--in}} -.bam&amp;lt;/code&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;Uncompressed BAM from stdin&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&amp;lt;code&amp;gt;{{#if: {{{noParam|}}} | |--in}} -.ubam&amp;lt;/code&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;}}&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Note: Uncompressed BAM is compressed using compression level-0 (so it is not an entirely uncompressed file).  This matches the &amp;lt;code&amp;gt;samtools&amp;lt;/code&amp;gt; implementation so pipes between our tools and &amp;lt;code&amp;gt;samtools&amp;lt;/code&amp;gt; are supported.&lt;/div&gt;</summary>
		<author><name>Mktrost</name></author>
	</entry>
	<entry>
		<id>http://genome.sph.umich.edu/w/index.php?title=Template:InBAMInputFile&amp;diff=15088</id>
		<title>Template:InBAMInputFile</title>
		<link rel="alternate" type="text/html" href="http://genome.sph.umich.edu/w/index.php?title=Template:InBAMInputFile&amp;diff=15088"/>
		<updated>2019-04-09T02:19:06Z</updated>

		<summary type="html">&lt;p&gt;Mktrost: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{{hdr|===}}} Input File ({{#if: {{{noParam|}}} | {{{noParam}}} argument|&amp;lt;code&amp;gt;{{{param|--in}}}&amp;lt;/code&amp;gt;}}) {{{hdr|===}}}&lt;br /&gt;
&lt;br /&gt;
{{#if: {{{noParam|}}} | The {{{noParam}}} argument is the name of the input SAM/BAM file. |&lt;br /&gt;
Use &amp;lt;code&amp;gt;{{{param|--in}}}&amp;lt;/code&amp;gt; followed by your file name to specify the SAM/BAM input file.}}&lt;br /&gt;
&lt;br /&gt;
The program automatically determines if your input file is SAM/BAM/uncompressed BAM without any input other than a filename from the user{{#if: {{{noStdin|.}}}|, unless your input file is stdin.}}&lt;br /&gt;
&lt;br /&gt;
{{#if: {{{noStdin|This tool does not support input from stdin.}}}|A &amp;lt;code&amp;gt;-&amp;lt;/code&amp;gt; is used to indicate to read from stdin and the extension is used to determine the file type (no extension indicates SAM).}}&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;1&amp;quot; cellspacing=&amp;quot;0&amp;quot; cellpadding=&amp;quot;2&amp;quot;&lt;br /&gt;
|SAM/BAM/Uncompressed BAM from file&lt;br /&gt;
| &amp;lt;code&amp;gt;{{#if: {{{noParam|}}} | |--in}} yourFileName&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|{{#if: {{{noStdin|}}} | |SAM from stdin}}&lt;br /&gt;
|{{#if: {{{noStdin|}}} | |&amp;lt;code&amp;gt;{{#if: {{{noParam|}}} | |--in}} -&amp;lt;/code&amp;gt;}}&lt;br /&gt;
|-&lt;br /&gt;
|BAM from stdin&lt;br /&gt;
| &amp;lt;code&amp;gt;{{#if: {{{noParam|}}} | |--in}} -.bam&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|Uncompressed BAM from stdin&lt;br /&gt;
| &amp;lt;code&amp;gt;{{#if: {{{noParam|}}} | |--in}} -.ubam&amp;lt;/code&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Note: Uncompressed BAM is compressed using compression level-0 (so it is not an entirely uncompressed file).  This matches the &amp;lt;code&amp;gt;samtools&amp;lt;/code&amp;gt; implementation so pipes between our tools and &amp;lt;code&amp;gt;samtools&amp;lt;/code&amp;gt; are supported.&lt;/div&gt;</summary>
		<author><name>Mktrost</name></author>
	</entry>
	<entry>
		<id>http://genome.sph.umich.edu/w/index.php?title=Template:InBAMInputFile&amp;diff=15087</id>
		<title>Template:InBAMInputFile</title>
		<link rel="alternate" type="text/html" href="http://genome.sph.umich.edu/w/index.php?title=Template:InBAMInputFile&amp;diff=15087"/>
		<updated>2019-04-09T02:17:30Z</updated>

		<summary type="html">&lt;p&gt;Mktrost: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{{hdr|===}}} Input File ({{#if: {{{noParam|}}} | {{{noParam}}} argument|&amp;lt;code&amp;gt;{{{param|--in}}}&amp;lt;/code&amp;gt;}}) {{{hdr|===}}}&lt;br /&gt;
&lt;br /&gt;
{{#if: {{{noParam|}}} | The {{{noParam}}} argument is the name of the input SAM/BAM file. |&lt;br /&gt;
Use &amp;lt;code&amp;gt;{{{param|--in}}}&amp;lt;/code&amp;gt; followed by your file name to specify the SAM/BAM input file.}}&lt;br /&gt;
&lt;br /&gt;
The program automatically determines if your input file is SAM/BAM/uncompressed BAM without any input other than a filename from the user{{#if: {{{noStdin|.}}}|, unless your input file is stdin.}}&lt;br /&gt;
&lt;br /&gt;
{{#if: {{{noStdin|This tool does not support input from stdin.}}}|A &amp;lt;code&amp;gt;-&amp;lt;/code&amp;gt; is used to indicate to read from stdin and the extension is used to determine the file type (no extension indicates SAM).}}&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;1&amp;quot; cellspacing=&amp;quot;0&amp;quot; cellpadding=&amp;quot;2&amp;quot;&lt;br /&gt;
|SAM/BAM/Uncompressed BAM from file&lt;br /&gt;
| &amp;lt;code&amp;gt;{{#if: {{{noParam|}}} | |--in}} yourFileName&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|{{#if: {{{noStdin|}}} | |SAM from stdin}}&lt;br /&gt;
| &amp;lt;code&amp;gt;{{#if: {{{noParam|}}} | |--in}} -&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|BAM from stdin&lt;br /&gt;
| &amp;lt;code&amp;gt;{{#if: {{{noParam|}}} | |--in}} -.bam&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|Uncompressed BAM from stdin&lt;br /&gt;
| &amp;lt;code&amp;gt;{{#if: {{{noParam|}}} | |--in}} -.ubam&amp;lt;/code&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Note: Uncompressed BAM is compressed using compression level-0 (so it is not an entirely uncompressed file).  This matches the &amp;lt;code&amp;gt;samtools&amp;lt;/code&amp;gt; implementation so pipes between our tools and &amp;lt;code&amp;gt;samtools&amp;lt;/code&amp;gt; are supported.&lt;/div&gt;</summary>
		<author><name>Mktrost</name></author>
	</entry>
	<entry>
		<id>http://genome.sph.umich.edu/w/index.php?title=BamUtil:_dedup&amp;diff=15086</id>
		<title>BamUtil: dedup</title>
		<link rel="alternate" type="text/html" href="http://genome.sph.umich.edu/w/index.php?title=BamUtil:_dedup&amp;diff=15086"/>
		<updated>2019-04-09T02:03:08Z</updated>

		<summary type="html">&lt;p&gt;Mktrost: /* Overview of the dedup function of bamUtil */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:BamUtil|validate]]&lt;br /&gt;
[[Category:BAM Software]]&lt;br /&gt;
[[Category:Software]]&lt;br /&gt;
&lt;br /&gt;
= Overview of the &amp;lt;code&amp;gt;dedup&amp;lt;/code&amp;gt; function of &amp;lt;code&amp;gt;[[bamUtil]]&amp;lt;/code&amp;gt; =&lt;br /&gt;
The &amp;lt;code&amp;gt;dedup&amp;lt;/code&amp;gt; option of [[bamUtil]] determines duplicates in a coordinate sorted SAM/BAM file. It either marks or removes the lower quality duplicates.&lt;br /&gt;
&lt;br /&gt;
This tool also contains the option to perform recalibration.&lt;br /&gt;
&lt;br /&gt;
NOTE: This tool does not properly work on templates that have more than 2 segments.  It does not properly match reads when more than 2 reads have the same read name.&lt;br /&gt;
&lt;br /&gt;
NOTE: Dedup cannot read from stdin since it reads the input file twice.&lt;br /&gt;
&lt;br /&gt;
Potential future features:&lt;br /&gt;
* Soft clip overlapping reads (for now, use: [[BamUtil: clipOverlap]])&lt;br /&gt;
&lt;br /&gt;
==Handling Duplicates==&lt;br /&gt;
&lt;br /&gt;
The deduper reads all the alignments in a coordinate-sorted SAM/BAM looking for duplicates, failing if the file is not coordinate-sorted.&lt;br /&gt;
&lt;br /&gt;
The deduper assumes that duplicates in the input BAM file are not marked.  When the deduper detects a marked duplicate in the input BAM file, it will throw an error and stop.  To override this behavior, use the [[#Ignore Previous Duplicate Marking (--force)|&amp;lt;code&amp;gt;--force&amp;lt;/code&amp;gt;]] option;  in this mode, alignments that are marked as duplicates in the input file are unmarked before the deduper begins its detection algorithm.  The result is that only duplicates detected by the deduper will be marked in or removed from the output file.&lt;br /&gt;
&lt;br /&gt;
The handling of paired-end reads assumes that the mate information in the SAM/BAM records is accurate.  If a mate is not found at the expected position, an error message is printed (once per file) indicating this error.  Paired-end reads whose mate cannot be found are not marked duplicate and are not used for duplicate marking of other paired-end reads.  Single-end reads with the same key as paired-end reads whose mate cannot be found are still marked as duplicate.  If this error is encountered, you may want to fix the mate information and reprocess the file through the deduper.  &lt;br /&gt;
&lt;br /&gt;
With the default settings this tool should produce similar results as Picard.&lt;br /&gt;
&lt;br /&gt;
Use the [[#Treat Reads with Mates On Different Chromosomes As Single-Ended (--oneChrom)|&amp;lt;code&amp;gt;--oneChrom&amp;lt;/code&amp;gt;]] option to treat reads with a mate on a different chromosome as single-ended.  This option is useful if you are running the deduper on just a single chromosome.  The code will use less memory with this option if mates are found on different chromosomes.  (Picard does not specially handle mates on different chromosomes, so the --oneChrom option may produce different results than Picard.)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Implementation Notes ===&lt;br /&gt;
Duplicates are determined by checking for matching keys.  &lt;br /&gt;
&lt;br /&gt;
The Key is comprised of:&lt;br /&gt;
# Chromosome&lt;br /&gt;
# Orientation (forward/reverse)&lt;br /&gt;
# Unclipped Start(forward)/End(reverse)&lt;br /&gt;
# Library&lt;br /&gt;
&lt;br /&gt;
Rules:&lt;br /&gt;
* Skip Unmapped Reads, they are not marked as duplicate&lt;br /&gt;
* Reads whose mate is unmapped are treated as single-end&lt;br /&gt;
* Mark a Single-End Read Duplicate (or remove it if configured to do so) if:&lt;br /&gt;
*# A paired-end record has the same key (even if the pair is not proper/the mate is not found)&amp;lt;br/&amp;gt;-OR-&lt;br /&gt;
*# A single-end record has the same key and a higher base quality sum (sum of all base qualities in the record above [[#Minimum Quality for Quality Calculations (--minQual)|&amp;lt;code&amp;gt;--minBaseQual&amp;lt;/code&amp;gt;]])&lt;br /&gt;
* Mark both Paired-End Reads Duplicate if:&lt;br /&gt;
# Another paired-end pair has the same set of keys and has a higher base quality sum (sum of all base qualities in the record above [[#Minimum Quality for Quality Calculations (--minQual)|&amp;lt;code&amp;gt;--minBaseQual&amp;lt;/code&amp;gt;]])&lt;br /&gt;
 &lt;br /&gt;
This code assumes that at most 1000 bases are clipped at the start of a read.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Deduping requires two passes through the file, so cannot read from stdin.&lt;br /&gt;
&lt;br /&gt;
==Handling Recalibration==&lt;br /&gt;
See [[BamUtil: recab]] for recalibration details.&lt;br /&gt;
&lt;br /&gt;
Recalibration parameters can be applied to deduping when --recab is specified.&lt;br /&gt;
&lt;br /&gt;
== How to use it ==&lt;br /&gt;
&lt;br /&gt;
When &amp;lt;code&amp;gt;dedup&amp;lt;/code&amp;gt; is invoked without any arguments the usage information is displayed as described below under [[#Usage|Usage]].&lt;br /&gt;
&lt;br /&gt;
The input SAM/BAM file is required, [[#input File (--in)|input File (--in)]], and must be sorted by coordinate.&lt;br /&gt;
&lt;br /&gt;
The output SAM/BAM file is also required, [[#output File (--out)|output File (--out)]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Recommended usage with Recalibrator: &lt;br /&gt;
&lt;br /&gt;
 /usr/cluster/bin/bam dedup --recab --in ${INPUT}.bam --out ${OUTPUT}.bam --force --refFile ${REF} --dbsnp ${DBSNP} --oneChrom --storeQualTag OQ --maxBaseQual 40&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Recommended usage without Recalibrator: &lt;br /&gt;
&lt;br /&gt;
 /usr/cluster/bin/bam dedup --in ${INPUT}.bam --out ${OUTPUT}.bam --force --oneChrom&lt;br /&gt;
&lt;br /&gt;
= Usage =&lt;br /&gt;
 ./bam dedup --in &amp;lt;InputBamFile&amp;gt; --out &amp;lt;OutputBamFile&amp;gt; [--minQual &amp;lt;minPhred&amp;gt;] [--log &amp;lt;logFile&amp;gt;] [--oneChrom] [--rmDups] [--force] [--excludeFlags &amp;lt;flag&amp;gt;] [--verbose] [--noeof] [--params] [--recab]&lt;br /&gt;
&lt;br /&gt;
Additional Recalibration Usage is documented at [[BamUtil: recab#Usage|BamUtil: recab -&amp;gt; Usage]]&lt;br /&gt;
&lt;br /&gt;
= Parameters =&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Required parameters :&lt;br /&gt;
	--in &amp;lt;infile&amp;gt;   : Input BAM file name (must be sorted)&lt;br /&gt;
	--out &amp;lt;outfile&amp;gt; : Output BAM file name (same order with original file)&lt;br /&gt;
Optional parameters : &lt;br /&gt;
	--minQual &amp;lt;int&amp;gt; : Only add scores over this phred quality when determining a read&#039;s quality (default: 15)&lt;br /&gt;
	--log &amp;lt;logfile&amp;gt; : Log and summary statistics (default: [outfile].log, or stderr if --out starts with &#039;-&#039;)&lt;br /&gt;
	--oneChrom      : Treat reads with mates on different chromosomes as single-ended.&lt;br /&gt;
	--rmDups        : Remove duplicates (default is to mark duplicates)&lt;br /&gt;
	--force         : Allow an already mark-duplicated BAM file, unmarking any previously marked &lt;br /&gt;
	                  duplicates and apply this duplicate marking logic.  Default is to throw errors&lt;br /&gt;
	                  and exit when trying to run on an already mark-duplicated BAM&lt;br /&gt;
	--excludeFlags &amp;lt;flag&amp;gt;    : exclude reads with any of these flags set when determining or marking duplicates&lt;br /&gt;
	                           by default (0xB04): exclude unmapped, secondary reads, QC failures, and supplementary reads&lt;br /&gt;
	--verbose       : Turn on verbose mode&lt;br /&gt;
	--noeof         : Do not expect an EOF block on a bam file.&lt;br /&gt;
	--params        : Print the parameter settings&lt;br /&gt;
	--recab         : Recalibrate in addition to deduping&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
{{PhoneHomeParamDesc}}&lt;br /&gt;
&lt;br /&gt;
Additional Recalibration Parameters are documented at [[BamUtil: recab#Parameters|BamUtil: recab -&amp;gt; Parameters]]&lt;br /&gt;
&lt;br /&gt;
== Required Parameters ==&lt;br /&gt;
{{inBAMInputFile}}&lt;br /&gt;
&lt;br /&gt;
Note: The input file must be sorted by coordinate.&lt;br /&gt;
{{outBAMOutputFile}}&lt;br /&gt;
&lt;br /&gt;
== Optional Parameters==&lt;br /&gt;
=== Minimum Quality for Quality Calculations (&amp;lt;code&amp;gt;--minQual&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
When duplicate reads are encountered, the read with the highest quality is kept.&lt;br /&gt;
&lt;br /&gt;
To determine the quality of a read, all of the phred base quality scores above the &amp;lt;code&amp;gt;--minQual&amp;lt;/code&amp;gt; value are added together.  If &amp;lt;code&amp;gt;--minQual&amp;lt;/code&amp;gt; is not specified, it is defaulted to 15.&lt;br /&gt;
&lt;br /&gt;
=== Output log &amp;amp; Summary Statistics FileName (&amp;lt;code&amp;gt;--log&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
Output file name for writing logs &amp;amp; summary statistics.&lt;br /&gt;
&lt;br /&gt;
If this parameter is not specified, it will write to the output file specified in &amp;lt;code&amp;gt;--out&amp;lt;/code&amp;gt; + &amp;quot;.log&amp;quot;.  Or if the output bam is written to stdout (&amp;lt;code&amp;gt;--out&amp;lt;/code&amp;gt; starts with &#039;-&#039;), the logs will be written to stderr.  If the filename after --log starts with &#039;-&#039; it will write to stderr.&lt;br /&gt;
&lt;br /&gt;
=== Treat Reads with Mates On Different Chromosomes As Single-Ended (&amp;lt;code&amp;gt;--oneChrom&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
If a read&#039;s mate is not found it will not be used for duplicate marking.  If you are running on a single chromosome, all read&#039;s whose mates are on different chromosomes will not be used for duplicate marking.  The &amp;lt;code&amp;gt;--oneChrom&amp;lt;/code&amp;gt; option will treat reads with mates on a different chromosome as single-ended.&lt;br /&gt;
&lt;br /&gt;
=== Remove Duplicates (&amp;lt;code&amp;gt;--rmDups&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
Instead of marking a read as duplicate in the flag, the &amp;lt;code&amp;gt;--rmDups&amp;lt;/code&amp;gt; option will remove it from the output BAM file.  &lt;br /&gt;
&lt;br /&gt;
=== Ignore Previous Duplicate Marking (&amp;lt;code&amp;gt;--force&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
By default the deduper will throw an error and stop if a read is already marked as duplicate.  The &amp;lt;code&amp;gt;--force&amp;lt;/code&amp;gt; option will removes any previous duplicate marking and marks the reads from scratch.  The resulting output file will only have reads determined by the deduper marked as duplicates.&lt;br /&gt;
&lt;br /&gt;
=== Skip Records with any of the Specified Flags (&amp;lt;code&amp;gt;--excludeFlags&amp;lt;/code&amp;gt;)===&lt;br /&gt;
Skip records with any of the specified flags set, default 0xB04&lt;br /&gt;
&lt;br /&gt;
By default skips reads with any of the following flags set:&lt;br /&gt;
* unmapped&lt;br /&gt;
* secondary alignment&lt;br /&gt;
* fails QC checks&lt;br /&gt;
* supplementary reads&lt;br /&gt;
&lt;br /&gt;
Secondary (0x100) and Supplementary (0x800) reads currently must be excluded.&lt;br /&gt;
&lt;br /&gt;
=== Turn on Verbose Mode (&amp;lt;code&amp;gt;--verbose&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
Turn on verbose logging to get more log messages in the log and to stderr.&lt;br /&gt;
&lt;br /&gt;
{{noeofBGZFParameter}}&lt;br /&gt;
{{paramsParameter}}&lt;br /&gt;
&lt;br /&gt;
== Recalibrate (&amp;lt;code&amp;gt;--recab&amp;lt;/code&amp;gt;) ==&lt;br /&gt;
&lt;br /&gt;
This option will recalibrate the input file in addition to deduping.&lt;br /&gt;
&lt;br /&gt;
See [[BamUtil: recab]] for recalibration details.&lt;br /&gt;
&lt;br /&gt;
{{PhoneHomeParameters}}&lt;br /&gt;
&lt;br /&gt;
= Return Value =&lt;br /&gt;
&lt;br /&gt;
Returns -1 if input parameters are invalid.&lt;br /&gt;
&lt;br /&gt;
Returns the SamStatus for the reads/writes (0 on success, non-0 on failure).&lt;/div&gt;</summary>
		<author><name>Mktrost</name></author>
	</entry>
	<entry>
		<id>http://genome.sph.umich.edu/w/index.php?title=BamUtil:_dedup&amp;diff=15085</id>
		<title>BamUtil: dedup</title>
		<link rel="alternate" type="text/html" href="http://genome.sph.umich.edu/w/index.php?title=BamUtil:_dedup&amp;diff=15085"/>
		<updated>2019-04-09T02:02:12Z</updated>

		<summary type="html">&lt;p&gt;Mktrost: /* Implementation Notes */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:BamUtil|validate]]&lt;br /&gt;
[[Category:BAM Software]]&lt;br /&gt;
[[Category:Software]]&lt;br /&gt;
&lt;br /&gt;
= Overview of the &amp;lt;code&amp;gt;dedup&amp;lt;/code&amp;gt; function of &amp;lt;code&amp;gt;[[bamUtil]]&amp;lt;/code&amp;gt; =&lt;br /&gt;
The &amp;lt;code&amp;gt;dedup&amp;lt;/code&amp;gt; option of [[bamUtil]] determines duplicates in a coordinate sorted SAM/BAM file. It either marks or removes the lower quality duplicates.&lt;br /&gt;
&lt;br /&gt;
This tool also contains the option to perform recalibration.&lt;br /&gt;
&lt;br /&gt;
NOTE: This tool does not properly work on templates that have more than 2 segments.  It does not properly match reads when more than 2 reads have the same read name.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Potential future features:&lt;br /&gt;
* Soft clip overlapping reads (for now, use: [[BamUtil: clipOverlap]])&lt;br /&gt;
&lt;br /&gt;
==Handling Duplicates==&lt;br /&gt;
&lt;br /&gt;
The deduper reads all the alignments in a coordinate-sorted SAM/BAM looking for duplicates, failing if the file is not coordinate-sorted.&lt;br /&gt;
&lt;br /&gt;
The deduper assumes that duplicates in the input BAM file are not marked.  When the deduper detects a marked duplicate in the input BAM file, it will throw an error and stop.  To override this behavior, use the [[#Ignore Previous Duplicate Marking (--force)|&amp;lt;code&amp;gt;--force&amp;lt;/code&amp;gt;]] option;  in this mode, alignments that are marked as duplicates in the input file are unmarked before the deduper begins its detection algorithm.  The result is that only duplicates detected by the deduper will be marked in or removed from the output file.&lt;br /&gt;
&lt;br /&gt;
The handling of paired-end reads assumes that the mate information in the SAM/BAM records is accurate.  If a mate is not found at the expected position, an error message is printed (once per file) indicating this error.  Paired-end reads whose mate cannot be found are not marked duplicate and are not used for duplicate marking of other paired-end reads.  Single-end reads with the same key as paired-end reads whose mate cannot be found are still marked as duplicate.  If this error is encountered, you may want to fix the mate information and reprocess the file through the deduper.  &lt;br /&gt;
&lt;br /&gt;
With the default settings this tool should produce similar results as Picard.&lt;br /&gt;
&lt;br /&gt;
Use the [[#Treat Reads with Mates On Different Chromosomes As Single-Ended (--oneChrom)|&amp;lt;code&amp;gt;--oneChrom&amp;lt;/code&amp;gt;]] option to treat reads with a mate on a different chromosome as single-ended.  This option is useful if you are running the deduper on just a single chromosome.  The code will use less memory with this option if mates are found on different chromosomes.  (Picard does not specially handle mates on different chromosomes, so the --oneChrom option may produce different results than Picard.)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Implementation Notes ===&lt;br /&gt;
Duplicates are determined by checking for matching keys.  &lt;br /&gt;
&lt;br /&gt;
The Key is comprised of:&lt;br /&gt;
# Chromosome&lt;br /&gt;
# Orientation (forward/reverse)&lt;br /&gt;
# Unclipped Start(forward)/End(reverse)&lt;br /&gt;
# Library&lt;br /&gt;
&lt;br /&gt;
Rules:&lt;br /&gt;
* Skip Unmapped Reads, they are not marked as duplicate&lt;br /&gt;
* Reads whose mate is unmapped are treated as single-end&lt;br /&gt;
* Mark a Single-End Read Duplicate (or remove it if configured to do so) if:&lt;br /&gt;
*# A paired-end record has the same key (even if the pair is not proper/the mate is not found)&amp;lt;br/&amp;gt;-OR-&lt;br /&gt;
*# A single-end record has the same key and a higher base quality sum (sum of all base qualities in the record above [[#Minimum Quality for Quality Calculations (--minQual)|&amp;lt;code&amp;gt;--minBaseQual&amp;lt;/code&amp;gt;]])&lt;br /&gt;
* Mark both Paired-End Reads Duplicate if:&lt;br /&gt;
# Another paired-end pair has the same set of keys and has a higher base quality sum (sum of all base qualities in the record above [[#Minimum Quality for Quality Calculations (--minQual)|&amp;lt;code&amp;gt;--minBaseQual&amp;lt;/code&amp;gt;]])&lt;br /&gt;
 &lt;br /&gt;
This code assumes that at most 1000 bases are clipped at the start of a read.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Deduping requires two passes through the file, so cannot read from stdin.&lt;br /&gt;
&lt;br /&gt;
==Handling Recalibration==&lt;br /&gt;
See [[BamUtil: recab]] for recalibration details.&lt;br /&gt;
&lt;br /&gt;
Recalibration parameters can be applied to deduping when --recab is specified.&lt;br /&gt;
&lt;br /&gt;
== How to use it ==&lt;br /&gt;
&lt;br /&gt;
When &amp;lt;code&amp;gt;dedup&amp;lt;/code&amp;gt; is invoked without any arguments the usage information is displayed as described below under [[#Usage|Usage]].&lt;br /&gt;
&lt;br /&gt;
The input SAM/BAM file is required, [[#input File (--in)|input File (--in)]], and must be sorted by coordinate.&lt;br /&gt;
&lt;br /&gt;
The output SAM/BAM file is also required, [[#output File (--out)|output File (--out)]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Recommended usage with Recalibrator: &lt;br /&gt;
&lt;br /&gt;
 /usr/cluster/bin/bam dedup --recab --in ${INPUT}.bam --out ${OUTPUT}.bam --force --refFile ${REF} --dbsnp ${DBSNP} --oneChrom --storeQualTag OQ --maxBaseQual 40&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Recommended usage without Recalibrator: &lt;br /&gt;
&lt;br /&gt;
 /usr/cluster/bin/bam dedup --in ${INPUT}.bam --out ${OUTPUT}.bam --force --oneChrom&lt;br /&gt;
&lt;br /&gt;
= Usage =&lt;br /&gt;
 ./bam dedup --in &amp;lt;InputBamFile&amp;gt; --out &amp;lt;OutputBamFile&amp;gt; [--minQual &amp;lt;minPhred&amp;gt;] [--log &amp;lt;logFile&amp;gt;] [--oneChrom] [--rmDups] [--force] [--excludeFlags &amp;lt;flag&amp;gt;] [--verbose] [--noeof] [--params] [--recab]&lt;br /&gt;
&lt;br /&gt;
Additional Recalibration Usage is documented at [[BamUtil: recab#Usage|BamUtil: recab -&amp;gt; Usage]]&lt;br /&gt;
&lt;br /&gt;
= Parameters =&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Required parameters :&lt;br /&gt;
	--in &amp;lt;infile&amp;gt;   : Input BAM file name (must be sorted)&lt;br /&gt;
	--out &amp;lt;outfile&amp;gt; : Output BAM file name (same order with original file)&lt;br /&gt;
Optional parameters : &lt;br /&gt;
	--minQual &amp;lt;int&amp;gt; : Only add scores over this phred quality when determining a read&#039;s quality (default: 15)&lt;br /&gt;
	--log &amp;lt;logfile&amp;gt; : Log and summary statistics (default: [outfile].log, or stderr if --out starts with &#039;-&#039;)&lt;br /&gt;
	--oneChrom      : Treat reads with mates on different chromosomes as single-ended.&lt;br /&gt;
	--rmDups        : Remove duplicates (default is to mark duplicates)&lt;br /&gt;
	--force         : Allow an already mark-duplicated BAM file, unmarking any previously marked &lt;br /&gt;
	                  duplicates and apply this duplicate marking logic.  Default is to throw errors&lt;br /&gt;
	                  and exit when trying to run on an already mark-duplicated BAM&lt;br /&gt;
	--excludeFlags &amp;lt;flag&amp;gt;    : exclude reads with any of these flags set when determining or marking duplicates&lt;br /&gt;
	                           by default (0xB04): exclude unmapped, secondary reads, QC failures, and supplementary reads&lt;br /&gt;
	--verbose       : Turn on verbose mode&lt;br /&gt;
	--noeof         : Do not expect an EOF block on a bam file.&lt;br /&gt;
	--params        : Print the parameter settings&lt;br /&gt;
	--recab         : Recalibrate in addition to deduping&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
{{PhoneHomeParamDesc}}&lt;br /&gt;
&lt;br /&gt;
Additional Recalibration Parameters are documented at [[BamUtil: recab#Parameters|BamUtil: recab -&amp;gt; Parameters]]&lt;br /&gt;
&lt;br /&gt;
== Required Parameters ==&lt;br /&gt;
{{inBAMInputFile}}&lt;br /&gt;
&lt;br /&gt;
Note: The input file must be sorted by coordinate.&lt;br /&gt;
{{outBAMOutputFile}}&lt;br /&gt;
&lt;br /&gt;
== Optional Parameters==&lt;br /&gt;
=== Minimum Quality for Quality Calculations (&amp;lt;code&amp;gt;--minQual&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
When duplicate reads are encountered, the read with the highest quality is kept.&lt;br /&gt;
&lt;br /&gt;
To determine the quality of a read, all of the phred base quality scores above the &amp;lt;code&amp;gt;--minQual&amp;lt;/code&amp;gt; value are added together.  If &amp;lt;code&amp;gt;--minQual&amp;lt;/code&amp;gt; is not specified, it is defaulted to 15.&lt;br /&gt;
&lt;br /&gt;
=== Output log &amp;amp; Summary Statistics FileName (&amp;lt;code&amp;gt;--log&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
Output file name for writing logs &amp;amp; summary statistics.&lt;br /&gt;
&lt;br /&gt;
If this parameter is not specified, it will write to the output file specified in &amp;lt;code&amp;gt;--out&amp;lt;/code&amp;gt; + &amp;quot;.log&amp;quot;.  Or if the output bam is written to stdout (&amp;lt;code&amp;gt;--out&amp;lt;/code&amp;gt; starts with &#039;-&#039;), the logs will be written to stderr.  If the filename after --log starts with &#039;-&#039; it will write to stderr.&lt;br /&gt;
&lt;br /&gt;
=== Treat Reads with Mates On Different Chromosomes As Single-Ended (&amp;lt;code&amp;gt;--oneChrom&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
If a read&#039;s mate is not found it will not be used for duplicate marking.  If you are running on a single chromosome, all read&#039;s whose mates are on different chromosomes will not be used for duplicate marking.  The &amp;lt;code&amp;gt;--oneChrom&amp;lt;/code&amp;gt; option will treat reads with mates on a different chromosome as single-ended.&lt;br /&gt;
&lt;br /&gt;
=== Remove Duplicates (&amp;lt;code&amp;gt;--rmDups&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
Instead of marking a read as duplicate in the flag, the &amp;lt;code&amp;gt;--rmDups&amp;lt;/code&amp;gt; option will remove it from the output BAM file.  &lt;br /&gt;
&lt;br /&gt;
=== Ignore Previous Duplicate Marking (&amp;lt;code&amp;gt;--force&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
By default the deduper will throw an error and stop if a read is already marked as duplicate.  The &amp;lt;code&amp;gt;--force&amp;lt;/code&amp;gt; option will removes any previous duplicate marking and marks the reads from scratch.  The resulting output file will only have reads determined by the deduper marked as duplicates.&lt;br /&gt;
&lt;br /&gt;
=== Skip Records with any of the Specified Flags (&amp;lt;code&amp;gt;--excludeFlags&amp;lt;/code&amp;gt;)===&lt;br /&gt;
Skip records with any of the specified flags set, default 0xB04&lt;br /&gt;
&lt;br /&gt;
By default skips reads with any of the following flags set:&lt;br /&gt;
* unmapped&lt;br /&gt;
* secondary alignment&lt;br /&gt;
* fails QC checks&lt;br /&gt;
* supplementary reads&lt;br /&gt;
&lt;br /&gt;
Secondary (0x100) and Supplementary (0x800) reads currently must be excluded.&lt;br /&gt;
&lt;br /&gt;
=== Turn on Verbose Mode (&amp;lt;code&amp;gt;--verbose&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
Turn on verbose logging to get more log messages in the log and to stderr.&lt;br /&gt;
&lt;br /&gt;
{{noeofBGZFParameter}}&lt;br /&gt;
{{paramsParameter}}&lt;br /&gt;
&lt;br /&gt;
== Recalibrate (&amp;lt;code&amp;gt;--recab&amp;lt;/code&amp;gt;) ==&lt;br /&gt;
&lt;br /&gt;
This option will recalibrate the input file in addition to deduping.&lt;br /&gt;
&lt;br /&gt;
See [[BamUtil: recab]] for recalibration details.&lt;br /&gt;
&lt;br /&gt;
{{PhoneHomeParameters}}&lt;br /&gt;
&lt;br /&gt;
= Return Value =&lt;br /&gt;
&lt;br /&gt;
Returns -1 if input parameters are invalid.&lt;br /&gt;
&lt;br /&gt;
Returns the SamStatus for the reads/writes (0 on success, non-0 on failure).&lt;/div&gt;</summary>
		<author><name>Mktrost</name></author>
	</entry>
	<entry>
		<id>http://genome.sph.umich.edu/w/index.php?title=BamUtil&amp;diff=15054</id>
		<title>BamUtil</title>
		<link rel="alternate" type="text/html" href="http://genome.sph.umich.edu/w/index.php?title=BamUtil&amp;diff=15054"/>
		<updated>2018-07-31T01:46:22Z</updated>

		<summary type="html">&lt;p&gt;Mktrost: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:bamUtil]]&lt;br /&gt;
[[Category:C++]]&lt;br /&gt;
[[Category:Software]]&lt;br /&gt;
&lt;br /&gt;
= bamUtil Overview =&lt;br /&gt;
&lt;br /&gt;
bamUtil is a repository that contains several programs that perform operations on SAM/BAM files.  All of these programs are built into a single executable, &amp;lt;code&amp;gt;bam&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Getting Help ==&lt;br /&gt;
&lt;br /&gt;
If you have any questions please use the [http://groups.google.com/group/bamUtils bamUtil Google Group] to ask questions or recommend improvements to bamUtil.&lt;br /&gt;
&lt;br /&gt;
Alternatively, you can e-mail me, Mary Kate Wing, at mktrost@umich.edu.&lt;br /&gt;
&lt;br /&gt;
See [[BamUtil: FAQ]] to see if your question has already been answered.&lt;br /&gt;
&lt;br /&gt;
== Where to Find It ==&lt;br /&gt;
{{ToolGitRepo|repoName=bamUtil}}&lt;br /&gt;
&lt;br /&gt;
== Releases ==&lt;br /&gt;
&lt;br /&gt;
If you prefer to run the last official release rather than the latest development version, you can download that here.&lt;br /&gt;
&lt;br /&gt;
There are two versions of the release, one that include libStatGen and one that does not.  If you already have libStatGen installed and want to use your own copy, use the version that does not include libStatGen.&lt;br /&gt;
&lt;br /&gt;
=== Full Release (includes libStatGen) ===&lt;br /&gt;
&lt;br /&gt;
To install an official release, unpack the downloaded file (tar xvf), cd into the bamUtil_x.x.x directory and type make all.&lt;br /&gt;
&lt;br /&gt;
For version 1.0.14 and later, please download libStatGen and bamUtil separately: &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Version 1.0.14 - Released 7/8/2015&#039;&#039;&#039;&lt;br /&gt;
*[[LibStatGen Download#Official Releases|libStatGen version 1.0.14]]&lt;br /&gt;
*[[#Release of just BamUtil (does not include libStatGen)|bamUtil version 1.0.14]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Older Releases&#039;&#039;&#039;&lt;br /&gt;
* [[Media:BamUtilLibStatGen.1.0.13.tgz|BamUtilLibStatGen.1.0.13.tgz‎]] - Released 2/20/2015&lt;br /&gt;
** Contains: [[LibStatGen Download#Official Releases|libStatGen version 1.0.13]] - see link for version updates&lt;br /&gt;
** Contains: [[#Release of just BamUtil (does not include libStatGen)|bamUtil version 1.0.13]] - see link for version updates&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* [[Media:BamUtilLibStatGen.1.0.12.tar.gz|BamUtilLibStatGen.1.0.12.tgz‎]] - Released 5/14/2014&lt;br /&gt;
** Contains: [[LibStatGen Download#Official Releases|libStatGen version 1.0.12]] - see link for version updates&lt;br /&gt;
** Contains: [[#Release of just BamUtil (does not include libStatGen)|bamUtil version 1.0.12]] - see link for version updates&lt;br /&gt;
** Adds regions to [[BamUtil: mergeBam|mergeBam]]&lt;br /&gt;
** Accept &#039;,&#039; delimiters for the tags string input in [[BamUtil: squeeze|squeeze]], [[BamUtil: revert|revert]], &amp;amp; [[BamUtil: diff|diff]]&lt;br /&gt;
&lt;br /&gt;
*[[Media:BamUtilLibStatGen.1.0.11.tar.gz|BamUtilLibStatGen.1.0.11.tar.gz‎]] - Released 2/28/2014&lt;br /&gt;
** Contains: [[LibStatGen Download#Official Releases|libStatGen version 1.0.11]] - see link for version updates&lt;br /&gt;
** Contains: [[#Release of just BamUtil (does not include libStatGen)|bamUtil version 1.0.11]] - see link for version updates&lt;br /&gt;
** Now properly supports &#039;B&#039; &amp;amp; &#039;f&#039; tags&lt;br /&gt;
** Cleanup - compile issues&lt;br /&gt;
&lt;br /&gt;
*[[Media:BamUtilLibStatGen.1.0.10.tar.gz|BamUtilLibStatGen.1.0.10.tar.gz‎]] - Released 1/2/2014&lt;br /&gt;
** Contains: [[LibStatGen Download#Official Releases|libStatGen version 1.0.10]] - see link for version updates&lt;br /&gt;
** Contains: [[#Release of just BamUtil (does not include libStatGen)|bamUtil version 1.0.10]] - see link for version updates&lt;br /&gt;
** Adds PhoneHome/Version checking. &lt;br /&gt;
&lt;br /&gt;
*[[Media:BamUtilLibStatGen.1.0.9.tgz|BamUtilLibStatGen.1.0.9.tgz‎]] - Released 7/7/2013&lt;br /&gt;
** Contains: [[LibStatGen Download#Official Releases|libStatGen version 1.0.9]] &lt;br /&gt;
** Contains: [[#Release of just BamUtil (does not include libStatGen)|bamUtil version 1.0.9]]&lt;br /&gt;
** Update to [[BamUtil: mergeBam|mergeBam]]&lt;br /&gt;
*** Update to ignore PG lines with duplicate IDs&lt;br /&gt;
*** Update to accept merges of matching RG lines&lt;br /&gt;
*** Update to log to stderr if no log/out file is specified&lt;br /&gt;
* There is no version 1.0.8.  It was skipped to stay in line with libStatGen versions (libStatGen 1.0.8 added vcf support)&lt;br /&gt;
*[[Media:BamUtilLibStatGen.1.0.7.tgz|BamUtilLibStatGen.1.0.7.tgz‎]] - Released 1/29/2013&lt;br /&gt;
** Contains: [[LibStatGen Download#Official Releases|libStatGen version 1.0.7]] &lt;br /&gt;
** Contains: [[#Release of just BamUtil (does not include libStatGen)|bamUtil version 1.0.7]]&lt;br /&gt;
** Update to fix some compile issues on ubuntu 12.10&lt;br /&gt;
** Update use of SamRecord::getStringTag to expect the return of a const string pointer due to libStatGen v1.0.7 updates&lt;br /&gt;
** Update SamReferenceInfo usage due to libStatGen v1.0.7 updates&lt;br /&gt;
** Update to [[BamUtil: diff|diff]]&lt;br /&gt;
***   Fix DIFF to test and properly handle running out of available records.  Previously no message was printed when this happened and there was a bug for which file it freed&lt;br /&gt;
** Update to [[BamUtil: clipOverlap|clipOverlap]]&lt;br /&gt;
*** Update to facilitate adding other overlap handling functions&lt;br /&gt;
** Update to [[BamUtil: mergeBam|mergeBam]] (formerly RGMergeBam)&lt;br /&gt;
*** Rename RGMergeBam to MergeBam&lt;br /&gt;
*** Update to handle files that already have an RG&lt;br /&gt;
&lt;br /&gt;
*[[Media:BamUtilLibStatGen.1.0.6.tgz|BamUtilLibStatGen.1.0.6.tgz‎]] - Released 11/14/2012&lt;br /&gt;
** Contains: [[LibStatGen Download#Official Releases|libStatGen version 1.0.6]] &lt;br /&gt;
** Contains: [[#Release of just BamUtil (does not include libStatGen)|bamUtil version 1.0.6]]&lt;br /&gt;
** Update to [[BamUtil: trimBam|trimBam]]&lt;br /&gt;
*** Update to allow trimming a different number of bases from each end of the read&lt;br /&gt;
*[[Media:BamUtilLibStatGen.1.0.5.tgz|BamUtilLibStatGen.1.0.5.tgz‎]] - Released 10/24/2012&lt;br /&gt;
** Contains: [[LibStatGen Download#Official Releases|libStatGen version 1.0.5]] &lt;br /&gt;
** Contains: [[#Release of just BamUtil (does not include libStatGen)|bamUtil version 1.0.5]]&lt;br /&gt;
** Updates to: [[BamUtil: dedup|dedup]], [[BamUtil: polishBam|polishBam]], [[BamUtil: recab|recab]]&lt;br /&gt;
** Update to add compile option to compile without C++0x/C++11&lt;br /&gt;
** See [[#Release of just BamUtil (does not include libStatGen)|below]] for additional details on updates&lt;br /&gt;
*BamUtilLibStatGen.1.0.4.tgz‎ - Released skipped&lt;br /&gt;
*[[Media:BamUtilLibStatGen.1.0.3.tgz|BamUtilLibStatGen.1.0.3.tgz‎]] - Released 09/19/2012&lt;br /&gt;
** Contains: [[LibStatGen Download#Official Releases|libStatGen version 1.0.3]] &lt;br /&gt;
** Contains: [[#Release of just BamUtil (does not include libStatGen)|bamUtil version 1.0.3]]&lt;br /&gt;
** Adds: [[BamUtil: dedup|dedup]] [[BamUtil: recab|recab]]&lt;br /&gt;
*[[Media:BamUtilLibStatGen.1.0.2.tgz|BamUtilLibStatGen.1.0.2.tgz‎]] - Released 05/16/2012&lt;br /&gt;
** Contains: [[LibStatGen Download#Official Releases|libStatGen version 1.0.2]] &lt;br /&gt;
** Adds: [[BamUtil: bam2FastQ|bam2FastQ]]&lt;br /&gt;
*[[Media:BamUtilLibStatGen.1.0.1.tgz|BamUtilLibStatGen.1.0.1.tgz‎]] - Released 05/04/2012&lt;br /&gt;
** Contains: [[LibStatGen Download#Official Releases|libStatGen version 1.0.1]] &lt;br /&gt;
** Adds: [[BamUtil: splitBam|splitBam]], [[BamUtil: clipOverlap|clipOverlap]],  [[BamUtil: trimBam|trimBam]], [[BamUtil: polishBam|polishBam]], [[BamUtil: rgMergeBam|rgMergeBam]], [[BamUtil: gapInfo|gapInfo]]&lt;br /&gt;
** Adds additional functionality to [[BamUtil: stats|stats]]&lt;br /&gt;
** Adds leftShifting to [[BamUtil: writeRegion|writeRegion]] and [[BamUtil: convert|convert]]&lt;br /&gt;
** Adds more diff fields to [[BamUtil: diff|diff]]&lt;br /&gt;
* [[Media:BamUtilLibStatGen.1.0.0.tgz|BamUtilLibStatGen.1.0.0.tgz‎]] - Released 10/10/2011&lt;br /&gt;
**Initial release of bamUtil that includes libStatGen version 1.0.0.  It started from the tool found in the deprecated StatGen repository.&lt;br /&gt;
**Contains: [[LibStatGen Download#Official Releases|libStatGen version 1.0.0]] [[BamUtil: validate|validate]], [[BamUtil: convert|convert]], [[BamUtil: dumpHeader|dumpHeader]], [[BamUtil: splitChromosome|splitChromosome]], [[BamUtil: writeRegion|writeRegion]], [[BamUtil: dumpRefInfo|dumpRefInfo]], [[BamUtil: dumpIndex|dumpIndex]], [[BamUtil: readIndexedBam|readIndexedBam]], [[BamUtil: filter|filter]], [[BamUtil: readReference|readReference]], [[BamUtil: revert|revert]], [[BamUtil: diff|diff]], [[BamUtil: squeeze|squeeze]], [[BamUtil: findCigars|findCigars]], [[BamUtil: stats|stats]]&lt;br /&gt;
&lt;br /&gt;
=== Release of just BamUtil (does not include libStatGen) ===&lt;br /&gt;
&lt;br /&gt;
To install an official release, unpack the downloaded file (tar xvf), cd into the bamUtil_x.x.x directory and type make all.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;BamUtil.1.0.14 Release Notes&#039;&#039;&#039;&lt;br /&gt;
* BamUtil Version 1.0.14 - Released 7/8/2015&lt;br /&gt;
** https://github.com/statgen/bamUtil/archive/v1.0.14.tar.gz&lt;br /&gt;
** Requires, but does not include: [[LibStatGen Download#Official Releases|libStatGen version 1.0.14]]&lt;br /&gt;
** Update [[BamUtil: trimBam|trimBam]]&lt;br /&gt;
*** Add option to soft clip (-c) instead of trimming&lt;br /&gt;
** Update [[BamUtil: clipOverlap|clipOverlap]]&lt;br /&gt;
*** Add option to mark reads as unmapped if they are entirely clipped&lt;br /&gt;
** Update to [[BamUtil: bam2FastQ|bam2FastQ]]&lt;br /&gt;
*** Add option to gzip the output files&lt;br /&gt;
*** Add option to split Read Groups into separate fastq files&lt;br /&gt;
*** Add option to get the quality from a tag&lt;br /&gt;
** Update [[BamUtil: recab|recab]]&lt;br /&gt;
*** Update to ignore ref &#039;N&#039; when building the recalibration table&lt;br /&gt;
*** Add ability to bin&lt;br /&gt;
** Add Dedup_LowMem tool&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Older Releases&#039;&#039;&#039;&lt;br /&gt;
* BamUtil Version 1.0.13 - Released 2/20/2015&lt;br /&gt;
** https://github.com/statgen/bamUtil/archive/v1.0.13.tar.gz&lt;br /&gt;
** Requires, but does not include: [[LibStatGen Download#Official Releases|libStatGen version 1.0.13]]&lt;br /&gt;
** Makefile Updates&lt;br /&gt;
*** Improve logic to determine actual path for the library&lt;br /&gt;
*** Update to append to USER_COMPILE_VARS even if specified on the command line&lt;br /&gt;
** Update [[BamUtil: writeRegion|writeRegion]]&lt;br /&gt;
*** Add option to specify readnames to keep in a file&lt;br /&gt;
*** Fixed bug that if a read overlapped 2 BED positions, it was printed twice&lt;br /&gt;
** Update to [[BamUtil: bam2FastQ|bam2FastQ]]&lt;br /&gt;
*** Update to skip non-primary reads&lt;br /&gt;
** Update to [[BamUtil: polishBam|polishBam]]&lt;br /&gt;
*** Update to handle &#039;\t&#039; string inputs and to add CO option&lt;br /&gt;
*** Fix MD5sum calculation to convert fasta to uppercase prior to calculating&lt;br /&gt;
&lt;br /&gt;
* [[Media:BamUtil.1.0.12.tgz|BamUtil.1.0.12.tgz‎]] - Released 5/14/2014&lt;br /&gt;
** Requires, but does not include: [[LibStatGen Download#Official Releases|libStatGen version 1.0.12]]&lt;br /&gt;
** Update [[BamUtil: mergeBam|mergeBam]]&lt;br /&gt;
*** Add a regions option&lt;br /&gt;
** Update to [[BamUtil: squeeze|squeeze]], [[BamUtil: revert|revert]], [[BamUtil: diff|diff]]&lt;br /&gt;
*** Also accept &#039;,&#039; instead of just &#039;;&#039; as the delimiter in the input tags string.&lt;br /&gt;
&lt;br /&gt;
* [[Media:BamUtil.1.0.11.tgz|BamUtil.1.0.11.tgz‎]] - Released 2/28/2014&lt;br /&gt;
** Requires, but does not include: [[LibStatGen Download#Official Releases|libStatGen version 1.0.11]]&lt;br /&gt;
*** Adds support for &#039;B&#039; &amp;amp; &#039;f&#039; tags that did not work properly before.&lt;br /&gt;
** Update [[BamUtil: splitBam|splitBam]] &amp;amp; [[BamUtil: polishBam|polishBam]]&lt;br /&gt;
*** Update to work properly if log &amp;amp; output file are not specified (no longer creates &#039;.log&#039;)&lt;br /&gt;
** Update Main dummy/example tool to indicate the correct tool&lt;br /&gt;
** Update to [[BamUtil: bam2FastQ|bam2FastQ]], [[BamUtil: clipOverlap|clipOverlap]], [[BamUtil: filter|filter]], [[BamUtil: mergeBam|mergeBam]], [[BamUtil: splitBam|splitBam]], [[BamUtil: squeeze|squeeze]], [[BamUtil: stats|stats]]&lt;br /&gt;
*** Cleanup usage/parameter descriptions&lt;br /&gt;
** Update [[BamUtil: revert|revert]]&lt;br /&gt;
*** Update compatibility with libStatGen due to &#039;B&#039; &amp;amp; &#039;f&#039; tag handling updates&lt;br /&gt;
** Add tests for &#039;B&#039; &amp;amp; &#039;f&#039; tags&lt;br /&gt;
&lt;br /&gt;
* [[Media:BamUtil.1.0.10.tar.gz|BamUtil.1.0.10.tar.gz‎]] - Released 1/2/2014&lt;br /&gt;
** Requires, but does not include: [[LibStatGen Download#Official Releases|libStatGen version 1.0.10]]&lt;br /&gt;
** All&lt;br /&gt;
*** Add PhoneHome/version checking&lt;br /&gt;
*** Make sub-program names case independent&lt;br /&gt;
*** Fix Logger.cpp compiler warning&lt;br /&gt;
** Adds: [[BamUtil: explainFlags|explainFlags]] - describes the SAM/BAM flags based on the flag value&lt;br /&gt;
** Update to [[BamUtil: stats|stats]]&lt;br /&gt;
*** Fix Stats to not try to not try to process a record after it is out of the loop (it would already have been processed or is invalid)&lt;br /&gt;
** Update to [[BamUtil: splitBam|splitBam]]&lt;br /&gt;
*** fix description of --noeof option&lt;br /&gt;
** Update to [[BamUtil: writeRegion|writeRegion]]&lt;br /&gt;
*** add exclude/required flags&lt;br /&gt;
** Update to [[BamUtil: dedup|dedup]] &amp;amp; [[BamUtil: recab|recab]]&lt;br /&gt;
*** Ignore secondary reads for dedup and making the recalibration table.&lt;br /&gt;
*** skip QC Failures&lt;br /&gt;
*** add excludeFlags parameters&lt;br /&gt;
** Update to [[BamUtil: clipOverlap|clipOverlap]]&lt;br /&gt;
*** add exclude flags&lt;br /&gt;
*** fix bug for readName sorted when a read is filtered due to flags&lt;br /&gt;
*** add sorting validation&lt;br /&gt;
** Update to [[BamUtil: bam2FastQ|bam2FastQ]]&lt;br /&gt;
*** add --merge option to generate interleaved files.&lt;br /&gt;
*** update to open the input file before opening the output files, so if there is an error, the outputs aren&#039;t opened&lt;br /&gt;
** Update to [[BamUtil: mergeBam|mergeBam]]&lt;br /&gt;
*** add option to ignore the RG PI field when checking headers&lt;br /&gt;
*** add more informative header merge error messages&lt;br /&gt;
&lt;br /&gt;
* [[Media:BamUtil.1.0.9.tgz|BamUtil.1.0.9.tgz‎]] - Released 7/7/2013&lt;br /&gt;
** Requires, but does not include: [[LibStatGen Download#Official Releases|libStatGen version 1.0.9]] (version 1.0.7 should also work)&lt;br /&gt;
** Update to [[BamUtil: mergeBam|mergeBam]]&lt;br /&gt;
*** Update to ignore PG lines with duplicate IDs&lt;br /&gt;
*** Update to accept merges of matching RG lines&lt;br /&gt;
*** Update to log to stderr if no log/out file is specified&lt;br /&gt;
&lt;br /&gt;
*[[Media:BamUtil.1.0.7.tgz|BamUtil.1.0.7.tgz‎]] - Released 1/29/2013&lt;br /&gt;
** Requires, but does not include: [[LibStatGen Download#Official Releases|libStatGen version 1.0.7]] or above&lt;br /&gt;
** Update to fix some compile issues on ubuntu 12.10&lt;br /&gt;
** Update use of SamRecord::getStringTag to expect the return of a const string pointer due to libStatGen v1.0.7 updates&lt;br /&gt;
** Update SamReferenceInfo usage due to libStatGen v1.0.7 updates&lt;br /&gt;
** Update to [[BamUtil: diff|diff]]&lt;br /&gt;
***   Fix DIFF to test and properly handle running out of available records.  Previously no message was printed when this happened and there was a bug for which file it freed&lt;br /&gt;
** Update to [[BamUtil: clipOverlap|clipOverlap]]&lt;br /&gt;
*** Update to facilitate adding other overlap handling functions&lt;br /&gt;
** Update to [[BamUtil: mergeBam|mergeBam]] (formerly RGMergeBam)&lt;br /&gt;
*** Rename RGMergeBam to MergeBam&lt;br /&gt;
*** Update to handle files that already have an RG&lt;br /&gt;
*[[Media:BamUtil.1.0.6.tgz|BamUtil.1.0.6.tgz‎]] - Released 11/14/2012&lt;br /&gt;
** Update to [[BamUtil: trimBam|trimBam]]&lt;br /&gt;
*** Update to allow trimming a different number of bases from each end of the read&lt;br /&gt;
*[[Media:BamUtil.1.0.5.tgz|BamUtil.1.0.5.tgz‎]] - Released 10/24/2012&lt;br /&gt;
** Update to [[BamUtil: dedup|dedup]]&lt;br /&gt;
*** Update logic for which pair to keep if they have the same quality&lt;br /&gt;
** Update to [[BamUtil: polishBam|polishBam]]&lt;br /&gt;
*** Update to print the number of successful header additions&lt;br /&gt;
** Update to [[BamUtil: recab|recab]]&lt;br /&gt;
*** Update to print the number of base skipped due to the base quality&lt;br /&gt;
** General Updates&lt;br /&gt;
*** Update to add compile option to compile without C++0x/C++11&lt;br /&gt;
*BamUtil.1.0.4.tgz‎ - Released skipped&lt;br /&gt;
*[[Media:BamUtil.1.0.3.tgz|BamUtil.1.0.3.tgz‎]] - Released 09/19/2012&lt;br /&gt;
** Adds: [[BamUtil: dedup|dedup]] [[BamUtil: recab|recab]]&lt;br /&gt;
** General Updates&lt;br /&gt;
*** Update Logger to write to stderr if output is stdout&lt;br /&gt;
** Update to [[BamUtil: stats|stats]]&lt;br /&gt;
*** Add required/exclude flags&lt;br /&gt;
*** Exclude Clips if excluding umapped&lt;br /&gt;
*** Add --withinRegion flag&lt;br /&gt;
*** Update phred/qual counts to be uint64_t instead of int to avoid overflow&lt;br /&gt;
** Update to [[BamUtil: validate|validate]]&lt;br /&gt;
*** Detect header failures&lt;br /&gt;
** Update to [[BamUtil: diff|diff]]&lt;br /&gt;
*** Update to specify chromosome/pos in ZP as a string rather than int so both can be shown&lt;br /&gt;
** Update to [[BamUtil: readReference|readReference]]&lt;br /&gt;
*** Output error message if the reference name is not found&lt;br /&gt;
** Update to [[BamUtil: splitChromosome|splitChromosome]]&lt;br /&gt;
*** Update to actually split the chromosomes and not just hard coded to output chromosomes ids 0-22&lt;br /&gt;
** Update Makefile to have cloneLib for cloning libStatGen&lt;br /&gt;
*[[Media:BamUtil.1.0.2.tgz|BamUtil.1.0.2.tgz‎]] - Released 05/16/2012&lt;br /&gt;
** Adds: [[BamUtil: bam2FastQ|bam2FastQ]]&lt;br /&gt;
*[[Media:BamUtil.1.0.1.tgz|BamUtil.1.0.1.tgz‎]] - Released 05/04/2012&lt;br /&gt;
** Adds: [[BamUtil: splitBam|splitBam]], [[BamUtil: clipOverlap|clipOverlap]],  [[BamUtil: trimBam|trimBam]], [[BamUtil: polishBam|polishBam]], [[BamUtil: rgMergeBam|rgMergeBam]], [[BamUtil: gapInfo|gapInfo]]&lt;br /&gt;
** Adds additional functionality to [[BamUtil: stats|stats]]&lt;br /&gt;
** Adds leftShifting to [[BamUtil: writeRegion|writeRegion]] and [[BamUtil: convert|convert]]&lt;br /&gt;
** Adds more diff fields to [[BamUtil: diff|diff]]&lt;br /&gt;
*[[Media:BamUtil.1.0.0.tgz|BamUtil.1.0.0.tgz‎]] - Released 10/10/2011&lt;br /&gt;
**Initial release of just bamUtil.  It started from the tool found in the deprecated StatGen repository.&lt;br /&gt;
**Contains: [[BamUtil: validate|validate]], [[BamUtil: convert|convert]], [[BamUtil: dumpHeader|dumpHeader]], [[BamUtil: splitChromosome|splitChromosome]], [[BamUtil: writeRegion|writeRegion]], [[BamUtil: dumpRefInfo|dumpRefInfo]], [[BamUtil: dumpIndex|dumpIndex]], [[BamUtil: readIndexedBam|readIndexedBam]], [[BamUtil: filter|filter]], [[BamUtil: readReference|readReference]], [[BamUtil: revert|revert]], [[BamUtil: diff|diff]], [[BamUtil: squeeze|squeeze]], [[BamUtil: findCigars|findCigars]], [[BamUtil: stats|stats]]&lt;br /&gt;
&lt;br /&gt;
== Citation ==&lt;br /&gt;
If you use BamUtil, please cite our publication on GotCloud which includes BamUtil: &lt;br /&gt;
[http://genome.cshlp.org/content/early/2015/04/14/gr.176552.114.abstract Jun, Goo, et al. &amp;quot;An efficient and scalable analysis framework for variant extraction and refinement from population scale DNA sequence data.&amp;quot; Genome research (2015): gr-176552.]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Programs =&lt;br /&gt;
&lt;br /&gt;
The software reads the beginning of an input file to determine if it is SAM/BAM.  To determine the format (SAM/BAM) of the output file, the software checks the output file&#039;s extension.  If the extension is &amp;quot;.bam&amp;quot; it writes a BAM file, otherwise it writes a SAM file.&lt;br /&gt;
&lt;br /&gt;
{{BamUtilPrograms}}&lt;/div&gt;</summary>
		<author><name>Mktrost</name></author>
	</entry>
	<entry>
		<id>http://genome.sph.umich.edu/w/index.php?title=LibStatGen_Troubleshooting&amp;diff=14943</id>
		<title>LibStatGen Troubleshooting</title>
		<link rel="alternate" type="text/html" href="http://genome.sph.umich.edu/w/index.php?title=LibStatGen_Troubleshooting&amp;diff=14943"/>
		<updated>2017-11-13T04:20:15Z</updated>

		<summary type="html">&lt;p&gt;Mktrost: /* Possible Compile Errors */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Possible Compile Errors =&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;If compilation fails due to warnings being treated as errors, please contact us so we can fix the warnings. As a work-around to get it to compile, you can disable the treatment of warnings as errors by editing libStatGen/general/Makefile to remove -Werror.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The following are a list of compile errors that have been encountered with recommendations on what they mean and how to fix them.&lt;br /&gt;
&lt;br /&gt;
== GenomeSequence.cpp:161: error: explicit instantiation... ==&lt;br /&gt;
If you are compiling on OSX and encounter this error:&lt;br /&gt;
;GenomeSequence.cpp&amp;lt;nowiki&amp;gt;:&amp;lt;/nowiki&amp;gt; In instantiation of ‘std&amp;lt;nowiki&amp;gt;::&amp;lt;/nowiki&amp;gt;basic_ostream&amp;lt;_CharT, _Traits&amp;gt;&amp;amp; std&amp;lt;nowiki&amp;gt;::&amp;lt;/nowiki&amp;gt;operator&amp;lt;&amp;lt;(std&amp;lt;nowiki&amp;gt;::&amp;lt;/nowiki&amp;gt;basic_ostream&amp;lt;_CharT, _Traits&amp;gt;&amp;amp;, const std&amp;lt;nowiki&amp;gt;::&amp;lt;/nowiki&amp;gt;basic_string&amp;lt;_CharT, _Traits, _Alloc&amp;gt;&amp;amp;) [with _CharT = char, _Traits = std&amp;lt;nowiki&amp;gt;::&amp;lt;/nowiki&amp;gt;char_traits&amp;lt;char&amp;gt;, _Alloc = std&amp;lt;nowiki&amp;gt;::&amp;lt;/nowiki&amp;gt;allocator&amp;lt;char&amp;gt;]’&amp;lt;nowiki&amp;gt;:&amp;lt;/nowiki&amp;gt;&amp;lt;br /&amp;gt;GenomeSequence.cpp&amp;lt;nowiki&amp;gt;:&amp;lt;/nowiki&amp;gt;161&amp;lt;nowiki&amp;gt;:&amp;lt;/nowiki&amp;gt;   instantiated from here&amp;lt;br /&amp;gt;GenomeSequence.cpp&amp;lt;nowiki&amp;gt;:&amp;lt;/nowiki&amp;gt;161&amp;lt;nowiki&amp;gt;:&amp;lt;/nowiki&amp;gt; error&amp;lt;nowiki&amp;gt;:&amp;lt;/nowiki&amp;gt; explicit instantiation of ‘std&amp;lt;nowiki&amp;gt;::&amp;lt;/nowiki&amp;gt;basic_ostream&amp;lt;_CharT, _Traits&amp;gt;&amp;amp; std&amp;lt;nowiki&amp;gt;::&amp;lt;/nowiki&amp;gt;operator&amp;lt;&amp;lt;(std&amp;lt;nowiki&amp;gt;::&amp;lt;/nowiki&amp;gt;basic_ostream&amp;lt;_CharT, _Traits&amp;gt;&amp;amp;, const std&amp;lt;nowiki&amp;gt;::&amp;lt;/nowiki&amp;gt;basic_string&amp;lt;_CharT, _Traits, _Alloc&amp;gt;&amp;amp;) [with _CharT = char, _Traits = std&amp;lt;nowiki&amp;gt;::&amp;lt;/nowiki&amp;gt;char_traits&amp;lt;char&amp;gt;, _Alloc = std&amp;lt;nowiki&amp;gt;::&amp;lt;/nowiki&amp;gt;allocator&amp;lt;char&amp;gt;]’ but no definition available&lt;br /&gt;
: Try compiling with:&lt;br /&gt;
 make USER_COMPILE_VARS=-mmacosx-version-min=10.8&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== error: Sam[filename].h: No such file or directory or &amp;quot;&#039;Sam[classname]&#039; has not been declared&amp;quot; ==&lt;br /&gt;
This error and other, similar errors with &amp;quot;Sam....h: No such file or directory&amp;quot; or &amp;quot;&#039;Sam...&#039; has not been declared&amp;quot; typically means that the library build failed.  Check for a previous error in your compile.&lt;br /&gt;
&lt;br /&gt;
A successful compile of the library will publish SamFile.h and all the other header files from the library into libStatGen/include.  If one of the programs within the statgen repository fails to compile with one of these errors, then the library did not successfully publish the header files and did not successfully build.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== InputFile.h (or any other library file): No such file or directory ==&lt;br /&gt;
Errors like the following:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
FastQFile.cpp:20:23: InputFile.h: No such file or directory&lt;br /&gt;
In file included from FastQFile.cpp:21:&lt;br /&gt;
FastQFile.h:23:26: StringBasics.h: No such file or directory&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Tend to occur if the library directory containing the file has not yet been compiled.  Try recompiling the entire library by typing make in libStatGen.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Compile Error on first time building ==&lt;br /&gt;
Record the error.&lt;br /&gt;
&lt;br /&gt;
Try to recompile and see if that fixes the problem.  If it does fix the compile error, let me know what the original error was so I can fix the dependency so it compiles in the correct order.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;NOTE: In the latest version, this should be fixed.&#039;&#039;&#039;&lt;/div&gt;</summary>
		<author><name>Mktrost</name></author>
	</entry>
	<entry>
		<id>http://genome.sph.umich.edu/w/index.php?title=Template:ToolGitRepo&amp;diff=14942</id>
		<title>Template:ToolGitRepo</title>
		<link rel="alternate" type="text/html" href="http://genome.sph.umich.edu/w/index.php?title=Template:ToolGitRepo&amp;diff=14942"/>
		<updated>2017-11-13T04:18:27Z</updated>

		<summary type="html">&lt;p&gt;Mktrost: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{#if: {{{noDownload|}}} |  | The {{{repoName}}} repository is available both via [[#Releases|release downloads]] and via github.}}&lt;br /&gt;
&lt;br /&gt;
On github, https://github.com/statgen/{{{repoName}}}, you can both browse and download the {{{repoName}}} source code as well as explore the history of changes.&lt;br /&gt;
&lt;br /&gt;
You can obtain the source either with or without git.&lt;br /&gt;
&lt;br /&gt;
{{#if: {{{nolibStatGen|}}} | |&lt;br /&gt;
{{#if: {{{libStatGen|}}} | A copy of libStatGen is included in certain releases of some statgen tools. |&lt;br /&gt;
The releases may be available both with and without libStatGen included.  &lt;br /&gt;
&lt;br /&gt;
If you do not use the release version that already contains libStatGen, you need to download the library: [[C++ Library: libStatGen|libStatGen]].&lt;br /&gt;
&lt;br /&gt;
If you try to compile {{{repoName}}} and it cannot find libStatGen, it will fail and provide instructions of what to do next:&lt;br /&gt;
* if libStatGen is in a different location then expected&lt;br /&gt;
** follow the directions to set the path to libStatGen&lt;br /&gt;
* if libStatGen is not downloaded and you have git&lt;br /&gt;
** &amp;lt;code&amp;gt;make libStatGen&amp;lt;/code&amp;gt; will download via git and build libStatGen&lt;br /&gt;
* if libStatGen is not downloaded and you don&#039;t have git&lt;br /&gt;
** See [[C++ Library: libStatGen|libStatGen]]&lt;br /&gt;
}}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== Using Git To Track the Current Development Version ===&lt;br /&gt;
&lt;br /&gt;
==== Clone (get your own copy) ====&lt;br /&gt;
You can create your own git clone (copy) using:&lt;br /&gt;
 git clone https://github.com/statgen/{{{repoName}}}.git&lt;br /&gt;
or&lt;br /&gt;
 git clone git://github.com/statgen/{{{repoName}}}.git&lt;br /&gt;
&lt;br /&gt;
Either of these commands create a directory called &amp;lt;code&amp;gt;{{{repoName}}}&amp;lt;/code&amp;gt; in the current directory.&lt;br /&gt;
&lt;br /&gt;
Then just &amp;lt;code&amp;gt;cd {{{repoName}}}&amp;lt;/code&amp;gt; and [[#Building|compile]].&lt;br /&gt;
&lt;br /&gt;
==== Get the latest Updates (update your copy) ====&lt;br /&gt;
To update your copy to the latest version (a major advantage of using git):&lt;br /&gt;
# &amp;lt;code&amp;gt;cd pathToYourCopy/{{{repoName}}}&amp;lt;/code&amp;gt;&lt;br /&gt;
# &amp;lt;code&amp;gt;make clean&amp;lt;/code&amp;gt;&lt;br /&gt;
# &amp;lt;code&amp;gt;git pull&amp;lt;/code&amp;gt;&lt;br /&gt;
# &amp;lt;code&amp;gt;make all&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Git Refresher ====&lt;br /&gt;
If you decide to use git, but need a refresher, see [[How To Use Git]] or [https://statgen.sph.umich.edu/wiki/How_To_Use_Git Notes on how to use git] (if you have access)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Downloading From GitHub Without Git ===&lt;br /&gt;
If you download the latest code/version, make sure you periodically update it by downloading a newer version.&lt;br /&gt;
&lt;br /&gt;
From github you can download:&lt;br /&gt;
# Latest Code (master branch)&lt;br /&gt;
#: via Website&lt;br /&gt;
#:# Goto: https://github.com/statgen/{{{repoName}}}&lt;br /&gt;
#:# Click on the &amp;lt;code&amp;gt;Download ZIP&amp;lt;/code&amp;gt; button on the right side panel.&lt;br /&gt;
#: via Command Line&lt;br /&gt;
#:: &amp;lt;code&amp;gt;wget https://github.com/statgen/{{{repoName}}}/archive/master.tar.gz&amp;lt;/code&amp;gt;&lt;br /&gt;
#::: or&lt;br /&gt;
#:: &amp;lt;code&amp;gt;wget https://github.com/statgen/{{{repoName}}}/archive/master.zip&amp;lt;/code&amp;gt;&lt;br /&gt;
# Specific Release (via a tag)&lt;br /&gt;
#: via Website&lt;br /&gt;
#:# Goto: https://github.com/statgen/{{{repoName}}}/releases to see the available releases&lt;br /&gt;
#:# Click &amp;lt;code&amp;gt;zip&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;tar.gz&amp;lt;/code&amp;gt; for the desired version.&lt;br /&gt;
#: via Command Line&lt;br /&gt;
#:: &amp;lt;code&amp;gt;wget https://github.com/statgen/{{{repoName}}}/archive/&amp;lt;tagName&amp;gt;.tar.gz&amp;lt;/code&amp;gt;&lt;br /&gt;
#::: or&lt;br /&gt;
#:: &amp;lt;code&amp;gt;wget https://github.com/statgen/{{{repoName}}}/archive/&amp;lt;tagName&amp;gt;.zip&amp;lt;/code&amp;gt;&lt;br /&gt;
{{#if: {{{latestReleaseBranch|}}} |&lt;br /&gt;
#Latest Release (via a branch)&lt;br /&gt;
#: via Website&lt;br /&gt;
#:# Goto: https://github.com/statgen/{{{repoName}}}/tree/{{{latestReleaseBranch}}} to see the latest release&lt;br /&gt;
#:# Click on the &amp;lt;code&amp;gt;Download ZIP&amp;lt;/code&amp;gt; button on the right side panel.&lt;br /&gt;
#: via Command Line&lt;br /&gt;
#:: &amp;lt;code&amp;gt;wget https://github.com/statgen/{{{repoName}}}/archive/{{{latestReleaseBranch}}}.tar.gz&amp;lt;/code&amp;gt;&lt;br /&gt;
#::: or&lt;br /&gt;
#:: &amp;lt;code&amp;gt;wget https://github.com/statgen/{{{repoName}}}/archive/{{{latestReleaseBranch}}}.zip&amp;lt;/code&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
After downloading the file, uncompress (unzip/untar) it.  The directory created will be named &amp;lt;code&amp;gt;{{{repoName}}}-&amp;lt;name of version you downloaded&amp;gt;&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{{#if: {{{skipBuild|}}}||&lt;br /&gt;
== Building ==&lt;br /&gt;
After obtaining the {{{repoName}}} repository (either by download or from github), compile the code using:&lt;br /&gt;
 &amp;lt;code&amp;gt;make all&amp;lt;/code&amp;gt;  &lt;br /&gt;
&lt;br /&gt;
Object (.o) files are compiled into the &amp;lt;code&amp;gt;obj&amp;lt;/code&amp;gt; directory with a subdirectory &amp;lt;code&amp;gt;debug&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;profile&amp;lt;/code&amp;gt; for the debugging and profiling objects.&lt;br /&gt;
&lt;br /&gt;
{{#if: {{{libBaseName|}}}|&lt;br /&gt;
This creates the libraries, {{{libBaseName}}}.a, {{{libBaseName}}}_debug.a, {{{libBaseName}}}_profile.a at the top level directory.&lt;br /&gt;
|&lt;br /&gt;
This creates the executable(s) in the &amp;lt;code&amp;gt;{{{repoName}}}/bin/&amp;lt;/code&amp;gt; directory, the debug executable(s) in the &amp;lt;code&amp;gt;{{{repoName}}}/bin/debug/&amp;lt;/code&amp;gt; directory, and the profiling executable(s) in the &amp;lt;code&amp;gt;{{{repoName}}}/bin/profile/&amp;lt;/code&amp;gt; directory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;make install&amp;lt;/code&amp;gt; installs the opt binary if you have permission.&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;make test&amp;lt;/code&amp;gt; compiles for opt, debug, and profile and runs the tests (found in the &amp;lt;code&amp;gt;test&amp;lt;/code&amp;gt; subdirectory).&lt;br /&gt;
&lt;br /&gt;
To see all make options, type &amp;lt;code&amp;gt;make help&amp;lt;/code&amp;gt;.&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If compilation fails due to warnings being treated as errors, please contact us so we can fix the warnings.  As a work-around to get it to compile, you can disable the treatment of warnings as errors by editing libStatGen/general/Makefile to remove &amp;lt;code&amp;gt;-Werror&amp;lt;/code&amp;gt;.&lt;/div&gt;</summary>
		<author><name>Mktrost</name></author>
	</entry>
	<entry>
		<id>http://genome.sph.umich.edu/w/index.php?title=LibStatGen_Download&amp;diff=14941</id>
		<title>LibStatGen Download</title>
		<link rel="alternate" type="text/html" href="http://genome.sph.umich.edu/w/index.php?title=LibStatGen_Download&amp;diff=14941"/>
		<updated>2017-11-13T04:04:10Z</updated>

		<summary type="html">&lt;p&gt;Mktrost: /* Official Releases */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= General libStatGen Information =&lt;br /&gt;
See [[C++ Library: libStatGen]].&lt;br /&gt;
&lt;br /&gt;
= Latest Development Versions =&lt;br /&gt;
For information about obtaining the latest Development Versions, see [[C++ Library: libStatGen#Where to Find It|Where to Find libStatGen]]&lt;br /&gt;
&lt;br /&gt;
= Official Releases =&lt;br /&gt;
If you prefer to run the last official release rather than the latest development version, you can download that here.&lt;br /&gt;
&lt;br /&gt;
To install an official release, unpack the downloaded file (tar xvf), cd into the libStatGen directory and type &amp;lt;code&amp;gt;make all&amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;LibStatGen.1.0.14 Release Notes&#039;&#039;&#039;&lt;br /&gt;
*Version 1.0.14 - Released 7/8/2015&lt;br /&gt;
** https://github.com/statgen/libStatGen/archive/v1.0.14.tar.gz&lt;br /&gt;
** Contains classes for general processing (string, reference file, parameters), bam, glf, fastq, and vcf&lt;br /&gt;
*** General Updates:&lt;br /&gt;
**** Compiling Updates:&lt;br /&gt;
***** PedigreeLoader.cpp - fix bool vs int definition&lt;br /&gt;
***** InputFile - add &#039;const&#039; to isOpen and ifeof methods. Also add comments about usage of &#039;operator &amp;gt;&amp;gt;&#039;&lt;br /&gt;
*** Bam/Tabix Updates:&lt;br /&gt;
**** Update how the index is stored in memory to not preallocate the maximum number of bins for each reference as this could use a lot of memory if there are a lot of references&lt;br /&gt;
*** BAM Updates:&lt;br /&gt;
**** SamFilter&lt;br /&gt;
***** Update to clear MapQ and N/A flags when marking as unmapped&lt;br /&gt;
***** Fix bug in clipping logic that didn&#039;t properly adjust the start position if the read was already clipped&lt;br /&gt;
*** VCF Updates:&lt;br /&gt;
**** Add missing include for c++11&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;LibStatGen.1.0.13 Release Notes&#039;&#039;&#039;&lt;br /&gt;
*Version 1.0.13 - Released 2/20/2015&lt;br /&gt;
** https://github.com/statgen/libStatGen/archive/v1.0.13.tar.gz&lt;br /&gt;
** Contains classes for general processing (string, reference file, parameters), bam, glf, fastq, and vcf&lt;br /&gt;
*** General Updates:&lt;br /&gt;
**** Added knetfile support to InputFile (only for bgzf files if KNET_ON=1 is set on compile line&lt;br /&gt;
**** GzipHeader - fix signed/unsigned comparison compile issue&lt;br /&gt;
**** Upgrade bgzf (also allow append mode)&lt;br /&gt;
*** Makefiles Updates:&lt;br /&gt;
**** Update dependencies to fix/improve some compiling issues&lt;br /&gt;
*** PhoneHome Updates:&lt;br /&gt;
**** Allow PhoneHome to be a legacy parameter&lt;br /&gt;
**** Update new version available message to stand out more&lt;br /&gt;
**** Fix bugs in checks for new version since it wasn&#039;t finding it.&lt;br /&gt;
*** BAM Updates:&lt;br /&gt;
**** SamReferenceInfo operator== - fix to not check hash, since hash could be different for same info&lt;br /&gt;
**** Pileup - improve error message for buffer overrun&lt;br /&gt;
*** VCF Updates:&lt;br /&gt;
**** Add option to update GT field&lt;br /&gt;
**** Add subset samples parameter to ReadRecord&lt;br /&gt;
**** Improve handling of adding CO header&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039; Older Releases&#039;&#039;&#039;&lt;br /&gt;
*[[Media:LibStatGen.1.0.12.tgz‎|LibStatGen.1.0.12.tgz‎]] - Released 5/14/2014&lt;br /&gt;
** Contains classes for general processing (string, reference file, parameters), bam, glf, fastq, and vcf&lt;br /&gt;
*** General Updates:&lt;br /&gt;
**** Improve Makefiles for adding additional libraries/creating external libraries&lt;br /&gt;
**** Cleanup compiling for mingw&lt;br /&gt;
**** Cleanup Copyrights&lt;br /&gt;
*** BAM Updates:&lt;br /&gt;
**** Update rmTags &amp;amp; getTagsString to accept &#039;,&#039; delimiter rather than just &#039;;&#039;&lt;br /&gt;
*[[Media:LibStatGen.1.0.11.tgz‎|LibStatGen.1.0.11.tar.gz‎]] - Released 2/28/2014&lt;br /&gt;
** Contains classes for general processing (string, reference file, parameters), bam, glf, fastq, and vcf&lt;br /&gt;
*** General Updates:&lt;br /&gt;
**** Cleanup compile warnings - should improve compatibility with Windows, RedHat, and older and newer compilers&lt;br /&gt;
**** StringBasics: Improve off-by-one overflow handling (from github user wavexx)&lt;br /&gt;
*** BAM Updates:&lt;br /&gt;
**** Fix it to properly handle &#039;B&#039; &amp;amp; &#039;f&#039; tags&lt;br /&gt;
**** Fix handling of duplicate tags&lt;br /&gt;
*** PhoneHome Updates:&lt;br /&gt;
**** Add parameters names (not values) to PhoneHome URL&lt;br /&gt;
*** VCF Updates:&lt;br /&gt;
**** Move allele count logic from VcfFileReader into VcfRecord.&lt;br /&gt;
*[[Media:LibStatGen.1.0.10.tar.gz‎|LibStatGen.1.0.10.tar.gz‎]] - Released 1/2/2014&lt;br /&gt;
** Contains classes for general processing (string, reference file, parameters), bam, glf, fastq, and vcf&lt;br /&gt;
*** Updates:&lt;br /&gt;
**** Add PhoneHome/version checking logic&lt;br /&gt;
***General Updates:&lt;br /&gt;
**** fix use of strncpy to fix compile problem for some users&lt;br /&gt;
**** Fix compile problem on gcc 4.8.1 by adding -Wno-strict-overflow in general/Makefile after -Werror&lt;br /&gt;
**** Reduce the default IFILE read buffer size from 1MB to 64KB.&lt;br /&gt;
**** Fix ifclose to take a IFILE reference so it can make the pointer 0 after closing&lt;br /&gt;
**** StringBasics::AsInteger now returns false if the string is empty.&lt;br /&gt;
**** GzipFileType - update to accept -.gz as stdin/stdout&lt;br /&gt;
**** Remove unnecssary line from Parameters Status call&lt;br /&gt;
**** Fix memory leak on Tabix destructor&lt;br /&gt;
*** Vcf Updates:&lt;br /&gt;
**** VCF - add class/methods to discard records based on ID&lt;br /&gt;
*** Bam Updates:&lt;br /&gt;
**** SamFlag - add isSecondary check&lt;br /&gt;
**** Fix SamFile so it only allows &#039;-&#039;, &#039;-.sam&#039;, &#039;-.bam&#039;, or &#039;-.ubam&#039; to indicate reading from stdin rather than anything that starts with &#039;-&#039; in order to protect it from misinterpreting another parameter as the stdin filename&lt;br /&gt;
**** SamRecord: Add warnings about Duplicate Tags being overwritten&lt;br /&gt;
**** SamFile - improve sort order validation error messages and compare using both String::Compare and strcmp to handle various sort mechanisms since neither matches samtools exactly (if either is successful, the sort order is OK)&lt;br /&gt;
*** Glf Updates:&lt;br /&gt;
**** GlfFile cleanup bugs/handle missind endMarkers &amp;amp; update &amp;quot;get&amp;quot; methods to be const&lt;br /&gt;
&lt;br /&gt;
*[[Media:LibStatGen.1.0.9.tgz‎|LibStatGen.1.0.9.tgz‎]] - Released 7/7/2013&lt;br /&gt;
** Contains classes for general processing (string, reference file, parameters), bam, glf, fastq, and vcf&lt;br /&gt;
*** Updates:&lt;br /&gt;
**** Update Makefile processing to check for a Makefile in the test directory before recursively calling make in there&lt;br /&gt;
**** Replace CFLAGS wtih COMPFLAGS&lt;br /&gt;
**** Update the Windows WIN32 if statements&lt;br /&gt;
***General Updates:&lt;br /&gt;
**** Add boundary check to StringBasics memory&lt;br /&gt;
**** Added support for new CIGAR characters (X &amp;amp; =)&lt;br /&gt;
**** Update bug in PedigreeLoader to specify WHITESPACE&lt;br /&gt;
**** add accessors for getting tabix information&lt;br /&gt;
*** Vcf Updates:&lt;br /&gt;
**** add ability to drop trailing missing Genotype fields&lt;br /&gt;
**** check that the tabix index is for VCF file type&lt;br /&gt;
**** Fix broken dependency&lt;br /&gt;
*** Bam Updates:&lt;br /&gt;
**** SamHeaderRecord: add accessor to get the value for the key&lt;br /&gt;
**** update some classes to have virtual destructors&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*[[Media:LibStatGen.1.0.8.tgz‎|LibStatGen.1.0.8.tgz‎]] - Released 1/29/2013&lt;br /&gt;
** Contains classes for general processing (string, reference file, parameters), bam, glf, fastq, and vcf&lt;br /&gt;
*** Updates:&lt;br /&gt;
**** Added VCF file handling (merged the vcf branch to master)&lt;br /&gt;
**** Add support for reading Tabix files&lt;br /&gt;
**** Add ReusableVector class that holds vectors that will remove only the last or be reset &amp;amp; reused without clearing memory.&lt;br /&gt;
&lt;br /&gt;
*[[Media:LibStatGen.1.0.7.tgz‎|LibStatGen.1.0.7.tgz‎]] - Released 1/29/2013&lt;br /&gt;
** Contains classes for general processing (string, reference file, parameters), bam, glf, and fastq&lt;br /&gt;
*** Updates: &lt;br /&gt;
**** Add operator== to StringIntHash&lt;br /&gt;
**** Cleanup compiling for files that are just headers with no .cpp&lt;br /&gt;
**** Update Makefile TOOLOBJ to handle fortran&lt;br /&gt;
**** ReferenceSequence.h fix compile problem on upgraded system&lt;br /&gt;
**** Add Makefile.extlib for compiling libraries that use libStatGen&lt;br /&gt;
*** BAM Updates:&lt;br /&gt;
**** Update to allow copying SamHeaderRecords and automatically update the SQ ReferenceInfo&lt;br /&gt;
**** Update SamFileHeader::getReferenceInfo() to return a SamReferenceInfo reference rather than ptr&lt;br /&gt;
**** Update SamRecord::getStringTag to return a const string pointer instead of just a string pointer&lt;br /&gt;
**** Update SamCoordOutput to add flushAll method&lt;br /&gt;
&lt;br /&gt;
* [[Media:LibStatGen.1.0.6.tgz‎|LibStatGen.1.0.6.tgz‎]] - Released 11/14/2012&lt;br /&gt;
** Contains classes for general processing (string, reference file, parameters), bam, glf, and fastq&lt;br /&gt;
*** Updates:&lt;br /&gt;
**** Fix a bug in the make install command&lt;br /&gt;
&lt;br /&gt;
* [[Media:LibStatGen.1.0.5.tgz‎|LibStatGen.1.0.5.tgz‎]] - Released 10/24/2012&lt;br /&gt;
** Contains classes for general processing (string, reference file, parameters), bam, glf, and fastq&lt;br /&gt;
*** Updates:&lt;br /&gt;
**** Cleanup compile warnings&lt;br /&gt;
**** Support compiling without ZLIB (use: make ZLIB_AVAIL=0)&lt;br /&gt;
*** BAM Updates:&lt;br /&gt;
**** Update to add error messages about failing to add a header&lt;br /&gt;
**** Handle a vtype of &#039;B&#039; in the TAG field (treats it like a string)&lt;br /&gt;
&lt;br /&gt;
* LibStatGen.1.0.4.tgz‎ - Released skipped&lt;br /&gt;
*[[Media:LibStatGen.1.0.3.tgz‎|LibStatGen.1.0.3.tgz‎]] - Released 09/19/2012&lt;br /&gt;
** Contains classes for general processing (string, reference file, parameters), bam, glf, and fastq&lt;br /&gt;
*** Additions:&lt;br /&gt;
**** Fix Makefile COMPILE_ANY_CHANGE logic to actually work&lt;br /&gt;
**** Fix compile problems on macs&lt;br /&gt;
***** Add #include &amp;lt;cstddef&amp;gt; to GzipFileType.h &amp;amp; #include &amp;lt;unistd.h&amp;gt; to MemoryMapArray.h&lt;br /&gt;
*** General Additions:&lt;br /&gt;
**** Update DBSNP processing in GenomeSequence to also accept gzipped files&lt;br /&gt;
**** Add support of fasta files in GenomeSequence&lt;br /&gt;
**** Update GenomeSequence constructor/open to create the umfa version if it doesn&#039;t already exist&lt;br /&gt;
**** Update StringAlias to add getAliases&lt;br /&gt;
**** Update StringHash to have an option to do case sensitive (instead of always case-insensitive)&lt;br /&gt;
**** Make library building PHONY so it is always checked for updates and only updated if objects are newer&lt;br /&gt;
*** BAM Additions:&lt;br /&gt;
**** Update BamIndex hex constant to use ULL&lt;br /&gt;
**** Cleanup handling of header errors&lt;br /&gt;
**** Update SamFileHeader to use case sensitive hashes&lt;br /&gt;
**** Make repeated header line keys a warning, not an error&lt;br /&gt;
*** FASTQ Additions:&lt;br /&gt;
**** Update to output average qualities&lt;br /&gt;
*[[Media:LibStatGen.1.0.2.tgz‎|LibStatGen.1.0.2.tgz‎]] - Released 05/16/2012&lt;br /&gt;
** Contains classes for general processing (string, reference file, parameters), bam, glf, and fastq&lt;br /&gt;
** Additions:&lt;br /&gt;
*** Add reverseComplement method to BaseUtilities.h&lt;br /&gt;
*[[Media:LibStatGen.1.0.1.tgz‎|LibStatGen.1.0.1.tgz‎]] - Released 05/04/2012&lt;br /&gt;
** Contains classes for general processing (string, reference file, parameters), bam, glf, and fastq&lt;br /&gt;
** BAM Additions:&lt;br /&gt;
*** Ability to use require/exclude flags when reading&lt;br /&gt;
*** CigarHelper for soft clipping&lt;br /&gt;
*** Fixed bug in BamIndex that wasn&#039;t closing the file&lt;br /&gt;
*** Additional cleanup/updates, see https://github.com/statgen/libStatGen/commits/master/bam for all changes between 10/10/2011 and 05/04/2012.&lt;br /&gt;
** General Additions:&lt;br /&gt;
*** Modifications to improve file handling/string processing&lt;br /&gt;
*** Fixed some compile warnings&lt;br /&gt;
*** Update Parameters class to always print warnings about unknown parameters to stderr&lt;br /&gt;
*** Update PedigreePerson to create/delete the strings object&lt;br /&gt;
*** Cleanup GenomeSequence to remove code that is also in BaseAsciiMap&lt;br /&gt;
** Samtools Modifications:&lt;br /&gt;
*** Do not use knetfile and fix compile warning&lt;br /&gt;
&lt;br /&gt;
*[[Media:LibStatGen.1.0.0.tgz‎|LibStatGen.1.0.0.tgz‎]] - Released 10/10/2011&lt;br /&gt;
** Contains classes for general processiong (string, reference file, parameters), bam, glf, and fastq&lt;br /&gt;
** Initial release of libStatGen.  It started from the library found in the deprecated StatGen repository.&lt;/div&gt;</summary>
		<author><name>Mktrost</name></author>
	</entry>
	<entry>
		<id>http://genome.sph.umich.edu/w/index.php?title=BamUtil&amp;diff=14940</id>
		<title>BamUtil</title>
		<link rel="alternate" type="text/html" href="http://genome.sph.umich.edu/w/index.php?title=BamUtil&amp;diff=14940"/>
		<updated>2017-11-13T03:55:56Z</updated>

		<summary type="html">&lt;p&gt;Mktrost: /* Full Release (includes libStatGen) */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:bamUtil]]&lt;br /&gt;
[[Category:C++]]&lt;br /&gt;
[[Category:Software]]&lt;br /&gt;
&lt;br /&gt;
= bamUtil Overview =&lt;br /&gt;
&lt;br /&gt;
bamUtil is a repository that contains several programs that perform operations on SAM/BAM files.  All of these programs are built into a single executable, &amp;lt;code&amp;gt;bam&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Getting Help ==&lt;br /&gt;
&lt;br /&gt;
If you have any questions please use the [http://groups.google.com/group/bamUtils bamUtil Google Group] to ask questions or recommend improvements to bamUtil.&lt;br /&gt;
&lt;br /&gt;
Alternatively, you can e-mail me, Mary Kate Wing, at mktrost@umich.edu.&lt;br /&gt;
&lt;br /&gt;
See [[BamUtil: FAQ]] to see if your question has already been answered.&lt;br /&gt;
&lt;br /&gt;
== Where to Find It ==&lt;br /&gt;
{{ToolGitRepo|repoName=bamUtil}}&lt;br /&gt;
&lt;br /&gt;
== Releases ==&lt;br /&gt;
&lt;br /&gt;
If you prefer to run the last official release rather than the latest development version, you can download that here.&lt;br /&gt;
&lt;br /&gt;
There are two versions of the release, one that include libStatGen and one that does not.  If you already have libStatGen installed and want to use your own copy, use the version that does not include libStatGen.&lt;br /&gt;
&lt;br /&gt;
=== Full Release (includes libStatGen) ===&lt;br /&gt;
&lt;br /&gt;
To install an official release, unpack the downloaded file (tar xvf), cd into the bamUtil_x.x.x directory and type make all.&lt;br /&gt;
&lt;br /&gt;
For version 1.0.14 and later, please download libStatGen and bamUtil separately: &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Version 1.0.14 - Released 7/8/2015&#039;&#039;&#039;&lt;br /&gt;
*[[LibStatGen Download#Official Releases|libStatGen version 1.0.14]]&lt;br /&gt;
*[[#Release of just BamUtil (does not include libStatGen)|bamUtil version 1.0.14]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Older Releases&#039;&#039;&#039;&lt;br /&gt;
* [[Media:BamUtilLibStatGen.1.0.13.tgz|BamUtilLibStatGen.1.0.13.tgz‎]] - Released 2/20/2015&lt;br /&gt;
** Contains: [[LibStatGen Download#Official Releases|libStatGen version 1.0.13]] - see link for version updates&lt;br /&gt;
** Contains: [[#Release of just BamUtil (does not include libStatGen)|bamUtil version 1.0.13]] - see link for version updates&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* [[Media:BamUtilLibStatGen.1.0.12.tar.gz|BamUtilLibStatGen.1.0.12.tgz‎]] - Released 5/14/2014&lt;br /&gt;
** Contains: [[LibStatGen Download#Official Releases|libStatGen version 1.0.12]] - see link for version updates&lt;br /&gt;
** Contains: [[#Release of just BamUtil (does not include libStatGen)|bamUtil version 1.0.12]] - see link for version updates&lt;br /&gt;
** Adds regions to [[BamUtil: mergeBam|mergeBam]]&lt;br /&gt;
** Accept &#039;,&#039; delimiters for the tags string input in [[BamUtil: squeeze|squeeze]], [[BamUtil: revert|revert]], &amp;amp; [[BamUtil: diff|diff]]&lt;br /&gt;
&lt;br /&gt;
*[[Media:BamUtilLibStatGen.1.0.11.tar.gz|BamUtilLibStatGen.1.0.11.tar.gz‎]] - Released 2/28/2014&lt;br /&gt;
** Contains: [[LibStatGen Download#Official Releases|libStatGen version 1.0.11]] - see link for version updates&lt;br /&gt;
** Contains: [[#Release of just BamUtil (does not include libStatGen)|bamUtil version 1.0.11]] - see link for version updates&lt;br /&gt;
** Now properly supports &#039;B&#039; &amp;amp; &#039;f&#039; tags&lt;br /&gt;
** Cleanup - compile issues&lt;br /&gt;
&lt;br /&gt;
*[[Media:BamUtilLibStatGen.1.0.10.tar.gz|BamUtilLibStatGen.1.0.10.tar.gz‎]] - Released 1/2/2014&lt;br /&gt;
** Contains: [[LibStatGen Download#Official Releases|libStatGen version 1.0.10]] - see link for version updates&lt;br /&gt;
** Contains: [[#Release of just BamUtil (does not include libStatGen)|bamUtil version 1.0.10]] - see link for version updates&lt;br /&gt;
** Adds PhoneHome/Version checking. &lt;br /&gt;
&lt;br /&gt;
*[[Media:BamUtilLibStatGen.1.0.9.tgz|BamUtilLibStatGen.1.0.9.tgz‎]] - Released 7/7/2013&lt;br /&gt;
** Contains: [[LibStatGen Download#Official Releases|libStatGen version 1.0.9]] &lt;br /&gt;
** Contains: [[#Release of just BamUtil (does not include libStatGen)|bamUtil version 1.0.9]]&lt;br /&gt;
** Update to [[BamUtil: mergeBam|mergeBam]]&lt;br /&gt;
*** Update to ignore PG lines with duplicate IDs&lt;br /&gt;
*** Update to accept merges of matching RG lines&lt;br /&gt;
*** Update to log to stderr if no log/out file is specified&lt;br /&gt;
* There is no version 1.0.8.  It was skipped to stay in line with libStatGen versions (libStatGen 1.0.8 added vcf support)&lt;br /&gt;
*[[Media:BamUtilLibStatGen.1.0.7.tgz|BamUtilLibStatGen.1.0.7.tgz‎]] - Released 1/29/2013&lt;br /&gt;
** Contains: [[LibStatGen Download#Official Releases|libStatGen version 1.0.7]] &lt;br /&gt;
** Contains: [[#Release of just BamUtil (does not include libStatGen)|bamUtil version 1.0.7]]&lt;br /&gt;
** Update to fix some compile issues on ubuntu 12.10&lt;br /&gt;
** Update use of SamRecord::getStringTag to expect the return of a const string pointer due to libStatGen v1.0.7 updates&lt;br /&gt;
** Update SamReferenceInfo usage due to libStatGen v1.0.7 updates&lt;br /&gt;
** Update to [[BamUtil: diff|diff]]&lt;br /&gt;
***   Fix DIFF to test and properly handle running out of available records.  Previously no message was printed when this happened and there was a bug for which file it freed&lt;br /&gt;
** Update to [[BamUtil: clipOverlap|clipOverlap]]&lt;br /&gt;
*** Update to facilitate adding other overlap handling functions&lt;br /&gt;
** Update to [[BamUtil: mergeBam|mergeBam]] (formerly RGMergeBam)&lt;br /&gt;
*** Rename RGMergeBam to MergeBam&lt;br /&gt;
*** Update to handle files that already have an RG&lt;br /&gt;
&lt;br /&gt;
*[[Media:BamUtilLibStatGen.1.0.6.tgz|BamUtilLibStatGen.1.0.6.tgz‎]] - Released 11/14/2012&lt;br /&gt;
** Contains: [[LibStatGen Download#Official Releases|libStatGen version 1.0.6]] &lt;br /&gt;
** Contains: [[#Release of just BamUtil (does not include libStatGen)|bamUtil version 1.0.6]]&lt;br /&gt;
** Update to [[BamUtil: trimBam|trimBam]]&lt;br /&gt;
*** Update to allow trimming a different number of bases from each end of the read&lt;br /&gt;
*[[Media:BamUtilLibStatGen.1.0.5.tgz|BamUtilLibStatGen.1.0.5.tgz‎]] - Released 10/24/2012&lt;br /&gt;
** Contains: [[LibStatGen Download#Official Releases|libStatGen version 1.0.5]] &lt;br /&gt;
** Contains: [[#Release of just BamUtil (does not include libStatGen)|bamUtil version 1.0.5]]&lt;br /&gt;
** Updates to: [[BamUtil: dedup|dedup]], [[BamUtil: polishBam|polishBam]], [[BamUtil: recab|recab]]&lt;br /&gt;
** Update to add compile option to compile without C++0x/C++11&lt;br /&gt;
** See [[#Release of just BamUtil (does not include libStatGen)|below]] for additional details on updates&lt;br /&gt;
*BamUtilLibStatGen.1.0.4.tgz‎ - Released skipped&lt;br /&gt;
*[[Media:BamUtilLibStatGen.1.0.3.tgz|BamUtilLibStatGen.1.0.3.tgz‎]] - Released 09/19/2012&lt;br /&gt;
** Contains: [[LibStatGen Download#Official Releases|libStatGen version 1.0.3]] &lt;br /&gt;
** Contains: [[#Release of just BamUtil (does not include libStatGen)|bamUtil version 1.0.3]]&lt;br /&gt;
** Adds: [[BamUtil: dedup|dedup]] [[BamUtil: recab|recab]]&lt;br /&gt;
*[[Media:BamUtilLibStatGen.1.0.2.tgz|BamUtilLibStatGen.1.0.2.tgz‎]] - Released 05/16/2012&lt;br /&gt;
** Contains: [[LibStatGen Download#Official Releases|libStatGen version 1.0.2]] &lt;br /&gt;
** Adds: [[BamUtil: bam2FastQ|bam2FastQ]]&lt;br /&gt;
*[[Media:BamUtilLibStatGen.1.0.1.tgz|BamUtilLibStatGen.1.0.1.tgz‎]] - Released 05/04/2012&lt;br /&gt;
** Contains: [[LibStatGen Download#Official Releases|libStatGen version 1.0.1]] &lt;br /&gt;
** Adds: [[BamUtil: splitBam|splitBam]], [[BamUtil: clipOverlap|clipOverlap]],  [[BamUtil: trimBam|trimBam]], [[BamUtil: polishBam|polishBam]], [[BamUtil: rgMergeBam|rgMergeBam]], [[BamUtil: gapInfo|gapInfo]]&lt;br /&gt;
** Adds additional functionality to [[BamUtil: stats|stats]]&lt;br /&gt;
** Adds leftShifting to [[BamUtil: writeRegion|writeRegion]] and [[BamUtil: convert|convert]]&lt;br /&gt;
** Adds more diff fields to [[BamUtil: diff|diff]]&lt;br /&gt;
* [[Media:BamUtilLibStatGen.1.0.0.tgz|BamUtilLibStatGen.1.0.0.tgz‎]] - Released 10/10/2011&lt;br /&gt;
**Initial release of bamUtil that includes libStatGen version 1.0.0.  It started from the tool found in the deprecated StatGen repository.&lt;br /&gt;
**Contains: [[LibStatGen Download#Official Releases|libStatGen version 1.0.0]] [[BamUtil: validate|validate]], [[BamUtil: convert|convert]], [[BamUtil: dumpHeader|dumpHeader]], [[BamUtil: splitChromosome|splitChromosome]], [[BamUtil: writeRegion|writeRegion]], [[BamUtil: dumpRefInfo|dumpRefInfo]], [[BamUtil: dumpIndex|dumpIndex]], [[BamUtil: readIndexedBam|readIndexedBam]], [[BamUtil: filter|filter]], [[BamUtil: readReference|readReference]], [[BamUtil: revert|revert]], [[BamUtil: diff|diff]], [[BamUtil: squeeze|squeeze]], [[BamUtil: findCigars|findCigars]], [[BamUtil: stats|stats]]&lt;br /&gt;
&lt;br /&gt;
=== Release of just BamUtil (does not include libStatGen) ===&lt;br /&gt;
&lt;br /&gt;
To install an official release, unpack the downloaded file (tar xvf), cd into the bamUtil_x.x.x directory and type make all.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;BamUtil.1.0.14 Release Notes&#039;&#039;&#039;&lt;br /&gt;
* BamUtil Version 1.0.14 - Released 7/8/2015&lt;br /&gt;
** https://github.com/statgen/bamUtil/archive/v1.0.14.tar.gz&lt;br /&gt;
** Requires, but does not include: [[LibStatGen Download#Official Releases|libStatGen version 1.0.14]]&lt;br /&gt;
** Update [[BamUtil: trimBam|trimBam]]&lt;br /&gt;
*** Add option to soft clip (-c) instead of trimming&lt;br /&gt;
** Update [[BamUtil: clipOverlap|clipOverlap]]&lt;br /&gt;
*** Add option to mark reads as unmapped if they are entirely clipped&lt;br /&gt;
** Update to [[BamUtil: bam2FastQ|bam2FastQ]]&lt;br /&gt;
*** Add option to gzip the output files&lt;br /&gt;
*** Add option to split Read Groups into separate fastq files&lt;br /&gt;
*** Add option to get the quality from a tag&lt;br /&gt;
** Update [[BamUtil: recab|recab]]&lt;br /&gt;
*** Update to ignore ref &#039;N&#039; when building the recalibration table&lt;br /&gt;
*** Add ability to bin&lt;br /&gt;
** Add Dedup_LowMem tool&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Older Releases&#039;&#039;&#039;&lt;br /&gt;
* BamUtil Version 1.0.13 - Released 2/20/2015&lt;br /&gt;
** https://github.com/statgen/bamUtil/archive/v1.0.13.tar.gz&lt;br /&gt;
** Requires, but does not include: [[LibStatGen Download#Official Releases|libStatGen version 1.0.13]]&lt;br /&gt;
** Makefile Updates&lt;br /&gt;
*** Improve logic to determine actual path for the library&lt;br /&gt;
*** Update to append to USER_COMPILE_VARS even if specified on the command line&lt;br /&gt;
** Update [[BamUtil: writeRegion|writeRegion]]&lt;br /&gt;
*** Add option to specify readnames to keep in a file&lt;br /&gt;
*** Fixed bug that if a read overlapped 2 BED positions, it was printed twice&lt;br /&gt;
** Update to [[BamUtil: bam2FastQ|bam2FastQ]]&lt;br /&gt;
*** Update to skip non-primary reads&lt;br /&gt;
** Update to [[BamUtil: polishBam|polishBam]]&lt;br /&gt;
*** Update to handle &#039;\t&#039; string inputs and to add CO option&lt;br /&gt;
*** Fix MD5sum calculation to convert fasta to uppercase prior to calculating&lt;br /&gt;
&lt;br /&gt;
* [[Media:BamUtil.1.0.12.tgz|BamUtil.1.0.12.tgz‎]] - Released 5/14/2014&lt;br /&gt;
** Requires, but does not include: [[LibStatGen Download#Official Releases|libStatGen version 1.0.12]]&lt;br /&gt;
** Update [[BamUtil: mergeBam|mergeBam]]&lt;br /&gt;
*** Add a regions option&lt;br /&gt;
** Update to [[BamUtil: squeeze|squeeze]], [[BamUtil: revert|revert]], [[BamUtil: diff|diff]]&lt;br /&gt;
*** Also accept &#039;,&#039; instead of just &#039;;&#039; as the delimiter in the input tags string.&lt;br /&gt;
&lt;br /&gt;
* [[Media:BamUtil.1.0.11.tgz|BamUtil.1.0.11.tgz‎]] - Released 2/28/2014&lt;br /&gt;
** Requires, but does not include: [[LibStatGen Download#Official Releases|libStatGen version 1.0.11]]&lt;br /&gt;
*** Adds support for &#039;B&#039; &amp;amp; &#039;f&#039; tags that did not work properly before.&lt;br /&gt;
** Update [[BamUtil: splitBam|splitBam]] &amp;amp; [[BamUtil: polishBam|polishBam]]&lt;br /&gt;
*** Update to work properly if log &amp;amp; output file are not specified (no longer creates &#039;.log&#039;)&lt;br /&gt;
** Update Main dummy/example tool to indicate the correct tool&lt;br /&gt;
** Update to [[BamUtil: bam2FastQ|bam2FastQ]], [[BamUtil: clipOverlap|clipOverlap]], [[BamUtil: filter|filter]], [[BamUtil: mergeBam|mergeBam]], [[BamUtil: splitBam|splitBam]], [[BamUtil: squeeze|squeeze]], [[BamUtil: stats|stats]]&lt;br /&gt;
*** Cleanup usage/parameter descriptions&lt;br /&gt;
** Update [[BamUtil: revert|revert]]&lt;br /&gt;
*** Update compatibility with libStatGen due to &#039;B&#039; &amp;amp; &#039;f&#039; tag handling updates&lt;br /&gt;
** Add tests for &#039;B&#039; &amp;amp; &#039;f&#039; tags&lt;br /&gt;
&lt;br /&gt;
* [[Media:BamUtil.1.0.10.tar.gz|BamUtil.1.0.10.tar.gz‎]] - Released 1/2/2014&lt;br /&gt;
** Requires, but does not include: [[LibStatGen Download#Official Releases|libStatGen version 1.0.10]]&lt;br /&gt;
** All&lt;br /&gt;
*** Add PhoneHome/version checking&lt;br /&gt;
*** Make sub-program names case independent&lt;br /&gt;
*** Fix Logger.cpp compiler warning&lt;br /&gt;
** Adds: [[BamUtil: explainFlags|explainFlags]] - describes the SAM/BAM flags based on the flag value&lt;br /&gt;
** Update to [[BamUtil: stats|stats]]&lt;br /&gt;
*** Fix Stats to not try to not try to process a record after it is out of the loop (it would already have been processed or is invalid)&lt;br /&gt;
** Update to [[BamUtil: splitBam|splitBam]]&lt;br /&gt;
*** fix description of --noeof option&lt;br /&gt;
** Update to [[BamUtil: writeRegion|writeRegion]]&lt;br /&gt;
*** add exclude/required flags&lt;br /&gt;
** Update to [[BamUtil: dedup|dedup]] &amp;amp; [[BamUtil: recab|recab]]&lt;br /&gt;
*** Ignore secondary reads for dedup and making the recalibration table.&lt;br /&gt;
*** skip QC Failures&lt;br /&gt;
*** add excludeFlags parameters&lt;br /&gt;
** Update to [[BamUtil: clipOverlap|clipOverlap]]&lt;br /&gt;
*** add exclude flags&lt;br /&gt;
*** fix bug for readName sorted when a read is filtered due to flags&lt;br /&gt;
*** add sorting validation&lt;br /&gt;
** Update to [[BamUtil: bam2FastQ|bam2FastQ]]&lt;br /&gt;
*** add --merge option to generate interleaved files.&lt;br /&gt;
*** update to open the input file before opening the output files, so if there is an error, the outputs aren&#039;t opened&lt;br /&gt;
** Update to [[BamUtil: mergeBam|mergeBam]]&lt;br /&gt;
*** add option to ignore the RG PI field when checking headers&lt;br /&gt;
*** add more informative header merge error messages&lt;br /&gt;
&lt;br /&gt;
* [[Media:BamUtil.1.0.9.tgz|BamUtil.1.0.9.tgz‎]] - Released 7/7/2013&lt;br /&gt;
** Requires, but does not include: [[LibStatGen Download#Official Releases|libStatGen version 1.0.9]] (version 1.0.7 should also work)&lt;br /&gt;
** Update to [[BamUtil: mergeBam|mergeBam]]&lt;br /&gt;
*** Update to ignore PG lines with duplicate IDs&lt;br /&gt;
*** Update to accept merges of matching RG lines&lt;br /&gt;
*** Update to log to stderr if no log/out file is specified&lt;br /&gt;
&lt;br /&gt;
*[[Media:BamUtil.1.0.7.tgz|BamUtil.1.0.7.tgz‎]] - Released 1/29/2013&lt;br /&gt;
** Requires, but does not include: [[LibStatGen Download#Official Releases|libStatGen version 1.0.7]] or above&lt;br /&gt;
** Update to fix some compile issues on ubuntu 12.10&lt;br /&gt;
** Update use of SamRecord::getStringTag to expect the return of a const string pointer due to libStatGen v1.0.7 updates&lt;br /&gt;
** Update SamReferenceInfo usage due to libStatGen v1.0.7 updates&lt;br /&gt;
** Update to [[BamUtil: diff|diff]]&lt;br /&gt;
***   Fix DIFF to test and properly handle running out of available records.  Previously no message was printed when this happened and there was a bug for which file it freed&lt;br /&gt;
** Update to [[BamUtil: clipOverlap|clipOverlap]]&lt;br /&gt;
*** Update to facilitate adding other overlap handling functions&lt;br /&gt;
** Update to [[BamUtil: mergeBam|mergeBam]] (formerly RGMergeBam)&lt;br /&gt;
*** Rename RGMergeBam to MergeBam&lt;br /&gt;
*** Update to handle files that already have an RG&lt;br /&gt;
*[[Media:BamUtil.1.0.6.tgz|BamUtil.1.0.6.tgz‎]] - Released 11/14/2012&lt;br /&gt;
** Update to [[BamUtil: trimBam|trimBam]]&lt;br /&gt;
*** Update to allow trimming a different number of bases from each end of the read&lt;br /&gt;
*[[Media:BamUtil.1.0.5.tgz|BamUtil.1.0.5.tgz‎]] - Released 10/24/2012&lt;br /&gt;
** Update to [[BamUtil: dedup|dedup]]&lt;br /&gt;
*** Update logic for which pair to keep if they have the same quality&lt;br /&gt;
** Update to [[BamUtil: polishBam|polishBam]]&lt;br /&gt;
*** Update to print the number of successful header additions&lt;br /&gt;
** Update to [[BamUtil: recab|recab]]&lt;br /&gt;
*** Update to print the number of base skipped due to the base quality&lt;br /&gt;
** General Updates&lt;br /&gt;
*** Update to add compile option to compile without C++0x/C++11&lt;br /&gt;
*BamUtil.1.0.4.tgz‎ - Released skipped&lt;br /&gt;
*[[Media:BamUtil.1.0.3.tgz|BamUtil.1.0.3.tgz‎]] - Released 09/19/2012&lt;br /&gt;
** Adds: [[BamUtil: dedup|dedup]] [[BamUtil: recab|recab]]&lt;br /&gt;
** General Updates&lt;br /&gt;
*** Update Logger to write to stderr if output is stdout&lt;br /&gt;
** Update to [[BamUtil: stats|stats]]&lt;br /&gt;
*** Add required/exclude flags&lt;br /&gt;
*** Exclude Clips if excluding umapped&lt;br /&gt;
*** Add --withinRegion flag&lt;br /&gt;
*** Update phred/qual counts to be uint64_t instead of int to avoid overflow&lt;br /&gt;
** Update to [[BamUtil: validate|validate]]&lt;br /&gt;
*** Detect header failures&lt;br /&gt;
** Update to [[BamUtil: diff|diff]]&lt;br /&gt;
*** Update to specify chromosome/pos in ZP as a string rather than int so both can be shown&lt;br /&gt;
** Update to [[BamUtil: readReference|readReference]]&lt;br /&gt;
*** Output error message if the reference name is not found&lt;br /&gt;
** Update to [[BamUtil: splitChromosome|splitChromosome]]&lt;br /&gt;
*** Update to actually split the chromosomes and not just hard coded to output chromosomes ids 0-22&lt;br /&gt;
** Update Makefile to have cloneLib for cloning libStatGen&lt;br /&gt;
*[[Media:BamUtil.1.0.2.tgz|BamUtil.1.0.2.tgz‎]] - Released 05/16/2012&lt;br /&gt;
** Adds: [[BamUtil: bam2FastQ|bam2FastQ]]&lt;br /&gt;
*[[Media:BamUtil.1.0.1.tgz|BamUtil.1.0.1.tgz‎]] - Released 05/04/2012&lt;br /&gt;
** Adds: [[BamUtil: splitBam|splitBam]], [[BamUtil: clipOverlap|clipOverlap]],  [[BamUtil: trimBam|trimBam]], [[BamUtil: polishBam|polishBam]], [[BamUtil: rgMergeBam|rgMergeBam]], [[BamUtil: gapInfo|gapInfo]]&lt;br /&gt;
** Adds additional functionality to [[BamUtil: stats|stats]]&lt;br /&gt;
** Adds leftShifting to [[BamUtil: writeRegion|writeRegion]] and [[BamUtil: convert|convert]]&lt;br /&gt;
** Adds more diff fields to [[BamUtil: diff|diff]]&lt;br /&gt;
*[[Media:BamUtil.1.0.0.tgz|BamUtil.1.0.0.tgz‎]] - Released 10/10/2011&lt;br /&gt;
**Initial release of just bamUtil.  It started from the tool found in the deprecated StatGen repository.&lt;br /&gt;
**Contains: [[BamUtil: validate|validate]], [[BamUtil: convert|convert]], [[BamUtil: dumpHeader|dumpHeader]], [[BamUtil: splitChromosome|splitChromosome]], [[BamUtil: writeRegion|writeRegion]], [[BamUtil: dumpRefInfo|dumpRefInfo]], [[BamUtil: dumpIndex|dumpIndex]], [[BamUtil: readIndexedBam|readIndexedBam]], [[BamUtil: filter|filter]], [[BamUtil: readReference|readReference]], [[BamUtil: revert|revert]], [[BamUtil: diff|diff]], [[BamUtil: squeeze|squeeze]], [[BamUtil: findCigars|findCigars]], [[BamUtil: stats|stats]]&lt;br /&gt;
&lt;br /&gt;
= Programs =&lt;br /&gt;
&lt;br /&gt;
The software reads the beginning of an input file to determine if it is SAM/BAM.  To determine the format (SAM/BAM) of the output file, the software checks the output file&#039;s extension.  If the extension is &amp;quot;.bam&amp;quot; it writes a BAM file, otherwise it writes a SAM file.&lt;br /&gt;
&lt;br /&gt;
{{BamUtilPrograms}}&lt;/div&gt;</summary>
		<author><name>Mktrost</name></author>
	</entry>
	<entry>
		<id>http://genome.sph.umich.edu/w/index.php?title=BamUtil&amp;diff=14939</id>
		<title>BamUtil</title>
		<link rel="alternate" type="text/html" href="http://genome.sph.umich.edu/w/index.php?title=BamUtil&amp;diff=14939"/>
		<updated>2017-11-13T03:49:26Z</updated>

		<summary type="html">&lt;p&gt;Mktrost: /* Release of just BamUtil (does not include libStatGen) */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:bamUtil]]&lt;br /&gt;
[[Category:C++]]&lt;br /&gt;
[[Category:Software]]&lt;br /&gt;
&lt;br /&gt;
= bamUtil Overview =&lt;br /&gt;
&lt;br /&gt;
bamUtil is a repository that contains several programs that perform operations on SAM/BAM files.  All of these programs are built into a single executable, &amp;lt;code&amp;gt;bam&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Getting Help ==&lt;br /&gt;
&lt;br /&gt;
If you have any questions please use the [http://groups.google.com/group/bamUtils bamUtil Google Group] to ask questions or recommend improvements to bamUtil.&lt;br /&gt;
&lt;br /&gt;
Alternatively, you can e-mail me, Mary Kate Wing, at mktrost@umich.edu.&lt;br /&gt;
&lt;br /&gt;
See [[BamUtil: FAQ]] to see if your question has already been answered.&lt;br /&gt;
&lt;br /&gt;
== Where to Find It ==&lt;br /&gt;
{{ToolGitRepo|repoName=bamUtil}}&lt;br /&gt;
&lt;br /&gt;
== Releases ==&lt;br /&gt;
&lt;br /&gt;
If you prefer to run the last official release rather than the latest development version, you can download that here.&lt;br /&gt;
&lt;br /&gt;
There are two versions of the release, one that include libStatGen and one that does not.  If you already have libStatGen installed and want to use your own copy, use the version that does not include libStatGen.&lt;br /&gt;
&lt;br /&gt;
=== Full Release (includes libStatGen) ===&lt;br /&gt;
&lt;br /&gt;
To install an official release, unpack the downloaded file (tar xvf), cd into the bamUtil_x.x.x directory and type make all.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Media:BamUtilLibStatGen.1.0.13.tgz|BamUtilLibStatGen.1.0.13.tgz‎]] - Released 2/20/2015&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;BamUtilLibStatGen.1.0.13 Release Notes&#039;&#039;&#039;&lt;br /&gt;
* Contains: [[LibStatGen Download#Official Releases|libStatGen version 1.0.13]] - see link for version updates&lt;br /&gt;
* Contains: [[#Release of just BamUtil (does not include libStatGen)|bamUtil version 1.0.13]] - see link for version updates&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Older Releases&#039;&#039;&#039;&lt;br /&gt;
* [[Media:BamUtilLibStatGen.1.0.12.tar.gz|BamUtilLibStatGen.1.0.12.tgz‎]] - Released 5/14/2014&lt;br /&gt;
** Contains: [[LibStatGen Download#Official Releases|libStatGen version 1.0.12]] - see link for version updates&lt;br /&gt;
** Contains: [[#Release of just BamUtil (does not include libStatGen)|bamUtil version 1.0.12]] - see link for version updates&lt;br /&gt;
** Adds regions to [[BamUtil: mergeBam|mergeBam]]&lt;br /&gt;
** Accept &#039;,&#039; delimiters for the tags string input in [[BamUtil: squeeze|squeeze]], [[BamUtil: revert|revert]], &amp;amp; [[BamUtil: diff|diff]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*[[Media:BamUtilLibStatGen.1.0.11.tar.gz|BamUtilLibStatGen.1.0.11.tar.gz‎]] - Released 2/28/2014&lt;br /&gt;
** Contains: [[LibStatGen Download#Official Releases|libStatGen version 1.0.11]] - see link for version updates&lt;br /&gt;
** Contains: [[#Release of just BamUtil (does not include libStatGen)|bamUtil version 1.0.11]] - see link for version updates&lt;br /&gt;
** Now properly supports &#039;B&#039; &amp;amp; &#039;f&#039; tags&lt;br /&gt;
** Cleanup - compile issues&lt;br /&gt;
&lt;br /&gt;
*[[Media:BamUtilLibStatGen.1.0.10.tar.gz|BamUtilLibStatGen.1.0.10.tar.gz‎]] - Released 1/2/2014&lt;br /&gt;
** Contains: [[LibStatGen Download#Official Releases|libStatGen version 1.0.10]] - see link for version updates&lt;br /&gt;
** Contains: [[#Release of just BamUtil (does not include libStatGen)|bamUtil version 1.0.10]] - see link for version updates&lt;br /&gt;
** Adds PhoneHome/Version checking. &lt;br /&gt;
&lt;br /&gt;
*[[Media:BamUtilLibStatGen.1.0.9.tgz|BamUtilLibStatGen.1.0.9.tgz‎]] - Released 7/7/2013&lt;br /&gt;
** Contains: [[LibStatGen Download#Official Releases|libStatGen version 1.0.9]] &lt;br /&gt;
** Contains: [[#Release of just BamUtil (does not include libStatGen)|bamUtil version 1.0.9]]&lt;br /&gt;
** Update to [[BamUtil: mergeBam|mergeBam]]&lt;br /&gt;
*** Update to ignore PG lines with duplicate IDs&lt;br /&gt;
*** Update to accept merges of matching RG lines&lt;br /&gt;
*** Update to log to stderr if no log/out file is specified&lt;br /&gt;
* There is no version 1.0.8.  It was skipped to stay in line with libStatGen versions (libStatGen 1.0.8 added vcf support)&lt;br /&gt;
*[[Media:BamUtilLibStatGen.1.0.7.tgz|BamUtilLibStatGen.1.0.7.tgz‎]] - Released 1/29/2013&lt;br /&gt;
** Contains: [[LibStatGen Download#Official Releases|libStatGen version 1.0.7]] &lt;br /&gt;
** Contains: [[#Release of just BamUtil (does not include libStatGen)|bamUtil version 1.0.7]]&lt;br /&gt;
** Update to fix some compile issues on ubuntu 12.10&lt;br /&gt;
** Update use of SamRecord::getStringTag to expect the return of a const string pointer due to libStatGen v1.0.7 updates&lt;br /&gt;
** Update SamReferenceInfo usage due to libStatGen v1.0.7 updates&lt;br /&gt;
** Update to [[BamUtil: diff|diff]]&lt;br /&gt;
***   Fix DIFF to test and properly handle running out of available records.  Previously no message was printed when this happened and there was a bug for which file it freed&lt;br /&gt;
** Update to [[BamUtil: clipOverlap|clipOverlap]]&lt;br /&gt;
*** Update to facilitate adding other overlap handling functions&lt;br /&gt;
** Update to [[BamUtil: mergeBam|mergeBam]] (formerly RGMergeBam)&lt;br /&gt;
*** Rename RGMergeBam to MergeBam&lt;br /&gt;
*** Update to handle files that already have an RG&lt;br /&gt;
&lt;br /&gt;
*[[Media:BamUtilLibStatGen.1.0.6.tgz|BamUtilLibStatGen.1.0.6.tgz‎]] - Released 11/14/2012&lt;br /&gt;
** Contains: [[LibStatGen Download#Official Releases|libStatGen version 1.0.6]] &lt;br /&gt;
** Contains: [[#Release of just BamUtil (does not include libStatGen)|bamUtil version 1.0.6]]&lt;br /&gt;
** Update to [[BamUtil: trimBam|trimBam]]&lt;br /&gt;
*** Update to allow trimming a different number of bases from each end of the read&lt;br /&gt;
*[[Media:BamUtilLibStatGen.1.0.5.tgz|BamUtilLibStatGen.1.0.5.tgz‎]] - Released 10/24/2012&lt;br /&gt;
** Contains: [[LibStatGen Download#Official Releases|libStatGen version 1.0.5]] &lt;br /&gt;
** Contains: [[#Release of just BamUtil (does not include libStatGen)|bamUtil version 1.0.5]]&lt;br /&gt;
** Updates to: [[BamUtil: dedup|dedup]], [[BamUtil: polishBam|polishBam]], [[BamUtil: recab|recab]]&lt;br /&gt;
** Update to add compile option to compile without C++0x/C++11&lt;br /&gt;
** See [[#Release of just BamUtil (does not include libStatGen)|below]] for additional details on updates&lt;br /&gt;
*BamUtilLibStatGen.1.0.4.tgz‎ - Released skipped&lt;br /&gt;
*[[Media:BamUtilLibStatGen.1.0.3.tgz|BamUtilLibStatGen.1.0.3.tgz‎]] - Released 09/19/2012&lt;br /&gt;
** Contains: [[LibStatGen Download#Official Releases|libStatGen version 1.0.3]] &lt;br /&gt;
** Contains: [[#Release of just BamUtil (does not include libStatGen)|bamUtil version 1.0.3]]&lt;br /&gt;
** Adds: [[BamUtil: dedup|dedup]] [[BamUtil: recab|recab]]&lt;br /&gt;
*[[Media:BamUtilLibStatGen.1.0.2.tgz|BamUtilLibStatGen.1.0.2.tgz‎]] - Released 05/16/2012&lt;br /&gt;
** Contains: [[LibStatGen Download#Official Releases|libStatGen version 1.0.2]] &lt;br /&gt;
** Adds: [[BamUtil: bam2FastQ|bam2FastQ]]&lt;br /&gt;
*[[Media:BamUtilLibStatGen.1.0.1.tgz|BamUtilLibStatGen.1.0.1.tgz‎]] - Released 05/04/2012&lt;br /&gt;
** Contains: [[LibStatGen Download#Official Releases|libStatGen version 1.0.1]] &lt;br /&gt;
** Adds: [[BamUtil: splitBam|splitBam]], [[BamUtil: clipOverlap|clipOverlap]],  [[BamUtil: trimBam|trimBam]], [[BamUtil: polishBam|polishBam]], [[BamUtil: rgMergeBam|rgMergeBam]], [[BamUtil: gapInfo|gapInfo]]&lt;br /&gt;
** Adds additional functionality to [[BamUtil: stats|stats]]&lt;br /&gt;
** Adds leftShifting to [[BamUtil: writeRegion|writeRegion]] and [[BamUtil: convert|convert]]&lt;br /&gt;
** Adds more diff fields to [[BamUtil: diff|diff]]&lt;br /&gt;
* [[Media:BamUtilLibStatGen.1.0.0.tgz|BamUtilLibStatGen.1.0.0.tgz‎]] - Released 10/10/2011&lt;br /&gt;
**Initial release of bamUtil that includes libStatGen version 1.0.0.  It started from the tool found in the deprecated StatGen repository.&lt;br /&gt;
**Contains: [[LibStatGen Download#Official Releases|libStatGen version 1.0.0]] [[BamUtil: validate|validate]], [[BamUtil: convert|convert]], [[BamUtil: dumpHeader|dumpHeader]], [[BamUtil: splitChromosome|splitChromosome]], [[BamUtil: writeRegion|writeRegion]], [[BamUtil: dumpRefInfo|dumpRefInfo]], [[BamUtil: dumpIndex|dumpIndex]], [[BamUtil: readIndexedBam|readIndexedBam]], [[BamUtil: filter|filter]], [[BamUtil: readReference|readReference]], [[BamUtil: revert|revert]], [[BamUtil: diff|diff]], [[BamUtil: squeeze|squeeze]], [[BamUtil: findCigars|findCigars]], [[BamUtil: stats|stats]]&lt;br /&gt;
&lt;br /&gt;
=== Release of just BamUtil (does not include libStatGen) ===&lt;br /&gt;
&lt;br /&gt;
To install an official release, unpack the downloaded file (tar xvf), cd into the bamUtil_x.x.x directory and type make all.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;BamUtil.1.0.14 Release Notes&#039;&#039;&#039;&lt;br /&gt;
* BamUtil Version 1.0.14 - Released 7/8/2015&lt;br /&gt;
** https://github.com/statgen/bamUtil/archive/v1.0.14.tar.gz&lt;br /&gt;
** Requires, but does not include: [[LibStatGen Download#Official Releases|libStatGen version 1.0.14]]&lt;br /&gt;
** Update [[BamUtil: trimBam|trimBam]]&lt;br /&gt;
*** Add option to soft clip (-c) instead of trimming&lt;br /&gt;
** Update [[BamUtil: clipOverlap|clipOverlap]]&lt;br /&gt;
*** Add option to mark reads as unmapped if they are entirely clipped&lt;br /&gt;
** Update to [[BamUtil: bam2FastQ|bam2FastQ]]&lt;br /&gt;
*** Add option to gzip the output files&lt;br /&gt;
*** Add option to split Read Groups into separate fastq files&lt;br /&gt;
*** Add option to get the quality from a tag&lt;br /&gt;
** Update [[BamUtil: recab|recab]]&lt;br /&gt;
*** Update to ignore ref &#039;N&#039; when building the recalibration table&lt;br /&gt;
*** Add ability to bin&lt;br /&gt;
** Add Dedup_LowMem tool&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Older Releases&#039;&#039;&#039;&lt;br /&gt;
* BamUtil Version 1.0.13 - Released 2/20/2015&lt;br /&gt;
** https://github.com/statgen/bamUtil/archive/v1.0.13.tar.gz&lt;br /&gt;
** Requires, but does not include: [[LibStatGen Download#Official Releases|libStatGen version 1.0.13]]&lt;br /&gt;
** Makefile Updates&lt;br /&gt;
*** Improve logic to determine actual path for the library&lt;br /&gt;
*** Update to append to USER_COMPILE_VARS even if specified on the command line&lt;br /&gt;
** Update [[BamUtil: writeRegion|writeRegion]]&lt;br /&gt;
*** Add option to specify readnames to keep in a file&lt;br /&gt;
*** Fixed bug that if a read overlapped 2 BED positions, it was printed twice&lt;br /&gt;
** Update to [[BamUtil: bam2FastQ|bam2FastQ]]&lt;br /&gt;
*** Update to skip non-primary reads&lt;br /&gt;
** Update to [[BamUtil: polishBam|polishBam]]&lt;br /&gt;
*** Update to handle &#039;\t&#039; string inputs and to add CO option&lt;br /&gt;
*** Fix MD5sum calculation to convert fasta to uppercase prior to calculating&lt;br /&gt;
&lt;br /&gt;
* [[Media:BamUtil.1.0.12.tgz|BamUtil.1.0.12.tgz‎]] - Released 5/14/2014&lt;br /&gt;
** Requires, but does not include: [[LibStatGen Download#Official Releases|libStatGen version 1.0.12]]&lt;br /&gt;
** Update [[BamUtil: mergeBam|mergeBam]]&lt;br /&gt;
*** Add a regions option&lt;br /&gt;
** Update to [[BamUtil: squeeze|squeeze]], [[BamUtil: revert|revert]], [[BamUtil: diff|diff]]&lt;br /&gt;
*** Also accept &#039;,&#039; instead of just &#039;;&#039; as the delimiter in the input tags string.&lt;br /&gt;
&lt;br /&gt;
* [[Media:BamUtil.1.0.11.tgz|BamUtil.1.0.11.tgz‎]] - Released 2/28/2014&lt;br /&gt;
** Requires, but does not include: [[LibStatGen Download#Official Releases|libStatGen version 1.0.11]]&lt;br /&gt;
*** Adds support for &#039;B&#039; &amp;amp; &#039;f&#039; tags that did not work properly before.&lt;br /&gt;
** Update [[BamUtil: splitBam|splitBam]] &amp;amp; [[BamUtil: polishBam|polishBam]]&lt;br /&gt;
*** Update to work properly if log &amp;amp; output file are not specified (no longer creates &#039;.log&#039;)&lt;br /&gt;
** Update Main dummy/example tool to indicate the correct tool&lt;br /&gt;
** Update to [[BamUtil: bam2FastQ|bam2FastQ]], [[BamUtil: clipOverlap|clipOverlap]], [[BamUtil: filter|filter]], [[BamUtil: mergeBam|mergeBam]], [[BamUtil: splitBam|splitBam]], [[BamUtil: squeeze|squeeze]], [[BamUtil: stats|stats]]&lt;br /&gt;
*** Cleanup usage/parameter descriptions&lt;br /&gt;
** Update [[BamUtil: revert|revert]]&lt;br /&gt;
*** Update compatibility with libStatGen due to &#039;B&#039; &amp;amp; &#039;f&#039; tag handling updates&lt;br /&gt;
** Add tests for &#039;B&#039; &amp;amp; &#039;f&#039; tags&lt;br /&gt;
&lt;br /&gt;
* [[Media:BamUtil.1.0.10.tar.gz|BamUtil.1.0.10.tar.gz‎]] - Released 1/2/2014&lt;br /&gt;
** Requires, but does not include: [[LibStatGen Download#Official Releases|libStatGen version 1.0.10]]&lt;br /&gt;
** All&lt;br /&gt;
*** Add PhoneHome/version checking&lt;br /&gt;
*** Make sub-program names case independent&lt;br /&gt;
*** Fix Logger.cpp compiler warning&lt;br /&gt;
** Adds: [[BamUtil: explainFlags|explainFlags]] - describes the SAM/BAM flags based on the flag value&lt;br /&gt;
** Update to [[BamUtil: stats|stats]]&lt;br /&gt;
*** Fix Stats to not try to not try to process a record after it is out of the loop (it would already have been processed or is invalid)&lt;br /&gt;
** Update to [[BamUtil: splitBam|splitBam]]&lt;br /&gt;
*** fix description of --noeof option&lt;br /&gt;
** Update to [[BamUtil: writeRegion|writeRegion]]&lt;br /&gt;
*** add exclude/required flags&lt;br /&gt;
** Update to [[BamUtil: dedup|dedup]] &amp;amp; [[BamUtil: recab|recab]]&lt;br /&gt;
*** Ignore secondary reads for dedup and making the recalibration table.&lt;br /&gt;
*** skip QC Failures&lt;br /&gt;
*** add excludeFlags parameters&lt;br /&gt;
** Update to [[BamUtil: clipOverlap|clipOverlap]]&lt;br /&gt;
*** add exclude flags&lt;br /&gt;
*** fix bug for readName sorted when a read is filtered due to flags&lt;br /&gt;
*** add sorting validation&lt;br /&gt;
** Update to [[BamUtil: bam2FastQ|bam2FastQ]]&lt;br /&gt;
*** add --merge option to generate interleaved files.&lt;br /&gt;
*** update to open the input file before opening the output files, so if there is an error, the outputs aren&#039;t opened&lt;br /&gt;
** Update to [[BamUtil: mergeBam|mergeBam]]&lt;br /&gt;
*** add option to ignore the RG PI field when checking headers&lt;br /&gt;
*** add more informative header merge error messages&lt;br /&gt;
&lt;br /&gt;
* [[Media:BamUtil.1.0.9.tgz|BamUtil.1.0.9.tgz‎]] - Released 7/7/2013&lt;br /&gt;
** Requires, but does not include: [[LibStatGen Download#Official Releases|libStatGen version 1.0.9]] (version 1.0.7 should also work)&lt;br /&gt;
** Update to [[BamUtil: mergeBam|mergeBam]]&lt;br /&gt;
*** Update to ignore PG lines with duplicate IDs&lt;br /&gt;
*** Update to accept merges of matching RG lines&lt;br /&gt;
*** Update to log to stderr if no log/out file is specified&lt;br /&gt;
&lt;br /&gt;
*[[Media:BamUtil.1.0.7.tgz|BamUtil.1.0.7.tgz‎]] - Released 1/29/2013&lt;br /&gt;
** Requires, but does not include: [[LibStatGen Download#Official Releases|libStatGen version 1.0.7]] or above&lt;br /&gt;
** Update to fix some compile issues on ubuntu 12.10&lt;br /&gt;
** Update use of SamRecord::getStringTag to expect the return of a const string pointer due to libStatGen v1.0.7 updates&lt;br /&gt;
** Update SamReferenceInfo usage due to libStatGen v1.0.7 updates&lt;br /&gt;
** Update to [[BamUtil: diff|diff]]&lt;br /&gt;
***   Fix DIFF to test and properly handle running out of available records.  Previously no message was printed when this happened and there was a bug for which file it freed&lt;br /&gt;
** Update to [[BamUtil: clipOverlap|clipOverlap]]&lt;br /&gt;
*** Update to facilitate adding other overlap handling functions&lt;br /&gt;
** Update to [[BamUtil: mergeBam|mergeBam]] (formerly RGMergeBam)&lt;br /&gt;
*** Rename RGMergeBam to MergeBam&lt;br /&gt;
*** Update to handle files that already have an RG&lt;br /&gt;
*[[Media:BamUtil.1.0.6.tgz|BamUtil.1.0.6.tgz‎]] - Released 11/14/2012&lt;br /&gt;
** Update to [[BamUtil: trimBam|trimBam]]&lt;br /&gt;
*** Update to allow trimming a different number of bases from each end of the read&lt;br /&gt;
*[[Media:BamUtil.1.0.5.tgz|BamUtil.1.0.5.tgz‎]] - Released 10/24/2012&lt;br /&gt;
** Update to [[BamUtil: dedup|dedup]]&lt;br /&gt;
*** Update logic for which pair to keep if they have the same quality&lt;br /&gt;
** Update to [[BamUtil: polishBam|polishBam]]&lt;br /&gt;
*** Update to print the number of successful header additions&lt;br /&gt;
** Update to [[BamUtil: recab|recab]]&lt;br /&gt;
*** Update to print the number of base skipped due to the base quality&lt;br /&gt;
** General Updates&lt;br /&gt;
*** Update to add compile option to compile without C++0x/C++11&lt;br /&gt;
*BamUtil.1.0.4.tgz‎ - Released skipped&lt;br /&gt;
*[[Media:BamUtil.1.0.3.tgz|BamUtil.1.0.3.tgz‎]] - Released 09/19/2012&lt;br /&gt;
** Adds: [[BamUtil: dedup|dedup]] [[BamUtil: recab|recab]]&lt;br /&gt;
** General Updates&lt;br /&gt;
*** Update Logger to write to stderr if output is stdout&lt;br /&gt;
** Update to [[BamUtil: stats|stats]]&lt;br /&gt;
*** Add required/exclude flags&lt;br /&gt;
*** Exclude Clips if excluding umapped&lt;br /&gt;
*** Add --withinRegion flag&lt;br /&gt;
*** Update phred/qual counts to be uint64_t instead of int to avoid overflow&lt;br /&gt;
** Update to [[BamUtil: validate|validate]]&lt;br /&gt;
*** Detect header failures&lt;br /&gt;
** Update to [[BamUtil: diff|diff]]&lt;br /&gt;
*** Update to specify chromosome/pos in ZP as a string rather than int so both can be shown&lt;br /&gt;
** Update to [[BamUtil: readReference|readReference]]&lt;br /&gt;
*** Output error message if the reference name is not found&lt;br /&gt;
** Update to [[BamUtil: splitChromosome|splitChromosome]]&lt;br /&gt;
*** Update to actually split the chromosomes and not just hard coded to output chromosomes ids 0-22&lt;br /&gt;
** Update Makefile to have cloneLib for cloning libStatGen&lt;br /&gt;
*[[Media:BamUtil.1.0.2.tgz|BamUtil.1.0.2.tgz‎]] - Released 05/16/2012&lt;br /&gt;
** Adds: [[BamUtil: bam2FastQ|bam2FastQ]]&lt;br /&gt;
*[[Media:BamUtil.1.0.1.tgz|BamUtil.1.0.1.tgz‎]] - Released 05/04/2012&lt;br /&gt;
** Adds: [[BamUtil: splitBam|splitBam]], [[BamUtil: clipOverlap|clipOverlap]],  [[BamUtil: trimBam|trimBam]], [[BamUtil: polishBam|polishBam]], [[BamUtil: rgMergeBam|rgMergeBam]], [[BamUtil: gapInfo|gapInfo]]&lt;br /&gt;
** Adds additional functionality to [[BamUtil: stats|stats]]&lt;br /&gt;
** Adds leftShifting to [[BamUtil: writeRegion|writeRegion]] and [[BamUtil: convert|convert]]&lt;br /&gt;
** Adds more diff fields to [[BamUtil: diff|diff]]&lt;br /&gt;
*[[Media:BamUtil.1.0.0.tgz|BamUtil.1.0.0.tgz‎]] - Released 10/10/2011&lt;br /&gt;
**Initial release of just bamUtil.  It started from the tool found in the deprecated StatGen repository.&lt;br /&gt;
**Contains: [[BamUtil: validate|validate]], [[BamUtil: convert|convert]], [[BamUtil: dumpHeader|dumpHeader]], [[BamUtil: splitChromosome|splitChromosome]], [[BamUtil: writeRegion|writeRegion]], [[BamUtil: dumpRefInfo|dumpRefInfo]], [[BamUtil: dumpIndex|dumpIndex]], [[BamUtil: readIndexedBam|readIndexedBam]], [[BamUtil: filter|filter]], [[BamUtil: readReference|readReference]], [[BamUtil: revert|revert]], [[BamUtil: diff|diff]], [[BamUtil: squeeze|squeeze]], [[BamUtil: findCigars|findCigars]], [[BamUtil: stats|stats]]&lt;br /&gt;
&lt;br /&gt;
= Programs =&lt;br /&gt;
&lt;br /&gt;
The software reads the beginning of an input file to determine if it is SAM/BAM.  To determine the format (SAM/BAM) of the output file, the software checks the output file&#039;s extension.  If the extension is &amp;quot;.bam&amp;quot; it writes a BAM file, otherwise it writes a SAM file.&lt;br /&gt;
&lt;br /&gt;
{{BamUtilPrograms}}&lt;/div&gt;</summary>
		<author><name>Mktrost</name></author>
	</entry>
	<entry>
		<id>http://genome.sph.umich.edu/w/index.php?title=BamUtil:_trimBam&amp;diff=14938</id>
		<title>BamUtil: trimBam</title>
		<link rel="alternate" type="text/html" href="http://genome.sph.umich.edu/w/index.php?title=BamUtil:_trimBam&amp;diff=14938"/>
		<updated>2017-11-13T03:28:36Z</updated>

		<summary type="html">&lt;p&gt;Mktrost: /* Soft Clipping Notes (--clip/-c) */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Overview of the &amp;lt;code&amp;gt;trimBam&amp;lt;/code&amp;gt; function of &amp;lt;code&amp;gt;bamUtil&amp;lt;/code&amp;gt; =&lt;br /&gt;
The &amp;lt;code&amp;gt;trimBam&amp;lt;/code&amp;gt; option on the [[bamUtil]] executable trims the end of reads in a SAM/BAM file, changing read ends to ‘N’ and quality to ‘!’, or by soft clipping (if command-line option, &amp;lt;code&amp;gt;--clip&amp;lt;/code&amp;gt; is specified).&lt;br /&gt;
&lt;br /&gt;
= Usage =&lt;br /&gt;
 ./bam trimBam [inFile] [outFile] [num-bases-to-trim-on-each-side]&lt;br /&gt;
&lt;br /&gt;
Version 1.0.6 and later:&lt;br /&gt;
&lt;br /&gt;
Alternately, the number of bases from each side can be specified (either or both -L/-R (--left/--right) can be specified):&lt;br /&gt;
 ./bam trimBam [inFile] [outFile] -L [num-bases-to-trim-from-left] -R [num-bases-to-trim-from-right]&lt;br /&gt;
&lt;br /&gt;
By default reverse strands are reversed and then the left &amp;amp; right are trimmed.&lt;br /&gt;
&lt;br /&gt;
This means that --left actually trims from the right of the read in the SAM/BAM for reverse reads.&lt;br /&gt;
&lt;br /&gt;
Optionally --ignoreStrand/-i can be specified to ignore the strand information and treat forward/reverse the same.&lt;br /&gt;
&lt;br /&gt;
trimBam will modify the sequences to &#039;N&#039;, and the quality string to &#039;!&#039; unless the optional parameter --clip/-c is specified.  If --clip/-c is specified, the ends will be soft clipped instead of modified.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Soft Clipping Notes (--clip/-c) ==&lt;br /&gt;
Available in version 1.0.14 and later.&lt;br /&gt;
&lt;br /&gt;
When soft clipping:&lt;br /&gt;
:* if the entire read would be soft clipped, no clipping is done, and instead the read is marked as unmapped&lt;br /&gt;
:* mate information is not updated (start positions/mapping may change after soft clipping)&lt;br /&gt;
:** run samtools fixmate to fix mate information (will first need to sort by read name)&lt;br /&gt;
:* output is not sorted (start positions/mapping may change after soft clipping)&lt;br /&gt;
:** run samtools sort to resort by coordinate (after fixmate)&lt;br /&gt;
:* soft clips already in the read are maintained or added to&lt;br /&gt;
:** if 3 bases were clipped and 2 are specified to be clipped, no change is made to that end&lt;br /&gt;
:** if 3 bases were clipped and 5 are specified to be clipped, 2 additional bases are clipped from that end&lt;br /&gt;
&lt;br /&gt;
=== Fixing the mate/resorting ===&lt;br /&gt;
In order to update the mate, samtools fixmate must be run. &lt;br /&gt;
&lt;br /&gt;
In order to reorder the file, samtools sort must be run.&lt;br /&gt;
&lt;br /&gt;
Notes about the samtools programs:&lt;br /&gt;
* samtools fixmate requires the file to be sorted by query name.&lt;br /&gt;
* samtools sort cannot write to pipes.&lt;br /&gt;
&lt;br /&gt;
====Steps====&lt;br /&gt;
# Run this program and pipe it into samtools sort by query name&lt;br /&gt;
#* &amp;lt;pre&amp;gt;./bam trimBam &amp;lt;your InputFile&amp;gt; - [#basesToTrim] [any other options] -c | samtools sort -n - tempQuerySort&amp;lt;/pre&amp;gt;&lt;br /&gt;
# Run samtools fixmate and pipe it into samtools sort by position&lt;br /&gt;
#* &amp;lt;pre&amp;gt; samtools fixmate tempQuerySort.bam - | samtools sort - finalResult&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Parameters =&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    Required Parameters:&lt;br /&gt;
        inFile  : the SAM/BAM file to be read&lt;br /&gt;
        outFile : the SAM/BAM file to be written&lt;br /&gt;
        num-bases-to-trim-on-each-side : the number of bases/qualities to trim from each side&lt;br /&gt;
    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)&lt;br /&gt;
    Optional Parameters:&lt;br /&gt;
        --ignoreStrand : ignore strand information - do not reverse left/right for reverse reads&lt;br /&gt;
        --clip         : soft clip the ends rather than setting to N/!&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
{{PhoneHomeParamDesc}}&lt;br /&gt;
&lt;br /&gt;
== Required Parameters==&lt;br /&gt;
&lt;br /&gt;
{{InBAMInputFile|noParam=1st}}&lt;br /&gt;
{{OutBAMOutputFile|noParam=2nd}}&lt;br /&gt;
&lt;br /&gt;
==Optional parameters==&lt;br /&gt;
=== Number of Bases to Trim from Each End (3rd argument) ===&lt;br /&gt;
If the 3rd argument a number (with no flag/option), it is the number of bases to trim from each end of the reads.&lt;br /&gt;
&lt;br /&gt;
===Trim Bases from the Left (&amp;lt;code&amp;gt;--left&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;-L&amp;lt;/code&amp;gt;)===&lt;br /&gt;
Use &amp;lt;code&amp;gt;--left&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;-L&amp;lt;/code&amp;gt; followed by the number of bases to be trimmed from the left.&lt;br /&gt;
&lt;br /&gt;
By default reverse strands are reversed and then the left is trimmed, meaning that &amp;lt;code&amp;gt;--left&amp;lt;/code&amp;gt; actually trims from the right of the read in the SAM/BAM for reverse reads.&lt;br /&gt;
&lt;br /&gt;
Use [[#Ignore the Strand when Trimming (--ignoreStrand or -i)|--ignoreStrand/-i]] to ignore the strand information and treat forward/reverse the same.&lt;br /&gt;
&lt;br /&gt;
===Trim Bases from the Right (&amp;lt;code&amp;gt;--right&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;-R&amp;lt;/code&amp;gt;)===&lt;br /&gt;
Use &amp;lt;code&amp;gt;--right&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;-R&amp;lt;/code&amp;gt; followed by the number of bases to be trimmed from the right.&lt;br /&gt;
&lt;br /&gt;
By default reverse strands are reversed and then the right is trimmed, meaning that &amp;lt;code&amp;gt;--right&amp;lt;/code&amp;gt; actually trims from the left of the read in the SAM/BAM for reverse reads.&lt;br /&gt;
&lt;br /&gt;
Use [[#Ignore the Strand when Trimming (--ignoreStrand or -i)|--ignoreStrand/-i]] to ignore the strand information and treat forward/reverse the same.&lt;br /&gt;
&lt;br /&gt;
=== Ignore the Strand when Trimming (&amp;lt;code&amp;gt;--ignoreStrand&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;-i&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
Use &amp;lt;code&amp;gt;--ignoreStrand&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;-i&amp;lt;/code&amp;gt; to ignore the strand information and treat forward/reverse the same.  When &amp;lt;code&amp;gt;--ignoreStrand&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;-i&amp;lt;/code&amp;gt; is set, do not reverse reverse reads prior to trimming left/right.&lt;br /&gt;
&lt;br /&gt;
=== SoftClip the Ends (&amp;lt;code&amp;gt;--clip&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;-c&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
Use &amp;lt;code&amp;gt;--clip&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;-c&amp;lt;/code&amp;gt; to soft clip the ends instead of setting to N/! (or set to unmapped if the entire read would be soft clipped).&lt;br /&gt;
&lt;br /&gt;
See [[#Soft Clipping Notes (--clip/-c)|Soft Clipping Notes]] for more information about clipping and post processing that will need to be done.&lt;br /&gt;
&lt;br /&gt;
{{noeofBGZFParameter}}&lt;br /&gt;
&lt;br /&gt;
{{PhoneHomeParameters}}&lt;br /&gt;
&lt;br /&gt;
= Return Value =&lt;br /&gt;
Returns the SamStatus for the reads/writes.  0 on success,  non-0 on failure.&lt;br /&gt;
&lt;br /&gt;
= Examples =&lt;br /&gt;
&lt;br /&gt;
==Trim the same number of bases from each side==&lt;br /&gt;
Example Input, trimming 2 bases:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
./bin trimBam testFiles/testSam.sam results/trimSam.sam 2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Example Output:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Arguments in effect: &lt;br /&gt;
	Input file : testFiles/testSam.sam&lt;br /&gt;
	Output file : results/trimSam.sam&lt;br /&gt;
	#Bases to trim from each side : 2&lt;br /&gt;
&lt;br /&gt;
Number of records read = 10&lt;br /&gt;
Number of records written = 10&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Trim different bases from each side, but treat reverse strands the opposite==&lt;br /&gt;
Example Input, trimming 1 base from the left and 2 bases from the right for forward strands and do the opposite for reverse strands:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
./bin trimBam testFiles/testSam.sam results/trimSam.sam -L 1 -R 2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Example Output:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Arguments in effect: &lt;br /&gt;
	Input file : testFiles/testSam.sam&lt;br /&gt;
	Output file : results/trimSam.sam&lt;br /&gt;
	#Bases to trim from the left of forward strands : 1&lt;br /&gt;
	#Bases to trim from the right of forward strands: 2&lt;br /&gt;
	#Bases to trim from the left of reverse strands : 2&lt;br /&gt;
	#Bases to trim from the right of reverse strands : 1&lt;br /&gt;
&lt;br /&gt;
Number of records read = 10&lt;br /&gt;
Number of records written = 10&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Trim different bases from each side, but treat forward &amp;amp; reverse the same==&lt;br /&gt;
Example Input, trimming 1 base from the left and 2 bases from the right ignoring strand information:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
./bin trimBam testFiles/testSam.sam results/trimSam.sam -L 1 -R 2 --ignoreStrand&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Example Output:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Arguments in effect: &lt;br /&gt;
	Input file : testFiles/testSam.sam&lt;br /&gt;
	Output file : results/trimSam.sam&lt;br /&gt;
	#Bases to trim from the left of forward strands : 1&lt;br /&gt;
	#Bases to trim from the right of forward strands: 2&lt;br /&gt;
	#Bases to trim from the left of reverse strands : 1&lt;br /&gt;
	#Bases to trim from the right of reverse strands : 2&lt;br /&gt;
&lt;br /&gt;
Number of records read = 10&lt;br /&gt;
Number of records written = 10&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:BamUtil|trimBam]]&lt;br /&gt;
[[Category:BAM Software]]&lt;br /&gt;
[[Category:Software]]&lt;/div&gt;</summary>
		<author><name>Mktrost</name></author>
	</entry>
	<entry>
		<id>http://genome.sph.umich.edu/w/index.php?title=BamUtil:_trimBam&amp;diff=14937</id>
		<title>BamUtil: trimBam</title>
		<link rel="alternate" type="text/html" href="http://genome.sph.umich.edu/w/index.php?title=BamUtil:_trimBam&amp;diff=14937"/>
		<updated>2017-11-13T03:28:02Z</updated>

		<summary type="html">&lt;p&gt;Mktrost: /* Soft Clipping Notes (--clip/-c) */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Overview of the &amp;lt;code&amp;gt;trimBam&amp;lt;/code&amp;gt; function of &amp;lt;code&amp;gt;bamUtil&amp;lt;/code&amp;gt; =&lt;br /&gt;
The &amp;lt;code&amp;gt;trimBam&amp;lt;/code&amp;gt; option on the [[bamUtil]] executable trims the end of reads in a SAM/BAM file, changing read ends to ‘N’ and quality to ‘!’, or by soft clipping (if command-line option, &amp;lt;code&amp;gt;--clip&amp;lt;/code&amp;gt; is specified).&lt;br /&gt;
&lt;br /&gt;
= Usage =&lt;br /&gt;
 ./bam trimBam [inFile] [outFile] [num-bases-to-trim-on-each-side]&lt;br /&gt;
&lt;br /&gt;
Version 1.0.6 and later:&lt;br /&gt;
&lt;br /&gt;
Alternately, the number of bases from each side can be specified (either or both -L/-R (--left/--right) can be specified):&lt;br /&gt;
 ./bam trimBam [inFile] [outFile] -L [num-bases-to-trim-from-left] -R [num-bases-to-trim-from-right]&lt;br /&gt;
&lt;br /&gt;
By default reverse strands are reversed and then the left &amp;amp; right are trimmed.&lt;br /&gt;
&lt;br /&gt;
This means that --left actually trims from the right of the read in the SAM/BAM for reverse reads.&lt;br /&gt;
&lt;br /&gt;
Optionally --ignoreStrand/-i can be specified to ignore the strand information and treat forward/reverse the same.&lt;br /&gt;
&lt;br /&gt;
trimBam will modify the sequences to &#039;N&#039;, and the quality string to &#039;!&#039; unless the optional parameter --clip/-c is specified.  If --clip/-c is specified, the ends will be soft clipped instead of modified.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Soft Clipping Notes (--clip/-c) ==&lt;br /&gt;
(Version 1.0.14 and later)&lt;br /&gt;
When soft clipping:&lt;br /&gt;
:* if the entire read would be soft clipped, no clipping is done, and instead the read is marked as unmapped&lt;br /&gt;
:* mate information is not updated (start positions/mapping may change after soft clipping)&lt;br /&gt;
:** run samtools fixmate to fix mate information (will first need to sort by read name)&lt;br /&gt;
:* output is not sorted (start positions/mapping may change after soft clipping)&lt;br /&gt;
:** run samtools sort to resort by coordinate (after fixmate)&lt;br /&gt;
:* soft clips already in the read are maintained or added to&lt;br /&gt;
:** if 3 bases were clipped and 2 are specified to be clipped, no change is made to that end&lt;br /&gt;
:** if 3 bases were clipped and 5 are specified to be clipped, 2 additional bases are clipped from that end&lt;br /&gt;
&lt;br /&gt;
=== Fixing the mate/resorting ===&lt;br /&gt;
In order to update the mate, samtools fixmate must be run. &lt;br /&gt;
&lt;br /&gt;
In order to reorder the file, samtools sort must be run.&lt;br /&gt;
&lt;br /&gt;
Notes about the samtools programs:&lt;br /&gt;
* samtools fixmate requires the file to be sorted by query name.&lt;br /&gt;
* samtools sort cannot write to pipes.&lt;br /&gt;
&lt;br /&gt;
====Steps====&lt;br /&gt;
# Run this program and pipe it into samtools sort by query name&lt;br /&gt;
#* &amp;lt;pre&amp;gt;./bam trimBam &amp;lt;your InputFile&amp;gt; - [#basesToTrim] [any other options] -c | samtools sort -n - tempQuerySort&amp;lt;/pre&amp;gt;&lt;br /&gt;
# Run samtools fixmate and pipe it into samtools sort by position&lt;br /&gt;
#* &amp;lt;pre&amp;gt; samtools fixmate tempQuerySort.bam - | samtools sort - finalResult&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Parameters =&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    Required Parameters:&lt;br /&gt;
        inFile  : the SAM/BAM file to be read&lt;br /&gt;
        outFile : the SAM/BAM file to be written&lt;br /&gt;
        num-bases-to-trim-on-each-side : the number of bases/qualities to trim from each side&lt;br /&gt;
    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)&lt;br /&gt;
    Optional Parameters:&lt;br /&gt;
        --ignoreStrand : ignore strand information - do not reverse left/right for reverse reads&lt;br /&gt;
        --clip         : soft clip the ends rather than setting to N/!&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
{{PhoneHomeParamDesc}}&lt;br /&gt;
&lt;br /&gt;
== Required Parameters==&lt;br /&gt;
&lt;br /&gt;
{{InBAMInputFile|noParam=1st}}&lt;br /&gt;
{{OutBAMOutputFile|noParam=2nd}}&lt;br /&gt;
&lt;br /&gt;
==Optional parameters==&lt;br /&gt;
=== Number of Bases to Trim from Each End (3rd argument) ===&lt;br /&gt;
If the 3rd argument a number (with no flag/option), it is the number of bases to trim from each end of the reads.&lt;br /&gt;
&lt;br /&gt;
===Trim Bases from the Left (&amp;lt;code&amp;gt;--left&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;-L&amp;lt;/code&amp;gt;)===&lt;br /&gt;
Use &amp;lt;code&amp;gt;--left&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;-L&amp;lt;/code&amp;gt; followed by the number of bases to be trimmed from the left.&lt;br /&gt;
&lt;br /&gt;
By default reverse strands are reversed and then the left is trimmed, meaning that &amp;lt;code&amp;gt;--left&amp;lt;/code&amp;gt; actually trims from the right of the read in the SAM/BAM for reverse reads.&lt;br /&gt;
&lt;br /&gt;
Use [[#Ignore the Strand when Trimming (--ignoreStrand or -i)|--ignoreStrand/-i]] to ignore the strand information and treat forward/reverse the same.&lt;br /&gt;
&lt;br /&gt;
===Trim Bases from the Right (&amp;lt;code&amp;gt;--right&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;-R&amp;lt;/code&amp;gt;)===&lt;br /&gt;
Use &amp;lt;code&amp;gt;--right&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;-R&amp;lt;/code&amp;gt; followed by the number of bases to be trimmed from the right.&lt;br /&gt;
&lt;br /&gt;
By default reverse strands are reversed and then the right is trimmed, meaning that &amp;lt;code&amp;gt;--right&amp;lt;/code&amp;gt; actually trims from the left of the read in the SAM/BAM for reverse reads.&lt;br /&gt;
&lt;br /&gt;
Use [[#Ignore the Strand when Trimming (--ignoreStrand or -i)|--ignoreStrand/-i]] to ignore the strand information and treat forward/reverse the same.&lt;br /&gt;
&lt;br /&gt;
=== Ignore the Strand when Trimming (&amp;lt;code&amp;gt;--ignoreStrand&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;-i&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
Use &amp;lt;code&amp;gt;--ignoreStrand&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;-i&amp;lt;/code&amp;gt; to ignore the strand information and treat forward/reverse the same.  When &amp;lt;code&amp;gt;--ignoreStrand&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;-i&amp;lt;/code&amp;gt; is set, do not reverse reverse reads prior to trimming left/right.&lt;br /&gt;
&lt;br /&gt;
=== SoftClip the Ends (&amp;lt;code&amp;gt;--clip&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;-c&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
Use &amp;lt;code&amp;gt;--clip&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;-c&amp;lt;/code&amp;gt; to soft clip the ends instead of setting to N/! (or set to unmapped if the entire read would be soft clipped).&lt;br /&gt;
&lt;br /&gt;
See [[#Soft Clipping Notes (--clip/-c)|Soft Clipping Notes]] for more information about clipping and post processing that will need to be done.&lt;br /&gt;
&lt;br /&gt;
{{noeofBGZFParameter}}&lt;br /&gt;
&lt;br /&gt;
{{PhoneHomeParameters}}&lt;br /&gt;
&lt;br /&gt;
= Return Value =&lt;br /&gt;
Returns the SamStatus for the reads/writes.  0 on success,  non-0 on failure.&lt;br /&gt;
&lt;br /&gt;
= Examples =&lt;br /&gt;
&lt;br /&gt;
==Trim the same number of bases from each side==&lt;br /&gt;
Example Input, trimming 2 bases:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
./bin trimBam testFiles/testSam.sam results/trimSam.sam 2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Example Output:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Arguments in effect: &lt;br /&gt;
	Input file : testFiles/testSam.sam&lt;br /&gt;
	Output file : results/trimSam.sam&lt;br /&gt;
	#Bases to trim from each side : 2&lt;br /&gt;
&lt;br /&gt;
Number of records read = 10&lt;br /&gt;
Number of records written = 10&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Trim different bases from each side, but treat reverse strands the opposite==&lt;br /&gt;
Example Input, trimming 1 base from the left and 2 bases from the right for forward strands and do the opposite for reverse strands:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
./bin trimBam testFiles/testSam.sam results/trimSam.sam -L 1 -R 2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Example Output:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Arguments in effect: &lt;br /&gt;
	Input file : testFiles/testSam.sam&lt;br /&gt;
	Output file : results/trimSam.sam&lt;br /&gt;
	#Bases to trim from the left of forward strands : 1&lt;br /&gt;
	#Bases to trim from the right of forward strands: 2&lt;br /&gt;
	#Bases to trim from the left of reverse strands : 2&lt;br /&gt;
	#Bases to trim from the right of reverse strands : 1&lt;br /&gt;
&lt;br /&gt;
Number of records read = 10&lt;br /&gt;
Number of records written = 10&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Trim different bases from each side, but treat forward &amp;amp; reverse the same==&lt;br /&gt;
Example Input, trimming 1 base from the left and 2 bases from the right ignoring strand information:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
./bin trimBam testFiles/testSam.sam results/trimSam.sam -L 1 -R 2 --ignoreStrand&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Example Output:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Arguments in effect: &lt;br /&gt;
	Input file : testFiles/testSam.sam&lt;br /&gt;
	Output file : results/trimSam.sam&lt;br /&gt;
	#Bases to trim from the left of forward strands : 1&lt;br /&gt;
	#Bases to trim from the right of forward strands: 2&lt;br /&gt;
	#Bases to trim from the left of reverse strands : 1&lt;br /&gt;
	#Bases to trim from the right of reverse strands : 2&lt;br /&gt;
&lt;br /&gt;
Number of records read = 10&lt;br /&gt;
Number of records written = 10&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:BamUtil|trimBam]]&lt;br /&gt;
[[Category:BAM Software]]&lt;br /&gt;
[[Category:Software]]&lt;/div&gt;</summary>
		<author><name>Mktrost</name></author>
	</entry>
	<entry>
		<id>http://genome.sph.umich.edu/w/index.php?title=VerifyBamID&amp;diff=14829</id>
		<title>VerifyBamID</title>
		<link rel="alternate" type="text/html" href="http://genome.sph.umich.edu/w/index.php?title=VerifyBamID&amp;diff=14829"/>
		<updated>2017-09-09T19:29:12Z</updated>

		<summary type="html">&lt;p&gt;Mktrost: /* Command Line Options */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Software|VerifyBamID]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;verifyBamID&#039;&#039;&#039; is a software that verifies whether the reads in particular file match previously known genotypes for an individual (or group of individuals), and checks whether the reads are contaminated as a mixture of two samples. &#039;&#039;&#039;verifyBamID&#039;&#039;&#039; can detect sample contamination and swaps when external genotypes are available. When external genotypes are not available, &#039;&#039;&#039;verifyBamID&#039;&#039;&#039; still robustly detects sample swaps.&lt;br /&gt;
&lt;br /&gt;
== Download verifyBamID  ==&lt;br /&gt;
&lt;br /&gt;
To get a copy of verifyBamId, go to: https://github.com/statgen/verifyBamID/releases&lt;br /&gt;
&lt;br /&gt;
Select the latest release and download in one of 3 ways:&lt;br /&gt;
# Binary expected to run in Ubuntu x64 platform. In other platforms, please download the source distribution and build it.&lt;br /&gt;
#* verifyBamID.#.#.#.gz&lt;br /&gt;
#* You will need to run &amp;quot;gunzip&amp;quot; on the .gz file&lt;br /&gt;
# Souce Code including libStatGen (uses a fixed version of libStatGen)&lt;br /&gt;
#* verifyBamIDLibStatGen.#.#.#.tgz&lt;br /&gt;
#* Run &amp;quot;tar xvf&amp;quot; on this file.  Cd into the resulting directory &amp;amp; type make.&lt;br /&gt;
# Source Code without libStatGen (allows alternative/newer versions of libStatGen)&lt;br /&gt;
#* Source code (tar.gz) or Source code (zip)&lt;br /&gt;
#* You will need to download libStatGen separately if you do not already have it.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To get a copy of older releases go to the [http://csg.sph.umich.edu//kang/verifyBamID/download VerifyBamID Download] download page.&lt;br /&gt;
&lt;br /&gt;
== Join in verifyBamID mailing list ==&lt;br /&gt;
&lt;br /&gt;
Please join in the [http://groups.google.com/group/verifybamid VerifyBamID Google Group] to ask / discuss / comment about verifyBamID.&lt;br /&gt;
&lt;br /&gt;
== What&#039;s new ==&lt;br /&gt;
&lt;br /&gt;
(2014/02/13)&lt;br /&gt;
* Put verifyBamID in github.&lt;br /&gt;
* Added PhoneHome/Version Checking to VerifyBamID&lt;br /&gt;
&lt;br /&gt;
(2012/06/20) &lt;br /&gt;
* Fixed a bug of incorrect estimate of contamination when --chip-full option was used (Thanks to Richard Smith)&lt;br /&gt;
* Fixed a bug of incorrect per-readgroup output in --chip-* parameter&lt;br /&gt;
&lt;br /&gt;
(2012/05/24) &lt;br /&gt;
* Fixed a bug of incorrect per-readgroup output (Thanks to Matthew Flickinger)&lt;br /&gt;
* &#039;&#039;&#039;(IMPORTANT)&#039;&#039;&#039; Add an option to remove either side of overlapping fragment. This option is turned on by default, and can be turned off usig --ignoreOverlapPair. If your sequence data has very short insert size, this update may increase the sensitivity of estimated contamination.&lt;br /&gt;
* Changes in the directory structure and Makefile&lt;br /&gt;
&lt;br /&gt;
(2012/05/18) The new release of verifyBamID have undergone major change since the last version (as of 2011 April). Here are the highlights&lt;br /&gt;
* The genotype / allele frequency file is now based on VCF format rather than PLINK format.&lt;br /&gt;
* The reference sequence information is no longer required&lt;br /&gt;
* Uses Brent&#039;s method for precise estimation of contamination parameters&lt;br /&gt;
* Generate the depth distribution statistics.&lt;br /&gt;
* Estimated reference-bias parameters (useful mostly for ABI SOLiD sequence data)&lt;br /&gt;
&lt;br /&gt;
== Build verifyBamID  ==&lt;br /&gt;
&lt;br /&gt;
The binary download of verifyBamID is available. You may use that version in Ubuntu 64-bit platform. &lt;br /&gt;
&lt;br /&gt;
If you download the source that includes libStatGen:&lt;br /&gt;
 tar xvf verifyBamIDLibStatGen.#.#.#.tgz&lt;br /&gt;
 cd verifyBamID_#.#.#&lt;br /&gt;
 make&lt;br /&gt;
 Executable: verifyBamID/bin/verifyBamID&lt;br /&gt;
&lt;br /&gt;
If you download the source without libStatGen:&lt;br /&gt;
 tar xvf verifyBamID-#.#.#.tar.gz&lt;br /&gt;
 cd verifyBamID-1.1.0&lt;br /&gt;
 make cloneLib (if ../libStatGen does not exist)&lt;br /&gt;
 make&lt;br /&gt;
 Executable: ./bin/verifyBamID&lt;br /&gt;
&lt;br /&gt;
Note that &#039;&#039;&#039;make cloneLib&#039;&#039;&#039; command will create a directory ../libStatGen under your verifyBamID directory, and &#039;&#039;&#039;make&#039;&#039;&#039; will create binary of verifyBamID under verifyBamID/bin/&lt;br /&gt;
&lt;br /&gt;
If you have a different version of libStatGen at that path, then skip the cloneLib step.  If the libStatGen you want to use is at a different location then update verifyBamID&#039;s Makefile.inc.  Replace: LIB_PATH_VERIFY_BAM_ID ?= $(LIB_PATH_GENERAL) with&lt;br /&gt;
 LIB_PATH_VERIFY_BAM_ID = /path/to/libStatGen&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
verifyBamID is designed to be reasonably portable. &lt;br /&gt;
&lt;br /&gt;
However, since development occurs only on Ubuntu (9.10-13.10) x86 and x64 platforms, and later, there are likely other portability issues. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Basic Usage ==&lt;br /&gt;
&lt;br /&gt;
A key step in any genetic analysis is to verify whether data being generated matches expectations. &#039;&#039;verifyBamID&#039;&#039; checks whether reads in a BAM file match previous genotypes for a specific sample. In addition, it detects possible sample mixture from population allele frequency only, which can be particularly useful when the genotype data is not available.&lt;br /&gt;
&lt;br /&gt;
Using a mathematical model that relates observed sequence reads to an hypothetical true genotype, &#039;&#039;verifyBamID&#039;&#039; tries to decide whether sequence reads match a particular individual or are more likely to be contaminated (including a small proportion of foreign DNA), derived from a closely related individual, or derived from a completely different individual.&lt;br /&gt;
&lt;br /&gt;
== Basic Usage Example ==&lt;br /&gt;
&lt;br /&gt;
Here is a typical command line:&lt;br /&gt;
&lt;br /&gt;
 verifyBamID --vcf [input.vcf] --bam [input.bam] --out [output.prefix] --verbose --ignoreRG&lt;br /&gt;
 &lt;br /&gt;
 where&lt;br /&gt;
 [input.bam] is a BAM (Binary Alignment Map) file of a sequence reads&lt;br /&gt;
 [input.vcf] is input VCF file containing individual genotypes or AF or AC/AN fields in the INFO field. gzipped VCF is also allowed.&lt;br /&gt;
 [outPrefix] is output prefix of output files - [outPrefix].{selfRG,selfSM,bestRG,bestSM,depthRG,depthSM} will be created.&lt;br /&gt;
&lt;br /&gt;
More detailed description of command line input is below&lt;br /&gt;
&lt;br /&gt;
== Preparing input files ==&lt;br /&gt;
&lt;br /&gt;
verifyBamID requires two input files - VCF file containing external genotypes or allele frequency information, and the BAM file.&lt;br /&gt;
&lt;br /&gt;
=== VCF input genotype file ===&lt;br /&gt;
&lt;br /&gt;
The input VCF file contains (1) external genotype information and/or (2) allele frequency information as AF entry or AC/AN entries in the INFO field. (See [http://www.1000genomes.org/wiki/Analysis/Variant%20Call%20Format/vcf-variant-call-format-version-41 | VCF specification] for further details). If neither information is provided, verifyBamID will not work properly.&lt;br /&gt;
&lt;br /&gt;
If external genotype information is provided, sequence+array method will identify contamination and sample swaps by comparing the concordance between the external genotypes and the sequence reads. Additionally, sequence-only method will provide additional contamination estimates by modeling the sequence reads as mixture of two unknown samples based on the allele frequency information in the VCF file.&lt;br /&gt;
&lt;br /&gt;
Input VCF file needs to meet several additional contraints need to meet in order to properly run verifyBamID.&lt;br /&gt;
* The VCF is assumed to be well-formed. For example, verifyBamID does not check whether REF allele actually matches with reference sequence.  &lt;br /&gt;
* The VCF should only contain SNPs. Current version of verifyBamID does not accept INDELs, MNPs, Structural Variations, or other complex variants.&lt;br /&gt;
* The individual IDs in the VCF file, must be identical with the individual identifier in the BAM file. Otherwise, --smID option can override the sample ID information of the BAM file to the ID that matches to the individual IDs in the VCF file.&lt;br /&gt;
* IMPORTANT : For targeted sequencing data, it is important to subselect the markers to only include on-target markers in the genotype file. Off-target markers are not likely to have multiple non-duplicated reads at the marker position, and it may create artifacts in the analysis due to overlapping fragments.&lt;br /&gt;
* Currently, verifyBamID takes only autosomal chromosomes as input VCF.&lt;br /&gt;
&lt;br /&gt;
An example input VCF file (without external genotype) is provided below. Note that AC and AC entries exists in the INFO field for the allele frequency information.&lt;br /&gt;
&lt;br /&gt;
 #CHROM	POS	ID	REF	ALT	QUAL	FILTER	INFO&lt;br /&gt;
 20	61651	SNP20-9651	C	A	.	PASS	CR=99.86851;GentrainScore=0.7055;HW=0.077647716;AN=2180;AC=11&lt;br /&gt;
 20	63231	SNP20-11231	T	G	.	PASS	CR=99.93036;GentrainScore=0.7837;HW=0.035481825;AN=2182;AC=275&lt;br /&gt;
 20	63244	rs6139074	A	C	.	PASS	CR=98.893394;GentrainScore=0.8001;HW=7.327299E-7;AN=2162;AC=501&lt;br /&gt;
 20	63799	rs1418258	C	T	.	PASS	CR=99.75217;GentrainScore=0.8170;HW=0.6653377;AN=2182;AC=881&lt;br /&gt;
&lt;br /&gt;
=== Input BAM file ===&lt;br /&gt;
&lt;br /&gt;
verifyBamID requires a sorted, indexed, base quality recalibrated, and duplication-marked BAM file. It also requires to contain &amp;quot;@RG&amp;quot; header lines to annotation different readGroups (sequencing runs and lanes). The SM tag in the &amp;quot;@RG&amp;quot; header should match with one of the genotyped sample. Otherwise, verifyBamID may not be able to test whether the sequenced sample matches with genotyped sample, but will try to detect sample mixture from allele frequency, and will try to detect the best-matching sample among the genotyped sample.&lt;br /&gt;
&lt;br /&gt;
== What the default option does ==&lt;br /&gt;
&lt;br /&gt;
The default option of &#039;&#039;&#039;verifyBamID&#039;&#039;&#039; is the recommended setting for the most sequencing studies to provide a rapid and informative response. The default option provides the following features:&lt;br /&gt;
* --free-mix is turned on for estimating contamination using sequence-only method&lt;br /&gt;
* --chip-mix is turned on for estimating contamination or swap using sequence+array method, if the external genotype file is provided in the VCF&lt;br /&gt;
* --self is turnd on : The default option does not try to compare the sequence reads to identify the best matching individual (which is possible with --best option). It only compares with the external genotypes from the same individual to the sequenced individual.&lt;br /&gt;
* --maxDepth 20 is used without --precise option : The default option is intended for whole genome low coverage sequencing. For the targeted exome sequencing, --maxDepth 1000 and --precise is recommended.&lt;br /&gt;
* --ignoreRG is not a default option, but a recommended option, when you want to check the contamination for the entire BAM rather than examining each read group separately. This option will increase the computational efficiency especially in the case whether the sequence reads are multiplexed across many sequencing runs.&lt;br /&gt;
&lt;br /&gt;
== Interpreting output files ==&lt;br /&gt;
&lt;br /&gt;
See also [[Understanding VerifyBamID output]].&lt;br /&gt;
&lt;br /&gt;
=== Output files ===&lt;br /&gt;
When verifyBamID runs successfully, the following sets of files may be generated.&lt;br /&gt;
* [outPrefix].selfSM - Per-sample statistics describing how well the sample matches to the annotated sample.&lt;br /&gt;
* [outPrefix].depthSM - The depth distribution of the sequence reads per sample&lt;br /&gt;
* [outPrefix].selfRG - Per-readGroup statistics describing how well each lane matches to the annotated sample. (available only without --ignoreRG option)&lt;br /&gt;
* [outPrefix].depthRG - The depth distribution of the sequence reads per readGroup. (available only without --ignoreRG option)&lt;br /&gt;
* [outPrefix].bestSM - Per-sample best-match statistics with best-matching sample among the genotyped sample (available only with --best option)&lt;br /&gt;
* [outPrefix].bestRG - Per-readgroup best-match statistics with best-matching sample among the genotyped sample (available only with --best and without --ignoreRG option)&lt;br /&gt;
&lt;br /&gt;
=== Column information in the output files ===&lt;br /&gt;
The .selfSM/.selfRG/.bestSM/.bestRG files have the following 19 columns per sample, or per readgroup (lane). &lt;br /&gt;
&lt;br /&gt;
# SEQ_SM : Sample ID of the sequenced sample. Obtained from @RG header / SM tag in the BAM file&lt;br /&gt;
# RG : ReadGroup ID of sequenced lane. For [outPrefix].selfSM and [outPrefix].bestSM, these values are &amp;quot;ALL&amp;quot;&lt;br /&gt;
# CHIP_ID : Sample ID compared to in the genotype file. For [outPrefix].selfRG and [outPrefix].selfSM, these values should be identical to [SEQ_SM] or &amp;quot;NA&amp;quot; if the genotype of sequenced samples are unavailable. For [outPrefix].bestRG and [outPrefix].bestSM, these values should be the ID of best-matching sample among the genotype files compared to.&lt;br /&gt;
# # SNPs : # of SNPs passing the criteria from the VCF file&lt;br /&gt;
# # READS : Total # of reads loaded from the BAM file&lt;br /&gt;
# # AVG_DP : Average sequencing depth at the sites in the VCF file&lt;br /&gt;
# FREEMIX : Sequence-only estimate of contamination (0-1 scale)&lt;br /&gt;
# FREELK1 : Maximum log-likelihood of the sequence reads given estimated contamination under sequence-only method&lt;br /&gt;
# FREELK0 : Log-likelihood of the sequence reads given no contamination under sequence-only method&lt;br /&gt;
# FREE_RH : Estimated reference bias parameter Pr(refBase|HET) (when --free-refBias or --free-full is used)&lt;br /&gt;
# FREE_RA : Estimated reference bias parameter Pr(refBase|HOMALT) (when --free-refBias or --free-full is used)&lt;br /&gt;
# CHIPMIX : Sequence+array estimate of contamination (NA if the external genotype is unavailable) (0-1 scale)&lt;br /&gt;
# CHIPLK1 : Maximum log-likelihood of the sequence reads given estimated contamination under sequence+array method (NA if the external genotypes are unavailable)&lt;br /&gt;
# CHIPLK0 : Log-likelihood of the sequence reads given no contamination under sequence+array method (NA if the external genotypes are unavailable)&lt;br /&gt;
# CHIP_RH : Estimated reference bias parameter Pr(refBase|HET) (when --chip-refBias or --chip-full is used)&lt;br /&gt;
# CHIP_RA : Estimated reference bias parameter Pr(refBase|HOMALT) (when --chip-refBias or --chip-full is used)&lt;br /&gt;
# DPREF : Depth (Coverage) of HomRef site (based on the genotypes of (SELF_SM/BEST_SM), passing mapQ, baseQual, maxDepth thresholds.&lt;br /&gt;
# RDPHET : DPHET/DPREF, Relative depth to HomRef site at Heterozygous site.&lt;br /&gt;
# RDPALT : DPHET/DPREF, Relative depth to HomRef site at HomAlt site.&lt;br /&gt;
&lt;br /&gt;
=== A guideline to interpret output files ===&lt;br /&gt;
&lt;br /&gt;
verifyBamID provides a series of information that is informative to determine whether the sample is possibly contaminated or swapped, but there is no single criteria that works for every circumstances. There are a few unmodeled factor in the estimation of [SELF-IBD]/[BEST-IBD] and [%MIX], so please note that the MLE estimation may not always exactly match to the true amount of contamination. Here we provide a guideline to flag potentially contaminated/swapped samples &lt;br /&gt;
&lt;br /&gt;
*  Each sample or lane can be checked in this way. When [CHIPMIX] &amp;gt;&amp;gt; 0.02 and/or [FREEMIX] &amp;gt;&amp;gt; 0.02, meaning 2% or more of non-reference bases are observed in reference sites, we recommend to examine the data more carefully for the possibility of contamination.&lt;br /&gt;
* We recommend to check each lane for the possibility of sample swaps. When [CHIPMIX] ~ 1 AND [FREEMIX] ~ 0, then it is possible that the sample is swapped with another sample. When [CHIPMIX] ~ 0 in .bestSM file, [CHIP_ID] might be actually the swapped sample. Otherwise, the swapped sample may not exist in the genotype data you have compared. &lt;br /&gt;
* When genotype data is not available but allele-frequency-based estimates of [FREEMIX] &amp;gt;= 0.03 and [FREELK1]-[FREELK0] is large, then it is possible that the sample is contaminated with other sample. We recommend to use per-sample data rather than per-lane data for checking this for low coverage data, because the inference will be more confident when there are large number of bases with depth 2 or higher.&lt;br /&gt;
&lt;br /&gt;
== Command Line Options ==&lt;br /&gt;
&lt;br /&gt;
 The following parameters are available.  Ones with &amp;quot;[]&amp;quot; are in effect:&lt;br /&gt;
 &lt;br /&gt;
 Available Options&lt;br /&gt;
                             Input Files : --vcf [], --bam [], --subset [],&lt;br /&gt;
                                           --smID []&lt;br /&gt;
                    VCF analysis options : --genoError [1.0e-03],&lt;br /&gt;
                                           --minAF [0.01],&lt;br /&gt;
                                           --minCallRate [0.50]&lt;br /&gt;
   Individuals to compare with chip data : --site, --self, --best&lt;br /&gt;
          Chip-free optimization options : --free-none, --free-mix [ON],&lt;br /&gt;
                                           --free-refBias, --free-full&lt;br /&gt;
          With-chip optimization options : --chip-none, --chip-mix [ON],&lt;br /&gt;
                                           --chip-refBias, --chip-full&lt;br /&gt;
                    BAM analysis options : --ignoreRG, --ignoreOverlapPair,&lt;br /&gt;
                                           --noEOF, --precise, --minMapQ [10],&lt;br /&gt;
                                           --maxDepth [20], --minQ [13],&lt;br /&gt;
                                           --maxQ [40], --grid [0.05]&lt;br /&gt;
                 Modeling Reference Bias : --refRef [1.00], --refHet [0.50],&lt;br /&gt;
                                           --refAlt [0.00]&lt;br /&gt;
                          Output options : --out [], --verbose&lt;br /&gt;
                               PhoneHome : --noPhoneHome,&lt;br /&gt;
                                           --phoneHomeThinning [50]&lt;br /&gt;
&lt;br /&gt;
Each option provides the following features:&lt;br /&gt;
* --vcf : specify required VCF file&lt;br /&gt;
* --bam : specify required BAM file (indexed with .bam.bai or .bai file)&lt;br /&gt;
* --subset : list of individual IDs to calculate the allele frequency. All individuals are used if unspecified&lt;br /&gt;
* --smID : If the individual ID in the BAM file and VCF file does not match, substitute the BAM file&#039;s ID into the specified argument&lt;br /&gt;
* --genoError : error rate of the external genotype file&lt;br /&gt;
* --minAF : minimum allele frequency of the markers to include&lt;br /&gt;
* --minAF : minimum call rate of the markers to include&lt;br /&gt;
* --site : If set, use only site information in the VCF and do not compare with the actual genotypes&lt;br /&gt;
* --self : Only compare the ID-matching individuals between the VCF and BAM file&lt;br /&gt;
* --best : Find the best matching individuals (.bestSM and .bestRG files will be produced). This option is substantially longer than the default option&lt;br /&gt;
* --free-none : Do not perform sequence-only method to estimate parameters&lt;br /&gt;
* --free-mix : (default) Estimate contamination using sequence-only method with Brent&#039;s single dimensional optimization.&lt;br /&gt;
* --free-refBias : Estimate the reference bias parameters using sequence-only method with Simplex method&lt;br /&gt;
* --free-full : Estimate both reference bias parameters and the contamination parameters using sequence-only method&lt;br /&gt;
* --chip-none : Do not perform sequence+array method to estimate parameters&lt;br /&gt;
* --chip-mix : (default) Estimate contamination using sequence+array method with Brent&#039;s single dimensional optimization.&lt;br /&gt;
* --chip-refBias : Estimate the refernece bias parameters using sequence+array method with Simplex method&lt;br /&gt;
* --chip-full : Estimate both reference bias parameters and the contamination parameters using sequence+array method&lt;br /&gt;
* --ignoreRG : ignore the read grouup level comparison and compare samples only (recommended for an expedited run)&lt;br /&gt;
* --ignoreOverlapPair : ignore overlapping pair end fragment covering the same base. Disabling this option may decrease the sensitivity of the method when the insert size is short (with slight gain in the computational speed)&lt;br /&gt;
* --noEOF : do not check the EOF marker of the BAM file (for earlier version of BAM)&lt;br /&gt;
* --precise : calculate the likelihood in log-scale for high-depth data (recommended when --maxDepth is greater than 20. Can be a little bit slower)&lt;br /&gt;
* --minMapQ : minimum mapping quality of the sequence reads to compare&lt;br /&gt;
* --minQ : minimum base quality to include&lt;br /&gt;
* --maxQ : maximum base quality to cap&lt;br /&gt;
* --grid : the grid interval to search the optimum before running Brent&#039;s algorithm.&lt;br /&gt;
* --refRef : Initial Pr(refBase|HOMREFGeno) parameter&lt;br /&gt;
* --refHet : Initial Pr(refBase|HETGeno) parameter&lt;br /&gt;
* --refAlt : Initial Pr(refBase|HOMALTGeno) parameter&lt;br /&gt;
* --out : output file prefix (required)&lt;br /&gt;
* --verbose : print the progress of the method on the screeen&lt;br /&gt;
{{PhoneHomeParameters|hdr=====|bullet=1}}&lt;br /&gt;
&lt;br /&gt;
== Principle of Operation ==&lt;br /&gt;
&lt;br /&gt;
Each read group in a BAM file is evaluated independently. This means that in file with multiple read groups, problems will be flagged at the read group level (a plus). However, it also means that it might be hard to discern the correct assignment of read groups with very little data.&lt;br /&gt;
&lt;br /&gt;
For each aligned base that overlaps a known genotype, we calculate the probability the probability that it was derived from a particular known genotype. This comparison considers only bases that overlap previously known genotypes and that meet the base quality and mapping quality thresholds.&lt;br /&gt;
&lt;br /&gt;
Each individual in a pedigree has a different combination of genotypes, and bamGenotypeCheck will systematically search for the individual whose genotypes best match the observed read data.&lt;br /&gt;
&lt;br /&gt;
For more about the technical details, see the page [[Verifying Sample Identities - Implementation]]&lt;br /&gt;
&lt;br /&gt;
== Reference ==&lt;br /&gt;
&lt;br /&gt;
Please cite the following paper:&lt;br /&gt;
&lt;br /&gt;
G. Jun, M. Flickinger, K. N. Hetrick, Kurt, J. M. Romm, K. F. Doheny, G. Abecasis, M. Boehnke,and H. M. Kang, &#039;&#039;Detecting and Estimating Contamination of Human DNA Samples in Sequencing and Array-Based Genotype Data&#039;&#039;, American journal of human genetics doi:10.1016/j.ajhg.2012.09.004 (volume 91 issue 5 pp.839 - 848) &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Contamination in Array Data ==&lt;br /&gt;
&lt;br /&gt;
[[VerifyIDintensity]] or [[BAFRegress]] can estimate sample contamination from Illumina genotype array data.&lt;br /&gt;
&lt;br /&gt;
== Acknowledgements ==&lt;br /&gt;
&lt;br /&gt;
VerifyBamID is a result from collaborative effort by Hyun Min Kang, Goo Jun, Matthew Flickinger, Mary Kate Wing, Goncalo Abecasis, and Michael Boehnke. Please email to Hyun Min Kang [hmkang@umich.edu ] for any questions.&lt;/div&gt;</summary>
		<author><name>Mktrost</name></author>
	</entry>
	<entry>
		<id>http://genome.sph.umich.edu/w/index.php?title=BamUtil:_stats&amp;diff=14828</id>
		<title>BamUtil: stats</title>
		<link rel="alternate" type="text/html" href="http://genome.sph.umich.edu/w/index.php?title=BamUtil:_stats&amp;diff=14828"/>
		<updated>2017-08-24T19:59:05Z</updated>

		<summary type="html">&lt;p&gt;Mktrost: /* BaseQC (--pBaseQC and --cBaseQC and --baseSum) */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;br&amp;gt; &lt;br /&gt;
&lt;br /&gt;
= Overview of the &amp;lt;code&amp;gt;stats&amp;lt;/code&amp;gt; function of &amp;lt;code&amp;gt;bamUtil&amp;lt;/code&amp;gt;  =&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;stats&amp;lt;/code&amp;gt; option on the [[BamUtil]] executable generates the specified statistics on a SAM/BAM file.&lt;br /&gt;
&lt;br /&gt;
== Troubleshooting ==&lt;br /&gt;
See [[BamUtil:_FAQ#BamUtil:_stats|BamUtil: FAQ -&amp;gt; BamUtil: stats]] for troubleshooting help.&lt;br /&gt;
&lt;br /&gt;
= Usage =&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 ./bam stats --in &amp;lt;inputFile&amp;gt; [--basic] [--qual] [--phred] [--pBaseQC &amp;lt;outputFileName&amp;gt;] [--cBaseQC &amp;lt;outputFileName&amp;gt;] [--maxNumReads &amp;lt;maxNum&amp;gt;][--unmapped] [--bamIndex &amp;lt;bamIndexFile&amp;gt;] [--regionList &amp;lt;regFileName&amp;gt;] [--requiredFlags &amp;lt;integerRequiredFlags&amp;gt;] [--excludeFlags &amp;lt;integerExcludeFlags&amp;gt;] [--noeof] [--params] [--withinRegion] [--baseSum] [--bufferSize &amp;lt;buffSize&amp;gt;] [--minMapQual &amp;lt;minMapQ&amp;gt;] [--dbsnp &amp;lt;dbsnpFile&amp;gt;]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Parameters  =&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
        Required Parameters:&lt;br /&gt;
                --in : the SAM/BAM file to calculate stats for&lt;br /&gt;
        Types of Statistics that can be generated:&lt;br /&gt;
                --basic         : Turn on basic statistic generation&lt;br /&gt;
                --qual          : Generate a count for each quality (displayed as non-phred quality)&lt;br /&gt;
                --phred         : Generate a count for each quality (displayed as phred quality)&lt;br /&gt;
                --pBaseQC       : Write per base statistics as Percentages to the specified file. (use - for stdout)&lt;br /&gt;
                                  pBaseQC &amp;amp; cBaseQC cannot both be specified.&lt;br /&gt;
                --cBaseQC       : Write per base statistics as Counts to the specified file. (use - for stdout)&lt;br /&gt;
                                  pBaseQC &amp;amp; cBaseQC cannot both be specified.&lt;br /&gt;
        Optional Parameters:&lt;br /&gt;
                --maxNumReads   : Maximum number of reads to process&lt;br /&gt;
                                  Defaults to -1 to indicate all reads.&lt;br /&gt;
                --unmapped      : Only process unmapped reads (requires a bamIndex file)&lt;br /&gt;
                --bamIndex      : The path/name of the bam index file&lt;br /&gt;
                                  (if required and not specified, uses the --in value + &amp;quot;.bai&amp;quot;)&lt;br /&gt;
                --regionList    : File containing the regions to be processed chr&amp;lt;tab&amp;gt;start_pos&amp;lt;tab&amp;gt;end_pos.&lt;br /&gt;
                                  Positions are 0 based and the end_pos is not included in the region.&lt;br /&gt;
                                  Uses bamIndex.&lt;br /&gt;
                --excludeFlags  : Skip any records with any of the specified flags set&lt;br /&gt;
                                  (specify an integer representation of the flags)&lt;br /&gt;
                --requiredFlags : Only process records with all of the specified flags set&lt;br /&gt;
                                  (specify an integer representation of the flags)&lt;br /&gt;
                --noeof         : Do not expect an EOF block on a bam file.&lt;br /&gt;
                --params        : Print the parameter settings.&lt;br /&gt;
        Optional phred/qual Only Parameters:&lt;br /&gt;
                --withinRegion  : Only count qualities if they fall within regions specified.&lt;br /&gt;
                                  Only applicable if regionList is also specified.&lt;br /&gt;
        Optional BaseQC Only Parameters:&lt;br /&gt;
                --baseSum       : Print an overall summary of the baseQC for the file to stderr.&lt;br /&gt;
                --bufferSize    : Size of the pileup buffer for calculating the BaseQC parameters.&lt;br /&gt;
                                  Default: 1024&lt;br /&gt;
                --minMapQual    : The minimum mapping quality for filtering reads in the baseQC stats.&lt;br /&gt;
                --dbsnp         : The dbSnp file of positions to exclude from baseQC analysis.&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
{{PhoneHomeParamDesc}}&lt;br /&gt;
&lt;br /&gt;
== Required Parameters ==&lt;br /&gt;
&lt;br /&gt;
{{inBAMInputFile}}&lt;br /&gt;
&lt;br /&gt;
== Optional Parameters ==&lt;br /&gt;
===  Maximum number of reads to process(&amp;lt;code&amp;gt;--maxNumReads&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
Use &amp;lt;code&amp;gt;--maxNumReads&amp;lt;/code&amp;gt; followed by a number to indicate the maximum number of reads to process before exiting.  By default, it is set to -1 to indicate all reads should be processed.&lt;br /&gt;
&lt;br /&gt;
=== Only Process Unmapped Reads (&amp;lt;code&amp;gt;--unmapped&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
Use &amp;lt;code&amp;gt;--unmapped&amp;lt;/code&amp;gt; to process only unmapped reads.&lt;br /&gt;
&lt;br /&gt;
This parameter requires [[#Bam Index File (--bamIndex)|&amp;lt;code&amp;gt;--bamIndex&amp;lt;/code&amp;gt;]].&lt;br /&gt;
&lt;br /&gt;
{{BamIndex}}&lt;br /&gt;
&lt;br /&gt;
=== Only Process Certain Regions (&amp;lt;code&amp;gt;--regionList&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
Use &amp;lt;code&amp;gt;--regionList&amp;lt;/code&amp;gt; followed by the filename to process only the regions specified in the file.&lt;br /&gt;
&lt;br /&gt;
The positions in the file are specified one per line with the following format: &amp;lt;nowiki&amp;gt;chr&amp;lt;tab&amp;gt;start_pos&amp;lt;tab&amp;gt;end_pos.&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Positions are 0 based and the end_pos is not included in the region.&lt;br /&gt;
&lt;br /&gt;
This parameter requires [[#Bam Index File (--bamIndex)|&amp;lt;code&amp;gt;--bamIndex&amp;lt;/code&amp;gt;]].&lt;br /&gt;
&lt;br /&gt;
=== Exclude Flags (&amp;lt;code&amp;gt;--excludeFlags&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
Use &amp;lt;code&amp;gt;--excludeFlags&amp;lt;/code&amp;gt; followed by an integer representation of the flags to only process reads with any of the specified flags set.&lt;br /&gt;
&lt;br /&gt;
=== Required Flags (&amp;lt;code&amp;gt;--requiredFlags&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
Use &amp;lt;code&amp;gt;--requiredFlags&amp;lt;/code&amp;gt; followed by an integer representation of the flags to only process records with all of the specified flags set.&lt;br /&gt;
&lt;br /&gt;
== Types of Statistics ==&lt;br /&gt;
&lt;br /&gt;
=== Basic (&amp;lt;code&amp;gt;--basic&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
Prints summary statistics for the file: &lt;br /&gt;
&lt;br /&gt;
*TotalReads - # of reads that are in the file &lt;br /&gt;
*MappedReads - # of reads marked mapped in the flag &lt;br /&gt;
*PairedReads - # of reads marked paired in the flag &lt;br /&gt;
*ProperPair - # of reads marked paired AND proper paired in the flag &lt;br /&gt;
*DuplicateReads - # of reads marked duplicate in the flag &lt;br /&gt;
*QCFailureReads - # of reads marked QC failure in the flag &lt;br /&gt;
*MappingRate(%) - # of reads marked mapped in the flag / TotalReads &lt;br /&gt;
*PairedReads(%) - # of reads marked paired in the flag / TotalReads &lt;br /&gt;
*ProperPair(%) - # of reads marked paired AND proper paired in the flag / TotalReads &lt;br /&gt;
*DupRate(%) - # of reads marked duplicate in the flag / TotalReads &lt;br /&gt;
*QCFailRate(%) - # of reads marked QC failure in the flag / TotalReads &lt;br /&gt;
*TotalBases - # of bases in all reads &lt;br /&gt;
*BasesInMappedReads - # of bases in reads marked mapped in the flag&lt;br /&gt;
&lt;br /&gt;
=== Qual/Phred (&amp;lt;code&amp;gt;--phred&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;--qual&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
Prints a count of the number of times each quality value appears in the file to stderr. &lt;br /&gt;
&lt;br /&gt;
*&amp;lt;code&amp;gt;phred&amp;lt;/code&amp;gt; Displays Quality as phred integers [0-93] &lt;br /&gt;
*&amp;lt;code&amp;gt;qual&amp;lt;/code&amp;gt; Displays Quality as non-phred integers (phred + 33) [33-126]&lt;br /&gt;
&lt;br /&gt;
By default, these counts include all qualities in the BAM file.&lt;br /&gt;
&lt;br /&gt;
To exclude unmapped reads and soft clips, use --excludeFlags 4.&lt;br /&gt;
&lt;br /&gt;
To only include records that overlap a set of regions, use --regionList and specify a bed file with the regions.  If a read overlaps the region, all qualities will be counted even if those bases do not fall in the region.  If you only want to count qualities that fall within the region, also specify --withinRegion.  Without excluding unmapped reads, it will include soft clips that overlap the region.&lt;br /&gt;
&lt;br /&gt;
==== Optional Phred/Qual Only Parameters ====&lt;br /&gt;
===== Within Region (&amp;lt;code&amp;gt;--withinRegion&amp;lt;/code&amp;gt;) =====&lt;br /&gt;
Use &amp;lt;code&amp;gt;--withinRegion&amp;lt;/code&amp;gt; with [[#Qual/Phred (--phred and --qual)|&amp;lt;code&amp;gt;--phred&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;--qual&amp;lt;/code&amp;gt;]] options to only count qualities if they fall within the regions specified using [[#Only Process Certain Regions (--regionList)|&amp;lt;code&amp;gt;--regionList&amp;lt;/code&amp;gt;]] (only applicable if [[#Only Process Certain Regions (--regionList)|&amp;lt;code&amp;gt;--regionList&amp;lt;/code&amp;gt;]]  is also specified).&lt;br /&gt;
&lt;br /&gt;
=== BaseQC (&amp;lt;code&amp;gt;--pBaseQC&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;--cBaseQC&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;--baseSum&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;pBaseQC&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;cBaseQC&amp;lt;/code&amp;gt; options generate per base statistics.  Only one of these two options can be specified.  They write statistics generated for each position to the file specified after the option (use &amp;lt;code&amp;gt;-&amp;lt;/code&amp;gt; to write to STDOUT).  They use the same logic for calculating statistics, but &amp;lt;code&amp;gt;pBaseQC&amp;lt;/code&amp;gt; writes the statistics as percentages, and &amp;lt;code&amp;gt;cBaseQC&amp;lt;/code&amp;gt; writes them as counts.  The order of the statistics are also different.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;baseSum&amp;lt;/code&amp;gt; option can be used with either &amp;lt;code&amp;gt;pBaseQC&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;cBaseQC&amp;lt;/code&amp;gt; or on its own.  &amp;lt;code&amp;gt;baseSum&amp;lt;/code&amp;gt; generates a summary of the per position statistics and writes it to stderr.  It calculates the per position base statistics even if they will not be written anywhere (neither &amp;lt;code&amp;gt;pBaseQC&amp;lt;/code&amp;gt; nor &amp;lt;code&amp;gt;cBaseQC&amp;lt;/code&amp;gt; are specified).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
All three options use the same logic for calculating the statistics:&lt;br /&gt;
* A read spans a position if the read starts at or before the position, ends at or after the position and the position is not a clip.  CIGAR operations allowed for the position are M/X/=/D/N.  If the CIGAR is &#039;*&#039;, only numbers for the specified reference position are incremented.&lt;br /&gt;
*Currently there is no special logic to exclude positions/reads where the reference base is &#039;N&#039; or the read base is &#039;N&#039;. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt; &lt;br /&gt;
&lt;br /&gt;
==== Percentage-Based Output Format (&amp;lt;code&amp;gt;--pBaseQC&amp;lt;/code&amp;gt;) ====&lt;br /&gt;
&lt;br /&gt;
Order/Descriptions: &lt;br /&gt;
&lt;br /&gt;
{|border=1 &lt;br /&gt;
! Field !! Description !!style=&amp;quot;width: 80px&amp;quot;| Excludes Duplicates, QC Failures !!style=&amp;quot;width: 80px&amp;quot;| Excludes Unmapped !!style=&amp;quot;width: 80px&amp;quot;|  Excludes MapQual = 255 !!style=&amp;quot;width: 80px&amp;quot;| Excludes Below Min MapQual !!style=&amp;quot;width: 80px&amp;quot;| Excludes CIGAR Deletions, Skips&lt;br /&gt;
|-&lt;br /&gt;
| chrom || Chromosome/reference name string from the SAM/BAM&lt;br /&gt;
|-&lt;br /&gt;
| chromStart || 0-based start position&lt;br /&gt;
|-&lt;br /&gt;
| chromEnd || 0-based end position (always 1 greater than start and not included in this region)&lt;br /&gt;
|-&lt;br /&gt;
| Depth || # of reads that are mapped with acceptable Mapping Quality, and are not duplicates or QC failures || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X&lt;br /&gt;
|-&lt;br /&gt;
| Q20Bases || # of bases at this position with a base quality (from the read) of Q20 or higher || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X&lt;br /&gt;
|-&lt;br /&gt;
| Q20BasesPct(%) || Q20Bases / Depth || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X&lt;br /&gt;
|-&lt;br /&gt;
| TotalReads || # of reads that span this position || || || || ||&lt;br /&gt;
|-&lt;br /&gt;
| MappedBases || # of reads marked mapped in the flag || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X || || ||&lt;br /&gt;
|-&lt;br /&gt;
| MappingRate(%) || MappedBases / TotalReads || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X || || ||&lt;br /&gt;
|-&lt;br /&gt;
| MapRate_MQPass(%) || # of reads that have a Mapping Quality &amp;amp;gt;= a minimum Mapping Quality / TotalReads || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X || || ||&lt;br /&gt;
|-&lt;br /&gt;
| ZeroMapQual(%) || # of reads that have a Mapping Quality of 0 / TotalReads || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X || || ||&lt;br /&gt;
|-&lt;br /&gt;
| MapQual&amp;amp;lt;10(%) || # of reads that have a Mapping Quality &amp;amp;lt; 10 / TotalReads || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X || || ||&lt;br /&gt;
|-&lt;br /&gt;
| PairedReads(%) || # of reads marked paired in the flag / TotalReads || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X || || ||&lt;br /&gt;
|-&lt;br /&gt;
| ProperPaired(%) || # of reads marked paired AND proper paired in the flag / TotalReads || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X || || ||&lt;br /&gt;
|-&lt;br /&gt;
| DupRate(%) || # of reads marked duplicate in the flag / TotalReads || || || || ||&lt;br /&gt;
|-&lt;br /&gt;
| QCFailRate(%) || # of reads marked QC failure in the flag / TotalReads || || || || ||&lt;br /&gt;
|-&lt;br /&gt;
| AverageMapQuality || sum of included mapping qualities / AverageMapQualCount || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X || ||&lt;br /&gt;
|-&lt;br /&gt;
| AverageMapQualCount || # of mapping qualities in AverageMapQuality || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X || ||&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
This output does not include a MapQual255 count. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===== Sample Output  =====&lt;br /&gt;
&amp;lt;pre&amp;gt;chrom	chromStart	chromEnd	Depth	Q20Bases	Q20BasesPct(%)	TotalReads	MappedBases	MappingRate(%)	MapRate_MQPass(%)	ZeroMapQual(%)	MapQual&amp;amp;lt;10(%)	PairedReads(%)	ProperPaired(%)	DupRate(%)	QCFailRate(%)	AverageMapQuality	AverageMapQualCount&lt;br /&gt;
1	100	101	2	2	100.000	3	3	100.000	66.667	33.333	66.667	100.000	0.000	0.000	0.000	11.000	3&lt;br /&gt;
1	101	102	2	0	0.000	3	3	100.000	66.667	33.333	66.667	100.000	0.000	0.000	0.000	11.000	3&lt;br /&gt;
1	102	103	0	0	0.000	3	3	100.000	66.667	33.333	66.667	100.000	0.000	0.000	0.000	0.000	0&lt;br /&gt;
1	103	104	0	0	0.000	3	3	100.000	66.667	33.333	66.667	100.000	0.000	0.000	0.000	0.000	0&lt;br /&gt;
1	104	105	2	0	0.000	3	3	100.000	66.667	33.333	66.667	100.000	0.000	0.000	0.000	11.000	3&lt;br /&gt;
1	105	106	2	2	100.000	3	3	100.000	66.667	33.333	66.667	100.000	0.000	0.000	0.000	11.000	3&lt;br /&gt;
1	110	111	0	0	0.000	3	3	100.000	66.667	33.333	66.667	100.000	0.000	0.000	0.000	0.000	0&lt;br /&gt;
1	111	112	2	2	100.000	3	3	100.000	66.667	33.333	66.667	100.000	0.000	0.000	0.000	11.000	3&lt;br /&gt;
1	112	113	2	2	100.000	3	3	100.000	66.667	33.333	66.667	100.000	0.000	0.000	0.000	11.000	3&lt;br /&gt;
1	10012	10013	14	0	0.000	42	33	78.571	52.381	26.190	52.381	85.714	35.714	14.286	14.286	11.000	21&lt;br /&gt;
1	10013	10014	14	10	71.429	39	30	76.923	51.282	25.641	51.282	84.615	38.462	15.385	15.385	11.000	21&lt;br /&gt;
1	10023	10024	0	0	0.000	39	30	76.923	51.282	25.641	51.282	84.615	38.462	15.385	15.385	0.000	0&lt;br /&gt;
1	10024	10025	14	12	85.714	39	30	76.923	51.282	25.641	51.282	84.615	38.462	15.385	15.385	11.000	21&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Count-Based Output Format (&amp;lt;code&amp;gt;--cBaseQC&amp;lt;/code&amp;gt;) ====&lt;br /&gt;
Order/Descriptions: &lt;br /&gt;
{|border=1 &lt;br /&gt;
! Field !! Description !!style=&amp;quot;width: 80px&amp;quot;| Excludes Duplicates, QC Failures !!style=&amp;quot;width: 80px&amp;quot;| Excludes Unmapped !!style=&amp;quot;width: 80px&amp;quot;|  Excludes MapQual = 255 !!style=&amp;quot;width: 80px&amp;quot;| Excludes Below Min MapQual !!style=&amp;quot;width: 80px&amp;quot;| Excludes CIGAR Deletions, Skips&lt;br /&gt;
|-&lt;br /&gt;
| chrom || Chromosome/reference name string from the SAM/BAM&lt;br /&gt;
|-&lt;br /&gt;
| chromStart || 0-based start position&lt;br /&gt;
|-&lt;br /&gt;
| chromEnd || 0-based end position (always 1 greater than start and not included in this region)&lt;br /&gt;
|-&lt;br /&gt;
| TotalReads || # of reads that span this position || || || || ||&lt;br /&gt;
|-&lt;br /&gt;
| Dups || # of reads marked duplicate in the flag || || || || ||&lt;br /&gt;
|-&lt;br /&gt;
| QCFail || # of reads marked QC failure in the flag || || || || ||&lt;br /&gt;
|-&lt;br /&gt;
| Mapped || # of reads marked mapped in the flag || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X || || ||&lt;br /&gt;
|-&lt;br /&gt;
| Paired || # of reads marked paired in the flag || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X || || ||&lt;br /&gt;
|-&lt;br /&gt;
| ProperPaired || # of reads marked paired AND proper paired in the flag || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X || || ||&lt;br /&gt;
|-&lt;br /&gt;
| ZeroMapQual || # of reads that have a Mapping Quality of 0 || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X || || ||&lt;br /&gt;
|-&lt;br /&gt;
| MapQual&amp;amp;lt;10(%) || # of reads that have a Mapping Quality &amp;amp;lt; 10 || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X || || ||&lt;br /&gt;
|-&lt;br /&gt;
| MapQual255 || # of reads that have a Mapping Quality = 255 || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X || || ||&lt;br /&gt;
|-&lt;br /&gt;
| PassMapQual || # of reads that have a Mapping Quality &amp;amp;gt;= a minimum Mapping Quality || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X || || ||&lt;br /&gt;
|-&lt;br /&gt;
| AverageMapQuality || sum of included mapping qualities / AverageMapQualCount || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X || ||&lt;br /&gt;
|-&lt;br /&gt;
| AverageMapQualCount || # of mapping qualities in AverageMapQuality || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X ||&lt;br /&gt;
|- ||&lt;br /&gt;
| Depth || # of reads that are mapped with acceptable Mapping Quality, and are not duplicates or QC failures || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X&lt;br /&gt;
|-&lt;br /&gt;
| Q20Bases || # of bases at this position with a base quality (from the read) of Q20 or higher || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Summary of per Position Statistics (&amp;lt;code&amp;gt;--baseSum&amp;lt;/code&amp;gt;) ====&lt;br /&gt;
Use &amp;lt;code&amp;gt;--baseSum&amp;lt;/code&amp;gt; to print an overall summary of the baseQC for the file to stderr.&lt;br /&gt;
&lt;br /&gt;
This option can be used with or without &amp;lt;code&amp;gt;--pBaseQC&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;--cBaseQC&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The values are tab delimited.  First there is a header line describing the summary.  The next line has the Means, and the last line has the Standard Deviations.&lt;br /&gt;
&lt;br /&gt;
{|border=1 &lt;br /&gt;
! Field !! Description !!style=&amp;quot;width: 80px&amp;quot;| Excludes Duplicates, QC Failures !!style=&amp;quot;width: 80px&amp;quot;| Excludes Unmapped !!style=&amp;quot;width: 80px&amp;quot;|  Excludes MapQual = 255 !!style=&amp;quot;width: 80px&amp;quot;| Excludes Below Min MapQual !!style=&amp;quot;width: 80px&amp;quot;| Excludes CIGAR Deletions, Skips&lt;br /&gt;
|-&lt;br /&gt;
| TotalReads || # of reads that span this position || || || || ||&lt;br /&gt;
|-&lt;br /&gt;
| Dups || # of reads marked duplicate in the flag || || || || ||&lt;br /&gt;
|-&lt;br /&gt;
| QCFail || # of reads marked QC failure in the flag || || || || ||&lt;br /&gt;
|-&lt;br /&gt;
| Mapped || # of reads marked mapped in the flag || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X || || ||&lt;br /&gt;
|-&lt;br /&gt;
| Paired || # of reads marked paired in the flag || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X || || ||&lt;br /&gt;
|-&lt;br /&gt;
| ProperPaired || # of reads marked paired AND proper paired in the flag || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X || || ||&lt;br /&gt;
|-&lt;br /&gt;
| ZeroMapQual || # of reads that have a Mapping Quality of 0 || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X || || ||&lt;br /&gt;
|-&lt;br /&gt;
| MapQual&amp;amp;lt;10(%) || # of reads that have a Mapping Quality &amp;amp;lt; 10 || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X || || ||&lt;br /&gt;
|-&lt;br /&gt;
| MapQual255 || # of reads that have a Mapping Quality = 255 || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X || || ||&lt;br /&gt;
|-&lt;br /&gt;
| PassMapQual || # of reads that have a Mapping Quality &amp;amp;gt;= a minimum Mapping Quality || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X || || ||&lt;br /&gt;
|-&lt;br /&gt;
| AverageMapQuality || sum of included mapping qualities / AverageMapQualCount || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X || ||&lt;br /&gt;
|-&lt;br /&gt;
| AverageMapQualCount || # of mapping qualities in AverageMapQuality || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X ||&lt;br /&gt;
|- ||&lt;br /&gt;
| Depth || # of reads that are mapped with acceptable Mapping Quality, and are not duplicates or QC failures || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X&lt;br /&gt;
|-&lt;br /&gt;
| Q20Bases || # of bases at this position with a base quality (from the read) of Q20 or higher || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===== Sample Output =====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Summary of Pileup Stats (1st Row is Mean, 2nd Row is Standard Deviation)&lt;br /&gt;
TotalReads	Dups	QCFail	Mapped	Paired	ProperPaired	ZeroMapQual	MapQual&amp;lt;10	MapQual255	PassMapQual	AverageMapQuality	AverageMapQualCount	&lt;br /&gt;
Depth	Q20Bases&lt;br /&gt;
14.307692	1.846154	1.846154	8.769231	7.846154	0.923077	2.923077	5.846154	0.000000	2.923077	11.000000	8.769231	2.076923	1.153846&lt;br /&gt;
17.670053	2.882307	2.882307	9.038380	7.603137	1.441153	3.012793	6.025586	0.000000	3.012793	0.000000	9.038380	2.841993	1.993579&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Optional BaseQC Only Parameters ====&lt;br /&gt;
===== Pileup Buffer Size (&amp;lt;code&amp;gt;--bufferSize&amp;lt;/code&amp;gt;) =====&lt;br /&gt;
Use the &amp;lt;code&amp;gt;--bufferSize&amp;lt;/code&amp;gt; option followed by the size of the pileup buffer to use for [[BaseQC (--pBaseQC and --cBaseQC and --baseSum)|baseQC]] stats.&lt;br /&gt;
&lt;br /&gt;
===== Minimum Mapping Quality (&amp;lt;code&amp;gt;--minMapQual&amp;lt;/code&amp;gt;) =====&lt;br /&gt;
Use the &amp;lt;code&amp;gt;--minMapQual&amp;lt;/code&amp;gt; option followed by the minimum mapping quality for filtering reads in the [[BaseQC (--pBaseQC and --cBaseQC and --baseSum)|baseQC]] stats.&lt;br /&gt;
&lt;br /&gt;
===== DBSNP File (&amp;lt;code&amp;gt;--dbsnp&amp;lt;/code&amp;gt;) =====&lt;br /&gt;
Use the &amp;lt;code&amp;gt;--dbsnp&amp;lt;/code&amp;gt; option followed by the name of the dbsnp file to specify the positions to exclude from [[BaseQC (--pBaseQC and --cBaseQC and --baseSum)|baseQC]] analysis.&lt;br /&gt;
&lt;br /&gt;
{{PhoneHomeParameters}}&lt;br /&gt;
&lt;br /&gt;
= Return Value =&lt;br /&gt;
0 on Success, non-0 on failure&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:BamUtil|stats]] [[Category:BAM_Software]] [[Category:Software]]&lt;/div&gt;</summary>
		<author><name>Mktrost</name></author>
	</entry>
	<entry>
		<id>http://genome.sph.umich.edu/w/index.php?title=BamUtil:_stats&amp;diff=14827</id>
		<title>BamUtil: stats</title>
		<link rel="alternate" type="text/html" href="http://genome.sph.umich.edu/w/index.php?title=BamUtil:_stats&amp;diff=14827"/>
		<updated>2017-08-24T19:58:21Z</updated>

		<summary type="html">&lt;p&gt;Mktrost: /* BaseQC (--pBaseQC and --cBaseQC and --baseSum) */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;br&amp;gt; &lt;br /&gt;
&lt;br /&gt;
= Overview of the &amp;lt;code&amp;gt;stats&amp;lt;/code&amp;gt; function of &amp;lt;code&amp;gt;bamUtil&amp;lt;/code&amp;gt;  =&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;stats&amp;lt;/code&amp;gt; option on the [[BamUtil]] executable generates the specified statistics on a SAM/BAM file.&lt;br /&gt;
&lt;br /&gt;
== Troubleshooting ==&lt;br /&gt;
See [[BamUtil:_FAQ#BamUtil:_stats|BamUtil: FAQ -&amp;gt; BamUtil: stats]] for troubleshooting help.&lt;br /&gt;
&lt;br /&gt;
= Usage =&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 ./bam stats --in &amp;lt;inputFile&amp;gt; [--basic] [--qual] [--phred] [--pBaseQC &amp;lt;outputFileName&amp;gt;] [--cBaseQC &amp;lt;outputFileName&amp;gt;] [--maxNumReads &amp;lt;maxNum&amp;gt;][--unmapped] [--bamIndex &amp;lt;bamIndexFile&amp;gt;] [--regionList &amp;lt;regFileName&amp;gt;] [--requiredFlags &amp;lt;integerRequiredFlags&amp;gt;] [--excludeFlags &amp;lt;integerExcludeFlags&amp;gt;] [--noeof] [--params] [--withinRegion] [--baseSum] [--bufferSize &amp;lt;buffSize&amp;gt;] [--minMapQual &amp;lt;minMapQ&amp;gt;] [--dbsnp &amp;lt;dbsnpFile&amp;gt;]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Parameters  =&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
        Required Parameters:&lt;br /&gt;
                --in : the SAM/BAM file to calculate stats for&lt;br /&gt;
        Types of Statistics that can be generated:&lt;br /&gt;
                --basic         : Turn on basic statistic generation&lt;br /&gt;
                --qual          : Generate a count for each quality (displayed as non-phred quality)&lt;br /&gt;
                --phred         : Generate a count for each quality (displayed as phred quality)&lt;br /&gt;
                --pBaseQC       : Write per base statistics as Percentages to the specified file. (use - for stdout)&lt;br /&gt;
                                  pBaseQC &amp;amp; cBaseQC cannot both be specified.&lt;br /&gt;
                --cBaseQC       : Write per base statistics as Counts to the specified file. (use - for stdout)&lt;br /&gt;
                                  pBaseQC &amp;amp; cBaseQC cannot both be specified.&lt;br /&gt;
        Optional Parameters:&lt;br /&gt;
                --maxNumReads   : Maximum number of reads to process&lt;br /&gt;
                                  Defaults to -1 to indicate all reads.&lt;br /&gt;
                --unmapped      : Only process unmapped reads (requires a bamIndex file)&lt;br /&gt;
                --bamIndex      : The path/name of the bam index file&lt;br /&gt;
                                  (if required and not specified, uses the --in value + &amp;quot;.bai&amp;quot;)&lt;br /&gt;
                --regionList    : File containing the regions to be processed chr&amp;lt;tab&amp;gt;start_pos&amp;lt;tab&amp;gt;end_pos.&lt;br /&gt;
                                  Positions are 0 based and the end_pos is not included in the region.&lt;br /&gt;
                                  Uses bamIndex.&lt;br /&gt;
                --excludeFlags  : Skip any records with any of the specified flags set&lt;br /&gt;
                                  (specify an integer representation of the flags)&lt;br /&gt;
                --requiredFlags : Only process records with all of the specified flags set&lt;br /&gt;
                                  (specify an integer representation of the flags)&lt;br /&gt;
                --noeof         : Do not expect an EOF block on a bam file.&lt;br /&gt;
                --params        : Print the parameter settings.&lt;br /&gt;
        Optional phred/qual Only Parameters:&lt;br /&gt;
                --withinRegion  : Only count qualities if they fall within regions specified.&lt;br /&gt;
                                  Only applicable if regionList is also specified.&lt;br /&gt;
        Optional BaseQC Only Parameters:&lt;br /&gt;
                --baseSum       : Print an overall summary of the baseQC for the file to stderr.&lt;br /&gt;
                --bufferSize    : Size of the pileup buffer for calculating the BaseQC parameters.&lt;br /&gt;
                                  Default: 1024&lt;br /&gt;
                --minMapQual    : The minimum mapping quality for filtering reads in the baseQC stats.&lt;br /&gt;
                --dbsnp         : The dbSnp file of positions to exclude from baseQC analysis.&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
{{PhoneHomeParamDesc}}&lt;br /&gt;
&lt;br /&gt;
== Required Parameters ==&lt;br /&gt;
&lt;br /&gt;
{{inBAMInputFile}}&lt;br /&gt;
&lt;br /&gt;
== Optional Parameters ==&lt;br /&gt;
===  Maximum number of reads to process(&amp;lt;code&amp;gt;--maxNumReads&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
Use &amp;lt;code&amp;gt;--maxNumReads&amp;lt;/code&amp;gt; followed by a number to indicate the maximum number of reads to process before exiting.  By default, it is set to -1 to indicate all reads should be processed.&lt;br /&gt;
&lt;br /&gt;
=== Only Process Unmapped Reads (&amp;lt;code&amp;gt;--unmapped&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
Use &amp;lt;code&amp;gt;--unmapped&amp;lt;/code&amp;gt; to process only unmapped reads.&lt;br /&gt;
&lt;br /&gt;
This parameter requires [[#Bam Index File (--bamIndex)|&amp;lt;code&amp;gt;--bamIndex&amp;lt;/code&amp;gt;]].&lt;br /&gt;
&lt;br /&gt;
{{BamIndex}}&lt;br /&gt;
&lt;br /&gt;
=== Only Process Certain Regions (&amp;lt;code&amp;gt;--regionList&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
Use &amp;lt;code&amp;gt;--regionList&amp;lt;/code&amp;gt; followed by the filename to process only the regions specified in the file.&lt;br /&gt;
&lt;br /&gt;
The positions in the file are specified one per line with the following format: &amp;lt;nowiki&amp;gt;chr&amp;lt;tab&amp;gt;start_pos&amp;lt;tab&amp;gt;end_pos.&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Positions are 0 based and the end_pos is not included in the region.&lt;br /&gt;
&lt;br /&gt;
This parameter requires [[#Bam Index File (--bamIndex)|&amp;lt;code&amp;gt;--bamIndex&amp;lt;/code&amp;gt;]].&lt;br /&gt;
&lt;br /&gt;
=== Exclude Flags (&amp;lt;code&amp;gt;--excludeFlags&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
Use &amp;lt;code&amp;gt;--excludeFlags&amp;lt;/code&amp;gt; followed by an integer representation of the flags to only process reads with any of the specified flags set.&lt;br /&gt;
&lt;br /&gt;
=== Required Flags (&amp;lt;code&amp;gt;--requiredFlags&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
Use &amp;lt;code&amp;gt;--requiredFlags&amp;lt;/code&amp;gt; followed by an integer representation of the flags to only process records with all of the specified flags set.&lt;br /&gt;
&lt;br /&gt;
== Types of Statistics ==&lt;br /&gt;
&lt;br /&gt;
=== Basic (&amp;lt;code&amp;gt;--basic&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
Prints summary statistics for the file: &lt;br /&gt;
&lt;br /&gt;
*TotalReads - # of reads that are in the file &lt;br /&gt;
*MappedReads - # of reads marked mapped in the flag &lt;br /&gt;
*PairedReads - # of reads marked paired in the flag &lt;br /&gt;
*ProperPair - # of reads marked paired AND proper paired in the flag &lt;br /&gt;
*DuplicateReads - # of reads marked duplicate in the flag &lt;br /&gt;
*QCFailureReads - # of reads marked QC failure in the flag &lt;br /&gt;
*MappingRate(%) - # of reads marked mapped in the flag / TotalReads &lt;br /&gt;
*PairedReads(%) - # of reads marked paired in the flag / TotalReads &lt;br /&gt;
*ProperPair(%) - # of reads marked paired AND proper paired in the flag / TotalReads &lt;br /&gt;
*DupRate(%) - # of reads marked duplicate in the flag / TotalReads &lt;br /&gt;
*QCFailRate(%) - # of reads marked QC failure in the flag / TotalReads &lt;br /&gt;
*TotalBases - # of bases in all reads &lt;br /&gt;
*BasesInMappedReads - # of bases in reads marked mapped in the flag&lt;br /&gt;
&lt;br /&gt;
=== Qual/Phred (&amp;lt;code&amp;gt;--phred&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;--qual&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
Prints a count of the number of times each quality value appears in the file to stderr. &lt;br /&gt;
&lt;br /&gt;
*&amp;lt;code&amp;gt;phred&amp;lt;/code&amp;gt; Displays Quality as phred integers [0-93] &lt;br /&gt;
*&amp;lt;code&amp;gt;qual&amp;lt;/code&amp;gt; Displays Quality as non-phred integers (phred + 33) [33-126]&lt;br /&gt;
&lt;br /&gt;
By default, these counts include all qualities in the BAM file.&lt;br /&gt;
&lt;br /&gt;
To exclude unmapped reads and soft clips, use --excludeFlags 4.&lt;br /&gt;
&lt;br /&gt;
To only include records that overlap a set of regions, use --regionList and specify a bed file with the regions.  If a read overlaps the region, all qualities will be counted even if those bases do not fall in the region.  If you only want to count qualities that fall within the region, also specify --withinRegion.  Without excluding unmapped reads, it will include soft clips that overlap the region.&lt;br /&gt;
&lt;br /&gt;
==== Optional Phred/Qual Only Parameters ====&lt;br /&gt;
===== Within Region (&amp;lt;code&amp;gt;--withinRegion&amp;lt;/code&amp;gt;) =====&lt;br /&gt;
Use &amp;lt;code&amp;gt;--withinRegion&amp;lt;/code&amp;gt; with [[#Qual/Phred (--phred and --qual)|&amp;lt;code&amp;gt;--phred&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;--qual&amp;lt;/code&amp;gt;]] options to only count qualities if they fall within the regions specified using [[#Only Process Certain Regions (--regionList)|&amp;lt;code&amp;gt;--regionList&amp;lt;/code&amp;gt;]] (only applicable if [[#Only Process Certain Regions (--regionList)|&amp;lt;code&amp;gt;--regionList&amp;lt;/code&amp;gt;]]  is also specified).&lt;br /&gt;
&lt;br /&gt;
=== BaseQC (&amp;lt;code&amp;gt;--pBaseQC&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;--cBaseQC&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;--baseSum&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;pBaseQC&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;cBaseQC&amp;lt;/code&amp;gt; options generate per base statistics.  Only one of these two options can be specified.  They write statistics generated for each position to the file specified after the option (use &#039;-&#039; to write to STDOUT).  They use the same logic for calculating statistics, but &amp;lt;code&amp;gt;pBaseQC&amp;lt;/code&amp;gt; writes the statistics as percentages, and &amp;lt;code&amp;gt;cBaseQC&amp;lt;/code&amp;gt; writes them as counts.  The order of the statistics are also different.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;baseSum&amp;lt;/code&amp;gt; option can be used with either &amp;lt;code&amp;gt;pBaseQC&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;cBaseQC&amp;lt;/code&amp;gt; or on its own.  &amp;lt;code&amp;gt;baseSum&amp;lt;/code&amp;gt; generates a summary of the per position statistics and writes it to stderr.  It calculates the per position base statistics even if they will not be written anywhere (neither &amp;lt;code&amp;gt;pBaseQC&amp;lt;/code&amp;gt; nor &amp;lt;code&amp;gt;cBaseQC&amp;lt;/code&amp;gt; are specified).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
All three options use the same logic for calculating the statistics:&lt;br /&gt;
* A read spans a position if the read starts at or before the position, ends at or after the position and the position is not a clip.  CIGAR operations allowed for the position are M/X/=/D/N.  If the CIGAR is &#039;*&#039;, only numbers for the specified reference position are incremented.&lt;br /&gt;
*Currently there is no special logic to exclude positions/reads where the reference base is &#039;N&#039; or the read base is &#039;N&#039;. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt; &lt;br /&gt;
&lt;br /&gt;
==== Percentage-Based Output Format (&amp;lt;code&amp;gt;--pBaseQC&amp;lt;/code&amp;gt;) ====&lt;br /&gt;
&lt;br /&gt;
Order/Descriptions: &lt;br /&gt;
&lt;br /&gt;
{|border=1 &lt;br /&gt;
! Field !! Description !!style=&amp;quot;width: 80px&amp;quot;| Excludes Duplicates, QC Failures !!style=&amp;quot;width: 80px&amp;quot;| Excludes Unmapped !!style=&amp;quot;width: 80px&amp;quot;|  Excludes MapQual = 255 !!style=&amp;quot;width: 80px&amp;quot;| Excludes Below Min MapQual !!style=&amp;quot;width: 80px&amp;quot;| Excludes CIGAR Deletions, Skips&lt;br /&gt;
|-&lt;br /&gt;
| chrom || Chromosome/reference name string from the SAM/BAM&lt;br /&gt;
|-&lt;br /&gt;
| chromStart || 0-based start position&lt;br /&gt;
|-&lt;br /&gt;
| chromEnd || 0-based end position (always 1 greater than start and not included in this region)&lt;br /&gt;
|-&lt;br /&gt;
| Depth || # of reads that are mapped with acceptable Mapping Quality, and are not duplicates or QC failures || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X&lt;br /&gt;
|-&lt;br /&gt;
| Q20Bases || # of bases at this position with a base quality (from the read) of Q20 or higher || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X&lt;br /&gt;
|-&lt;br /&gt;
| Q20BasesPct(%) || Q20Bases / Depth || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X&lt;br /&gt;
|-&lt;br /&gt;
| TotalReads || # of reads that span this position || || || || ||&lt;br /&gt;
|-&lt;br /&gt;
| MappedBases || # of reads marked mapped in the flag || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X || || ||&lt;br /&gt;
|-&lt;br /&gt;
| MappingRate(%) || MappedBases / TotalReads || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X || || ||&lt;br /&gt;
|-&lt;br /&gt;
| MapRate_MQPass(%) || # of reads that have a Mapping Quality &amp;amp;gt;= a minimum Mapping Quality / TotalReads || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X || || ||&lt;br /&gt;
|-&lt;br /&gt;
| ZeroMapQual(%) || # of reads that have a Mapping Quality of 0 / TotalReads || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X || || ||&lt;br /&gt;
|-&lt;br /&gt;
| MapQual&amp;amp;lt;10(%) || # of reads that have a Mapping Quality &amp;amp;lt; 10 / TotalReads || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X || || ||&lt;br /&gt;
|-&lt;br /&gt;
| PairedReads(%) || # of reads marked paired in the flag / TotalReads || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X || || ||&lt;br /&gt;
|-&lt;br /&gt;
| ProperPaired(%) || # of reads marked paired AND proper paired in the flag / TotalReads || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X || || ||&lt;br /&gt;
|-&lt;br /&gt;
| DupRate(%) || # of reads marked duplicate in the flag / TotalReads || || || || ||&lt;br /&gt;
|-&lt;br /&gt;
| QCFailRate(%) || # of reads marked QC failure in the flag / TotalReads || || || || ||&lt;br /&gt;
|-&lt;br /&gt;
| AverageMapQuality || sum of included mapping qualities / AverageMapQualCount || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X || ||&lt;br /&gt;
|-&lt;br /&gt;
| AverageMapQualCount || # of mapping qualities in AverageMapQuality || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X || ||&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
This output does not include a MapQual255 count. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===== Sample Output  =====&lt;br /&gt;
&amp;lt;pre&amp;gt;chrom	chromStart	chromEnd	Depth	Q20Bases	Q20BasesPct(%)	TotalReads	MappedBases	MappingRate(%)	MapRate_MQPass(%)	ZeroMapQual(%)	MapQual&amp;amp;lt;10(%)	PairedReads(%)	ProperPaired(%)	DupRate(%)	QCFailRate(%)	AverageMapQuality	AverageMapQualCount&lt;br /&gt;
1	100	101	2	2	100.000	3	3	100.000	66.667	33.333	66.667	100.000	0.000	0.000	0.000	11.000	3&lt;br /&gt;
1	101	102	2	0	0.000	3	3	100.000	66.667	33.333	66.667	100.000	0.000	0.000	0.000	11.000	3&lt;br /&gt;
1	102	103	0	0	0.000	3	3	100.000	66.667	33.333	66.667	100.000	0.000	0.000	0.000	0.000	0&lt;br /&gt;
1	103	104	0	0	0.000	3	3	100.000	66.667	33.333	66.667	100.000	0.000	0.000	0.000	0.000	0&lt;br /&gt;
1	104	105	2	0	0.000	3	3	100.000	66.667	33.333	66.667	100.000	0.000	0.000	0.000	11.000	3&lt;br /&gt;
1	105	106	2	2	100.000	3	3	100.000	66.667	33.333	66.667	100.000	0.000	0.000	0.000	11.000	3&lt;br /&gt;
1	110	111	0	0	0.000	3	3	100.000	66.667	33.333	66.667	100.000	0.000	0.000	0.000	0.000	0&lt;br /&gt;
1	111	112	2	2	100.000	3	3	100.000	66.667	33.333	66.667	100.000	0.000	0.000	0.000	11.000	3&lt;br /&gt;
1	112	113	2	2	100.000	3	3	100.000	66.667	33.333	66.667	100.000	0.000	0.000	0.000	11.000	3&lt;br /&gt;
1	10012	10013	14	0	0.000	42	33	78.571	52.381	26.190	52.381	85.714	35.714	14.286	14.286	11.000	21&lt;br /&gt;
1	10013	10014	14	10	71.429	39	30	76.923	51.282	25.641	51.282	84.615	38.462	15.385	15.385	11.000	21&lt;br /&gt;
1	10023	10024	0	0	0.000	39	30	76.923	51.282	25.641	51.282	84.615	38.462	15.385	15.385	0.000	0&lt;br /&gt;
1	10024	10025	14	12	85.714	39	30	76.923	51.282	25.641	51.282	84.615	38.462	15.385	15.385	11.000	21&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Count-Based Output Format (&amp;lt;code&amp;gt;--cBaseQC&amp;lt;/code&amp;gt;) ====&lt;br /&gt;
Order/Descriptions: &lt;br /&gt;
{|border=1 &lt;br /&gt;
! Field !! Description !!style=&amp;quot;width: 80px&amp;quot;| Excludes Duplicates, QC Failures !!style=&amp;quot;width: 80px&amp;quot;| Excludes Unmapped !!style=&amp;quot;width: 80px&amp;quot;|  Excludes MapQual = 255 !!style=&amp;quot;width: 80px&amp;quot;| Excludes Below Min MapQual !!style=&amp;quot;width: 80px&amp;quot;| Excludes CIGAR Deletions, Skips&lt;br /&gt;
|-&lt;br /&gt;
| chrom || Chromosome/reference name string from the SAM/BAM&lt;br /&gt;
|-&lt;br /&gt;
| chromStart || 0-based start position&lt;br /&gt;
|-&lt;br /&gt;
| chromEnd || 0-based end position (always 1 greater than start and not included in this region)&lt;br /&gt;
|-&lt;br /&gt;
| TotalReads || # of reads that span this position || || || || ||&lt;br /&gt;
|-&lt;br /&gt;
| Dups || # of reads marked duplicate in the flag || || || || ||&lt;br /&gt;
|-&lt;br /&gt;
| QCFail || # of reads marked QC failure in the flag || || || || ||&lt;br /&gt;
|-&lt;br /&gt;
| Mapped || # of reads marked mapped in the flag || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X || || ||&lt;br /&gt;
|-&lt;br /&gt;
| Paired || # of reads marked paired in the flag || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X || || ||&lt;br /&gt;
|-&lt;br /&gt;
| ProperPaired || # of reads marked paired AND proper paired in the flag || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X || || ||&lt;br /&gt;
|-&lt;br /&gt;
| ZeroMapQual || # of reads that have a Mapping Quality of 0 || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X || || ||&lt;br /&gt;
|-&lt;br /&gt;
| MapQual&amp;amp;lt;10(%) || # of reads that have a Mapping Quality &amp;amp;lt; 10 || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X || || ||&lt;br /&gt;
|-&lt;br /&gt;
| MapQual255 || # of reads that have a Mapping Quality = 255 || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X || || ||&lt;br /&gt;
|-&lt;br /&gt;
| PassMapQual || # of reads that have a Mapping Quality &amp;amp;gt;= a minimum Mapping Quality || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X || || ||&lt;br /&gt;
|-&lt;br /&gt;
| AverageMapQuality || sum of included mapping qualities / AverageMapQualCount || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X || ||&lt;br /&gt;
|-&lt;br /&gt;
| AverageMapQualCount || # of mapping qualities in AverageMapQuality || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X ||&lt;br /&gt;
|- ||&lt;br /&gt;
| Depth || # of reads that are mapped with acceptable Mapping Quality, and are not duplicates or QC failures || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X&lt;br /&gt;
|-&lt;br /&gt;
| Q20Bases || # of bases at this position with a base quality (from the read) of Q20 or higher || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Summary of per Position Statistics (&amp;lt;code&amp;gt;--baseSum&amp;lt;/code&amp;gt;) ====&lt;br /&gt;
Use &amp;lt;code&amp;gt;--baseSum&amp;lt;/code&amp;gt; to print an overall summary of the baseQC for the file to stderr.&lt;br /&gt;
&lt;br /&gt;
This option can be used with or without &amp;lt;code&amp;gt;--pBaseQC&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;--cBaseQC&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The values are tab delimited.  First there is a header line describing the summary.  The next line has the Means, and the last line has the Standard Deviations.&lt;br /&gt;
&lt;br /&gt;
{|border=1 &lt;br /&gt;
! Field !! Description !!style=&amp;quot;width: 80px&amp;quot;| Excludes Duplicates, QC Failures !!style=&amp;quot;width: 80px&amp;quot;| Excludes Unmapped !!style=&amp;quot;width: 80px&amp;quot;|  Excludes MapQual = 255 !!style=&amp;quot;width: 80px&amp;quot;| Excludes Below Min MapQual !!style=&amp;quot;width: 80px&amp;quot;| Excludes CIGAR Deletions, Skips&lt;br /&gt;
|-&lt;br /&gt;
| TotalReads || # of reads that span this position || || || || ||&lt;br /&gt;
|-&lt;br /&gt;
| Dups || # of reads marked duplicate in the flag || || || || ||&lt;br /&gt;
|-&lt;br /&gt;
| QCFail || # of reads marked QC failure in the flag || || || || ||&lt;br /&gt;
|-&lt;br /&gt;
| Mapped || # of reads marked mapped in the flag || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X || || ||&lt;br /&gt;
|-&lt;br /&gt;
| Paired || # of reads marked paired in the flag || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X || || ||&lt;br /&gt;
|-&lt;br /&gt;
| ProperPaired || # of reads marked paired AND proper paired in the flag || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X || || ||&lt;br /&gt;
|-&lt;br /&gt;
| ZeroMapQual || # of reads that have a Mapping Quality of 0 || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X || || ||&lt;br /&gt;
|-&lt;br /&gt;
| MapQual&amp;amp;lt;10(%) || # of reads that have a Mapping Quality &amp;amp;lt; 10 || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X || || ||&lt;br /&gt;
|-&lt;br /&gt;
| MapQual255 || # of reads that have a Mapping Quality = 255 || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X || || ||&lt;br /&gt;
|-&lt;br /&gt;
| PassMapQual || # of reads that have a Mapping Quality &amp;amp;gt;= a minimum Mapping Quality || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X || || ||&lt;br /&gt;
|-&lt;br /&gt;
| AverageMapQuality || sum of included mapping qualities / AverageMapQualCount || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X || ||&lt;br /&gt;
|-&lt;br /&gt;
| AverageMapQualCount || # of mapping qualities in AverageMapQuality || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X ||&lt;br /&gt;
|- ||&lt;br /&gt;
| Depth || # of reads that are mapped with acceptable Mapping Quality, and are not duplicates or QC failures || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X&lt;br /&gt;
|-&lt;br /&gt;
| Q20Bases || # of bases at this position with a base quality (from the read) of Q20 or higher || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===== Sample Output =====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Summary of Pileup Stats (1st Row is Mean, 2nd Row is Standard Deviation)&lt;br /&gt;
TotalReads	Dups	QCFail	Mapped	Paired	ProperPaired	ZeroMapQual	MapQual&amp;lt;10	MapQual255	PassMapQual	AverageMapQuality	AverageMapQualCount	&lt;br /&gt;
Depth	Q20Bases&lt;br /&gt;
14.307692	1.846154	1.846154	8.769231	7.846154	0.923077	2.923077	5.846154	0.000000	2.923077	11.000000	8.769231	2.076923	1.153846&lt;br /&gt;
17.670053	2.882307	2.882307	9.038380	7.603137	1.441153	3.012793	6.025586	0.000000	3.012793	0.000000	9.038380	2.841993	1.993579&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Optional BaseQC Only Parameters ====&lt;br /&gt;
===== Pileup Buffer Size (&amp;lt;code&amp;gt;--bufferSize&amp;lt;/code&amp;gt;) =====&lt;br /&gt;
Use the &amp;lt;code&amp;gt;--bufferSize&amp;lt;/code&amp;gt; option followed by the size of the pileup buffer to use for [[BaseQC (--pBaseQC and --cBaseQC and --baseSum)|baseQC]] stats.&lt;br /&gt;
&lt;br /&gt;
===== Minimum Mapping Quality (&amp;lt;code&amp;gt;--minMapQual&amp;lt;/code&amp;gt;) =====&lt;br /&gt;
Use the &amp;lt;code&amp;gt;--minMapQual&amp;lt;/code&amp;gt; option followed by the minimum mapping quality for filtering reads in the [[BaseQC (--pBaseQC and --cBaseQC and --baseSum)|baseQC]] stats.&lt;br /&gt;
&lt;br /&gt;
===== DBSNP File (&amp;lt;code&amp;gt;--dbsnp&amp;lt;/code&amp;gt;) =====&lt;br /&gt;
Use the &amp;lt;code&amp;gt;--dbsnp&amp;lt;/code&amp;gt; option followed by the name of the dbsnp file to specify the positions to exclude from [[BaseQC (--pBaseQC and --cBaseQC and --baseSum)|baseQC]] analysis.&lt;br /&gt;
&lt;br /&gt;
{{PhoneHomeParameters}}&lt;br /&gt;
&lt;br /&gt;
= Return Value =&lt;br /&gt;
0 on Success, non-0 on failure&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:BamUtil|stats]] [[Category:BAM_Software]] [[Category:Software]]&lt;/div&gt;</summary>
		<author><name>Mktrost</name></author>
	</entry>
	<entry>
		<id>http://genome.sph.umich.edu/w/index.php?title=BamUtil:_stats&amp;diff=14826</id>
		<title>BamUtil: stats</title>
		<link rel="alternate" type="text/html" href="http://genome.sph.umich.edu/w/index.php?title=BamUtil:_stats&amp;diff=14826"/>
		<updated>2017-08-24T19:57:14Z</updated>

		<summary type="html">&lt;p&gt;Mktrost: /* Parameters */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;br&amp;gt; &lt;br /&gt;
&lt;br /&gt;
= Overview of the &amp;lt;code&amp;gt;stats&amp;lt;/code&amp;gt; function of &amp;lt;code&amp;gt;bamUtil&amp;lt;/code&amp;gt;  =&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;stats&amp;lt;/code&amp;gt; option on the [[BamUtil]] executable generates the specified statistics on a SAM/BAM file.&lt;br /&gt;
&lt;br /&gt;
== Troubleshooting ==&lt;br /&gt;
See [[BamUtil:_FAQ#BamUtil:_stats|BamUtil: FAQ -&amp;gt; BamUtil: stats]] for troubleshooting help.&lt;br /&gt;
&lt;br /&gt;
= Usage =&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 ./bam stats --in &amp;lt;inputFile&amp;gt; [--basic] [--qual] [--phred] [--pBaseQC &amp;lt;outputFileName&amp;gt;] [--cBaseQC &amp;lt;outputFileName&amp;gt;] [--maxNumReads &amp;lt;maxNum&amp;gt;][--unmapped] [--bamIndex &amp;lt;bamIndexFile&amp;gt;] [--regionList &amp;lt;regFileName&amp;gt;] [--requiredFlags &amp;lt;integerRequiredFlags&amp;gt;] [--excludeFlags &amp;lt;integerExcludeFlags&amp;gt;] [--noeof] [--params] [--withinRegion] [--baseSum] [--bufferSize &amp;lt;buffSize&amp;gt;] [--minMapQual &amp;lt;minMapQ&amp;gt;] [--dbsnp &amp;lt;dbsnpFile&amp;gt;]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Parameters  =&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
        Required Parameters:&lt;br /&gt;
                --in : the SAM/BAM file to calculate stats for&lt;br /&gt;
        Types of Statistics that can be generated:&lt;br /&gt;
                --basic         : Turn on basic statistic generation&lt;br /&gt;
                --qual          : Generate a count for each quality (displayed as non-phred quality)&lt;br /&gt;
                --phred         : Generate a count for each quality (displayed as phred quality)&lt;br /&gt;
                --pBaseQC       : Write per base statistics as Percentages to the specified file. (use - for stdout)&lt;br /&gt;
                                  pBaseQC &amp;amp; cBaseQC cannot both be specified.&lt;br /&gt;
                --cBaseQC       : Write per base statistics as Counts to the specified file. (use - for stdout)&lt;br /&gt;
                                  pBaseQC &amp;amp; cBaseQC cannot both be specified.&lt;br /&gt;
        Optional Parameters:&lt;br /&gt;
                --maxNumReads   : Maximum number of reads to process&lt;br /&gt;
                                  Defaults to -1 to indicate all reads.&lt;br /&gt;
                --unmapped      : Only process unmapped reads (requires a bamIndex file)&lt;br /&gt;
                --bamIndex      : The path/name of the bam index file&lt;br /&gt;
                                  (if required and not specified, uses the --in value + &amp;quot;.bai&amp;quot;)&lt;br /&gt;
                --regionList    : File containing the regions to be processed chr&amp;lt;tab&amp;gt;start_pos&amp;lt;tab&amp;gt;end_pos.&lt;br /&gt;
                                  Positions are 0 based and the end_pos is not included in the region.&lt;br /&gt;
                                  Uses bamIndex.&lt;br /&gt;
                --excludeFlags  : Skip any records with any of the specified flags set&lt;br /&gt;
                                  (specify an integer representation of the flags)&lt;br /&gt;
                --requiredFlags : Only process records with all of the specified flags set&lt;br /&gt;
                                  (specify an integer representation of the flags)&lt;br /&gt;
                --noeof         : Do not expect an EOF block on a bam file.&lt;br /&gt;
                --params        : Print the parameter settings.&lt;br /&gt;
        Optional phred/qual Only Parameters:&lt;br /&gt;
                --withinRegion  : Only count qualities if they fall within regions specified.&lt;br /&gt;
                                  Only applicable if regionList is also specified.&lt;br /&gt;
        Optional BaseQC Only Parameters:&lt;br /&gt;
                --baseSum       : Print an overall summary of the baseQC for the file to stderr.&lt;br /&gt;
                --bufferSize    : Size of the pileup buffer for calculating the BaseQC parameters.&lt;br /&gt;
                                  Default: 1024&lt;br /&gt;
                --minMapQual    : The minimum mapping quality for filtering reads in the baseQC stats.&lt;br /&gt;
                --dbsnp         : The dbSnp file of positions to exclude from baseQC analysis.&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
{{PhoneHomeParamDesc}}&lt;br /&gt;
&lt;br /&gt;
== Required Parameters ==&lt;br /&gt;
&lt;br /&gt;
{{inBAMInputFile}}&lt;br /&gt;
&lt;br /&gt;
== Optional Parameters ==&lt;br /&gt;
===  Maximum number of reads to process(&amp;lt;code&amp;gt;--maxNumReads&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
Use &amp;lt;code&amp;gt;--maxNumReads&amp;lt;/code&amp;gt; followed by a number to indicate the maximum number of reads to process before exiting.  By default, it is set to -1 to indicate all reads should be processed.&lt;br /&gt;
&lt;br /&gt;
=== Only Process Unmapped Reads (&amp;lt;code&amp;gt;--unmapped&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
Use &amp;lt;code&amp;gt;--unmapped&amp;lt;/code&amp;gt; to process only unmapped reads.&lt;br /&gt;
&lt;br /&gt;
This parameter requires [[#Bam Index File (--bamIndex)|&amp;lt;code&amp;gt;--bamIndex&amp;lt;/code&amp;gt;]].&lt;br /&gt;
&lt;br /&gt;
{{BamIndex}}&lt;br /&gt;
&lt;br /&gt;
=== Only Process Certain Regions (&amp;lt;code&amp;gt;--regionList&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
Use &amp;lt;code&amp;gt;--regionList&amp;lt;/code&amp;gt; followed by the filename to process only the regions specified in the file.&lt;br /&gt;
&lt;br /&gt;
The positions in the file are specified one per line with the following format: &amp;lt;nowiki&amp;gt;chr&amp;lt;tab&amp;gt;start_pos&amp;lt;tab&amp;gt;end_pos.&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Positions are 0 based and the end_pos is not included in the region.&lt;br /&gt;
&lt;br /&gt;
This parameter requires [[#Bam Index File (--bamIndex)|&amp;lt;code&amp;gt;--bamIndex&amp;lt;/code&amp;gt;]].&lt;br /&gt;
&lt;br /&gt;
=== Exclude Flags (&amp;lt;code&amp;gt;--excludeFlags&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
Use &amp;lt;code&amp;gt;--excludeFlags&amp;lt;/code&amp;gt; followed by an integer representation of the flags to only process reads with any of the specified flags set.&lt;br /&gt;
&lt;br /&gt;
=== Required Flags (&amp;lt;code&amp;gt;--requiredFlags&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
Use &amp;lt;code&amp;gt;--requiredFlags&amp;lt;/code&amp;gt; followed by an integer representation of the flags to only process records with all of the specified flags set.&lt;br /&gt;
&lt;br /&gt;
== Types of Statistics ==&lt;br /&gt;
&lt;br /&gt;
=== Basic (&amp;lt;code&amp;gt;--basic&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
Prints summary statistics for the file: &lt;br /&gt;
&lt;br /&gt;
*TotalReads - # of reads that are in the file &lt;br /&gt;
*MappedReads - # of reads marked mapped in the flag &lt;br /&gt;
*PairedReads - # of reads marked paired in the flag &lt;br /&gt;
*ProperPair - # of reads marked paired AND proper paired in the flag &lt;br /&gt;
*DuplicateReads - # of reads marked duplicate in the flag &lt;br /&gt;
*QCFailureReads - # of reads marked QC failure in the flag &lt;br /&gt;
*MappingRate(%) - # of reads marked mapped in the flag / TotalReads &lt;br /&gt;
*PairedReads(%) - # of reads marked paired in the flag / TotalReads &lt;br /&gt;
*ProperPair(%) - # of reads marked paired AND proper paired in the flag / TotalReads &lt;br /&gt;
*DupRate(%) - # of reads marked duplicate in the flag / TotalReads &lt;br /&gt;
*QCFailRate(%) - # of reads marked QC failure in the flag / TotalReads &lt;br /&gt;
*TotalBases - # of bases in all reads &lt;br /&gt;
*BasesInMappedReads - # of bases in reads marked mapped in the flag&lt;br /&gt;
&lt;br /&gt;
=== Qual/Phred (&amp;lt;code&amp;gt;--phred&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;--qual&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
Prints a count of the number of times each quality value appears in the file to stderr. &lt;br /&gt;
&lt;br /&gt;
*&amp;lt;code&amp;gt;phred&amp;lt;/code&amp;gt; Displays Quality as phred integers [0-93] &lt;br /&gt;
*&amp;lt;code&amp;gt;qual&amp;lt;/code&amp;gt; Displays Quality as non-phred integers (phred + 33) [33-126]&lt;br /&gt;
&lt;br /&gt;
By default, these counts include all qualities in the BAM file.&lt;br /&gt;
&lt;br /&gt;
To exclude unmapped reads and soft clips, use --excludeFlags 4.&lt;br /&gt;
&lt;br /&gt;
To only include records that overlap a set of regions, use --regionList and specify a bed file with the regions.  If a read overlaps the region, all qualities will be counted even if those bases do not fall in the region.  If you only want to count qualities that fall within the region, also specify --withinRegion.  Without excluding unmapped reads, it will include soft clips that overlap the region.&lt;br /&gt;
&lt;br /&gt;
==== Optional Phred/Qual Only Parameters ====&lt;br /&gt;
===== Within Region (&amp;lt;code&amp;gt;--withinRegion&amp;lt;/code&amp;gt;) =====&lt;br /&gt;
Use &amp;lt;code&amp;gt;--withinRegion&amp;lt;/code&amp;gt; with [[#Qual/Phred (--phred and --qual)|&amp;lt;code&amp;gt;--phred&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;--qual&amp;lt;/code&amp;gt;]] options to only count qualities if they fall within the regions specified using [[#Only Process Certain Regions (--regionList)|&amp;lt;code&amp;gt;--regionList&amp;lt;/code&amp;gt;]] (only applicable if [[#Only Process Certain Regions (--regionList)|&amp;lt;code&amp;gt;--regionList&amp;lt;/code&amp;gt;]]  is also specified).&lt;br /&gt;
&lt;br /&gt;
=== BaseQC (&amp;lt;code&amp;gt;--pBaseQC&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;--cBaseQC&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;--baseSum&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;pBaseQC&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;cBaseQC&amp;lt;/code&amp;gt; options generate per base statistics.  Only one of these two options can be specified.  They write statistics generated for each position to the file specified after the option.  They use the same logic for calculating statistics, but &amp;lt;code&amp;gt;pBaseQC&amp;lt;/code&amp;gt; writes the statistics as percentages, and &amp;lt;code&amp;gt;cBaseQC&amp;lt;/code&amp;gt; writes them as counts.  The order of the statistics are also different.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;baseSum&amp;lt;/code&amp;gt; option can be used with either &amp;lt;code&amp;gt;pBaseQC&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;cBaseQC&amp;lt;/code&amp;gt; or on its own.  &amp;lt;code&amp;gt;baseSum&amp;lt;/code&amp;gt; generates a summary of the per position statistics and writes it to stderr.  It calculates the per position base statistics even if they will not be written anywhere (neither &amp;lt;code&amp;gt;pBaseQC&amp;lt;/code&amp;gt; nor &amp;lt;code&amp;gt;cBaseQC&amp;lt;/code&amp;gt; are specified).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
All three options use the same logic for calculating the statistics:&lt;br /&gt;
* A read spans a position if the read starts at or before the position, ends at or after the position and the position is not a clip.  CIGAR operations allowed for the position are M/X/=/D/N.  If the CIGAR is &#039;*&#039;, only numbers for the specified reference position are incremented.&lt;br /&gt;
*Currently there is no special logic to exclude positions/reads where the reference base is &#039;N&#039; or the read base is &#039;N&#039;. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt; &lt;br /&gt;
&lt;br /&gt;
==== Percentage-Based Output Format (&amp;lt;code&amp;gt;--pBaseQC&amp;lt;/code&amp;gt;) ====&lt;br /&gt;
&lt;br /&gt;
Order/Descriptions: &lt;br /&gt;
&lt;br /&gt;
{|border=1 &lt;br /&gt;
! Field !! Description !!style=&amp;quot;width: 80px&amp;quot;| Excludes Duplicates, QC Failures !!style=&amp;quot;width: 80px&amp;quot;| Excludes Unmapped !!style=&amp;quot;width: 80px&amp;quot;|  Excludes MapQual = 255 !!style=&amp;quot;width: 80px&amp;quot;| Excludes Below Min MapQual !!style=&amp;quot;width: 80px&amp;quot;| Excludes CIGAR Deletions, Skips&lt;br /&gt;
|-&lt;br /&gt;
| chrom || Chromosome/reference name string from the SAM/BAM&lt;br /&gt;
|-&lt;br /&gt;
| chromStart || 0-based start position&lt;br /&gt;
|-&lt;br /&gt;
| chromEnd || 0-based end position (always 1 greater than start and not included in this region)&lt;br /&gt;
|-&lt;br /&gt;
| Depth || # of reads that are mapped with acceptable Mapping Quality, and are not duplicates or QC failures || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X&lt;br /&gt;
|-&lt;br /&gt;
| Q20Bases || # of bases at this position with a base quality (from the read) of Q20 or higher || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X&lt;br /&gt;
|-&lt;br /&gt;
| Q20BasesPct(%) || Q20Bases / Depth || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X&lt;br /&gt;
|-&lt;br /&gt;
| TotalReads || # of reads that span this position || || || || ||&lt;br /&gt;
|-&lt;br /&gt;
| MappedBases || # of reads marked mapped in the flag || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X || || ||&lt;br /&gt;
|-&lt;br /&gt;
| MappingRate(%) || MappedBases / TotalReads || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X || || ||&lt;br /&gt;
|-&lt;br /&gt;
| MapRate_MQPass(%) || # of reads that have a Mapping Quality &amp;amp;gt;= a minimum Mapping Quality / TotalReads || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X || || ||&lt;br /&gt;
|-&lt;br /&gt;
| ZeroMapQual(%) || # of reads that have a Mapping Quality of 0 / TotalReads || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X || || ||&lt;br /&gt;
|-&lt;br /&gt;
| MapQual&amp;amp;lt;10(%) || # of reads that have a Mapping Quality &amp;amp;lt; 10 / TotalReads || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X || || ||&lt;br /&gt;
|-&lt;br /&gt;
| PairedReads(%) || # of reads marked paired in the flag / TotalReads || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X || || ||&lt;br /&gt;
|-&lt;br /&gt;
| ProperPaired(%) || # of reads marked paired AND proper paired in the flag / TotalReads || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X || || ||&lt;br /&gt;
|-&lt;br /&gt;
| DupRate(%) || # of reads marked duplicate in the flag / TotalReads || || || || ||&lt;br /&gt;
|-&lt;br /&gt;
| QCFailRate(%) || # of reads marked QC failure in the flag / TotalReads || || || || ||&lt;br /&gt;
|-&lt;br /&gt;
| AverageMapQuality || sum of included mapping qualities / AverageMapQualCount || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X || ||&lt;br /&gt;
|-&lt;br /&gt;
| AverageMapQualCount || # of mapping qualities in AverageMapQuality || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X || ||&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
This output does not include a MapQual255 count. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===== Sample Output  =====&lt;br /&gt;
&amp;lt;pre&amp;gt;chrom	chromStart	chromEnd	Depth	Q20Bases	Q20BasesPct(%)	TotalReads	MappedBases	MappingRate(%)	MapRate_MQPass(%)	ZeroMapQual(%)	MapQual&amp;amp;lt;10(%)	PairedReads(%)	ProperPaired(%)	DupRate(%)	QCFailRate(%)	AverageMapQuality	AverageMapQualCount&lt;br /&gt;
1	100	101	2	2	100.000	3	3	100.000	66.667	33.333	66.667	100.000	0.000	0.000	0.000	11.000	3&lt;br /&gt;
1	101	102	2	0	0.000	3	3	100.000	66.667	33.333	66.667	100.000	0.000	0.000	0.000	11.000	3&lt;br /&gt;
1	102	103	0	0	0.000	3	3	100.000	66.667	33.333	66.667	100.000	0.000	0.000	0.000	0.000	0&lt;br /&gt;
1	103	104	0	0	0.000	3	3	100.000	66.667	33.333	66.667	100.000	0.000	0.000	0.000	0.000	0&lt;br /&gt;
1	104	105	2	0	0.000	3	3	100.000	66.667	33.333	66.667	100.000	0.000	0.000	0.000	11.000	3&lt;br /&gt;
1	105	106	2	2	100.000	3	3	100.000	66.667	33.333	66.667	100.000	0.000	0.000	0.000	11.000	3&lt;br /&gt;
1	110	111	0	0	0.000	3	3	100.000	66.667	33.333	66.667	100.000	0.000	0.000	0.000	0.000	0&lt;br /&gt;
1	111	112	2	2	100.000	3	3	100.000	66.667	33.333	66.667	100.000	0.000	0.000	0.000	11.000	3&lt;br /&gt;
1	112	113	2	2	100.000	3	3	100.000	66.667	33.333	66.667	100.000	0.000	0.000	0.000	11.000	3&lt;br /&gt;
1	10012	10013	14	0	0.000	42	33	78.571	52.381	26.190	52.381	85.714	35.714	14.286	14.286	11.000	21&lt;br /&gt;
1	10013	10014	14	10	71.429	39	30	76.923	51.282	25.641	51.282	84.615	38.462	15.385	15.385	11.000	21&lt;br /&gt;
1	10023	10024	0	0	0.000	39	30	76.923	51.282	25.641	51.282	84.615	38.462	15.385	15.385	0.000	0&lt;br /&gt;
1	10024	10025	14	12	85.714	39	30	76.923	51.282	25.641	51.282	84.615	38.462	15.385	15.385	11.000	21&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Count-Based Output Format (&amp;lt;code&amp;gt;--cBaseQC&amp;lt;/code&amp;gt;) ====&lt;br /&gt;
Order/Descriptions: &lt;br /&gt;
{|border=1 &lt;br /&gt;
! Field !! Description !!style=&amp;quot;width: 80px&amp;quot;| Excludes Duplicates, QC Failures !!style=&amp;quot;width: 80px&amp;quot;| Excludes Unmapped !!style=&amp;quot;width: 80px&amp;quot;|  Excludes MapQual = 255 !!style=&amp;quot;width: 80px&amp;quot;| Excludes Below Min MapQual !!style=&amp;quot;width: 80px&amp;quot;| Excludes CIGAR Deletions, Skips&lt;br /&gt;
|-&lt;br /&gt;
| chrom || Chromosome/reference name string from the SAM/BAM&lt;br /&gt;
|-&lt;br /&gt;
| chromStart || 0-based start position&lt;br /&gt;
|-&lt;br /&gt;
| chromEnd || 0-based end position (always 1 greater than start and not included in this region)&lt;br /&gt;
|-&lt;br /&gt;
| TotalReads || # of reads that span this position || || || || ||&lt;br /&gt;
|-&lt;br /&gt;
| Dups || # of reads marked duplicate in the flag || || || || ||&lt;br /&gt;
|-&lt;br /&gt;
| QCFail || # of reads marked QC failure in the flag || || || || ||&lt;br /&gt;
|-&lt;br /&gt;
| Mapped || # of reads marked mapped in the flag || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X || || ||&lt;br /&gt;
|-&lt;br /&gt;
| Paired || # of reads marked paired in the flag || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X || || ||&lt;br /&gt;
|-&lt;br /&gt;
| ProperPaired || # of reads marked paired AND proper paired in the flag || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X || || ||&lt;br /&gt;
|-&lt;br /&gt;
| ZeroMapQual || # of reads that have a Mapping Quality of 0 || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X || || ||&lt;br /&gt;
|-&lt;br /&gt;
| MapQual&amp;amp;lt;10(%) || # of reads that have a Mapping Quality &amp;amp;lt; 10 || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X || || ||&lt;br /&gt;
|-&lt;br /&gt;
| MapQual255 || # of reads that have a Mapping Quality = 255 || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X || || ||&lt;br /&gt;
|-&lt;br /&gt;
| PassMapQual || # of reads that have a Mapping Quality &amp;amp;gt;= a minimum Mapping Quality || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X || || ||&lt;br /&gt;
|-&lt;br /&gt;
| AverageMapQuality || sum of included mapping qualities / AverageMapQualCount || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X || ||&lt;br /&gt;
|-&lt;br /&gt;
| AverageMapQualCount || # of mapping qualities in AverageMapQuality || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X ||&lt;br /&gt;
|- ||&lt;br /&gt;
| Depth || # of reads that are mapped with acceptable Mapping Quality, and are not duplicates or QC failures || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X&lt;br /&gt;
|-&lt;br /&gt;
| Q20Bases || # of bases at this position with a base quality (from the read) of Q20 or higher || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Summary of per Position Statistics (&amp;lt;code&amp;gt;--baseSum&amp;lt;/code&amp;gt;) ====&lt;br /&gt;
Use &amp;lt;code&amp;gt;--baseSum&amp;lt;/code&amp;gt; to print an overall summary of the baseQC for the file to stderr.&lt;br /&gt;
&lt;br /&gt;
This option can be used with or without &amp;lt;code&amp;gt;--pBaseQC&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;--cBaseQC&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The values are tab delimited.  First there is a header line describing the summary.  The next line has the Means, and the last line has the Standard Deviations.&lt;br /&gt;
&lt;br /&gt;
{|border=1 &lt;br /&gt;
! Field !! Description !!style=&amp;quot;width: 80px&amp;quot;| Excludes Duplicates, QC Failures !!style=&amp;quot;width: 80px&amp;quot;| Excludes Unmapped !!style=&amp;quot;width: 80px&amp;quot;|  Excludes MapQual = 255 !!style=&amp;quot;width: 80px&amp;quot;| Excludes Below Min MapQual !!style=&amp;quot;width: 80px&amp;quot;| Excludes CIGAR Deletions, Skips&lt;br /&gt;
|-&lt;br /&gt;
| TotalReads || # of reads that span this position || || || || ||&lt;br /&gt;
|-&lt;br /&gt;
| Dups || # of reads marked duplicate in the flag || || || || ||&lt;br /&gt;
|-&lt;br /&gt;
| QCFail || # of reads marked QC failure in the flag || || || || ||&lt;br /&gt;
|-&lt;br /&gt;
| Mapped || # of reads marked mapped in the flag || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X || || ||&lt;br /&gt;
|-&lt;br /&gt;
| Paired || # of reads marked paired in the flag || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X || || ||&lt;br /&gt;
|-&lt;br /&gt;
| ProperPaired || # of reads marked paired AND proper paired in the flag || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X || || ||&lt;br /&gt;
|-&lt;br /&gt;
| ZeroMapQual || # of reads that have a Mapping Quality of 0 || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X || || ||&lt;br /&gt;
|-&lt;br /&gt;
| MapQual&amp;amp;lt;10(%) || # of reads that have a Mapping Quality &amp;amp;lt; 10 || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X || || ||&lt;br /&gt;
|-&lt;br /&gt;
| MapQual255 || # of reads that have a Mapping Quality = 255 || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X || || ||&lt;br /&gt;
|-&lt;br /&gt;
| PassMapQual || # of reads that have a Mapping Quality &amp;amp;gt;= a minimum Mapping Quality || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X || || ||&lt;br /&gt;
|-&lt;br /&gt;
| AverageMapQuality || sum of included mapping qualities / AverageMapQualCount || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X || ||&lt;br /&gt;
|-&lt;br /&gt;
| AverageMapQualCount || # of mapping qualities in AverageMapQuality || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X ||&lt;br /&gt;
|- ||&lt;br /&gt;
| Depth || # of reads that are mapped with acceptable Mapping Quality, and are not duplicates or QC failures || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X&lt;br /&gt;
|-&lt;br /&gt;
| Q20Bases || # of bases at this position with a base quality (from the read) of Q20 or higher || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X || align=&amp;quot;center&amp;quot;|X&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===== Sample Output =====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Summary of Pileup Stats (1st Row is Mean, 2nd Row is Standard Deviation)&lt;br /&gt;
TotalReads	Dups	QCFail	Mapped	Paired	ProperPaired	ZeroMapQual	MapQual&amp;lt;10	MapQual255	PassMapQual	AverageMapQuality	AverageMapQualCount	&lt;br /&gt;
Depth	Q20Bases&lt;br /&gt;
14.307692	1.846154	1.846154	8.769231	7.846154	0.923077	2.923077	5.846154	0.000000	2.923077	11.000000	8.769231	2.076923	1.153846&lt;br /&gt;
17.670053	2.882307	2.882307	9.038380	7.603137	1.441153	3.012793	6.025586	0.000000	3.012793	0.000000	9.038380	2.841993	1.993579&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Optional BaseQC Only Parameters ====&lt;br /&gt;
===== Pileup Buffer Size (&amp;lt;code&amp;gt;--bufferSize&amp;lt;/code&amp;gt;) =====&lt;br /&gt;
Use the &amp;lt;code&amp;gt;--bufferSize&amp;lt;/code&amp;gt; option followed by the size of the pileup buffer to use for [[BaseQC (--pBaseQC and --cBaseQC and --baseSum)|baseQC]] stats.&lt;br /&gt;
&lt;br /&gt;
===== Minimum Mapping Quality (&amp;lt;code&amp;gt;--minMapQual&amp;lt;/code&amp;gt;) =====&lt;br /&gt;
Use the &amp;lt;code&amp;gt;--minMapQual&amp;lt;/code&amp;gt; option followed by the minimum mapping quality for filtering reads in the [[BaseQC (--pBaseQC and --cBaseQC and --baseSum)|baseQC]] stats.&lt;br /&gt;
&lt;br /&gt;
===== DBSNP File (&amp;lt;code&amp;gt;--dbsnp&amp;lt;/code&amp;gt;) =====&lt;br /&gt;
Use the &amp;lt;code&amp;gt;--dbsnp&amp;lt;/code&amp;gt; option followed by the name of the dbsnp file to specify the positions to exclude from [[BaseQC (--pBaseQC and --cBaseQC and --baseSum)|baseQC]] analysis.&lt;br /&gt;
&lt;br /&gt;
{{PhoneHomeParameters}}&lt;br /&gt;
&lt;br /&gt;
= Return Value =&lt;br /&gt;
0 on Success, non-0 on failure&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:BamUtil|stats]] [[Category:BAM_Software]] [[Category:Software]]&lt;/div&gt;</summary>
		<author><name>Mktrost</name></author>
	</entry>
	<entry>
		<id>http://genome.sph.umich.edu/w/index.php?title=VerifyBamID&amp;diff=14718</id>
		<title>VerifyBamID</title>
		<link rel="alternate" type="text/html" href="http://genome.sph.umich.edu/w/index.php?title=VerifyBamID&amp;diff=14718"/>
		<updated>2017-06-14T08:20:37Z</updated>

		<summary type="html">&lt;p&gt;Mktrost: /* Column information in the output files */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Software|VerifyBamID]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;verifyBamID&#039;&#039;&#039; is a software that verifies whether the reads in particular file match previously known genotypes for an individual (or group of individuals), and checks whether the reads are contaminated as a mixture of two samples. &#039;&#039;&#039;verifyBamID&#039;&#039;&#039; can detect sample contamination and swaps when external genotypes are available. When external genotypes are not available, &#039;&#039;&#039;verifyBamID&#039;&#039;&#039; still robustly detects sample swaps.&lt;br /&gt;
&lt;br /&gt;
== Download verifyBamID  ==&lt;br /&gt;
&lt;br /&gt;
To get a copy of verifyBamId, go to: https://github.com/statgen/verifyBamID/releases&lt;br /&gt;
&lt;br /&gt;
Select the latest release and download in one of 3 ways:&lt;br /&gt;
# Binary expected to run in Ubuntu x64 platform. In other platforms, please download the source distribution and build it.&lt;br /&gt;
#* verifyBamID.#.#.#.gz&lt;br /&gt;
#* You will need to run &amp;quot;gunzip&amp;quot; on the .gz file&lt;br /&gt;
# Souce Code including libStatGen (uses a fixed version of libStatGen)&lt;br /&gt;
#* verifyBamIDLibStatGen.#.#.#.tgz&lt;br /&gt;
#* Run &amp;quot;tar xvf&amp;quot; on this file.  Cd into the resulting directory &amp;amp; type make.&lt;br /&gt;
# Source Code without libStatGen (allows alternative/newer versions of libStatGen)&lt;br /&gt;
#* Source code (tar.gz) or Source code (zip)&lt;br /&gt;
#* You will need to download libStatGen separately if you do not already have it.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To get a copy of older releases go to the [http://csg.sph.umich.edu//kang/verifyBamID/download VerifyBamID Download] download page.&lt;br /&gt;
&lt;br /&gt;
== Join in verifyBamID mailing list ==&lt;br /&gt;
&lt;br /&gt;
Please join in the [http://groups.google.com/group/verifybamid VerifyBamID Google Group] to ask / discuss / comment about verifyBamID.&lt;br /&gt;
&lt;br /&gt;
== What&#039;s new ==&lt;br /&gt;
&lt;br /&gt;
(2014/02/13)&lt;br /&gt;
* Put verifyBamID in github.&lt;br /&gt;
* Added PhoneHome/Version Checking to VerifyBamID&lt;br /&gt;
&lt;br /&gt;
(2012/06/20) &lt;br /&gt;
* Fixed a bug of incorrect estimate of contamination when --chip-full option was used (Thanks to Richard Smith)&lt;br /&gt;
* Fixed a bug of incorrect per-readgroup output in --chip-* parameter&lt;br /&gt;
&lt;br /&gt;
(2012/05/24) &lt;br /&gt;
* Fixed a bug of incorrect per-readgroup output (Thanks to Matthew Flickinger)&lt;br /&gt;
* &#039;&#039;&#039;(IMPORTANT)&#039;&#039;&#039; Add an option to remove either side of overlapping fragment. This option is turned on by default, and can be turned off usig --ignoreOverlapPair. If your sequence data has very short insert size, this update may increase the sensitivity of estimated contamination.&lt;br /&gt;
* Changes in the directory structure and Makefile&lt;br /&gt;
&lt;br /&gt;
(2012/05/18) The new release of verifyBamID have undergone major change since the last version (as of 2011 April). Here are the highlights&lt;br /&gt;
* The genotype / allele frequency file is now based on VCF format rather than PLINK format.&lt;br /&gt;
* The reference sequence information is no longer required&lt;br /&gt;
* Uses Brent&#039;s method for precise estimation of contamination parameters&lt;br /&gt;
* Generate the depth distribution statistics.&lt;br /&gt;
* Estimated reference-bias parameters (useful mostly for ABI SOLiD sequence data)&lt;br /&gt;
&lt;br /&gt;
== Build verifyBamID  ==&lt;br /&gt;
&lt;br /&gt;
The binary download of verifyBamID is available. You may use that version in Ubuntu 64-bit platform. &lt;br /&gt;
&lt;br /&gt;
If you download the source that includes libStatGen:&lt;br /&gt;
 tar xvf verifyBamIDLibStatGen.#.#.#.tgz&lt;br /&gt;
 cd verifyBamID_#.#.#&lt;br /&gt;
 make&lt;br /&gt;
 Executable: verifyBamID/bin/verifyBamID&lt;br /&gt;
&lt;br /&gt;
If you download the source without libStatGen:&lt;br /&gt;
 tar xvf verifyBamID-#.#.#.tar.gz&lt;br /&gt;
 cd verifyBamID-1.1.0&lt;br /&gt;
 make cloneLib (if ../libStatGen does not exist)&lt;br /&gt;
 make&lt;br /&gt;
 Executable: ./bin/verifyBamID&lt;br /&gt;
&lt;br /&gt;
Note that &#039;&#039;&#039;make cloneLib&#039;&#039;&#039; command will create a directory ../libStatGen under your verifyBamID directory, and &#039;&#039;&#039;make&#039;&#039;&#039; will create binary of verifyBamID under verifyBamID/bin/&lt;br /&gt;
&lt;br /&gt;
If you have a different version of libStatGen at that path, then skip the cloneLib step.  If the libStatGen you want to use is at a different location then update verifyBamID&#039;s Makefile.inc.  Replace: LIB_PATH_VERIFY_BAM_ID ?= $(LIB_PATH_GENERAL) with&lt;br /&gt;
 LIB_PATH_VERIFY_BAM_ID = /path/to/libStatGen&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
verifyBamID is designed to be reasonably portable. &lt;br /&gt;
&lt;br /&gt;
However, since development occurs only on Ubuntu (9.10-13.10) x86 and x64 platforms, and later, there are likely other portability issues. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Basic Usage ==&lt;br /&gt;
&lt;br /&gt;
A key step in any genetic analysis is to verify whether data being generated matches expectations. &#039;&#039;verifyBamID&#039;&#039; checks whether reads in a BAM file match previous genotypes for a specific sample. In addition, it detects possible sample mixture from population allele frequency only, which can be particularly useful when the genotype data is not available.&lt;br /&gt;
&lt;br /&gt;
Using a mathematical model that relates observed sequence reads to an hypothetical true genotype, &#039;&#039;verifyBamID&#039;&#039; tries to decide whether sequence reads match a particular individual or are more likely to be contaminated (including a small proportion of foreign DNA), derived from a closely related individual, or derived from a completely different individual.&lt;br /&gt;
&lt;br /&gt;
== Basic Usage Example ==&lt;br /&gt;
&lt;br /&gt;
Here is a typical command line:&lt;br /&gt;
&lt;br /&gt;
 verifyBamID --vcf [input.vcf] --bam [input.bam] --out [output.prefix] --verbose --ignoreRG&lt;br /&gt;
 &lt;br /&gt;
 where&lt;br /&gt;
 [input.bam] is a BAM (Binary Alignment Map) file of a sequence reads&lt;br /&gt;
 [input.vcf] is input VCF file containing individual genotypes or AF or AC/AN fields in the INFO field. gzipped VCF is also allowed.&lt;br /&gt;
 [outPrefix] is output prefix of output files - [outPrefix].{selfRG,selfSM,bestRG,bestSM,depthRG,depthSM} will be created.&lt;br /&gt;
&lt;br /&gt;
More detailed description of command line input is below&lt;br /&gt;
&lt;br /&gt;
== Preparing input files ==&lt;br /&gt;
&lt;br /&gt;
verifyBamID requires two input files - VCF file containing external genotypes or allele frequency information, and the BAM file.&lt;br /&gt;
&lt;br /&gt;
=== VCF input genotype file ===&lt;br /&gt;
&lt;br /&gt;
The input VCF file contains (1) external genotype information and/or (2) allele frequency information as AF entry or AC/AN entries in the INFO field. (See [http://www.1000genomes.org/wiki/Analysis/Variant%20Call%20Format/vcf-variant-call-format-version-41 | VCF specification] for further details). If neither information is provided, verifyBamID will not work properly.&lt;br /&gt;
&lt;br /&gt;
If external genotype information is provided, sequence+array method will identify contamination and sample swaps by comparing the concordance between the external genotypes and the sequence reads. Additionally, sequence-only method will provide additional contamination estimates by modeling the sequence reads as mixture of two unknown samples based on the allele frequency information in the VCF file.&lt;br /&gt;
&lt;br /&gt;
Input VCF file needs to meet several additional contraints need to meet in order to properly run verifyBamID.&lt;br /&gt;
* The VCF is assumed to be well-formed. For example, verifyBamID does not check whether REF allele actually matches with reference sequence.  &lt;br /&gt;
* The VCF should only contain SNPs. Current version of verifyBamID does not accept INDELs, MNPs, Structural Variations, or other complex variants.&lt;br /&gt;
* The individual IDs in the VCF file, must be identical with the individual identifier in the BAM file. Otherwise, --smID option can override the sample ID information of the BAM file to the ID that matches to the individual IDs in the VCF file.&lt;br /&gt;
* IMPORTANT : For targeted sequencing data, it is important to subselect the markers to only include on-target markers in the genotype file. Off-target markers are not likely to have multiple non-duplicated reads at the marker position, and it may create artifacts in the analysis due to overlapping fragments.&lt;br /&gt;
* Currently, verifyBamID takes only autosomal chromosomes as input VCF.&lt;br /&gt;
&lt;br /&gt;
An example input VCF file (without external genotype) is provided below. Note that AC and AC entries exists in the INFO field for the allele frequency information.&lt;br /&gt;
&lt;br /&gt;
 #CHROM	POS	ID	REF	ALT	QUAL	FILTER	INFO&lt;br /&gt;
 20	61651	SNP20-9651	C	A	.	PASS	CR=99.86851;GentrainScore=0.7055;HW=0.077647716;AN=2180;AC=11&lt;br /&gt;
 20	63231	SNP20-11231	T	G	.	PASS	CR=99.93036;GentrainScore=0.7837;HW=0.035481825;AN=2182;AC=275&lt;br /&gt;
 20	63244	rs6139074	A	C	.	PASS	CR=98.893394;GentrainScore=0.8001;HW=7.327299E-7;AN=2162;AC=501&lt;br /&gt;
 20	63799	rs1418258	C	T	.	PASS	CR=99.75217;GentrainScore=0.8170;HW=0.6653377;AN=2182;AC=881&lt;br /&gt;
&lt;br /&gt;
=== Input BAM file ===&lt;br /&gt;
&lt;br /&gt;
verifyBamID requires a sorted, indexed, base quality recalibrated, and duplication-marked BAM file. It also requires to contain &amp;quot;@RG&amp;quot; header lines to annotation different readGroups (sequencing runs and lanes). The SM tag in the &amp;quot;@RG&amp;quot; header should match with one of the genotyped sample. Otherwise, verifyBamID may not be able to test whether the sequenced sample matches with genotyped sample, but will try to detect sample mixture from allele frequency, and will try to detect the best-matching sample among the genotyped sample.&lt;br /&gt;
&lt;br /&gt;
== What the default option does ==&lt;br /&gt;
&lt;br /&gt;
The default option of &#039;&#039;&#039;verifyBamID&#039;&#039;&#039; is the recommended setting for the most sequencing studies to provide a rapid and informative response. The default option provides the following features:&lt;br /&gt;
* --free-mix is turned on for estimating contamination using sequence-only method&lt;br /&gt;
* --chip-mix is turned on for estimating contamination or swap using sequence+array method, if the external genotype file is provided in the VCF&lt;br /&gt;
* --self is turnd on : The default option does not try to compare the sequence reads to identify the best matching individual (which is possible with --best option). It only compares with the external genotypes from the same individual to the sequenced individual.&lt;br /&gt;
* --maxDepth 20 is used without --precise option : The default option is intended for whole genome low coverage sequencing. For the targeted exome sequencing, --maxDepth 1000 and --precise is recommended.&lt;br /&gt;
* --ignoreRG is not a default option, but a recommended option, when you want to check the contamination for the entire BAM rather than examining each read group separately. This option will increase the computational efficiency especially in the case whether the sequence reads are multiplexed across many sequencing runs.&lt;br /&gt;
&lt;br /&gt;
== Interpreting output files ==&lt;br /&gt;
&lt;br /&gt;
See also [[Understanding VerifyBamID output]].&lt;br /&gt;
&lt;br /&gt;
=== Output files ===&lt;br /&gt;
When verifyBamID runs successfully, the following sets of files may be generated.&lt;br /&gt;
* [outPrefix].selfSM - Per-sample statistics describing how well the sample matches to the annotated sample.&lt;br /&gt;
* [outPrefix].depthSM - The depth distribution of the sequence reads per sample&lt;br /&gt;
* [outPrefix].selfRG - Per-readGroup statistics describing how well each lane matches to the annotated sample. (available only without --ignoreRG option)&lt;br /&gt;
* [outPrefix].depthRG - The depth distribution of the sequence reads per readGroup. (available only without --ignoreRG option)&lt;br /&gt;
* [outPrefix].bestSM - Per-sample best-match statistics with best-matching sample among the genotyped sample (available only with --best option)&lt;br /&gt;
* [outPrefix].bestRG - Per-readgroup best-match statistics with best-matching sample among the genotyped sample (available only with --best and without --ignoreRG option)&lt;br /&gt;
&lt;br /&gt;
=== Column information in the output files ===&lt;br /&gt;
The .selfSM/.selfRG/.bestSM/.bestRG files have the following 19 columns per sample, or per readgroup (lane). &lt;br /&gt;
&lt;br /&gt;
# SEQ_SM : Sample ID of the sequenced sample. Obtained from @RG header / SM tag in the BAM file&lt;br /&gt;
# RG : ReadGroup ID of sequenced lane. For [outPrefix].selfSM and [outPrefix].bestSM, these values are &amp;quot;ALL&amp;quot;&lt;br /&gt;
# CHIP_ID : Sample ID compared to in the genotype file. For [outPrefix].selfRG and [outPrefix].selfSM, these values should be identical to [SEQ_SM] or &amp;quot;NA&amp;quot; if the genotype of sequenced samples are unavailable. For [outPrefix].bestRG and [outPrefix].bestSM, these values should be the ID of best-matching sample among the genotype files compared to.&lt;br /&gt;
# # SNPs : # of SNPs passing the criteria from the VCF file&lt;br /&gt;
# # READS : Total # of reads loaded from the BAM file&lt;br /&gt;
# # AVG_DP : Average sequencing depth at the sites in the VCF file&lt;br /&gt;
# FREEMIX : Sequence-only estimate of contamination (0-1 scale)&lt;br /&gt;
# FREELK1 : Maximum log-likelihood of the sequence reads given estimated contamination under sequence-only method&lt;br /&gt;
# FREELK0 : Log-likelihood of the sequence reads given no contamination under sequence-only method&lt;br /&gt;
# FREE_RH : Estimated reference bias parameter Pr(refBase|HET) (when --free-refBias or --free-full is used)&lt;br /&gt;
# FREE_RA : Estimated reference bias parameter Pr(refBase|HOMALT) (when --free-refBias or --free-full is used)&lt;br /&gt;
# CHIPMIX : Sequence+array estimate of contamination (NA if the external genotype is unavailable) (0-1 scale)&lt;br /&gt;
# CHIPLK1 : Maximum log-likelihood of the sequence reads given estimated contamination under sequence+array method (NA if the external genotypes are unavailable)&lt;br /&gt;
# CHIPLK0 : Log-likelihood of the sequence reads given no contamination under sequence+array method (NA if the external genotypes are unavailable)&lt;br /&gt;
# CHIP_RH : Estimated reference bias parameter Pr(refBase|HET) (when --chip-refBias or --chip-full is used)&lt;br /&gt;
# CHIP_RA : Estimated reference bias parameter Pr(refBase|HOMALT) (when --chip-refBias or --chip-full is used)&lt;br /&gt;
# DPREF : Depth (Coverage) of HomRef site (based on the genotypes of (SELF_SM/BEST_SM), passing mapQ, baseQual, maxDepth thresholds.&lt;br /&gt;
# RDPHET : DPHET/DPREF, Relative depth to HomRef site at Heterozygous site.&lt;br /&gt;
# RDPALT : DPHET/DPREF, Relative depth to HomRef site at HomAlt site.&lt;br /&gt;
&lt;br /&gt;
=== A guideline to interpret output files ===&lt;br /&gt;
&lt;br /&gt;
verifyBamID provides a series of information that is informative to determine whether the sample is possibly contaminated or swapped, but there is no single criteria that works for every circumstances. There are a few unmodeled factor in the estimation of [SELF-IBD]/[BEST-IBD] and [%MIX], so please note that the MLE estimation may not always exactly match to the true amount of contamination. Here we provide a guideline to flag potentially contaminated/swapped samples &lt;br /&gt;
&lt;br /&gt;
*  Each sample or lane can be checked in this way. When [CHIPMIX] &amp;gt;&amp;gt; 0.02 and/or [FREEMIX] &amp;gt;&amp;gt; 0.02, meaning 2% or more of non-reference bases are observed in reference sites, we recommend to examine the data more carefully for the possibility of contamination.&lt;br /&gt;
* We recommend to check each lane for the possibility of sample swaps. When [CHIPMIX] ~ 1 AND [FREEMIX] ~ 0, then it is possible that the sample is swapped with another sample. When [CHIPMIX] ~ 0 in .bestSM file, [CHIP_ID] might be actually the swapped sample. Otherwise, the swapped sample may not exist in the genotype data you have compared. &lt;br /&gt;
* When genotype data is not available but allele-frequency-based estimates of [FREEMIX] &amp;gt;= 0.03 and [FREELK1]-[FREELK0] is large, then it is possible that the sample is contaminated with other sample. We recommend to use per-sample data rather than per-lane data for checking this for low coverage data, because the inference will be more confident when there are large number of bases with depth 2 or higher.&lt;br /&gt;
&lt;br /&gt;
== Command Line Options ==&lt;br /&gt;
&lt;br /&gt;
 The following parameters are available.  Ones with &amp;quot;[]&amp;quot; are in effect:&lt;br /&gt;
 &lt;br /&gt;
 Available Options&lt;br /&gt;
                             Input Files : --vcf [], --bam [], --subset [],&lt;br /&gt;
                                           --smID []&lt;br /&gt;
                    VCF analysis options : --genoError [1.0e-03],&lt;br /&gt;
                                           --minAF [0.01],&lt;br /&gt;
                                           --minCallRate [0.50]&lt;br /&gt;
   Individuals to compare with chip data : --site, --self, --best&lt;br /&gt;
          Chip-free optimization options : --free-none, --free-mix [ON],&lt;br /&gt;
                                           --free-refBias, --free-full&lt;br /&gt;
          With-chip optimization options : --chip-none, --chip-mix [ON],&lt;br /&gt;
                                           --chip-refBias, --chip-full&lt;br /&gt;
                    BAM analysis options : --ignoreRG, --ignoreOverlapPair,&lt;br /&gt;
                                           --noEOF, --precise, --minMapQ [10],&lt;br /&gt;
                                           --maxDepth [20], --minQ [13],&lt;br /&gt;
                                           --maxQ [40], --grid [0.05]&lt;br /&gt;
                 Modeling Reference Bias : --refRef [1.00], --refHet [0.50],&lt;br /&gt;
                                           --refAlt [0.00]&lt;br /&gt;
                          Output options : --out [], --verbose&lt;br /&gt;
                               PhoneHome : --noPhoneHome,&lt;br /&gt;
                                           --phoneHomeThinning [50]&lt;br /&gt;
&lt;br /&gt;
Each option provides the following features:&lt;br /&gt;
* --vcf : specify required VCF file&lt;br /&gt;
* --bam : specify required BAM file (indexed with .bam.bai or .bai file)&lt;br /&gt;
* --subset : list of individual IDs to calculate the allele frequency. All individuals are used if unspecified&lt;br /&gt;
* --smID : If the individual ID in the BAM file and VCF file does not match, substitute the BAM file&#039;s ID into the specified argument&lt;br /&gt;
* --genoError : error rate of the external genotype file&lt;br /&gt;
* --minAF : minimum allele frequency of the markers to include&lt;br /&gt;
* --minAF : minimum call rate of the markers to include&lt;br /&gt;
* --site : If set, use only site information in the VCF and do not compare with the actual genotypes&lt;br /&gt;
* --self : Only compare the ID-matching individuals between the VCF and BAM file&lt;br /&gt;
* --best : Find the best matching individuals (.bestSM and .bestRG files will be produced). This option is substantially longer than the default option&lt;br /&gt;
* --free-none : Do not perform sequence-only method to estimate parameters&lt;br /&gt;
* --free-mix : (default) Estimate contamination using sequence-only method with Brent&#039;s single dimensional optimization.&lt;br /&gt;
* --free-refBias : Estimate the reference bias parameters using sequence-only method with Simplex method&lt;br /&gt;
* --free-full : Estimate both reference bias parameters and the contamination parameters using sequence-only method&lt;br /&gt;
* --chip-none : Do not perform sequence+array method to estimate parameters&lt;br /&gt;
* --free-mix : (default) Estimate contamination using sequence+array method with Brent&#039;s single dimensional optimization.&lt;br /&gt;
* --free-refBias : Estimate the refernece bias parameters using sequence+array method with Simplex method&lt;br /&gt;
* --free-full : Estimate both reference bias parameters and the contamination parameters using sequence+array method&lt;br /&gt;
* --ignoreRG : ignore the read grouup level comparison and compare samples only (recommended for an expedited run)&lt;br /&gt;
* --ignoreOverlapPair : ignore overlapping pair end fragment covering the same base. Disabling this option may decrease the sensitivity of the method when the insert size is short (with slight gain in the computational speed)&lt;br /&gt;
* --noEOF : do not check the EOF marker of the BAM file (for earlier version of BAM)&lt;br /&gt;
* --precise : calculate the likelihood in log-scale for high-depth data (recommended when --maxDepth is greater than 20. Can be a little bit slower)&lt;br /&gt;
* --minMapQ : minimum mapping quality of the sequence reads to compare&lt;br /&gt;
* --minQ : minimum base quality to include&lt;br /&gt;
* --maxQ : maximum base quality to cap&lt;br /&gt;
* --grid : the grid interval to search the optimum before running Brent&#039;s algorithm.&lt;br /&gt;
* --refRef : Initial Pr(refBase|HOMREFGeno) parameter&lt;br /&gt;
* --refHet : Initial Pr(refBase|HETGeno) parameter&lt;br /&gt;
* --refAlt : Initial Pr(refBase|HOMALTGeno) parameter&lt;br /&gt;
* --out : output file prefix (required)&lt;br /&gt;
* --verbose : print the progress of the method on the screeen&lt;br /&gt;
{{PhoneHomeParameters|hdr=====|bullet=1}}&lt;br /&gt;
&lt;br /&gt;
== Principle of Operation ==&lt;br /&gt;
&lt;br /&gt;
Each read group in a BAM file is evaluated independently. This means that in file with multiple read groups, problems will be flagged at the read group level (a plus). However, it also means that it might be hard to discern the correct assignment of read groups with very little data.&lt;br /&gt;
&lt;br /&gt;
For each aligned base that overlaps a known genotype, we calculate the probability the probability that it was derived from a particular known genotype. This comparison considers only bases that overlap previously known genotypes and that meet the base quality and mapping quality thresholds.&lt;br /&gt;
&lt;br /&gt;
Each individual in a pedigree has a different combination of genotypes, and bamGenotypeCheck will systematically search for the individual whose genotypes best match the observed read data.&lt;br /&gt;
&lt;br /&gt;
For more about the technical details, see the page [[Verifying Sample Identities - Implementation]]&lt;br /&gt;
&lt;br /&gt;
== Reference ==&lt;br /&gt;
&lt;br /&gt;
Please cite the following paper:&lt;br /&gt;
&lt;br /&gt;
G. Jun, M. Flickinger, K. N. Hetrick, Kurt, J. M. Romm, K. F. Doheny, G. Abecasis, M. Boehnke,and H. M. Kang, &#039;&#039;Detecting and Estimating Contamination of Human DNA Samples in Sequencing and Array-Based Genotype Data&#039;&#039;, American journal of human genetics doi:10.1016/j.ajhg.2012.09.004 (volume 91 issue 5 pp.839 - 848) &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Contamination in Array Data ==&lt;br /&gt;
&lt;br /&gt;
[[VerifyIDintensity]] or [[BAFRegress]] can estimate sample contamination from Illumina genotype array data.&lt;br /&gt;
&lt;br /&gt;
== Acknowledgements ==&lt;br /&gt;
&lt;br /&gt;
VerifyBamID is a result from collaborative effort by Hyun Min Kang, Goo Jun, Matthew Flickinger, Mary Kate Wing, Goncalo Abecasis, and Michael Boehnke. Please email to Hyun Min Kang [hmkang@umich.edu ] for any questions.&lt;/div&gt;</summary>
		<author><name>Mktrost</name></author>
	</entry>
	<entry>
		<id>http://genome.sph.umich.edu/w/index.php?title=User_talk:Gzajac&amp;diff=14528</id>
		<title>User talk:Gzajac</title>
		<link rel="alternate" type="text/html" href="http://genome.sph.umich.edu/w/index.php?title=User_talk:Gzajac&amp;diff=14528"/>
		<updated>2017-01-04T19:42:09Z</updated>

		<summary type="html">&lt;p&gt;Mktrost: Welcome!&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;&#039;Welcome to &#039;&#039;Genome Analysis Wiki&#039;&#039;!&#039;&#039;&#039;&lt;br /&gt;
We hope you will contribute much and well.&lt;br /&gt;
You will probably want to read the [[Help:Contents|help pages]].&lt;br /&gt;
Again, welcome and have fun! [[User:Mktrost|Mktrost]] ([[User talk:Mktrost|talk]]) 14:42, 4 January 2017 (EST)&lt;/div&gt;</summary>
		<author><name>Mktrost</name></author>
	</entry>
	<entry>
		<id>http://genome.sph.umich.edu/w/index.php?title=User:Gzajac&amp;diff=14527</id>
		<title>User:Gzajac</title>
		<link rel="alternate" type="text/html" href="http://genome.sph.umich.edu/w/index.php?title=User:Gzajac&amp;diff=14527"/>
		<updated>2017-01-04T19:42:08Z</updated>

		<summary type="html">&lt;p&gt;Mktrost: Creating user page for new user.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;University of Missouri BS Statistics 2009 - 2013&lt;br /&gt;
University of Michigan MS Biostatistics 2013 - 2015&lt;br /&gt;
University of Michigan PhD Biostatistics 2015 - In Progress&lt;br /&gt;
&lt;br /&gt;
I have been in Goncalo’s lab since coming to the University of Michigan in 2013&lt;br /&gt;
I have been in the Genome Science Training Program since I started the PhD program in 2015&lt;/div&gt;</summary>
		<author><name>Mktrost</name></author>
	</entry>
	<entry>
		<id>http://genome.sph.umich.edu/w/index.php?title=BamUtil:_dedup&amp;diff=14153</id>
		<title>BamUtil: dedup</title>
		<link rel="alternate" type="text/html" href="http://genome.sph.umich.edu/w/index.php?title=BamUtil:_dedup&amp;diff=14153"/>
		<updated>2016-04-15T02:30:35Z</updated>

		<summary type="html">&lt;p&gt;Mktrost: /* Implementation Notes */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:BamUtil|validate]]&lt;br /&gt;
[[Category:BAM Software]]&lt;br /&gt;
[[Category:Software]]&lt;br /&gt;
&lt;br /&gt;
= Overview of the &amp;lt;code&amp;gt;dedup&amp;lt;/code&amp;gt; function of &amp;lt;code&amp;gt;[[bamUtil]]&amp;lt;/code&amp;gt; =&lt;br /&gt;
The &amp;lt;code&amp;gt;dedup&amp;lt;/code&amp;gt; option of [[bamUtil]] determines duplicates in a coordinate sorted SAM/BAM file. It either marks or removes the lower quality duplicates.&lt;br /&gt;
&lt;br /&gt;
This tool also contains the option to perform recalibration.&lt;br /&gt;
&lt;br /&gt;
NOTE: This tool does not properly work on templates that have more than 2 segments.  It does not properly match reads when more than 2 reads have the same read name.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Potential future features:&lt;br /&gt;
* Soft clip overlapping reads (for now, use: [[BamUtil: clipOverlap]])&lt;br /&gt;
&lt;br /&gt;
==Handling Duplicates==&lt;br /&gt;
&lt;br /&gt;
The deduper reads all the alignments in a coordinate-sorted SAM/BAM looking for duplicates, failing if the file is not coordinate-sorted.&lt;br /&gt;
&lt;br /&gt;
The deduper assumes that duplicates in the input BAM file are not marked.  When the deduper detects a marked duplicate in the input BAM file, it will throw an error and stop.  To override this behavior, use the [[#Ignore Previous Duplicate Marking (--force)|&amp;lt;code&amp;gt;--force&amp;lt;/code&amp;gt;]] option;  in this mode, alignments that are marked as duplicates in the input file are unmarked before the deduper begins its detection algorithm.  The result is that only duplicates detected by the deduper will be marked in or removed from the output file.&lt;br /&gt;
&lt;br /&gt;
The handling of paired-end reads assumes that the mate information in the SAM/BAM records is accurate.  If a mate is not found at the expected position, an error message is printed (once per file) indicating this error.  Paired-end reads whose mate cannot be found are not marked duplicate and are not used for duplicate marking of other paired-end reads.  Single-end reads with the same key as paired-end reads whose mate cannot be found are still marked as duplicate.  If this error is encountered, you may want to fix the mate information and reprocess the file through the deduper.  &lt;br /&gt;
&lt;br /&gt;
With the default settings this tool should produce similar results as Picard.&lt;br /&gt;
&lt;br /&gt;
Use the [[#Treat Reads with Mates On Different Chromosomes As Single-Ended (--oneChrom)|&amp;lt;code&amp;gt;--oneChrom&amp;lt;/code&amp;gt;]] option to treat reads with a mate on a different chromosome as single-ended.  This option is useful if you are running the deduper on just a single chromosome.  The code will use less memory with this option if mates are found on different chromosomes.  (Picard does not specially handle mates on different chromosomes, so the --oneChrom option may produce different results than Picard.)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Implementation Notes ===&lt;br /&gt;
Duplicates are determined by checking for matching keys.  &lt;br /&gt;
&lt;br /&gt;
The Key is comprised of:&lt;br /&gt;
# Chromosome&lt;br /&gt;
# Orientation (forward/reverse)&lt;br /&gt;
# Unclipped Start(forward)/End(reverse)&lt;br /&gt;
# Library&lt;br /&gt;
&lt;br /&gt;
Rules:&lt;br /&gt;
* Skip Unmapped Reads, they are not marked as duplicate&lt;br /&gt;
* Reads whose mate is unmapped are treated as single-end&lt;br /&gt;
* Mark a Single-End Read Duplicate (or remove it if configured to do so) if:&lt;br /&gt;
*# A paired-end record has the same key (even if the pair is not proper/the mate is not found)&amp;lt;br/&amp;gt;-OR-&lt;br /&gt;
*# A single-end record has the same key and a higher base quality sum (sum of all base qualities in the record above [[#Minimum Quality for Quality Calculations (--minQual)|&amp;lt;code&amp;gt;--minBaseQual&amp;lt;/code&amp;gt;]])&lt;br /&gt;
* Mark both Paired-End Reads Duplicate if:&lt;br /&gt;
# Another paired-end pair has the same set of keys and has a higher base quality sum (sum of all base qualities in the record above [[#Minimum Quality for Quality Calculations (--minQual)|&amp;lt;code&amp;gt;--minBaseQual&amp;lt;/code&amp;gt;]])&lt;br /&gt;
 &lt;br /&gt;
This code assumes that at most 1000 bases are clipped at the start of a read.&lt;br /&gt;
&lt;br /&gt;
==Handling Recalibration==&lt;br /&gt;
See [[BamUtil: recab]] for recalibration details.&lt;br /&gt;
&lt;br /&gt;
Recalibration parameters can be applied to deduping when --recab is specified.&lt;br /&gt;
&lt;br /&gt;
== How to use it ==&lt;br /&gt;
&lt;br /&gt;
When &amp;lt;code&amp;gt;dedup&amp;lt;/code&amp;gt; is invoked without any arguments the usage information is displayed as described below under [[#Usage|Usage]].&lt;br /&gt;
&lt;br /&gt;
The input SAM/BAM file is required, [[#input File (--in)|input File (--in)]], and must be sorted by coordinate.&lt;br /&gt;
&lt;br /&gt;
The output SAM/BAM file is also required, [[#output File (--out)|output File (--out)]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Recommended usage with Recalibrator: &lt;br /&gt;
&lt;br /&gt;
 /usr/cluster/bin/bam dedup --recab --in ${INPUT}.bam --out ${OUTPUT}.bam --force --refFile ${REF} --dbsnp ${DBSNP} --oneChrom --storeQualTag OQ --maxBaseQual 40&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Recommended usage without Recalibrator: &lt;br /&gt;
&lt;br /&gt;
 /usr/cluster/bin/bam dedup --in ${INPUT}.bam --out ${OUTPUT}.bam --force --oneChrom&lt;br /&gt;
&lt;br /&gt;
= Usage =&lt;br /&gt;
 ./bam dedup --in &amp;lt;InputBamFile&amp;gt; --out &amp;lt;OutputBamFile&amp;gt; [--minQual &amp;lt;minPhred&amp;gt;] [--log &amp;lt;logFile&amp;gt;] [--oneChrom] [--rmDups] [--force] [--excludeFlags &amp;lt;flag&amp;gt;] [--verbose] [--noeof] [--params] [--recab]&lt;br /&gt;
&lt;br /&gt;
Additional Recalibration Usage is documented at [[BamUtil: recab#Usage|BamUtil: recab -&amp;gt; Usage]]&lt;br /&gt;
&lt;br /&gt;
= Parameters =&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Required parameters :&lt;br /&gt;
	--in &amp;lt;infile&amp;gt;   : Input BAM file name (must be sorted)&lt;br /&gt;
	--out &amp;lt;outfile&amp;gt; : Output BAM file name (same order with original file)&lt;br /&gt;
Optional parameters : &lt;br /&gt;
	--minQual &amp;lt;int&amp;gt; : Only add scores over this phred quality when determining a read&#039;s quality (default: 15)&lt;br /&gt;
	--log &amp;lt;logfile&amp;gt; : Log and summary statistics (default: [outfile].log, or stderr if --out starts with &#039;-&#039;)&lt;br /&gt;
	--oneChrom      : Treat reads with mates on different chromosomes as single-ended.&lt;br /&gt;
	--rmDups        : Remove duplicates (default is to mark duplicates)&lt;br /&gt;
	--force         : Allow an already mark-duplicated BAM file, unmarking any previously marked &lt;br /&gt;
	                  duplicates and apply this duplicate marking logic.  Default is to throw errors&lt;br /&gt;
	                  and exit when trying to run on an already mark-duplicated BAM&lt;br /&gt;
	--excludeFlags &amp;lt;flag&amp;gt;    : exclude reads with any of these flags set when determining or marking duplicates&lt;br /&gt;
	                           by default (0xB04): exclude unmapped, secondary reads, QC failures, and supplementary reads&lt;br /&gt;
	--verbose       : Turn on verbose mode&lt;br /&gt;
	--noeof         : Do not expect an EOF block on a bam file.&lt;br /&gt;
	--params        : Print the parameter settings&lt;br /&gt;
	--recab         : Recalibrate in addition to deduping&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
{{PhoneHomeParamDesc}}&lt;br /&gt;
&lt;br /&gt;
Additional Recalibration Parameters are documented at [[BamUtil: recab#Parameters|BamUtil: recab -&amp;gt; Parameters]]&lt;br /&gt;
&lt;br /&gt;
== Required Parameters ==&lt;br /&gt;
{{inBAMInputFile}}&lt;br /&gt;
&lt;br /&gt;
Note: The input file must be sorted by coordinate.&lt;br /&gt;
{{outBAMOutputFile}}&lt;br /&gt;
&lt;br /&gt;
== Optional Parameters==&lt;br /&gt;
=== Minimum Quality for Quality Calculations (&amp;lt;code&amp;gt;--minQual&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
When duplicate reads are encountered, the read with the highest quality is kept.&lt;br /&gt;
&lt;br /&gt;
To determine the quality of a read, all of the phred base quality scores above the &amp;lt;code&amp;gt;--minQual&amp;lt;/code&amp;gt; value are added together.  If &amp;lt;code&amp;gt;--minQual&amp;lt;/code&amp;gt; is not specified, it is defaulted to 15.&lt;br /&gt;
&lt;br /&gt;
=== Output log &amp;amp; Summary Statistics FileName (&amp;lt;code&amp;gt;--log&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
Output file name for writing logs &amp;amp; summary statistics.&lt;br /&gt;
&lt;br /&gt;
If this parameter is not specified, it will write to the output file specified in &amp;lt;code&amp;gt;--out&amp;lt;/code&amp;gt; + &amp;quot;.log&amp;quot;.  Or if the output bam is written to stdout (&amp;lt;code&amp;gt;--out&amp;lt;/code&amp;gt; starts with &#039;-&#039;), the logs will be written to stderr.  If the filename after --log starts with &#039;-&#039; it will write to stderr.&lt;br /&gt;
&lt;br /&gt;
=== Treat Reads with Mates On Different Chromosomes As Single-Ended (&amp;lt;code&amp;gt;--oneChrom&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
If a read&#039;s mate is not found it will not be used for duplicate marking.  If you are running on a single chromosome, all read&#039;s whose mates are on different chromosomes will not be used for duplicate marking.  The &amp;lt;code&amp;gt;--oneChrom&amp;lt;/code&amp;gt; option will treat reads with mates on a different chromosome as single-ended.&lt;br /&gt;
&lt;br /&gt;
=== Remove Duplicates (&amp;lt;code&amp;gt;--rmDups&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
Instead of marking a read as duplicate in the flag, the &amp;lt;code&amp;gt;--rmDups&amp;lt;/code&amp;gt; option will remove it from the output BAM file.  &lt;br /&gt;
&lt;br /&gt;
=== Ignore Previous Duplicate Marking (&amp;lt;code&amp;gt;--force&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
By default the deduper will throw an error and stop if a read is already marked as duplicate.  The &amp;lt;code&amp;gt;--force&amp;lt;/code&amp;gt; option will removes any previous duplicate marking and marks the reads from scratch.  The resulting output file will only have reads determined by the deduper marked as duplicates.&lt;br /&gt;
&lt;br /&gt;
=== Skip Records with any of the Specified Flags (&amp;lt;code&amp;gt;--excludeFlags&amp;lt;/code&amp;gt;)===&lt;br /&gt;
Skip records with any of the specified flags set, default 0xB04&lt;br /&gt;
&lt;br /&gt;
By default skips reads with any of the following flags set:&lt;br /&gt;
* unmapped&lt;br /&gt;
* secondary alignment&lt;br /&gt;
* fails QC checks&lt;br /&gt;
* supplementary reads&lt;br /&gt;
&lt;br /&gt;
Secondary (0x100) and Supplementary (0x800) reads currently must be excluded.&lt;br /&gt;
&lt;br /&gt;
=== Turn on Verbose Mode (&amp;lt;code&amp;gt;--verbose&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
Turn on verbose logging to get more log messages in the log and to stderr.&lt;br /&gt;
&lt;br /&gt;
{{noeofBGZFParameter}}&lt;br /&gt;
{{paramsParameter}}&lt;br /&gt;
&lt;br /&gt;
== Recalibrate (&amp;lt;code&amp;gt;--recab&amp;lt;/code&amp;gt;) ==&lt;br /&gt;
&lt;br /&gt;
This option will recalibrate the input file in addition to deduping.&lt;br /&gt;
&lt;br /&gt;
See [[BamUtil: recab]] for recalibration details.&lt;br /&gt;
&lt;br /&gt;
{{PhoneHomeParameters}}&lt;br /&gt;
&lt;br /&gt;
= Return Value =&lt;br /&gt;
&lt;br /&gt;
Returns -1 if input parameters are invalid.&lt;br /&gt;
&lt;br /&gt;
Returns the SamStatus for the reads/writes (0 on success, non-0 on failure).&lt;/div&gt;</summary>
		<author><name>Mktrost</name></author>
	</entry>
	<entry>
		<id>http://genome.sph.umich.edu/w/index.php?title=BamUtil:_gapInfo&amp;diff=14128</id>
		<title>BamUtil: gapInfo</title>
		<link rel="alternate" type="text/html" href="http://genome.sph.umich.edu/w/index.php?title=BamUtil:_gapInfo&amp;diff=14128"/>
		<updated>2016-03-06T05:45:28Z</updated>

		<summary type="html">&lt;p&gt;Mktrost: /* Rules */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:BamUtil|gapInfo]]&lt;br /&gt;
[[Category:BAM Software]]&lt;br /&gt;
[[Category:Software]]&lt;br /&gt;
&lt;br /&gt;
= Overview of the &amp;lt;code&amp;gt;gapInfo&amp;lt;/code&amp;gt; function of &amp;lt;code&amp;gt;bamUtil&amp;lt;/code&amp;gt; =&lt;br /&gt;
The &amp;lt;code&amp;gt;gapInfo&amp;lt;/code&amp;gt; option on the [[bamUtil]] prints information on the gap between read pairs in a SAM/BAM File.&lt;br /&gt;
&lt;br /&gt;
There are two ways to run: standard/detailed.  To run as detailed, use the &amp;lt;code&amp;gt;--detailed&amp;lt;/code&amp;gt; option.&lt;br /&gt;
&lt;br /&gt;
Standard output prints the number of pairs that have a given gap size.&lt;br /&gt;
&lt;br /&gt;
The gap size is calculated by counting the number of bases between the clipped end of the first read and the clipped start of the 2nd read.  (mate0BasedClippedStart - 0BasedPositionClippedEnd - 1)&lt;br /&gt;
&lt;br /&gt;
The gap size will be negative if the reads overlap.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Rules =&lt;br /&gt;
gapInfo skips any records that are marked in the flag as:&lt;br /&gt;
* unmapped&lt;br /&gt;
* not paired&lt;br /&gt;
* mate is unmapped&lt;br /&gt;
* secondary alignment (not primary alignment)&lt;br /&gt;
* supplementary alignment&lt;br /&gt;
* duplicates&lt;br /&gt;
* QC Failure&lt;br /&gt;
* mate is on a different chromosome&lt;br /&gt;
* chromosome is unknown (-1/*)&lt;br /&gt;
* mate starts before this record&lt;br /&gt;
* mate starts at the same location as this record &amp;amp; this record is the reverse strand&lt;br /&gt;
* reverse strands (unless &amp;lt;code&amp;gt;--detailed&amp;lt;/code&amp;gt; is specified)&lt;br /&gt;
&lt;br /&gt;
When &amp;lt;code&amp;gt;--refFile&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;--detailed&amp;lt;/code&amp;gt; is not specified gaps that contain reference base &#039;N&#039; are skipped.&lt;br /&gt;
&lt;br /&gt;
= Usage =&lt;br /&gt;
 ./bam gapInfo --in &amp;lt;inputFile&amp;gt; --out &amp;lt;outputFile&amp;gt; [--noeof] [--params]&lt;br /&gt;
&lt;br /&gt;
= Parameters =&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
	Required Parameters:&lt;br /&gt;
		--in          : the SAM/BAM file to print read pair gap info for&lt;br /&gt;
		--out         : the output file to be written&lt;br /&gt;
	Optional Parameters:&lt;br /&gt;
		--refFile     : reference file, used to skip gaps that include reference base &#039;N&#039; (for runs without --detailed)		--detailed    : Print  the details for each read pair&lt;br /&gt;
	Optional Parameters for the Detailed Option:&lt;br /&gt;
		--checkFirst  : Check the first in pair flag and print &amp;quot;NotFirst&amp;quot; if it isn&#039;t first&lt;br /&gt;
		--checkStrand : Check the strand flag and print &amp;quot;Reverse&amp;quot; if it is reverse complimented&lt;br /&gt;
		--noeof       : Do not expect an EOF block on a bam file.&lt;br /&gt;
		--params      : Print the parameter settings to stderr&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
{{PhoneHomeParamDesc}}&lt;br /&gt;
&lt;br /&gt;
== Required Parameters ==&lt;br /&gt;
{{inBAMInputFile}}&lt;br /&gt;
&lt;br /&gt;
=== Output File (&amp;lt;code&amp;gt;--out&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
Use &amp;lt;code&amp;gt;--out&amp;lt;/code&amp;gt; followed by a file name to specify the output file to write.&lt;br /&gt;
&lt;br /&gt;
The Standard Output prints a 2-column (separated by tabs) line for each gapSize found in the SAM/BAM file.  The first column contains the gap size and the 2nd column contains the number of pairs that have that gap size. The first line is a header line describing the columns.&lt;br /&gt;
&lt;br /&gt;
Detailed output does not have a header line and is described below under the [[#Print Detailed Per-Pair Information (&amp;lt;code&amp;gt;--detailed&amp;lt;/code&amp;gt;) | --detailed]] parameter.&lt;br /&gt;
&lt;br /&gt;
== Optional Prameters ==&lt;br /&gt;
{{RefFile}}&lt;br /&gt;
&lt;br /&gt;
With this option specified, do not increment counters for the number of times that a gap is found if any of the reference bases in the gap are an &#039;N&#039;.  (N/A if &amp;lt;code&amp;gt;--detailed&amp;lt;/code&amp;gt; is specified.)&lt;br /&gt;
&lt;br /&gt;
=== Print Detailed Per-Pair Information (&amp;lt;code&amp;gt;--detailed&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
With this option, for every record processed per the above rules, the following information is printed on a line as tab separated columns:&lt;br /&gt;
* Reference/Chromosome Name &lt;br /&gt;
* 1-based read end position (clipped)&lt;br /&gt;
* gap size&lt;br /&gt;
Additional columns if &amp;lt;code&amp;gt;--checkFirst&amp;lt;/code&amp;gt; and/or &amp;lt;code&amp;gt;--checkStrand&amp;lt;/code&amp;gt; are specified.&lt;br /&gt;
&lt;br /&gt;
Detailed output does not have a header line.&lt;br /&gt;
&lt;br /&gt;
See [[#Optional Parameters for --detailed|Optional Parameters for &amp;lt;code&amp;gt;--detailed&amp;lt;/code&amp;gt;]] for additional options related to &amp;lt;code&amp;gt;--detailed&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{{noeofBGZFParameter}}&lt;br /&gt;
{{paramsParameter}}&lt;br /&gt;
&lt;br /&gt;
== Optional Parameters for [[#Print Detailed Per-Pair Information (--detailed)|&amp;lt;code&amp;gt;--detailed&amp;lt;/code&amp;gt;]] ==&lt;br /&gt;
=== Check First (&amp;lt;code&amp;gt;--checkFirst&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
Only applicable if [[#Print Detailed Per-Pair Information (--detailed)|&amp;lt;code&amp;gt;--detailed&amp;lt;/code&amp;gt;]] is also provided.&lt;br /&gt;
&lt;br /&gt;
When specified along with [[#Print Detailed Per-Pair Information (--detailed)|&amp;lt;code&amp;gt;--detailed&amp;lt;/code&amp;gt;]], the output for each record processed also includes &amp;quot;NotFirst&amp;quot; if it is not marked as FirstFragment in the flags.&lt;br /&gt;
&lt;br /&gt;
=== Check Strand (&amp;lt;code&amp;gt;--checkStrand&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
Only applicable if [[#Print Detailed Per-Pair Information (--detailed)|&amp;lt;code&amp;gt;--detailed&amp;lt;/code&amp;gt;]] is also provided.&lt;br /&gt;
&lt;br /&gt;
When specified along with [[#Print Detailed Per-Pair Information (--detailed)|&amp;lt;code&amp;gt;--detailed&amp;lt;/code&amp;gt;]], the output for each record processed also includes &amp;quot;Reverse&amp;quot; if it is marked as the reverse strand in the flags.&lt;br /&gt;
&lt;br /&gt;
{{PhoneHomeParameters}}&lt;br /&gt;
&lt;br /&gt;
= Return Value =&lt;br /&gt;
&lt;br /&gt;
Returns -1 if input parameters are invalid.&lt;br /&gt;
&lt;br /&gt;
Returns the SamStatus for the reads/writes (0 on success, non-0 on failure).&lt;br /&gt;
&lt;br /&gt;
= Output =&lt;br /&gt;
&lt;br /&gt;
All status messages are written to stderr.&lt;br /&gt;
&lt;br /&gt;
Tab-delimited columns as described above.&lt;br /&gt;
&lt;br /&gt;
== Example Output == &lt;br /&gt;
For standard output:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
GapSize	NumPairs&lt;br /&gt;
-23	3&lt;br /&gt;
-21	3&lt;br /&gt;
-20	4&lt;br /&gt;
-5	1&lt;br /&gt;
30	1&lt;br /&gt;
70	3&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For detailed output with both &amp;lt;code&amp;gt;--checkFirst&amp;lt;/code&amp;gt; &amp;amp; &amp;lt;code&amp;gt;--checkStrand&amp;lt;/code&amp;gt; specified:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
1	28	70&lt;br /&gt;
1	10028	71	NotFirst	Reverse&lt;br /&gt;
1	10028	70&lt;br /&gt;
1	10028	70&lt;br /&gt;
1	10028	30&lt;br /&gt;
1	10028	-19	NotFirst	Reverse&lt;br /&gt;
1	10028	-19	NotFirst	Reverse&lt;br /&gt;
1	10028	-19	NotFirst	Reverse&lt;br /&gt;
1	10030	-21&lt;br /&gt;
1	10030	-20&lt;br /&gt;
1	10030	-20&lt;br /&gt;
1	10030	-21&lt;br /&gt;
1	10030	-21&lt;br /&gt;
1	10030	-20&lt;br /&gt;
1	10030	-20&lt;br /&gt;
2	32	-18	NotFirst	Reverse&lt;br /&gt;
4	24	-23&lt;br /&gt;
4	27	-23&lt;br /&gt;
4	30	-23&lt;br /&gt;
4	34	-5&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Mktrost</name></author>
	</entry>
	<entry>
		<id>http://genome.sph.umich.edu/w/index.php?title=BamUtil:_recab&amp;diff=14127</id>
		<title>BamUtil: recab</title>
		<link rel="alternate" type="text/html" href="http://genome.sph.umich.edu/w/index.php?title=BamUtil:_recab&amp;diff=14127"/>
		<updated>2016-03-06T05:10:36Z</updated>

		<summary type="html">&lt;p&gt;Mktrost: /* Parameters */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:BamUtil|validate]]&lt;br /&gt;
[[Category:BAM Software]]&lt;br /&gt;
[[Category:Software]]&lt;br /&gt;
&lt;br /&gt;
= Overview of the &amp;lt;code&amp;gt;recab&amp;lt;/code&amp;gt; function of &amp;lt;code&amp;gt;[[bamUtil]]&amp;lt;/code&amp;gt; =&lt;br /&gt;
The &amp;lt;code&amp;gt;recab&amp;lt;/code&amp;gt; option of [[bamUtil]] recalibrates a SAM/BAM file. &lt;br /&gt;
&lt;br /&gt;
Recalibration can also be called as an option of [[bamUtil: dedup]].  This will perform the recalibration and  the deduping in the same set of steps, increasing processing speed.&lt;br /&gt;
&lt;br /&gt;
==Handling Recalibration/Implementation Notes==&lt;br /&gt;
&lt;br /&gt;
Recalibration is a 2-step process that loops through the file twice:&lt;br /&gt;
# Build Recalibration Table&lt;br /&gt;
# Apply Recalibration Table&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Recalibration Table groups bases based on a set of covariates:&lt;br /&gt;
* Read Group&lt;br /&gt;
* Quality (either from the quality string or [[#Read the quality from a tag (--qualField)|from a tag]])&lt;br /&gt;
* Cycle (reverse complement for reverse strands)&lt;br /&gt;
* 1st/2nd read in pair&lt;br /&gt;
* Previous Cycle&#039;s Base (reverse complement for reverse strands)&lt;br /&gt;
* This Cycle&#039;s Base (reverse complement for reverse strands)&lt;br /&gt;
&lt;br /&gt;
The Recalibration Table tracks the number of matches/mismatches for each set of covariates.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Only bases meeting all of the following criteria are used to Build the Recalibration Table:&lt;br /&gt;
* Read criteria&lt;br /&gt;
** not a duplicate&lt;br /&gt;
** mapped&lt;br /&gt;
** mapping quality != 0&lt;br /&gt;
** mapping quality != 255&lt;br /&gt;
* Base criteria&lt;br /&gt;
** match/mismatch (not an insertion/deletion/skip/clip)&lt;br /&gt;
** not a [[#DBSNP File (--dbsnp)|dbSNP position]]&lt;br /&gt;
** base quality &amp;gt; [[#Minimum Recalibration Base Quality (--minBaseQual)|minBaseQual (5 by default)]]&lt;br /&gt;
* Additional criteria for cycle != 1 (can be turned off via flags)&lt;br /&gt;
** previous base is a CIGAR Match/Mismatch (Use [[#Allow Previous Base Non-Match/Mismatch (--keepPrevNonAdjacent)|&amp;lt;code&amp;gt;--keepPrevNonAdjacent&amp;lt;/code&amp;gt;]] to disable)&lt;br /&gt;
** previous base position is not a [[#DBSNP File (--dbsnp)|dbSNP position]] (Use [[#Allow Previous Base DBSNP (--keepPrevDbsnp)|&amp;lt;code&amp;gt;--keepPrevDbsnp&amp;lt;/code&amp;gt;]] to disable)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Recalibration Table is applied to all bases meeting all of the following criteria (even if they were not used for creating the table):&lt;br /&gt;
* base quality &amp;gt; [[#Minimum Recalibration Base Quality (--minBaseQual)|minBaseQual (5 by default)]]&lt;br /&gt;
* at least 1 match or mismatch for the set of covariates&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Recalibrated Quality is: &amp;lt;math&amp;gt;-10 * \log \frac{mismatches + 1}{mismatches + matches + 1}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Alternatively, [[#Logistic Regression (--useLogReg)|logistic regression]] can be used for calculating the new quality.&lt;br /&gt;
&lt;br /&gt;
If the Recalibrated Quality is greater than [[#Maximum Recalibration Base Quality (--maxBaseQual)|maxBaseQual]], the updated quality is set to maxBaseQual.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Optionally, the previous quality can be [[#Store the original quality (--storeQualTag)|stored in a tag]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The current recalibration logic was designed for recalibrating ILLUMINA data.&lt;br /&gt;
&lt;br /&gt;
NOTE: GATK ignores/skips adapters, but our logic does not.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== How to use it ==&lt;br /&gt;
&lt;br /&gt;
When &amp;lt;code&amp;gt;recab&amp;lt;/code&amp;gt; is invoked without any arguments the usage information is displayed as described below under [[#Usage|Usage]].&lt;br /&gt;
&lt;br /&gt;
The input SAM/BAM file ([[#input File (--in)|--in]]), the output SAM/BAM file ([[#output File (--out)|--out]]), and the reference file ([[#Reference File (--refFile)|--refFile]]) are required inputs.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Recommended usage with Deduper: &lt;br /&gt;
&lt;br /&gt;
 /usr/cluster/bin/bam dedup --recab --in ${INPUT}.bam --out ${OUTPUT}.bam --force --refFile ${REF} --dbsnp ${DBSNP} --oneChrom --storeQualTag OQ --maxBaseQual 40&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Recommended usage without Deduper: &lt;br /&gt;
&lt;br /&gt;
 /usr/cluster/bin/bam recab --in ${INPUT}.bam --out ${OUTPUT}.bam --refFile ${REF} --dbsnp ${DBSNP} --storeQualTag OQ --maxBaseQual 40&lt;br /&gt;
&lt;br /&gt;
= Usage =&lt;br /&gt;
 ./bam recab (options) --in &amp;lt;InputBamFile&amp;gt; --out &amp;lt;OutputFile&amp;gt; [--log &amp;lt;logFile&amp;gt;] [--verbose] [--noeof] [--params] --refFile &amp;lt;ReferenceFile&amp;gt; [--dbsnp &amp;lt;dbsnpFile&amp;gt;] [--minBaseQual &amp;lt;minBaseQual&amp;gt;] [--maxBaseQual &amp;lt;maxBaseQual&amp;gt;] [--blended &amp;lt;weight&amp;gt;] [--fitModel] [--fast] [--keepPrevDbsnp] [--keepPrevNonAdjacent] [--useLogReg] [--qualField &amp;lt;tag&amp;gt;] [--storeQualTag &amp;lt;tag&amp;gt;] [--buildExcludeFlags &amp;lt;flag&amp;gt;] [--applyExcludeFlags &amp;lt;flag&amp;gt;]&lt;br /&gt;
&lt;br /&gt;
= Parameters =&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Required General Parameters :&lt;br /&gt;
        --in &amp;lt;infile&amp;gt;   : input BAM file name&lt;br /&gt;
        --out &amp;lt;outfile&amp;gt; : output recalibration file name&lt;br /&gt;
Optional General Parameters :&lt;br /&gt;
        --log &amp;lt;logfile&amp;gt; : log and summary statistics (default: [outfile].log)&lt;br /&gt;
        --verbose       : Turn on verbose mode&lt;br /&gt;
        --noeof         : do not expect an EOF block on a bam file.&lt;br /&gt;
        --params        : print the parameter settings&lt;br /&gt;
&lt;br /&gt;
Recab Specific Required Parameters&lt;br /&gt;
        --refFile &amp;lt;reference file&amp;gt;    : reference file name&lt;br /&gt;
Recab Specific Optional Parameters :&lt;br /&gt;
        --dbsnp &amp;lt;known variance file&amp;gt; : dbsnp file of positions&lt;br /&gt;
        --minBaseQual &amp;lt;minBaseQual&amp;gt;   : minimum base quality of bases to recalibrate (default: 5)&lt;br /&gt;
        --maxBaseQual &amp;lt;maxBaseQual&amp;gt;   : maximum recalibrated base quality (default: 50)&lt;br /&gt;
                                        qualities over this value will be set to this value.&lt;br /&gt;
                                        This setting is applied after binning (if applicable).&lt;br /&gt;
        --blended &amp;lt;weight&amp;gt;            : blended model weight&lt;br /&gt;
        --fitModel                    : check if the logistic regression model fits the data&lt;br /&gt;
                                        overriden by fast, but automatically applied by useLogReg&lt;br /&gt;
        --fast                        : use a compact representation that only allows:&lt;br /&gt;
                                           * at most 256 Read Groups&lt;br /&gt;
                                           * maximum quality 63&lt;br /&gt;
                                           * at most 127 cycles&lt;br /&gt;
                                        overrides fitModel, but is overridden by useLogReg&lt;br /&gt;
                                        uses up to about 2.25G more memory than running without --fast.&lt;br /&gt;
        --keepPrevDbsnp               : do not exclude entries where the previous base is in dbsnp when&lt;br /&gt;
                                        building the recalibration table&lt;br /&gt;
                                        By default they are excluded from the table.&lt;br /&gt;
        --keepPrevNonAdjacent         : do not exclude entries where the previous base is not adjacent&lt;br /&gt;
                                        (not a Cigar M/X/=) when building the recalibration table&lt;br /&gt;
                                        By default they are excluded from the table (except the first cycle).&lt;br /&gt;
        --useLogReg                   : use logistic regression calculated quality for the new quality&lt;br /&gt;
                                        automatically applies fitModel and overrides fast.&lt;br /&gt;
        --qualField &amp;lt;quality tag&amp;gt;     : tag to get the starting base quality&lt;br /&gt;
                                        (default is to get it from the Quality field)&lt;br /&gt;
        --storeQualTag &amp;lt;quality tag&amp;gt;  : tag to store the previous quality into&lt;br /&gt;
        --buildExcludeFlags &amp;lt;flag&amp;gt;    : exclude reads with any of these flags set when building the&lt;br /&gt;
                                        recalibration table.  Default is 0xF04&lt;br /&gt;
        --applyExcludeFlags &amp;lt;flag&amp;gt;    : do not apply the recalibration table to any reads with any of these flags set&lt;br /&gt;
        Quality Binning Parameters (optional):&lt;br /&gt;
          Bin qualities by phred score, into the ranges specified by binQualS or binQualF (both cannot be used)&lt;br /&gt;
          Ranges are specified by comma separated minimum phred score for the bin, example: 1,17,20,30,40,50,70&lt;br /&gt;
          The first bin always starts at 0, so does not need to be specified.&lt;br /&gt;
          By default, the bin value is the low end of the range.&lt;br /&gt;
                --binQualS   : Bin the Qualities as specified (phred): minQualOfBin2, minQualofBin3...&lt;br /&gt;
                --binQualF   : Bin the Qualities based on the specified file&lt;br /&gt;
                --binMid     : Use the mid point of the quality bin range for the quality value of the bin.&lt;br /&gt;
                --binHigh    : Use the high end of the quality bin range for the quality value of the bin.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
{{PhoneHomeParamDesc}}&lt;br /&gt;
&lt;br /&gt;
== Required Generic Parameters ==&lt;br /&gt;
{{inBAMInputFile}}&lt;br /&gt;
{{outBAMOutputFile}}&lt;br /&gt;
&lt;br /&gt;
== Optional Generic Parameters ==&lt;br /&gt;
=== Output log &amp;amp; Summary Statistics FileName (&amp;lt;code&amp;gt;--log&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
Output file name for writing logs &amp;amp; summary statistics.&lt;br /&gt;
&lt;br /&gt;
If this parameter is not specified, it will write to the output file specified in &amp;lt;code&amp;gt;--out&amp;lt;/code&amp;gt; + &amp;quot;.log&amp;quot;.  Or if the output bam is written to stdout (&amp;lt;code&amp;gt;--out&amp;lt;/code&amp;gt; starts with &#039;-&#039;), the logs will be written to stderr.  If the filename after --log starts with &#039;-&#039; it will write to stderr.&lt;br /&gt;
&lt;br /&gt;
=== Turn on Verbose Mode (&amp;lt;code&amp;gt;--verbose&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
Turn on verbose logging to get more log messages in the log and to stderr.&lt;br /&gt;
&lt;br /&gt;
{{noeofBGZFParameter}}&lt;br /&gt;
{{paramsParameter}}&lt;br /&gt;
&lt;br /&gt;
{{PhoneHomeParameters}}&lt;br /&gt;
&lt;br /&gt;
== Required Recalibration Parameters ==&lt;br /&gt;
=== Reference File (&amp;lt;code&amp;gt;--refFile&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
The reference file is a required parameter used for comparing read bases to the reference.&lt;br /&gt;
&lt;br /&gt;
== Optional Recalibration Parameters ==&lt;br /&gt;
&lt;br /&gt;
=== DBSNP File (&amp;lt;code&amp;gt;--dbsnp&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
The dbsnp file that specifies positions to skip recalibrating.  Tab delimited file with the chromosome in the first column and the 1-based position in the 2nd column.&lt;br /&gt;
&lt;br /&gt;
=== Minimum Recalibration Base Quality (&amp;lt;code&amp;gt;--minBaseQual&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
When recalibrating reads, only positions with a base quality greater than this minimum phred quality will be recalibrated.  If &amp;lt;code&amp;gt;--minBaseQual&amp;lt;/code&amp;gt; is not specified, it is defaulted to 5. &lt;br /&gt;
&lt;br /&gt;
The ILLUMINA specs indicate that any quality below 5 can be used as an error indicator so we do not want to recalibrate those.&lt;br /&gt;
&lt;br /&gt;
=== Maximum Recalibration Base Quality (&amp;lt;code&amp;gt;--maxBaseQual&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
This value sets the maximum phred base quality assigned to a base after recalibrating. Any qualities above this value will be set to this value.  It is defaulted to 50. &lt;br /&gt;
&lt;br /&gt;
=== Blended Model Weight (&amp;lt;code&amp;gt;--blended&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;TBD - this parameter is not yet implemented.&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Fit Model (&amp;lt;code&amp;gt;--fitModel&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
Check if the logistic regression model fits the data.&lt;br /&gt;
&lt;br /&gt;
This option does NOT set the new qualities to the logistic regression calculated qualities, it only checks the fit.  To apply the logistic regression qualities, see [[#Logistic Regression (--useLogReg)|&amp;lt;code&amp;gt;--useLogReg&amp;lt;/code&amp;gt;]].  &amp;lt;code&amp;gt;--fitModel&amp;lt;/code&amp;gt; is automatically applied when &amp;lt;code&amp;gt;--useLogReg&amp;lt;/code&amp;gt; is specified.&lt;br /&gt;
	                               &lt;br /&gt;
This option cannot be used in conjunction with [[#Fast Recalibration (--fast)|&amp;lt;code&amp;gt;--fast&amp;lt;/code&amp;gt;]] and is overriden by &amp;lt;code&amp;gt;--fast&amp;lt;/code&amp;gt;, but automatically applied by useLogReg&lt;br /&gt;
&lt;br /&gt;
=== Fast Recalibration (&amp;lt;code&amp;gt;--fast&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
Use a compact representation of the Recalibration Table that only allows:&lt;br /&gt;
* at most 256 Read Groups&lt;br /&gt;
* maximum quality 63&lt;br /&gt;
* at most 127 cycles&lt;br /&gt;
&lt;br /&gt;
This option will run faster than the default recalibration, but uses up to about 2.25G more memory than running without --fast.&lt;br /&gt;
&lt;br /&gt;
This option cannot be used in conjunction with [[#Fit Model (--fitModel)|&amp;lt;code&amp;gt;--fitModel&amp;lt;/code&amp;gt;]], or [[#Logistic Regression (--useLogReg)|&amp;lt;code&amp;gt;--useLogReg&amp;lt;/code&amp;gt;]] and overrides [[#Fit Model (--fitModel)|&amp;lt;code&amp;gt;--fitModel&amp;lt;/code&amp;gt;]], but is overridden by [[#Logistic Regression (--useLogReg)|&amp;lt;code&amp;gt;--useLogReg&amp;lt;/code&amp;gt;]].&lt;br /&gt;
&lt;br /&gt;
=== Allow Previous Base DBSNP (&amp;lt;code&amp;gt;--keepPrevDbsnp&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
By default bases where the previous base is in DBSNP are excluded from the Recalibration Table.&lt;br /&gt;
&lt;br /&gt;
This option includes these bases in the building of the Recalibration Table.&lt;br /&gt;
&lt;br /&gt;
=== Allow Previous Base Non-Match/Mismatch (&amp;lt;code&amp;gt;--keepPrevNonAdjacent&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
By default bases where the previous base is not a CIGAR Match/Mismatch are excluded from the Recalibration Table.&lt;br /&gt;
&lt;br /&gt;
This option includes these bases in the building of the Recalibration Table.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Logistic Regression (&amp;lt;code&amp;gt;--useLogReg&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
Use the logistic regression empirical qualities for setting the new base qualities instead of the default formula.&lt;br /&gt;
&lt;br /&gt;
This option automatically enables [[#Fit Model (--fitModel)|&amp;lt;code&amp;gt;--fitModel&amp;lt;/code&amp;gt;]] and disables [[#Fast Recalibration (--fast)|&amp;lt;code&amp;gt;--fast&amp;lt;/code&amp;gt;]].&lt;br /&gt;
&lt;br /&gt;
=== Read the quality from a tag (&amp;lt;code&amp;gt;--qualField&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
If this parameter is set, then read the quality string from the specified tag name.  If the tag is not found, the quality is read from the quality field.&lt;br /&gt;
&lt;br /&gt;
=== Store the original quality (&amp;lt;code&amp;gt;--storeQualTag&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
If this parameter is set, the original quality will be stored as a string in the specified tag.&lt;br /&gt;
&lt;br /&gt;
=== Skip Records with any of the Specified Flags (&amp;lt;code&amp;gt;--buildExcludeFlags&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;--applyExcludeFlags&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
Use &amp;lt;code&amp;gt;--buildExcludeFlags&amp;lt;/code&amp;gt; to skip records with any of the specified flags set when building the recalibration table, default 0xF04.&lt;br /&gt;
&lt;br /&gt;
By default, when building the recalibration table reads with any of the following flags set are skipped:&lt;br /&gt;
* unmapped&lt;br /&gt;
* secondary alignment&lt;br /&gt;
* fails QC checks&lt;br /&gt;
* duplicate&lt;br /&gt;
* supplementary alignment&lt;br /&gt;
&lt;br /&gt;
Use &amp;lt;code&amp;gt;--applyExcludeFlags&amp;lt;/code&amp;gt; to skip records with any of the specified flags set when applying the recalibration table.  The default value is 0x000, do not skip any reads.&lt;br /&gt;
&lt;br /&gt;
= Return Value =&lt;br /&gt;
&lt;br /&gt;
Returns -1 if input parameters are invalid.&lt;br /&gt;
&lt;br /&gt;
Returns the SamStatus for the reads/writes (0 on success, non-0 on failure).&lt;/div&gt;</summary>
		<author><name>Mktrost</name></author>
	</entry>
	<entry>
		<id>http://genome.sph.umich.edu/w/index.php?title=BamUtil:_recab&amp;diff=14126</id>
		<title>BamUtil: recab</title>
		<link rel="alternate" type="text/html" href="http://genome.sph.umich.edu/w/index.php?title=BamUtil:_recab&amp;diff=14126"/>
		<updated>2016-03-06T05:07:51Z</updated>

		<summary type="html">&lt;p&gt;Mktrost: /* Skip Records with any of the Specified Flags (--buildExcludeFlags, --applyExcludeFlags) */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:BamUtil|validate]]&lt;br /&gt;
[[Category:BAM Software]]&lt;br /&gt;
[[Category:Software]]&lt;br /&gt;
&lt;br /&gt;
= Overview of the &amp;lt;code&amp;gt;recab&amp;lt;/code&amp;gt; function of &amp;lt;code&amp;gt;[[bamUtil]]&amp;lt;/code&amp;gt; =&lt;br /&gt;
The &amp;lt;code&amp;gt;recab&amp;lt;/code&amp;gt; option of [[bamUtil]] recalibrates a SAM/BAM file. &lt;br /&gt;
&lt;br /&gt;
Recalibration can also be called as an option of [[bamUtil: dedup]].  This will perform the recalibration and  the deduping in the same set of steps, increasing processing speed.&lt;br /&gt;
&lt;br /&gt;
==Handling Recalibration/Implementation Notes==&lt;br /&gt;
&lt;br /&gt;
Recalibration is a 2-step process that loops through the file twice:&lt;br /&gt;
# Build Recalibration Table&lt;br /&gt;
# Apply Recalibration Table&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Recalibration Table groups bases based on a set of covariates:&lt;br /&gt;
* Read Group&lt;br /&gt;
* Quality (either from the quality string or [[#Read the quality from a tag (--qualField)|from a tag]])&lt;br /&gt;
* Cycle (reverse complement for reverse strands)&lt;br /&gt;
* 1st/2nd read in pair&lt;br /&gt;
* Previous Cycle&#039;s Base (reverse complement for reverse strands)&lt;br /&gt;
* This Cycle&#039;s Base (reverse complement for reverse strands)&lt;br /&gt;
&lt;br /&gt;
The Recalibration Table tracks the number of matches/mismatches for each set of covariates.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Only bases meeting all of the following criteria are used to Build the Recalibration Table:&lt;br /&gt;
* Read criteria&lt;br /&gt;
** not a duplicate&lt;br /&gt;
** mapped&lt;br /&gt;
** mapping quality != 0&lt;br /&gt;
** mapping quality != 255&lt;br /&gt;
* Base criteria&lt;br /&gt;
** match/mismatch (not an insertion/deletion/skip/clip)&lt;br /&gt;
** not a [[#DBSNP File (--dbsnp)|dbSNP position]]&lt;br /&gt;
** base quality &amp;gt; [[#Minimum Recalibration Base Quality (--minBaseQual)|minBaseQual (5 by default)]]&lt;br /&gt;
* Additional criteria for cycle != 1 (can be turned off via flags)&lt;br /&gt;
** previous base is a CIGAR Match/Mismatch (Use [[#Allow Previous Base Non-Match/Mismatch (--keepPrevNonAdjacent)|&amp;lt;code&amp;gt;--keepPrevNonAdjacent&amp;lt;/code&amp;gt;]] to disable)&lt;br /&gt;
** previous base position is not a [[#DBSNP File (--dbsnp)|dbSNP position]] (Use [[#Allow Previous Base DBSNP (--keepPrevDbsnp)|&amp;lt;code&amp;gt;--keepPrevDbsnp&amp;lt;/code&amp;gt;]] to disable)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Recalibration Table is applied to all bases meeting all of the following criteria (even if they were not used for creating the table):&lt;br /&gt;
* base quality &amp;gt; [[#Minimum Recalibration Base Quality (--minBaseQual)|minBaseQual (5 by default)]]&lt;br /&gt;
* at least 1 match or mismatch for the set of covariates&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Recalibrated Quality is: &amp;lt;math&amp;gt;-10 * \log \frac{mismatches + 1}{mismatches + matches + 1}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Alternatively, [[#Logistic Regression (--useLogReg)|logistic regression]] can be used for calculating the new quality.&lt;br /&gt;
&lt;br /&gt;
If the Recalibrated Quality is greater than [[#Maximum Recalibration Base Quality (--maxBaseQual)|maxBaseQual]], the updated quality is set to maxBaseQual.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Optionally, the previous quality can be [[#Store the original quality (--storeQualTag)|stored in a tag]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The current recalibration logic was designed for recalibrating ILLUMINA data.&lt;br /&gt;
&lt;br /&gt;
NOTE: GATK ignores/skips adapters, but our logic does not.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== How to use it ==&lt;br /&gt;
&lt;br /&gt;
When &amp;lt;code&amp;gt;recab&amp;lt;/code&amp;gt; is invoked without any arguments the usage information is displayed as described below under [[#Usage|Usage]].&lt;br /&gt;
&lt;br /&gt;
The input SAM/BAM file ([[#input File (--in)|--in]]), the output SAM/BAM file ([[#output File (--out)|--out]]), and the reference file ([[#Reference File (--refFile)|--refFile]]) are required inputs.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Recommended usage with Deduper: &lt;br /&gt;
&lt;br /&gt;
 /usr/cluster/bin/bam dedup --recab --in ${INPUT}.bam --out ${OUTPUT}.bam --force --refFile ${REF} --dbsnp ${DBSNP} --oneChrom --storeQualTag OQ --maxBaseQual 40&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Recommended usage without Deduper: &lt;br /&gt;
&lt;br /&gt;
 /usr/cluster/bin/bam recab --in ${INPUT}.bam --out ${OUTPUT}.bam --refFile ${REF} --dbsnp ${DBSNP} --storeQualTag OQ --maxBaseQual 40&lt;br /&gt;
&lt;br /&gt;
= Usage =&lt;br /&gt;
 ./bam recab (options) --in &amp;lt;InputBamFile&amp;gt; --out &amp;lt;OutputFile&amp;gt; [--log &amp;lt;logFile&amp;gt;] [--verbose] [--noeof] [--params] --refFile &amp;lt;ReferenceFile&amp;gt; [--dbsnp &amp;lt;dbsnpFile&amp;gt;] [--minBaseQual &amp;lt;minBaseQual&amp;gt;] [--maxBaseQual &amp;lt;maxBaseQual&amp;gt;] [--blended &amp;lt;weight&amp;gt;] [--fitModel] [--fast] [--keepPrevDbsnp] [--keepPrevNonAdjacent] [--useLogReg] [--qualField &amp;lt;tag&amp;gt;] [--storeQualTag &amp;lt;tag&amp;gt;] [--buildExcludeFlags &amp;lt;flag&amp;gt;] [--applyExcludeFlags &amp;lt;flag&amp;gt;]&lt;br /&gt;
&lt;br /&gt;
= Parameters =&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Required General Parameters :&lt;br /&gt;
	--in &amp;lt;infile&amp;gt;   : input BAM file name&lt;br /&gt;
	--out &amp;lt;outfile&amp;gt; : output recalibration file name&lt;br /&gt;
Optional General Parameters : &lt;br /&gt;
	--log &amp;lt;logfile&amp;gt; : log and summary statistics (default: [outfile].log)&lt;br /&gt;
	--verbose       : Turn on verbose mode&lt;br /&gt;
	--noeof         : do not expect an EOF block on a bam file.&lt;br /&gt;
	--params        : print the parameter settings&lt;br /&gt;
&lt;br /&gt;
Recab Specific Required Parameters&lt;br /&gt;
	--refFile &amp;lt;reference file&amp;gt;    : reference file name&lt;br /&gt;
Recab Specific Optional Parameters : &lt;br /&gt;
	--dbsnp &amp;lt;known variance file&amp;gt; : dbsnp file of positions&lt;br /&gt;
	--minBaseQual &amp;lt;minBaseQual&amp;gt;   : minimum base quality of bases to recalibrate (default: 5)&lt;br /&gt;
	--maxBaseQual &amp;lt;maxBaseQual&amp;gt;   : maximum recalibrated base quality (default: 50)&lt;br /&gt;
	--blended &amp;lt;weight&amp;gt;            : blended model weight&lt;br /&gt;
	--fitModel                    : check if the logistic regression model fits the data&lt;br /&gt;
	                                overriden by fast, but automatically applied by useLogReg&lt;br /&gt;
	--fast                        : use a compact representation that only allows:&lt;br /&gt;
	                                   * at most 256 Read Groups&lt;br /&gt;
	                                   * maximum quality 63&lt;br /&gt;
	                                   * at most 127 cycles&lt;br /&gt;
	                                overrides fitModel, but is overridden by useLogReg&lt;br /&gt;
	                                uses up to about 2.25G more memory than running without --fast.&lt;br /&gt;
	--keepPrevDbsnp               : do not exclude entries where the previous base is in dbsnp when&lt;br /&gt;
	                                building the recalibration table&lt;br /&gt;
	                                By default they are excluded from the table.&lt;br /&gt;
	--keepPrevNonAdjacent         : do not exclude entries where the previous base is not adjacent&lt;br /&gt;
	                                (not a Cigar M/X/=) when building the recalibration table&lt;br /&gt;
	                                By default they are excluded from the table (except the first cycle).&lt;br /&gt;
	--useLogReg                   : use logistic regression calculated quality for the new quality&lt;br /&gt;
	                                automatically applies fitModel and overrides fast.&lt;br /&gt;
	--qualField &amp;lt;quality tag&amp;gt;     : tag to get the starting base quality&lt;br /&gt;
	                                (default is to get it from the Quality field)&lt;br /&gt;
	--storeQualTag &amp;lt;quality tag&amp;gt;  : tag to store the previous quality into&lt;br /&gt;
	--buildExcludeFlags &amp;lt;flag&amp;gt;    : exclude reads with any of these flags set when building the&lt;br /&gt;
	                                recalibration table&lt;br /&gt;
	--applyExcludeFlags &amp;lt;flag&amp;gt;    : do not apply the recalibration table to any reads with any of these flags set&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
{{PhoneHomeParamDesc}}&lt;br /&gt;
&lt;br /&gt;
== Required Generic Parameters ==&lt;br /&gt;
{{inBAMInputFile}}&lt;br /&gt;
{{outBAMOutputFile}}&lt;br /&gt;
&lt;br /&gt;
== Optional Generic Parameters ==&lt;br /&gt;
=== Output log &amp;amp; Summary Statistics FileName (&amp;lt;code&amp;gt;--log&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
Output file name for writing logs &amp;amp; summary statistics.&lt;br /&gt;
&lt;br /&gt;
If this parameter is not specified, it will write to the output file specified in &amp;lt;code&amp;gt;--out&amp;lt;/code&amp;gt; + &amp;quot;.log&amp;quot;.  Or if the output bam is written to stdout (&amp;lt;code&amp;gt;--out&amp;lt;/code&amp;gt; starts with &#039;-&#039;), the logs will be written to stderr.  If the filename after --log starts with &#039;-&#039; it will write to stderr.&lt;br /&gt;
&lt;br /&gt;
=== Turn on Verbose Mode (&amp;lt;code&amp;gt;--verbose&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
Turn on verbose logging to get more log messages in the log and to stderr.&lt;br /&gt;
&lt;br /&gt;
{{noeofBGZFParameter}}&lt;br /&gt;
{{paramsParameter}}&lt;br /&gt;
&lt;br /&gt;
{{PhoneHomeParameters}}&lt;br /&gt;
&lt;br /&gt;
== Required Recalibration Parameters ==&lt;br /&gt;
=== Reference File (&amp;lt;code&amp;gt;--refFile&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
The reference file is a required parameter used for comparing read bases to the reference.&lt;br /&gt;
&lt;br /&gt;
== Optional Recalibration Parameters ==&lt;br /&gt;
&lt;br /&gt;
=== DBSNP File (&amp;lt;code&amp;gt;--dbsnp&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
The dbsnp file that specifies positions to skip recalibrating.  Tab delimited file with the chromosome in the first column and the 1-based position in the 2nd column.&lt;br /&gt;
&lt;br /&gt;
=== Minimum Recalibration Base Quality (&amp;lt;code&amp;gt;--minBaseQual&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
When recalibrating reads, only positions with a base quality greater than this minimum phred quality will be recalibrated.  If &amp;lt;code&amp;gt;--minBaseQual&amp;lt;/code&amp;gt; is not specified, it is defaulted to 5. &lt;br /&gt;
&lt;br /&gt;
The ILLUMINA specs indicate that any quality below 5 can be used as an error indicator so we do not want to recalibrate those.&lt;br /&gt;
&lt;br /&gt;
=== Maximum Recalibration Base Quality (&amp;lt;code&amp;gt;--maxBaseQual&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
This value sets the maximum phred base quality assigned to a base after recalibrating. Any qualities above this value will be set to this value.  It is defaulted to 50. &lt;br /&gt;
&lt;br /&gt;
=== Blended Model Weight (&amp;lt;code&amp;gt;--blended&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;TBD - this parameter is not yet implemented.&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Fit Model (&amp;lt;code&amp;gt;--fitModel&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
Check if the logistic regression model fits the data.&lt;br /&gt;
&lt;br /&gt;
This option does NOT set the new qualities to the logistic regression calculated qualities, it only checks the fit.  To apply the logistic regression qualities, see [[#Logistic Regression (--useLogReg)|&amp;lt;code&amp;gt;--useLogReg&amp;lt;/code&amp;gt;]].  &amp;lt;code&amp;gt;--fitModel&amp;lt;/code&amp;gt; is automatically applied when &amp;lt;code&amp;gt;--useLogReg&amp;lt;/code&amp;gt; is specified.&lt;br /&gt;
	                               &lt;br /&gt;
This option cannot be used in conjunction with [[#Fast Recalibration (--fast)|&amp;lt;code&amp;gt;--fast&amp;lt;/code&amp;gt;]] and is overriden by &amp;lt;code&amp;gt;--fast&amp;lt;/code&amp;gt;, but automatically applied by useLogReg&lt;br /&gt;
&lt;br /&gt;
=== Fast Recalibration (&amp;lt;code&amp;gt;--fast&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
Use a compact representation of the Recalibration Table that only allows:&lt;br /&gt;
* at most 256 Read Groups&lt;br /&gt;
* maximum quality 63&lt;br /&gt;
* at most 127 cycles&lt;br /&gt;
&lt;br /&gt;
This option will run faster than the default recalibration, but uses up to about 2.25G more memory than running without --fast.&lt;br /&gt;
&lt;br /&gt;
This option cannot be used in conjunction with [[#Fit Model (--fitModel)|&amp;lt;code&amp;gt;--fitModel&amp;lt;/code&amp;gt;]], or [[#Logistic Regression (--useLogReg)|&amp;lt;code&amp;gt;--useLogReg&amp;lt;/code&amp;gt;]] and overrides [[#Fit Model (--fitModel)|&amp;lt;code&amp;gt;--fitModel&amp;lt;/code&amp;gt;]], but is overridden by [[#Logistic Regression (--useLogReg)|&amp;lt;code&amp;gt;--useLogReg&amp;lt;/code&amp;gt;]].&lt;br /&gt;
&lt;br /&gt;
=== Allow Previous Base DBSNP (&amp;lt;code&amp;gt;--keepPrevDbsnp&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
By default bases where the previous base is in DBSNP are excluded from the Recalibration Table.&lt;br /&gt;
&lt;br /&gt;
This option includes these bases in the building of the Recalibration Table.&lt;br /&gt;
&lt;br /&gt;
=== Allow Previous Base Non-Match/Mismatch (&amp;lt;code&amp;gt;--keepPrevNonAdjacent&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
By default bases where the previous base is not a CIGAR Match/Mismatch are excluded from the Recalibration Table.&lt;br /&gt;
&lt;br /&gt;
This option includes these bases in the building of the Recalibration Table.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Logistic Regression (&amp;lt;code&amp;gt;--useLogReg&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
Use the logistic regression empirical qualities for setting the new base qualities instead of the default formula.&lt;br /&gt;
&lt;br /&gt;
This option automatically enables [[#Fit Model (--fitModel)|&amp;lt;code&amp;gt;--fitModel&amp;lt;/code&amp;gt;]] and disables [[#Fast Recalibration (--fast)|&amp;lt;code&amp;gt;--fast&amp;lt;/code&amp;gt;]].&lt;br /&gt;
&lt;br /&gt;
=== Read the quality from a tag (&amp;lt;code&amp;gt;--qualField&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
If this parameter is set, then read the quality string from the specified tag name.  If the tag is not found, the quality is read from the quality field.&lt;br /&gt;
&lt;br /&gt;
=== Store the original quality (&amp;lt;code&amp;gt;--storeQualTag&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
If this parameter is set, the original quality will be stored as a string in the specified tag.&lt;br /&gt;
&lt;br /&gt;
=== Skip Records with any of the Specified Flags (&amp;lt;code&amp;gt;--buildExcludeFlags&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;--applyExcludeFlags&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
Use &amp;lt;code&amp;gt;--buildExcludeFlags&amp;lt;/code&amp;gt; to skip records with any of the specified flags set when building the recalibration table, default 0xF04.&lt;br /&gt;
&lt;br /&gt;
By default, when building the recalibration table reads with any of the following flags set are skipped:&lt;br /&gt;
* unmapped&lt;br /&gt;
* secondary alignment&lt;br /&gt;
* fails QC checks&lt;br /&gt;
* duplicate&lt;br /&gt;
* supplementary alignment&lt;br /&gt;
&lt;br /&gt;
Use &amp;lt;code&amp;gt;--applyExcludeFlags&amp;lt;/code&amp;gt; to skip records with any of the specified flags set when applying the recalibration table.  The default value is 0x000, do not skip any reads.&lt;br /&gt;
&lt;br /&gt;
= Return Value =&lt;br /&gt;
&lt;br /&gt;
Returns -1 if input parameters are invalid.&lt;br /&gt;
&lt;br /&gt;
Returns the SamStatus for the reads/writes (0 on success, non-0 on failure).&lt;/div&gt;</summary>
		<author><name>Mktrost</name></author>
	</entry>
	<entry>
		<id>http://genome.sph.umich.edu/w/index.php?title=BamUtil:_dedup&amp;diff=14125</id>
		<title>BamUtil: dedup</title>
		<link rel="alternate" type="text/html" href="http://genome.sph.umich.edu/w/index.php?title=BamUtil:_dedup&amp;diff=14125"/>
		<updated>2016-03-06T04:45:48Z</updated>

		<summary type="html">&lt;p&gt;Mktrost: /* Skip Records with any of the Specified Flags (--excludeFlags) */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:BamUtil|validate]]&lt;br /&gt;
[[Category:BAM Software]]&lt;br /&gt;
[[Category:Software]]&lt;br /&gt;
&lt;br /&gt;
= Overview of the &amp;lt;code&amp;gt;dedup&amp;lt;/code&amp;gt; function of &amp;lt;code&amp;gt;[[bamUtil]]&amp;lt;/code&amp;gt; =&lt;br /&gt;
The &amp;lt;code&amp;gt;dedup&amp;lt;/code&amp;gt; option of [[bamUtil]] determines duplicates in a coordinate sorted SAM/BAM file. It either marks or removes the lower quality duplicates.&lt;br /&gt;
&lt;br /&gt;
This tool also contains the option to perform recalibration.&lt;br /&gt;
&lt;br /&gt;
NOTE: This tool does not properly work on templates that have more than 2 segments.  It does not properly match reads when more than 2 reads have the same read name.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Potential future features:&lt;br /&gt;
* Soft clip overlapping reads (for now, use: [[BamUtil: clipOverlap]])&lt;br /&gt;
&lt;br /&gt;
==Handling Duplicates==&lt;br /&gt;
&lt;br /&gt;
The deduper reads all the alignments in a coordinate-sorted SAM/BAM looking for duplicates, failing if the file is not coordinate-sorted.&lt;br /&gt;
&lt;br /&gt;
The deduper assumes that duplicates in the input BAM file are not marked.  When the deduper detects a marked duplicate in the input BAM file, it will throw an error and stop.  To override this behavior, use the [[#Ignore Previous Duplicate Marking (--force)|&amp;lt;code&amp;gt;--force&amp;lt;/code&amp;gt;]] option;  in this mode, alignments that are marked as duplicates in the input file are unmarked before the deduper begins its detection algorithm.  The result is that only duplicates detected by the deduper will be marked in or removed from the output file.&lt;br /&gt;
&lt;br /&gt;
The handling of paired-end reads assumes that the mate information in the SAM/BAM records is accurate.  If a mate is not found at the expected position, an error message is printed (once per file) indicating this error.  Paired-end reads whose mate cannot be found are not marked duplicate and are not used for duplicate marking of other paired-end reads.  Single-end reads with the same key as paired-end reads whose mate cannot be found are still marked as duplicate.  If this error is encountered, you may want to fix the mate information and reprocess the file through the deduper.  &lt;br /&gt;
&lt;br /&gt;
With the default settings this tool should produce similar results as Picard.&lt;br /&gt;
&lt;br /&gt;
Use the [[#Treat Reads with Mates On Different Chromosomes As Single-Ended (--oneChrom)|&amp;lt;code&amp;gt;--oneChrom&amp;lt;/code&amp;gt;]] option to treat reads with a mate on a different chromosome as single-ended.  This option is useful if you are running the deduper on just a single chromosome.  The code will use less memory with this option if mates are found on different chromosomes.  (Picard does not specially handle mates on different chromosomes, so the --oneChrom option may produce different results than Picard.)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Implementation Notes ===&lt;br /&gt;
Duplicates are determined by checking for matching keys.  &lt;br /&gt;
&lt;br /&gt;
The Key is comprised of:&lt;br /&gt;
# Chromosome&lt;br /&gt;
# Orientation (forward/reverse)&lt;br /&gt;
# Unclipped Start(forward)/End(reverse)&lt;br /&gt;
# Library&lt;br /&gt;
&lt;br /&gt;
Rules:&lt;br /&gt;
* Skip Unmapped Reads, they are not marked as duplicate&lt;br /&gt;
* Mark a Single-End Read Duplicate (or remove it if configured to do so) if:&lt;br /&gt;
*# A paired-end record has the same key (even if the pair is not proper/the mate is unmapped/the mate is not found)&amp;lt;br/&amp;gt;-OR-&lt;br /&gt;
*# A single-end record has the same key and a higher base quality sum (sum of all base qualities in the record above [[#Minimum Quality for Quality Calculations (--minQual)|&amp;lt;code&amp;gt;--minBaseQual&amp;lt;/code&amp;gt;]])&lt;br /&gt;
* Mark both Paired-End Reads Duplicate if:&lt;br /&gt;
# Another paired-end pair has the same set of keys and has a higher base quality sum (sum of all base qualities in the record above [[#Minimum Quality for Quality Calculations (--minQual)|&amp;lt;code&amp;gt;--minBaseQual&amp;lt;/code&amp;gt;]])&lt;br /&gt;
 &lt;br /&gt;
This code assumes that at most 1000 bases are clipped at the start of a read.&lt;br /&gt;
&lt;br /&gt;
==Handling Recalibration==&lt;br /&gt;
See [[BamUtil: recab]] for recalibration details.&lt;br /&gt;
&lt;br /&gt;
Recalibration parameters can be applied to deduping when --recab is specified.&lt;br /&gt;
&lt;br /&gt;
== How to use it ==&lt;br /&gt;
&lt;br /&gt;
When &amp;lt;code&amp;gt;dedup&amp;lt;/code&amp;gt; is invoked without any arguments the usage information is displayed as described below under [[#Usage|Usage]].&lt;br /&gt;
&lt;br /&gt;
The input SAM/BAM file is required, [[#input File (--in)|input File (--in)]], and must be sorted by coordinate.&lt;br /&gt;
&lt;br /&gt;
The output SAM/BAM file is also required, [[#output File (--out)|output File (--out)]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Recommended usage with Recalibrator: &lt;br /&gt;
&lt;br /&gt;
 /usr/cluster/bin/bam dedup --recab --in ${INPUT}.bam --out ${OUTPUT}.bam --force --refFile ${REF} --dbsnp ${DBSNP} --oneChrom --storeQualTag OQ --maxBaseQual 40&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Recommended usage without Recalibrator: &lt;br /&gt;
&lt;br /&gt;
 /usr/cluster/bin/bam dedup --in ${INPUT}.bam --out ${OUTPUT}.bam --force --oneChrom&lt;br /&gt;
&lt;br /&gt;
= Usage =&lt;br /&gt;
 ./bam dedup --in &amp;lt;InputBamFile&amp;gt; --out &amp;lt;OutputBamFile&amp;gt; [--minQual &amp;lt;minPhred&amp;gt;] [--log &amp;lt;logFile&amp;gt;] [--oneChrom] [--rmDups] [--force] [--excludeFlags &amp;lt;flag&amp;gt;] [--verbose] [--noeof] [--params] [--recab]&lt;br /&gt;
&lt;br /&gt;
Additional Recalibration Usage is documented at [[BamUtil: recab#Usage|BamUtil: recab -&amp;gt; Usage]]&lt;br /&gt;
&lt;br /&gt;
= Parameters =&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Required parameters :&lt;br /&gt;
	--in &amp;lt;infile&amp;gt;   : Input BAM file name (must be sorted)&lt;br /&gt;
	--out &amp;lt;outfile&amp;gt; : Output BAM file name (same order with original file)&lt;br /&gt;
Optional parameters : &lt;br /&gt;
	--minQual &amp;lt;int&amp;gt; : Only add scores over this phred quality when determining a read&#039;s quality (default: 15)&lt;br /&gt;
	--log &amp;lt;logfile&amp;gt; : Log and summary statistics (default: [outfile].log, or stderr if --out starts with &#039;-&#039;)&lt;br /&gt;
	--oneChrom      : Treat reads with mates on different chromosomes as single-ended.&lt;br /&gt;
	--rmDups        : Remove duplicates (default is to mark duplicates)&lt;br /&gt;
	--force         : Allow an already mark-duplicated BAM file, unmarking any previously marked &lt;br /&gt;
	                  duplicates and apply this duplicate marking logic.  Default is to throw errors&lt;br /&gt;
	                  and exit when trying to run on an already mark-duplicated BAM&lt;br /&gt;
	--excludeFlags &amp;lt;flag&amp;gt;    : exclude reads with any of these flags set when determining or marking duplicates&lt;br /&gt;
	                           by default (0xB04): exclude unmapped, secondary reads, QC failures, and supplementary reads&lt;br /&gt;
	--verbose       : Turn on verbose mode&lt;br /&gt;
	--noeof         : Do not expect an EOF block on a bam file.&lt;br /&gt;
	--params        : Print the parameter settings&lt;br /&gt;
	--recab         : Recalibrate in addition to deduping&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
{{PhoneHomeParamDesc}}&lt;br /&gt;
&lt;br /&gt;
Additional Recalibration Parameters are documented at [[BamUtil: recab#Parameters|BamUtil: recab -&amp;gt; Parameters]]&lt;br /&gt;
&lt;br /&gt;
== Required Parameters ==&lt;br /&gt;
{{inBAMInputFile}}&lt;br /&gt;
&lt;br /&gt;
Note: The input file must be sorted by coordinate.&lt;br /&gt;
{{outBAMOutputFile}}&lt;br /&gt;
&lt;br /&gt;
== Optional Parameters==&lt;br /&gt;
=== Minimum Quality for Quality Calculations (&amp;lt;code&amp;gt;--minQual&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
When duplicate reads are encountered, the read with the highest quality is kept.&lt;br /&gt;
&lt;br /&gt;
To determine the quality of a read, all of the phred base quality scores above the &amp;lt;code&amp;gt;--minQual&amp;lt;/code&amp;gt; value are added together.  If &amp;lt;code&amp;gt;--minQual&amp;lt;/code&amp;gt; is not specified, it is defaulted to 15.&lt;br /&gt;
&lt;br /&gt;
=== Output log &amp;amp; Summary Statistics FileName (&amp;lt;code&amp;gt;--log&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
Output file name for writing logs &amp;amp; summary statistics.&lt;br /&gt;
&lt;br /&gt;
If this parameter is not specified, it will write to the output file specified in &amp;lt;code&amp;gt;--out&amp;lt;/code&amp;gt; + &amp;quot;.log&amp;quot;.  Or if the output bam is written to stdout (&amp;lt;code&amp;gt;--out&amp;lt;/code&amp;gt; starts with &#039;-&#039;), the logs will be written to stderr.  If the filename after --log starts with &#039;-&#039; it will write to stderr.&lt;br /&gt;
&lt;br /&gt;
=== Treat Reads with Mates On Different Chromosomes As Single-Ended (&amp;lt;code&amp;gt;--oneChrom&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
If a read&#039;s mate is not found it will not be used for duplicate marking.  If you are running on a single chromosome, all read&#039;s whose mates are on different chromosomes will not be used for duplicate marking.  The &amp;lt;code&amp;gt;--oneChrom&amp;lt;/code&amp;gt; option will treat reads with mates on a different chromosome as single-ended.&lt;br /&gt;
&lt;br /&gt;
=== Remove Duplicates (&amp;lt;code&amp;gt;--rmDups&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
Instead of marking a read as duplicate in the flag, the &amp;lt;code&amp;gt;--rmDups&amp;lt;/code&amp;gt; option will remove it from the output BAM file.  &lt;br /&gt;
&lt;br /&gt;
=== Ignore Previous Duplicate Marking (&amp;lt;code&amp;gt;--force&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
By default the deduper will throw an error and stop if a read is already marked as duplicate.  The &amp;lt;code&amp;gt;--force&amp;lt;/code&amp;gt; option will removes any previous duplicate marking and marks the reads from scratch.  The resulting output file will only have reads determined by the deduper marked as duplicates.&lt;br /&gt;
&lt;br /&gt;
=== Skip Records with any of the Specified Flags (&amp;lt;code&amp;gt;--excludeFlags&amp;lt;/code&amp;gt;)===&lt;br /&gt;
Skip records with any of the specified flags set, default 0xB04&lt;br /&gt;
&lt;br /&gt;
By default skips reads with any of the following flags set:&lt;br /&gt;
* unmapped&lt;br /&gt;
* secondary alignment&lt;br /&gt;
* fails QC checks&lt;br /&gt;
* supplementary reads&lt;br /&gt;
&lt;br /&gt;
Secondary (0x100) and Supplementary (0x800) reads currently must be excluded.&lt;br /&gt;
&lt;br /&gt;
=== Turn on Verbose Mode (&amp;lt;code&amp;gt;--verbose&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
Turn on verbose logging to get more log messages in the log and to stderr.&lt;br /&gt;
&lt;br /&gt;
{{noeofBGZFParameter}}&lt;br /&gt;
{{paramsParameter}}&lt;br /&gt;
&lt;br /&gt;
== Recalibrate (&amp;lt;code&amp;gt;--recab&amp;lt;/code&amp;gt;) ==&lt;br /&gt;
&lt;br /&gt;
This option will recalibrate the input file in addition to deduping.&lt;br /&gt;
&lt;br /&gt;
See [[BamUtil: recab]] for recalibration details.&lt;br /&gt;
&lt;br /&gt;
{{PhoneHomeParameters}}&lt;br /&gt;
&lt;br /&gt;
= Return Value =&lt;br /&gt;
&lt;br /&gt;
Returns -1 if input parameters are invalid.&lt;br /&gt;
&lt;br /&gt;
Returns the SamStatus for the reads/writes (0 on success, non-0 on failure).&lt;/div&gt;</summary>
		<author><name>Mktrost</name></author>
	</entry>
	<entry>
		<id>http://genome.sph.umich.edu/w/index.php?title=BamUtil:_dedup&amp;diff=14124</id>
		<title>BamUtil: dedup</title>
		<link rel="alternate" type="text/html" href="http://genome.sph.umich.edu/w/index.php?title=BamUtil:_dedup&amp;diff=14124"/>
		<updated>2016-03-06T04:20:58Z</updated>

		<summary type="html">&lt;p&gt;Mktrost: /* Skip Records with any of the Specified Flags (--excludeFlags) */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:BamUtil|validate]]&lt;br /&gt;
[[Category:BAM Software]]&lt;br /&gt;
[[Category:Software]]&lt;br /&gt;
&lt;br /&gt;
= Overview of the &amp;lt;code&amp;gt;dedup&amp;lt;/code&amp;gt; function of &amp;lt;code&amp;gt;[[bamUtil]]&amp;lt;/code&amp;gt; =&lt;br /&gt;
The &amp;lt;code&amp;gt;dedup&amp;lt;/code&amp;gt; option of [[bamUtil]] determines duplicates in a coordinate sorted SAM/BAM file. It either marks or removes the lower quality duplicates.&lt;br /&gt;
&lt;br /&gt;
This tool also contains the option to perform recalibration.&lt;br /&gt;
&lt;br /&gt;
NOTE: This tool does not properly work on templates that have more than 2 segments.  It does not properly match reads when more than 2 reads have the same read name.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Potential future features:&lt;br /&gt;
* Soft clip overlapping reads (for now, use: [[BamUtil: clipOverlap]])&lt;br /&gt;
&lt;br /&gt;
==Handling Duplicates==&lt;br /&gt;
&lt;br /&gt;
The deduper reads all the alignments in a coordinate-sorted SAM/BAM looking for duplicates, failing if the file is not coordinate-sorted.&lt;br /&gt;
&lt;br /&gt;
The deduper assumes that duplicates in the input BAM file are not marked.  When the deduper detects a marked duplicate in the input BAM file, it will throw an error and stop.  To override this behavior, use the [[#Ignore Previous Duplicate Marking (--force)|&amp;lt;code&amp;gt;--force&amp;lt;/code&amp;gt;]] option;  in this mode, alignments that are marked as duplicates in the input file are unmarked before the deduper begins its detection algorithm.  The result is that only duplicates detected by the deduper will be marked in or removed from the output file.&lt;br /&gt;
&lt;br /&gt;
The handling of paired-end reads assumes that the mate information in the SAM/BAM records is accurate.  If a mate is not found at the expected position, an error message is printed (once per file) indicating this error.  Paired-end reads whose mate cannot be found are not marked duplicate and are not used for duplicate marking of other paired-end reads.  Single-end reads with the same key as paired-end reads whose mate cannot be found are still marked as duplicate.  If this error is encountered, you may want to fix the mate information and reprocess the file through the deduper.  &lt;br /&gt;
&lt;br /&gt;
With the default settings this tool should produce similar results as Picard.&lt;br /&gt;
&lt;br /&gt;
Use the [[#Treat Reads with Mates On Different Chromosomes As Single-Ended (--oneChrom)|&amp;lt;code&amp;gt;--oneChrom&amp;lt;/code&amp;gt;]] option to treat reads with a mate on a different chromosome as single-ended.  This option is useful if you are running the deduper on just a single chromosome.  The code will use less memory with this option if mates are found on different chromosomes.  (Picard does not specially handle mates on different chromosomes, so the --oneChrom option may produce different results than Picard.)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Implementation Notes ===&lt;br /&gt;
Duplicates are determined by checking for matching keys.  &lt;br /&gt;
&lt;br /&gt;
The Key is comprised of:&lt;br /&gt;
# Chromosome&lt;br /&gt;
# Orientation (forward/reverse)&lt;br /&gt;
# Unclipped Start(forward)/End(reverse)&lt;br /&gt;
# Library&lt;br /&gt;
&lt;br /&gt;
Rules:&lt;br /&gt;
* Skip Unmapped Reads, they are not marked as duplicate&lt;br /&gt;
* Mark a Single-End Read Duplicate (or remove it if configured to do so) if:&lt;br /&gt;
*# A paired-end record has the same key (even if the pair is not proper/the mate is unmapped/the mate is not found)&amp;lt;br/&amp;gt;-OR-&lt;br /&gt;
*# A single-end record has the same key and a higher base quality sum (sum of all base qualities in the record above [[#Minimum Quality for Quality Calculations (--minQual)|&amp;lt;code&amp;gt;--minBaseQual&amp;lt;/code&amp;gt;]])&lt;br /&gt;
* Mark both Paired-End Reads Duplicate if:&lt;br /&gt;
# Another paired-end pair has the same set of keys and has a higher base quality sum (sum of all base qualities in the record above [[#Minimum Quality for Quality Calculations (--minQual)|&amp;lt;code&amp;gt;--minBaseQual&amp;lt;/code&amp;gt;]])&lt;br /&gt;
 &lt;br /&gt;
This code assumes that at most 1000 bases are clipped at the start of a read.&lt;br /&gt;
&lt;br /&gt;
==Handling Recalibration==&lt;br /&gt;
See [[BamUtil: recab]] for recalibration details.&lt;br /&gt;
&lt;br /&gt;
Recalibration parameters can be applied to deduping when --recab is specified.&lt;br /&gt;
&lt;br /&gt;
== How to use it ==&lt;br /&gt;
&lt;br /&gt;
When &amp;lt;code&amp;gt;dedup&amp;lt;/code&amp;gt; is invoked without any arguments the usage information is displayed as described below under [[#Usage|Usage]].&lt;br /&gt;
&lt;br /&gt;
The input SAM/BAM file is required, [[#input File (--in)|input File (--in)]], and must be sorted by coordinate.&lt;br /&gt;
&lt;br /&gt;
The output SAM/BAM file is also required, [[#output File (--out)|output File (--out)]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Recommended usage with Recalibrator: &lt;br /&gt;
&lt;br /&gt;
 /usr/cluster/bin/bam dedup --recab --in ${INPUT}.bam --out ${OUTPUT}.bam --force --refFile ${REF} --dbsnp ${DBSNP} --oneChrom --storeQualTag OQ --maxBaseQual 40&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Recommended usage without Recalibrator: &lt;br /&gt;
&lt;br /&gt;
 /usr/cluster/bin/bam dedup --in ${INPUT}.bam --out ${OUTPUT}.bam --force --oneChrom&lt;br /&gt;
&lt;br /&gt;
= Usage =&lt;br /&gt;
 ./bam dedup --in &amp;lt;InputBamFile&amp;gt; --out &amp;lt;OutputBamFile&amp;gt; [--minQual &amp;lt;minPhred&amp;gt;] [--log &amp;lt;logFile&amp;gt;] [--oneChrom] [--rmDups] [--force] [--excludeFlags &amp;lt;flag&amp;gt;] [--verbose] [--noeof] [--params] [--recab]&lt;br /&gt;
&lt;br /&gt;
Additional Recalibration Usage is documented at [[BamUtil: recab#Usage|BamUtil: recab -&amp;gt; Usage]]&lt;br /&gt;
&lt;br /&gt;
= Parameters =&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Required parameters :&lt;br /&gt;
	--in &amp;lt;infile&amp;gt;   : Input BAM file name (must be sorted)&lt;br /&gt;
	--out &amp;lt;outfile&amp;gt; : Output BAM file name (same order with original file)&lt;br /&gt;
Optional parameters : &lt;br /&gt;
	--minQual &amp;lt;int&amp;gt; : Only add scores over this phred quality when determining a read&#039;s quality (default: 15)&lt;br /&gt;
	--log &amp;lt;logfile&amp;gt; : Log and summary statistics (default: [outfile].log, or stderr if --out starts with &#039;-&#039;)&lt;br /&gt;
	--oneChrom      : Treat reads with mates on different chromosomes as single-ended.&lt;br /&gt;
	--rmDups        : Remove duplicates (default is to mark duplicates)&lt;br /&gt;
	--force         : Allow an already mark-duplicated BAM file, unmarking any previously marked &lt;br /&gt;
	                  duplicates and apply this duplicate marking logic.  Default is to throw errors&lt;br /&gt;
	                  and exit when trying to run on an already mark-duplicated BAM&lt;br /&gt;
	--excludeFlags &amp;lt;flag&amp;gt;    : exclude reads with any of these flags set when determining or marking duplicates&lt;br /&gt;
	                           by default (0xB04): exclude unmapped, secondary reads, QC failures, and supplementary reads&lt;br /&gt;
	--verbose       : Turn on verbose mode&lt;br /&gt;
	--noeof         : Do not expect an EOF block on a bam file.&lt;br /&gt;
	--params        : Print the parameter settings&lt;br /&gt;
	--recab         : Recalibrate in addition to deduping&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
{{PhoneHomeParamDesc}}&lt;br /&gt;
&lt;br /&gt;
Additional Recalibration Parameters are documented at [[BamUtil: recab#Parameters|BamUtil: recab -&amp;gt; Parameters]]&lt;br /&gt;
&lt;br /&gt;
== Required Parameters ==&lt;br /&gt;
{{inBAMInputFile}}&lt;br /&gt;
&lt;br /&gt;
Note: The input file must be sorted by coordinate.&lt;br /&gt;
{{outBAMOutputFile}}&lt;br /&gt;
&lt;br /&gt;
== Optional Parameters==&lt;br /&gt;
=== Minimum Quality for Quality Calculations (&amp;lt;code&amp;gt;--minQual&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
When duplicate reads are encountered, the read with the highest quality is kept.&lt;br /&gt;
&lt;br /&gt;
To determine the quality of a read, all of the phred base quality scores above the &amp;lt;code&amp;gt;--minQual&amp;lt;/code&amp;gt; value are added together.  If &amp;lt;code&amp;gt;--minQual&amp;lt;/code&amp;gt; is not specified, it is defaulted to 15.&lt;br /&gt;
&lt;br /&gt;
=== Output log &amp;amp; Summary Statistics FileName (&amp;lt;code&amp;gt;--log&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
Output file name for writing logs &amp;amp; summary statistics.&lt;br /&gt;
&lt;br /&gt;
If this parameter is not specified, it will write to the output file specified in &amp;lt;code&amp;gt;--out&amp;lt;/code&amp;gt; + &amp;quot;.log&amp;quot;.  Or if the output bam is written to stdout (&amp;lt;code&amp;gt;--out&amp;lt;/code&amp;gt; starts with &#039;-&#039;), the logs will be written to stderr.  If the filename after --log starts with &#039;-&#039; it will write to stderr.&lt;br /&gt;
&lt;br /&gt;
=== Treat Reads with Mates On Different Chromosomes As Single-Ended (&amp;lt;code&amp;gt;--oneChrom&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
If a read&#039;s mate is not found it will not be used for duplicate marking.  If you are running on a single chromosome, all read&#039;s whose mates are on different chromosomes will not be used for duplicate marking.  The &amp;lt;code&amp;gt;--oneChrom&amp;lt;/code&amp;gt; option will treat reads with mates on a different chromosome as single-ended.&lt;br /&gt;
&lt;br /&gt;
=== Remove Duplicates (&amp;lt;code&amp;gt;--rmDups&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
Instead of marking a read as duplicate in the flag, the &amp;lt;code&amp;gt;--rmDups&amp;lt;/code&amp;gt; option will remove it from the output BAM file.  &lt;br /&gt;
&lt;br /&gt;
=== Ignore Previous Duplicate Marking (&amp;lt;code&amp;gt;--force&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
By default the deduper will throw an error and stop if a read is already marked as duplicate.  The &amp;lt;code&amp;gt;--force&amp;lt;/code&amp;gt; option will removes any previous duplicate marking and marks the reads from scratch.  The resulting output file will only have reads determined by the deduper marked as duplicates.&lt;br /&gt;
&lt;br /&gt;
=== Skip Records with any of the Specified Flags (&amp;lt;code&amp;gt;--excludeFlags&amp;lt;/code&amp;gt;)===&lt;br /&gt;
Skip records with any of the specified flags set, default 0xB04&lt;br /&gt;
&lt;br /&gt;
By default skips reads with any of the following flags set:&lt;br /&gt;
* unmapped&lt;br /&gt;
* secondary alignment&lt;br /&gt;
* fails QC checks&lt;br /&gt;
* supplementary reads&lt;br /&gt;
&lt;br /&gt;
The Deduper will not work if secondary or supplementary reads are not excluded.  It will not properly find the mates since there will be more than 2 reads with the same mate information.&lt;br /&gt;
&lt;br /&gt;
=== Turn on Verbose Mode (&amp;lt;code&amp;gt;--verbose&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
Turn on verbose logging to get more log messages in the log and to stderr.&lt;br /&gt;
&lt;br /&gt;
{{noeofBGZFParameter}}&lt;br /&gt;
{{paramsParameter}}&lt;br /&gt;
&lt;br /&gt;
== Recalibrate (&amp;lt;code&amp;gt;--recab&amp;lt;/code&amp;gt;) ==&lt;br /&gt;
&lt;br /&gt;
This option will recalibrate the input file in addition to deduping.&lt;br /&gt;
&lt;br /&gt;
See [[BamUtil: recab]] for recalibration details.&lt;br /&gt;
&lt;br /&gt;
{{PhoneHomeParameters}}&lt;br /&gt;
&lt;br /&gt;
= Return Value =&lt;br /&gt;
&lt;br /&gt;
Returns -1 if input parameters are invalid.&lt;br /&gt;
&lt;br /&gt;
Returns the SamStatus for the reads/writes (0 on success, non-0 on failure).&lt;/div&gt;</summary>
		<author><name>Mktrost</name></author>
	</entry>
	<entry>
		<id>http://genome.sph.umich.edu/w/index.php?title=BamUtil:_dedup&amp;diff=14123</id>
		<title>BamUtil: dedup</title>
		<link rel="alternate" type="text/html" href="http://genome.sph.umich.edu/w/index.php?title=BamUtil:_dedup&amp;diff=14123"/>
		<updated>2016-03-06T04:15:36Z</updated>

		<summary type="html">&lt;p&gt;Mktrost: /* Parameters */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:BamUtil|validate]]&lt;br /&gt;
[[Category:BAM Software]]&lt;br /&gt;
[[Category:Software]]&lt;br /&gt;
&lt;br /&gt;
= Overview of the &amp;lt;code&amp;gt;dedup&amp;lt;/code&amp;gt; function of &amp;lt;code&amp;gt;[[bamUtil]]&amp;lt;/code&amp;gt; =&lt;br /&gt;
The &amp;lt;code&amp;gt;dedup&amp;lt;/code&amp;gt; option of [[bamUtil]] determines duplicates in a coordinate sorted SAM/BAM file. It either marks or removes the lower quality duplicates.&lt;br /&gt;
&lt;br /&gt;
This tool also contains the option to perform recalibration.&lt;br /&gt;
&lt;br /&gt;
NOTE: This tool does not properly work on templates that have more than 2 segments.  It does not properly match reads when more than 2 reads have the same read name.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Potential future features:&lt;br /&gt;
* Soft clip overlapping reads (for now, use: [[BamUtil: clipOverlap]])&lt;br /&gt;
&lt;br /&gt;
==Handling Duplicates==&lt;br /&gt;
&lt;br /&gt;
The deduper reads all the alignments in a coordinate-sorted SAM/BAM looking for duplicates, failing if the file is not coordinate-sorted.&lt;br /&gt;
&lt;br /&gt;
The deduper assumes that duplicates in the input BAM file are not marked.  When the deduper detects a marked duplicate in the input BAM file, it will throw an error and stop.  To override this behavior, use the [[#Ignore Previous Duplicate Marking (--force)|&amp;lt;code&amp;gt;--force&amp;lt;/code&amp;gt;]] option;  in this mode, alignments that are marked as duplicates in the input file are unmarked before the deduper begins its detection algorithm.  The result is that only duplicates detected by the deduper will be marked in or removed from the output file.&lt;br /&gt;
&lt;br /&gt;
The handling of paired-end reads assumes that the mate information in the SAM/BAM records is accurate.  If a mate is not found at the expected position, an error message is printed (once per file) indicating this error.  Paired-end reads whose mate cannot be found are not marked duplicate and are not used for duplicate marking of other paired-end reads.  Single-end reads with the same key as paired-end reads whose mate cannot be found are still marked as duplicate.  If this error is encountered, you may want to fix the mate information and reprocess the file through the deduper.  &lt;br /&gt;
&lt;br /&gt;
With the default settings this tool should produce similar results as Picard.&lt;br /&gt;
&lt;br /&gt;
Use the [[#Treat Reads with Mates On Different Chromosomes As Single-Ended (--oneChrom)|&amp;lt;code&amp;gt;--oneChrom&amp;lt;/code&amp;gt;]] option to treat reads with a mate on a different chromosome as single-ended.  This option is useful if you are running the deduper on just a single chromosome.  The code will use less memory with this option if mates are found on different chromosomes.  (Picard does not specially handle mates on different chromosomes, so the --oneChrom option may produce different results than Picard.)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Implementation Notes ===&lt;br /&gt;
Duplicates are determined by checking for matching keys.  &lt;br /&gt;
&lt;br /&gt;
The Key is comprised of:&lt;br /&gt;
# Chromosome&lt;br /&gt;
# Orientation (forward/reverse)&lt;br /&gt;
# Unclipped Start(forward)/End(reverse)&lt;br /&gt;
# Library&lt;br /&gt;
&lt;br /&gt;
Rules:&lt;br /&gt;
* Skip Unmapped Reads, they are not marked as duplicate&lt;br /&gt;
* Mark a Single-End Read Duplicate (or remove it if configured to do so) if:&lt;br /&gt;
*# A paired-end record has the same key (even if the pair is not proper/the mate is unmapped/the mate is not found)&amp;lt;br/&amp;gt;-OR-&lt;br /&gt;
*# A single-end record has the same key and a higher base quality sum (sum of all base qualities in the record above [[#Minimum Quality for Quality Calculations (--minQual)|&amp;lt;code&amp;gt;--minBaseQual&amp;lt;/code&amp;gt;]])&lt;br /&gt;
* Mark both Paired-End Reads Duplicate if:&lt;br /&gt;
# Another paired-end pair has the same set of keys and has a higher base quality sum (sum of all base qualities in the record above [[#Minimum Quality for Quality Calculations (--minQual)|&amp;lt;code&amp;gt;--minBaseQual&amp;lt;/code&amp;gt;]])&lt;br /&gt;
 &lt;br /&gt;
This code assumes that at most 1000 bases are clipped at the start of a read.&lt;br /&gt;
&lt;br /&gt;
==Handling Recalibration==&lt;br /&gt;
See [[BamUtil: recab]] for recalibration details.&lt;br /&gt;
&lt;br /&gt;
Recalibration parameters can be applied to deduping when --recab is specified.&lt;br /&gt;
&lt;br /&gt;
== How to use it ==&lt;br /&gt;
&lt;br /&gt;
When &amp;lt;code&amp;gt;dedup&amp;lt;/code&amp;gt; is invoked without any arguments the usage information is displayed as described below under [[#Usage|Usage]].&lt;br /&gt;
&lt;br /&gt;
The input SAM/BAM file is required, [[#input File (--in)|input File (--in)]], and must be sorted by coordinate.&lt;br /&gt;
&lt;br /&gt;
The output SAM/BAM file is also required, [[#output File (--out)|output File (--out)]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Recommended usage with Recalibrator: &lt;br /&gt;
&lt;br /&gt;
 /usr/cluster/bin/bam dedup --recab --in ${INPUT}.bam --out ${OUTPUT}.bam --force --refFile ${REF} --dbsnp ${DBSNP} --oneChrom --storeQualTag OQ --maxBaseQual 40&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Recommended usage without Recalibrator: &lt;br /&gt;
&lt;br /&gt;
 /usr/cluster/bin/bam dedup --in ${INPUT}.bam --out ${OUTPUT}.bam --force --oneChrom&lt;br /&gt;
&lt;br /&gt;
= Usage =&lt;br /&gt;
 ./bam dedup --in &amp;lt;InputBamFile&amp;gt; --out &amp;lt;OutputBamFile&amp;gt; [--minQual &amp;lt;minPhred&amp;gt;] [--log &amp;lt;logFile&amp;gt;] [--oneChrom] [--rmDups] [--force] [--excludeFlags &amp;lt;flag&amp;gt;] [--verbose] [--noeof] [--params] [--recab]&lt;br /&gt;
&lt;br /&gt;
Additional Recalibration Usage is documented at [[BamUtil: recab#Usage|BamUtil: recab -&amp;gt; Usage]]&lt;br /&gt;
&lt;br /&gt;
= Parameters =&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Required parameters :&lt;br /&gt;
	--in &amp;lt;infile&amp;gt;   : Input BAM file name (must be sorted)&lt;br /&gt;
	--out &amp;lt;outfile&amp;gt; : Output BAM file name (same order with original file)&lt;br /&gt;
Optional parameters : &lt;br /&gt;
	--minQual &amp;lt;int&amp;gt; : Only add scores over this phred quality when determining a read&#039;s quality (default: 15)&lt;br /&gt;
	--log &amp;lt;logfile&amp;gt; : Log and summary statistics (default: [outfile].log, or stderr if --out starts with &#039;-&#039;)&lt;br /&gt;
	--oneChrom      : Treat reads with mates on different chromosomes as single-ended.&lt;br /&gt;
	--rmDups        : Remove duplicates (default is to mark duplicates)&lt;br /&gt;
	--force         : Allow an already mark-duplicated BAM file, unmarking any previously marked &lt;br /&gt;
	                  duplicates and apply this duplicate marking logic.  Default is to throw errors&lt;br /&gt;
	                  and exit when trying to run on an already mark-duplicated BAM&lt;br /&gt;
	--excludeFlags &amp;lt;flag&amp;gt;    : exclude reads with any of these flags set when determining or marking duplicates&lt;br /&gt;
	                           by default (0xB04): exclude unmapped, secondary reads, QC failures, and supplementary reads&lt;br /&gt;
	--verbose       : Turn on verbose mode&lt;br /&gt;
	--noeof         : Do not expect an EOF block on a bam file.&lt;br /&gt;
	--params        : Print the parameter settings&lt;br /&gt;
	--recab         : Recalibrate in addition to deduping&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
{{PhoneHomeParamDesc}}&lt;br /&gt;
&lt;br /&gt;
Additional Recalibration Parameters are documented at [[BamUtil: recab#Parameters|BamUtil: recab -&amp;gt; Parameters]]&lt;br /&gt;
&lt;br /&gt;
== Required Parameters ==&lt;br /&gt;
{{inBAMInputFile}}&lt;br /&gt;
&lt;br /&gt;
Note: The input file must be sorted by coordinate.&lt;br /&gt;
{{outBAMOutputFile}}&lt;br /&gt;
&lt;br /&gt;
== Optional Parameters==&lt;br /&gt;
=== Minimum Quality for Quality Calculations (&amp;lt;code&amp;gt;--minQual&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
When duplicate reads are encountered, the read with the highest quality is kept.&lt;br /&gt;
&lt;br /&gt;
To determine the quality of a read, all of the phred base quality scores above the &amp;lt;code&amp;gt;--minQual&amp;lt;/code&amp;gt; value are added together.  If &amp;lt;code&amp;gt;--minQual&amp;lt;/code&amp;gt; is not specified, it is defaulted to 15.&lt;br /&gt;
&lt;br /&gt;
=== Output log &amp;amp; Summary Statistics FileName (&amp;lt;code&amp;gt;--log&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
Output file name for writing logs &amp;amp; summary statistics.&lt;br /&gt;
&lt;br /&gt;
If this parameter is not specified, it will write to the output file specified in &amp;lt;code&amp;gt;--out&amp;lt;/code&amp;gt; + &amp;quot;.log&amp;quot;.  Or if the output bam is written to stdout (&amp;lt;code&amp;gt;--out&amp;lt;/code&amp;gt; starts with &#039;-&#039;), the logs will be written to stderr.  If the filename after --log starts with &#039;-&#039; it will write to stderr.&lt;br /&gt;
&lt;br /&gt;
=== Treat Reads with Mates On Different Chromosomes As Single-Ended (&amp;lt;code&amp;gt;--oneChrom&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
If a read&#039;s mate is not found it will not be used for duplicate marking.  If you are running on a single chromosome, all read&#039;s whose mates are on different chromosomes will not be used for duplicate marking.  The &amp;lt;code&amp;gt;--oneChrom&amp;lt;/code&amp;gt; option will treat reads with mates on a different chromosome as single-ended.&lt;br /&gt;
&lt;br /&gt;
=== Remove Duplicates (&amp;lt;code&amp;gt;--rmDups&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
Instead of marking a read as duplicate in the flag, the &amp;lt;code&amp;gt;--rmDups&amp;lt;/code&amp;gt; option will remove it from the output BAM file.  &lt;br /&gt;
&lt;br /&gt;
=== Ignore Previous Duplicate Marking (&amp;lt;code&amp;gt;--force&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
By default the deduper will throw an error and stop if a read is already marked as duplicate.  The &amp;lt;code&amp;gt;--force&amp;lt;/code&amp;gt; option will removes any previous duplicate marking and marks the reads from scratch.  The resulting output file will only have reads determined by the deduper marked as duplicates.&lt;br /&gt;
&lt;br /&gt;
=== Skip Records with any of the Specified Flags (&amp;lt;code&amp;gt;--excludeFlags&amp;lt;/code&amp;gt;)===&lt;br /&gt;
Skip records with any of the specified flags set, default 0xB04&lt;br /&gt;
&lt;br /&gt;
By default skips reads with any of the following flags set:&lt;br /&gt;
* unmapped&lt;br /&gt;
* secondary alignment&lt;br /&gt;
* fails QC checks&lt;br /&gt;
* supplementary reads&lt;br /&gt;
&lt;br /&gt;
This parameter was added in version 1.0.10.&lt;br /&gt;
&lt;br /&gt;
=== Turn on Verbose Mode (&amp;lt;code&amp;gt;--verbose&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
Turn on verbose logging to get more log messages in the log and to stderr.&lt;br /&gt;
&lt;br /&gt;
{{noeofBGZFParameter}}&lt;br /&gt;
{{paramsParameter}}&lt;br /&gt;
&lt;br /&gt;
== Recalibrate (&amp;lt;code&amp;gt;--recab&amp;lt;/code&amp;gt;) ==&lt;br /&gt;
&lt;br /&gt;
This option will recalibrate the input file in addition to deduping.&lt;br /&gt;
&lt;br /&gt;
See [[BamUtil: recab]] for recalibration details.&lt;br /&gt;
&lt;br /&gt;
{{PhoneHomeParameters}}&lt;br /&gt;
&lt;br /&gt;
= Return Value =&lt;br /&gt;
&lt;br /&gt;
Returns -1 if input parameters are invalid.&lt;br /&gt;
&lt;br /&gt;
Returns the SamStatus for the reads/writes (0 on success, non-0 on failure).&lt;/div&gt;</summary>
		<author><name>Mktrost</name></author>
	</entry>
	<entry>
		<id>http://genome.sph.umich.edu/w/index.php?title=BamUtil:_clipOverlap&amp;diff=14122</id>
		<title>BamUtil: clipOverlap</title>
		<link rel="alternate" type="text/html" href="http://genome.sph.umich.edu/w/index.php?title=BamUtil:_clipOverlap&amp;diff=14122"/>
		<updated>2016-03-06T04:01:37Z</updated>

		<summary type="html">&lt;p&gt;Mktrost: /* ASSUMPTIONS/RESTRICTIONS */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:BamUtil|clipOverlap]]&lt;br /&gt;
[[Category:BAM Software]]&lt;br /&gt;
[[Category:Software]]&lt;br /&gt;
&lt;br /&gt;
= Overview of the &amp;lt;code&amp;gt;clipOverlap&amp;lt;/code&amp;gt; function of &amp;lt;code&amp;gt;bamUtil&amp;lt;/code&amp;gt; =&lt;br /&gt;
The &amp;lt;code&amp;gt;clipOverlap&amp;lt;/code&amp;gt; option on the [[bamUtil]] executable clips overlapping read pairs.&lt;br /&gt;
&lt;br /&gt;
The input file and resulting output file are sorted by coordinate (or readName if specified in the options).&lt;br /&gt;
&lt;br /&gt;
When a read is clipped from the front:&lt;br /&gt;
* the read start position is updated to reflect the clipping.&lt;br /&gt;
* the mate&#039;s mate start position is updated to reflect the record&#039;s new position.&lt;br /&gt;
* the record is placed in the output file in the correct location based on the updated position.&lt;br /&gt;
&lt;br /&gt;
To handle coordinate-sorted files, SAM/BAM records are buffered up until it is known that all following records will have a later start position.  To prevent the program from running away with memory, a limit is set to the number of records that can be buffered, see [[#Set the SAM/BAMs record buffer size (--poolSize)|&amp;lt;code&amp;gt;--poolSize&amp;lt;/code&amp;gt;]] for more information.&lt;br /&gt;
&lt;br /&gt;
When two mates overlap, this tool will clip the record&#039;s whose clipped region would have the lowest average quality.&lt;br /&gt;
&lt;br /&gt;
It also checks strand. If a forward strand extends past the end of a reverse strand, that will be clipped.  Similarly, if a reverse strand starts before the forward strand, the region prior to the forward strand will be clipped. If the reverse strand occurs entirely before the forward strand, both strands will be entirely clipped.  If the [[#Mark entirely clipped reads as unmapped (--unmapped)|&amp;lt;code&amp;gt;--unmapped&amp;lt;/code&amp;gt;]] option is specified, then rather than clipping an entire read, it will be marked as unmapped.&lt;br /&gt;
&lt;br /&gt;
The qualities on the two strands remain unchanged even with clipping.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== ASSUMPTIONS/RESTRICTIONS ==&lt;br /&gt;
&lt;br /&gt;
*Assumes the file is sorted by Coordinate (or ReadName if using &amp;lt;code&amp;gt;--readName&amp;lt;/code&amp;gt; option)&lt;br /&gt;
*Assumes only 2 reads have matching ReadNames (Supplementary and Secondary reads are ignored/skipped by default so will not cause a problem)&lt;br /&gt;
**It matches in pairs, so if there are 3, the first 2 will be matched and compared, but the 3rd won&#039;t.  If there are 4, the first 2 will be matched and the last 2 will be matched and compared.&lt;br /&gt;
*Only mapped reads will be clipped&lt;br /&gt;
*Assumes that mate information in records are accurate&lt;br /&gt;
&lt;br /&gt;
= Rules for Clipping =&lt;br /&gt;
&lt;br /&gt;
== Clipping from the front==&lt;br /&gt;
The first operation after the softclip will be a Match/Mismatch, meaning that any trailing pads, deletions, insertions, or skips will also be soft clipped.&lt;br /&gt;
{|border=&amp;quot;1&amp;quot; cellspacing=&amp;quot;0&amp;quot; cellpadding=&amp;quot;2&amp;quot;&lt;br /&gt;
! Clip Location !! How it is handled&lt;br /&gt;
|-&lt;br /&gt;
|If the clip position falls in a skip/deletion&lt;br /&gt;
| Removes the entire skip/deletion&lt;br /&gt;
|-&lt;br /&gt;
|If the position immediately after the clip is a skip/deletion&lt;br /&gt;
| Also removes the skip/deletion&lt;br /&gt;
|-&lt;br /&gt;
|If the position immediately after the clip is an Insert&lt;br /&gt;
| Softclips the insert&lt;br /&gt;
|-&lt;br /&gt;
|If the position immediately after the clip is a Pad&lt;br /&gt;
| Removes the pad&lt;br /&gt;
|-&lt;br /&gt;
| Clip occurs at the last match/mismatch position of the read (the entire read is clipped)&lt;br /&gt;
| Entire read is soft clipped, 0-based position is left as the original (not modified)&lt;br /&gt;
|-&lt;br /&gt;
| Clip occurs after the read ends&lt;br /&gt;
| Entire read is soft clipped, 0-based position is left as the original (not modified)&lt;br /&gt;
|-&lt;br /&gt;
| Clip occurs before the read starts&lt;br /&gt;
| Nothing is clipped.  The read is not changed.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Clipping from the back==&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;1&amp;quot; cellspacing=&amp;quot;0&amp;quot; cellpadding=&amp;quot;2&amp;quot;&lt;br /&gt;
! Clip Location !! How it is handled&lt;br /&gt;
|-&lt;br /&gt;
|If the clip position falls in a skip/deletion&lt;br /&gt;
| Removes the entire skip/deletion&lt;br /&gt;
|-&lt;br /&gt;
|If the position immediately before the clip is a deletion/skip/pad&lt;br /&gt;
| Remove the deletion/skip/pad&lt;br /&gt;
|-&lt;br /&gt;
|If the position immediately before the clip is an insertion&lt;br /&gt;
| Leave the insertion, even if it results in a 70M3I27S&lt;br /&gt;
|-&lt;br /&gt;
|Clip occurs at the first position of the read (the entire read is clipped)&lt;br /&gt;
| Entire read is soft clipped, preceding insertions remain, 0-based position is left as the original (not modified)&lt;br /&gt;
|-&lt;br /&gt;
| Clip occurs before the read starts&lt;br /&gt;
| Entire read is soft clipped, 0-based position is left as the original (not modified)&lt;br /&gt;
|-&lt;br /&gt;
| Clip occurs after the read ends&lt;br /&gt;
| Nothing is clipped.  The read is not changed.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= Usage =&lt;br /&gt;
 ./bam clipOverlap --in &amp;lt;inputFile&amp;gt; --out &amp;lt;outputFile&amp;gt; [--storeOrig &amp;lt;tag&amp;gt;] [--readName] [--stats] [--overlapsOnly] [--excludeFlags &amp;lt;flag&amp;gt;] [--poolSize &amp;lt;numRecords allowed to allocate&amp;gt;] [--poolSkipOverlap] [--noeof] [--params]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Parameters =&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
	Required Parameters:&lt;br /&gt;
		--in           : the SAM/BAM file to clip overlaping read pairs for&lt;br /&gt;
		--out          : the SAM/BAM file to be written&lt;br /&gt;
	Optional Parameters:&lt;br /&gt;
		--storeOrig    : Store the original cigar in the specified tag.&lt;br /&gt;
		--readName     : Original file is sorted by Read Name instead of coordinate.&lt;br /&gt;
		--stats        : Print some statistics on the overlaps.&lt;br /&gt;
		--overlapsOnly : Only output overlapping read pairs&lt;br /&gt;
		--excludeFlags : Skip records with any of the specified flags set, default 0xF0C&lt;br /&gt;
                --unmapped     : Mark records that would be completely clipped as unmapped&lt;br /&gt;
 		--noeof        : Do not expect an EOF block on a bam file.&lt;br /&gt;
		--params       : Print the parameter settings to stderr&lt;br /&gt;
	Clipping By Coordinate Optional Parameters:&lt;br /&gt;
		--poolSize     : Maximum number of records the program is allowed to allocate&lt;br /&gt;
		                 for clipping on Coordinate sorted files. (Default: 1000000)&lt;br /&gt;
		--poolSkipClip : Skip clipping reads to free of usable records when the&lt;br /&gt;
		                 poolSize is hit. The default action is to just clip the&lt;br /&gt;
		                 first read in a pair to free up the record.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
{{PhoneHomeParamDesc}}&lt;br /&gt;
&lt;br /&gt;
== Required Parameters==&lt;br /&gt;
{{inBAMInputFile}}&lt;br /&gt;
{{outBAMOutputFile}}&lt;br /&gt;
&lt;br /&gt;
== Optional Parameters ==&lt;br /&gt;
=== Store the original cigar string in a tag (&amp;lt;code&amp;gt;--storeOrig&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
Use &amp;lt;code&amp;gt;--storeOrig&amp;lt;/code&amp;gt; followed by the two character TAG to store the original CIGAR.&lt;br /&gt;
&lt;br /&gt;
It will be stored with the specified tag as a &amp;quot;Z&amp;quot; tag type.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Work on SAM/BAMs sorted by Read Name instead of by coordinate (&amp;lt;code&amp;gt;--readName&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
If your file is sorted by read name rather than by coordinate, specify &amp;lt;code&amp;gt;--readName&amp;lt;/code&amp;gt;.  The resulting file will still be sorted by read name.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Print Overlap Statistics (&amp;lt;code&amp;gt;--stats&amp;lt;/code&amp;gt;)===&lt;br /&gt;
Print some basic overlap statistics to stderr.&lt;br /&gt;
&lt;br /&gt;
Output values&lt;br /&gt;
* count of the number of overlapping pairs that are clipped&lt;br /&gt;
* average of the number of overlapping reference bases that are clipped&lt;br /&gt;
* variance of the number of overlapping reference bases that are clipped&lt;br /&gt;
* number of times the forward strand is clipped when read pairs overlap&lt;br /&gt;
* number of times the reverse strand is clipped when read pairs overlap&lt;br /&gt;
* number of times the orientation causes clipping/additional clipping&lt;br /&gt;
** reads that are only clipped due to orientation are not counted in the other stats&lt;br /&gt;
&lt;br /&gt;
==== Example Output ====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Overlap Statistics:&lt;br /&gt;
Number of overlapping pairs: 14&lt;br /&gt;
Average # Reference Bases Overlapped: 18.3571&lt;br /&gt;
Variance of Reference Bases overlapped: 39.1703&lt;br /&gt;
Number of times the forward strand was clipped: 6&lt;br /&gt;
Number of times the reverse strand was clipped: 8&lt;br /&gt;
Number of times orientation causes additional clipping: 4&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Print Only Overlaping Reads (&amp;lt;code&amp;gt;--overlapsOnly&amp;lt;/code&amp;gt;)===&lt;br /&gt;
Only output Read Pairs that overlap.  Drop all other records.&lt;br /&gt;
&lt;br /&gt;
=== Skip Records with any of the Specified Flags (&amp;lt;code&amp;gt;--excludeFlags&amp;lt;/code&amp;gt;)===&lt;br /&gt;
Skip records with any of the specified flags set, default 0xF0C&lt;br /&gt;
&lt;br /&gt;
By default skips reads with any of the following flags set:&lt;br /&gt;
* unmapped&lt;br /&gt;
* mate unmapped&lt;br /&gt;
* secondary alignment&lt;br /&gt;
* fails QC checks&lt;br /&gt;
* duplicate&lt;br /&gt;
* supplementary&lt;br /&gt;
&lt;br /&gt;
=== Mark entirely clipped reads as unmapped (&amp;lt;code&amp;gt;--unmapped&amp;lt;/code&amp;gt;)===&lt;br /&gt;
Specify this option if instead of marking reads as entirely clipped, mark them as unmapped.&lt;br /&gt;
&lt;br /&gt;
When marking a read as unmapped, it will:&lt;br /&gt;
* Set CIGAR to 0&lt;br /&gt;
* Set MapQ to 0&lt;br /&gt;
* Clear N/A flag fields:&lt;br /&gt;
** Proper pair&lt;br /&gt;
** Secondary Alignment&lt;br /&gt;
** Supplementary Alignment&lt;br /&gt;
* Update the Mate&#039;s flag to indicate:&lt;br /&gt;
** Mate Unmapped&lt;br /&gt;
** Not proper pair&lt;br /&gt;
&lt;br /&gt;
{{noeofBGZFParameter}}&lt;br /&gt;
{{paramsParameter}}&lt;br /&gt;
&lt;br /&gt;
==Clipping By Coordinate Optional Parameters==&lt;br /&gt;
=== Set the SAM/BAMs record buffer size (&amp;lt;code&amp;gt;--poolSize&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
To handle coordinate sorted files, SAM/BAM records are buffered until it is known that all following records will have a later start position.  To prevent the program from running away with memory, a limit is set to the number of records that can be buffered (defaults to 1000000).&lt;br /&gt;
&lt;br /&gt;
If the poolSize is exhausted, the code will write the earliest record awaiting its overlapping mate and any previous records that are being buffered.&lt;br /&gt;
&lt;br /&gt;
Depending on whether or not &amp;lt;code&amp;gt;--poolSkipClip&amp;lt;/code&amp;gt; is set, it will either, clip the end of the read at the position where the mate is supposed to start or it will not clip either read.  An error message is written to stderr to indicate that one of these has happened and an unsuccessful return value is returned (2: NO_MORE_RECS).&lt;br /&gt;
&lt;br /&gt;
The resulting file will still be sorted by coordinate.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Skip Clipping Coordinate Sorted Files When Out of Records (&amp;lt;code&amp;gt;--poolSkipClip&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
When clipping coordinate sorted SAM/BAM files, we can run out of buffers available in the pool (&amp;lt;code&amp;gt;--poolSize&amp;lt;/code&amp;gt;).&lt;br /&gt;
&lt;br /&gt;
By default when we run out of pooled records, we can no longer read in new records, so instead we release some of the stored records.  We do this by dropping the first record that is being held awaiting its mate.&lt;br /&gt;
&lt;br /&gt;
This record can either be:&lt;br /&gt;
* Clipped starting at its mate&#039;s start position until the end of the read (DEFAULT)&lt;br /&gt;
* Left as is with no clipping, leaving the mates mates overlapping (specify &amp;lt;code&amp;gt;--poolSkipClip&amp;lt;/code&amp;gt;)&lt;br /&gt;
&lt;br /&gt;
With either option, the resulting file will still be sorted by coordinate.&lt;br /&gt;
&lt;br /&gt;
{{PhoneHomeParameters}}&lt;br /&gt;
&lt;br /&gt;
= Return Value =&lt;br /&gt;
&lt;br /&gt;
Returns -1 if input parameters are invalid.&lt;br /&gt;
&lt;br /&gt;
Returns the SamStatus for the reads/writes (0 for success, non-0 for failure).&lt;br /&gt;
&lt;br /&gt;
Returns SamStatus::NO_MORE_RECS, 2, if it was clipping files sorted by coordinate and it ran out of records in the pool so had to clip based on the &amp;lt;code&amp;gt;--poolSkipClip&amp;lt;/code&amp;gt; setting.&lt;br /&gt;
&lt;br /&gt;
= Output =&lt;br /&gt;
&lt;br /&gt;
All status messages are written to stderr.&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;1&amp;quot; cellspacing=&amp;quot;0&amp;quot; cellpadding=&amp;quot;2&amp;quot;&lt;br /&gt;
! Situation !! Sorted Type !! Output Message&lt;br /&gt;
|-&lt;br /&gt;
| Everything ran successfully&lt;br /&gt;
| ReadName/Coordinate&lt;br /&gt;
|&lt;br /&gt;
 Completed ClipOverlap Successfully.&lt;br /&gt;
|-&lt;br /&gt;
| Failed to allocate any records&lt;br /&gt;
| ReadName/Coordinate&lt;br /&gt;
|&lt;br /&gt;
 Failed to allocate any records.&lt;br /&gt;
 Failed to complete ClipOverlap.&lt;br /&gt;
|-&lt;br /&gt;
| Error writing a record&lt;br /&gt;
| ReadName&lt;br /&gt;
|&lt;br /&gt;
 Failed to complete ClipOverlap.&lt;br /&gt;
|-&lt;br /&gt;
| Expected pair to overlap, but 2nd read was not found in the specified position (may be combined with output for running out of pooled records)&lt;br /&gt;
| Coordinate&lt;br /&gt;
|&lt;br /&gt;
 Failed to find expected overlapping mates for XX records.&lt;br /&gt;
 Completed ClipOverlap Successfully.&lt;br /&gt;
|-&lt;br /&gt;
| Ran out of pooled Records with &amp;lt;code&amp;gt;--poolSkipClip&amp;lt;/code&amp;gt; setting&lt;br /&gt;
| Coordinate&lt;br /&gt;
|&lt;br /&gt;
 Due to hitting the max record poolSize, had to skip clipping XX records.&lt;br /&gt;
 Completed ClipOverlap.&lt;br /&gt;
|-&lt;br /&gt;
| Ran out of pooled Records without &amp;lt;code&amp;gt;--poolSkipClip&amp;lt;/code&amp;gt; setting&lt;br /&gt;
| Coordinate&lt;br /&gt;
|&lt;br /&gt;
 Due to hitting the max record poolSize, had to default clip XX records.&lt;br /&gt;
 Completed ClipOverlap.&lt;br /&gt;
|-&lt;br /&gt;
| Any other error&lt;br /&gt;
| Coordinate&lt;br /&gt;
|&lt;br /&gt;
 Failed to complete ClipOverlap.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Example Output == &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Failed to find expected overlapping mates for 2 records.&lt;br /&gt;
Due to hitting the max record poolSize, had to default clip 9 records.&lt;br /&gt;
Completed ClipOverlap.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Mktrost</name></author>
	</entry>
	<entry>
		<id>http://genome.sph.umich.edu/w/index.php?title=BamUtil:_clipOverlap&amp;diff=14121</id>
		<title>BamUtil: clipOverlap</title>
		<link rel="alternate" type="text/html" href="http://genome.sph.umich.edu/w/index.php?title=BamUtil:_clipOverlap&amp;diff=14121"/>
		<updated>2016-03-06T04:00:24Z</updated>

		<summary type="html">&lt;p&gt;Mktrost: /* Parameters */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:BamUtil|clipOverlap]]&lt;br /&gt;
[[Category:BAM Software]]&lt;br /&gt;
[[Category:Software]]&lt;br /&gt;
&lt;br /&gt;
= Overview of the &amp;lt;code&amp;gt;clipOverlap&amp;lt;/code&amp;gt; function of &amp;lt;code&amp;gt;bamUtil&amp;lt;/code&amp;gt; =&lt;br /&gt;
The &amp;lt;code&amp;gt;clipOverlap&amp;lt;/code&amp;gt; option on the [[bamUtil]] executable clips overlapping read pairs.&lt;br /&gt;
&lt;br /&gt;
The input file and resulting output file are sorted by coordinate (or readName if specified in the options).&lt;br /&gt;
&lt;br /&gt;
When a read is clipped from the front:&lt;br /&gt;
* the read start position is updated to reflect the clipping.&lt;br /&gt;
* the mate&#039;s mate start position is updated to reflect the record&#039;s new position.&lt;br /&gt;
* the record is placed in the output file in the correct location based on the updated position.&lt;br /&gt;
&lt;br /&gt;
To handle coordinate-sorted files, SAM/BAM records are buffered up until it is known that all following records will have a later start position.  To prevent the program from running away with memory, a limit is set to the number of records that can be buffered, see [[#Set the SAM/BAMs record buffer size (--poolSize)|&amp;lt;code&amp;gt;--poolSize&amp;lt;/code&amp;gt;]] for more information.&lt;br /&gt;
&lt;br /&gt;
When two mates overlap, this tool will clip the record&#039;s whose clipped region would have the lowest average quality.&lt;br /&gt;
&lt;br /&gt;
It also checks strand. If a forward strand extends past the end of a reverse strand, that will be clipped.  Similarly, if a reverse strand starts before the forward strand, the region prior to the forward strand will be clipped. If the reverse strand occurs entirely before the forward strand, both strands will be entirely clipped.  If the [[#Mark entirely clipped reads as unmapped (--unmapped)|&amp;lt;code&amp;gt;--unmapped&amp;lt;/code&amp;gt;]] option is specified, then rather than clipping an entire read, it will be marked as unmapped.&lt;br /&gt;
&lt;br /&gt;
The qualities on the two strands remain unchanged even with clipping.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== ASSUMPTIONS/RESTRICTIONS ==&lt;br /&gt;
&lt;br /&gt;
*Assumes the file is sorted by Coordinate (or ReadName if using &amp;lt;code&amp;gt;--readName&amp;lt;/code&amp;gt; option)&lt;br /&gt;
*Assumes only 2 reads have matching ReadNames&lt;br /&gt;
**It matches in pairs, so if there are 3, the first 2 will be matched and compared, but the 3rd won&#039;t.  If there are 4, the first 2 will be matched and the last 2 will be matched and compared.&lt;br /&gt;
*Only mapped reads will be clipped&lt;br /&gt;
*Assumes that mate information in records are accurate&lt;br /&gt;
&lt;br /&gt;
= Rules for Clipping =&lt;br /&gt;
&lt;br /&gt;
== Clipping from the front==&lt;br /&gt;
The first operation after the softclip will be a Match/Mismatch, meaning that any trailing pads, deletions, insertions, or skips will also be soft clipped.&lt;br /&gt;
{|border=&amp;quot;1&amp;quot; cellspacing=&amp;quot;0&amp;quot; cellpadding=&amp;quot;2&amp;quot;&lt;br /&gt;
! Clip Location !! How it is handled&lt;br /&gt;
|-&lt;br /&gt;
|If the clip position falls in a skip/deletion&lt;br /&gt;
| Removes the entire skip/deletion&lt;br /&gt;
|-&lt;br /&gt;
|If the position immediately after the clip is a skip/deletion&lt;br /&gt;
| Also removes the skip/deletion&lt;br /&gt;
|-&lt;br /&gt;
|If the position immediately after the clip is an Insert&lt;br /&gt;
| Softclips the insert&lt;br /&gt;
|-&lt;br /&gt;
|If the position immediately after the clip is a Pad&lt;br /&gt;
| Removes the pad&lt;br /&gt;
|-&lt;br /&gt;
| Clip occurs at the last match/mismatch position of the read (the entire read is clipped)&lt;br /&gt;
| Entire read is soft clipped, 0-based position is left as the original (not modified)&lt;br /&gt;
|-&lt;br /&gt;
| Clip occurs after the read ends&lt;br /&gt;
| Entire read is soft clipped, 0-based position is left as the original (not modified)&lt;br /&gt;
|-&lt;br /&gt;
| Clip occurs before the read starts&lt;br /&gt;
| Nothing is clipped.  The read is not changed.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Clipping from the back==&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;1&amp;quot; cellspacing=&amp;quot;0&amp;quot; cellpadding=&amp;quot;2&amp;quot;&lt;br /&gt;
! Clip Location !! How it is handled&lt;br /&gt;
|-&lt;br /&gt;
|If the clip position falls in a skip/deletion&lt;br /&gt;
| Removes the entire skip/deletion&lt;br /&gt;
|-&lt;br /&gt;
|If the position immediately before the clip is a deletion/skip/pad&lt;br /&gt;
| Remove the deletion/skip/pad&lt;br /&gt;
|-&lt;br /&gt;
|If the position immediately before the clip is an insertion&lt;br /&gt;
| Leave the insertion, even if it results in a 70M3I27S&lt;br /&gt;
|-&lt;br /&gt;
|Clip occurs at the first position of the read (the entire read is clipped)&lt;br /&gt;
| Entire read is soft clipped, preceding insertions remain, 0-based position is left as the original (not modified)&lt;br /&gt;
|-&lt;br /&gt;
| Clip occurs before the read starts&lt;br /&gt;
| Entire read is soft clipped, 0-based position is left as the original (not modified)&lt;br /&gt;
|-&lt;br /&gt;
| Clip occurs after the read ends&lt;br /&gt;
| Nothing is clipped.  The read is not changed.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= Usage =&lt;br /&gt;
 ./bam clipOverlap --in &amp;lt;inputFile&amp;gt; --out &amp;lt;outputFile&amp;gt; [--storeOrig &amp;lt;tag&amp;gt;] [--readName] [--stats] [--overlapsOnly] [--excludeFlags &amp;lt;flag&amp;gt;] [--poolSize &amp;lt;numRecords allowed to allocate&amp;gt;] [--poolSkipOverlap] [--noeof] [--params]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Parameters =&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
	Required Parameters:&lt;br /&gt;
		--in           : the SAM/BAM file to clip overlaping read pairs for&lt;br /&gt;
		--out          : the SAM/BAM file to be written&lt;br /&gt;
	Optional Parameters:&lt;br /&gt;
		--storeOrig    : Store the original cigar in the specified tag.&lt;br /&gt;
		--readName     : Original file is sorted by Read Name instead of coordinate.&lt;br /&gt;
		--stats        : Print some statistics on the overlaps.&lt;br /&gt;
		--overlapsOnly : Only output overlapping read pairs&lt;br /&gt;
		--excludeFlags : Skip records with any of the specified flags set, default 0xF0C&lt;br /&gt;
                --unmapped     : Mark records that would be completely clipped as unmapped&lt;br /&gt;
 		--noeof        : Do not expect an EOF block on a bam file.&lt;br /&gt;
		--params       : Print the parameter settings to stderr&lt;br /&gt;
	Clipping By Coordinate Optional Parameters:&lt;br /&gt;
		--poolSize     : Maximum number of records the program is allowed to allocate&lt;br /&gt;
		                 for clipping on Coordinate sorted files. (Default: 1000000)&lt;br /&gt;
		--poolSkipClip : Skip clipping reads to free of usable records when the&lt;br /&gt;
		                 poolSize is hit. The default action is to just clip the&lt;br /&gt;
		                 first read in a pair to free up the record.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
{{PhoneHomeParamDesc}}&lt;br /&gt;
&lt;br /&gt;
== Required Parameters==&lt;br /&gt;
{{inBAMInputFile}}&lt;br /&gt;
{{outBAMOutputFile}}&lt;br /&gt;
&lt;br /&gt;
== Optional Parameters ==&lt;br /&gt;
=== Store the original cigar string in a tag (&amp;lt;code&amp;gt;--storeOrig&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
Use &amp;lt;code&amp;gt;--storeOrig&amp;lt;/code&amp;gt; followed by the two character TAG to store the original CIGAR.&lt;br /&gt;
&lt;br /&gt;
It will be stored with the specified tag as a &amp;quot;Z&amp;quot; tag type.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Work on SAM/BAMs sorted by Read Name instead of by coordinate (&amp;lt;code&amp;gt;--readName&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
If your file is sorted by read name rather than by coordinate, specify &amp;lt;code&amp;gt;--readName&amp;lt;/code&amp;gt;.  The resulting file will still be sorted by read name.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Print Overlap Statistics (&amp;lt;code&amp;gt;--stats&amp;lt;/code&amp;gt;)===&lt;br /&gt;
Print some basic overlap statistics to stderr.&lt;br /&gt;
&lt;br /&gt;
Output values&lt;br /&gt;
* count of the number of overlapping pairs that are clipped&lt;br /&gt;
* average of the number of overlapping reference bases that are clipped&lt;br /&gt;
* variance of the number of overlapping reference bases that are clipped&lt;br /&gt;
* number of times the forward strand is clipped when read pairs overlap&lt;br /&gt;
* number of times the reverse strand is clipped when read pairs overlap&lt;br /&gt;
* number of times the orientation causes clipping/additional clipping&lt;br /&gt;
** reads that are only clipped due to orientation are not counted in the other stats&lt;br /&gt;
&lt;br /&gt;
==== Example Output ====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Overlap Statistics:&lt;br /&gt;
Number of overlapping pairs: 14&lt;br /&gt;
Average # Reference Bases Overlapped: 18.3571&lt;br /&gt;
Variance of Reference Bases overlapped: 39.1703&lt;br /&gt;
Number of times the forward strand was clipped: 6&lt;br /&gt;
Number of times the reverse strand was clipped: 8&lt;br /&gt;
Number of times orientation causes additional clipping: 4&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Print Only Overlaping Reads (&amp;lt;code&amp;gt;--overlapsOnly&amp;lt;/code&amp;gt;)===&lt;br /&gt;
Only output Read Pairs that overlap.  Drop all other records.&lt;br /&gt;
&lt;br /&gt;
=== Skip Records with any of the Specified Flags (&amp;lt;code&amp;gt;--excludeFlags&amp;lt;/code&amp;gt;)===&lt;br /&gt;
Skip records with any of the specified flags set, default 0xF0C&lt;br /&gt;
&lt;br /&gt;
By default skips reads with any of the following flags set:&lt;br /&gt;
* unmapped&lt;br /&gt;
* mate unmapped&lt;br /&gt;
* secondary alignment&lt;br /&gt;
* fails QC checks&lt;br /&gt;
* duplicate&lt;br /&gt;
* supplementary&lt;br /&gt;
&lt;br /&gt;
=== Mark entirely clipped reads as unmapped (&amp;lt;code&amp;gt;--unmapped&amp;lt;/code&amp;gt;)===&lt;br /&gt;
Specify this option if instead of marking reads as entirely clipped, mark them as unmapped.&lt;br /&gt;
&lt;br /&gt;
When marking a read as unmapped, it will:&lt;br /&gt;
* Set CIGAR to 0&lt;br /&gt;
* Set MapQ to 0&lt;br /&gt;
* Clear N/A flag fields:&lt;br /&gt;
** Proper pair&lt;br /&gt;
** Secondary Alignment&lt;br /&gt;
** Supplementary Alignment&lt;br /&gt;
* Update the Mate&#039;s flag to indicate:&lt;br /&gt;
** Mate Unmapped&lt;br /&gt;
** Not proper pair&lt;br /&gt;
&lt;br /&gt;
{{noeofBGZFParameter}}&lt;br /&gt;
{{paramsParameter}}&lt;br /&gt;
&lt;br /&gt;
==Clipping By Coordinate Optional Parameters==&lt;br /&gt;
=== Set the SAM/BAMs record buffer size (&amp;lt;code&amp;gt;--poolSize&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
To handle coordinate sorted files, SAM/BAM records are buffered until it is known that all following records will have a later start position.  To prevent the program from running away with memory, a limit is set to the number of records that can be buffered (defaults to 1000000).&lt;br /&gt;
&lt;br /&gt;
If the poolSize is exhausted, the code will write the earliest record awaiting its overlapping mate and any previous records that are being buffered.&lt;br /&gt;
&lt;br /&gt;
Depending on whether or not &amp;lt;code&amp;gt;--poolSkipClip&amp;lt;/code&amp;gt; is set, it will either, clip the end of the read at the position where the mate is supposed to start or it will not clip either read.  An error message is written to stderr to indicate that one of these has happened and an unsuccessful return value is returned (2: NO_MORE_RECS).&lt;br /&gt;
&lt;br /&gt;
The resulting file will still be sorted by coordinate.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Skip Clipping Coordinate Sorted Files When Out of Records (&amp;lt;code&amp;gt;--poolSkipClip&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
When clipping coordinate sorted SAM/BAM files, we can run out of buffers available in the pool (&amp;lt;code&amp;gt;--poolSize&amp;lt;/code&amp;gt;).&lt;br /&gt;
&lt;br /&gt;
By default when we run out of pooled records, we can no longer read in new records, so instead we release some of the stored records.  We do this by dropping the first record that is being held awaiting its mate.&lt;br /&gt;
&lt;br /&gt;
This record can either be:&lt;br /&gt;
* Clipped starting at its mate&#039;s start position until the end of the read (DEFAULT)&lt;br /&gt;
* Left as is with no clipping, leaving the mates mates overlapping (specify &amp;lt;code&amp;gt;--poolSkipClip&amp;lt;/code&amp;gt;)&lt;br /&gt;
&lt;br /&gt;
With either option, the resulting file will still be sorted by coordinate.&lt;br /&gt;
&lt;br /&gt;
{{PhoneHomeParameters}}&lt;br /&gt;
&lt;br /&gt;
= Return Value =&lt;br /&gt;
&lt;br /&gt;
Returns -1 if input parameters are invalid.&lt;br /&gt;
&lt;br /&gt;
Returns the SamStatus for the reads/writes (0 for success, non-0 for failure).&lt;br /&gt;
&lt;br /&gt;
Returns SamStatus::NO_MORE_RECS, 2, if it was clipping files sorted by coordinate and it ran out of records in the pool so had to clip based on the &amp;lt;code&amp;gt;--poolSkipClip&amp;lt;/code&amp;gt; setting.&lt;br /&gt;
&lt;br /&gt;
= Output =&lt;br /&gt;
&lt;br /&gt;
All status messages are written to stderr.&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;1&amp;quot; cellspacing=&amp;quot;0&amp;quot; cellpadding=&amp;quot;2&amp;quot;&lt;br /&gt;
! Situation !! Sorted Type !! Output Message&lt;br /&gt;
|-&lt;br /&gt;
| Everything ran successfully&lt;br /&gt;
| ReadName/Coordinate&lt;br /&gt;
|&lt;br /&gt;
 Completed ClipOverlap Successfully.&lt;br /&gt;
|-&lt;br /&gt;
| Failed to allocate any records&lt;br /&gt;
| ReadName/Coordinate&lt;br /&gt;
|&lt;br /&gt;
 Failed to allocate any records.&lt;br /&gt;
 Failed to complete ClipOverlap.&lt;br /&gt;
|-&lt;br /&gt;
| Error writing a record&lt;br /&gt;
| ReadName&lt;br /&gt;
|&lt;br /&gt;
 Failed to complete ClipOverlap.&lt;br /&gt;
|-&lt;br /&gt;
| Expected pair to overlap, but 2nd read was not found in the specified position (may be combined with output for running out of pooled records)&lt;br /&gt;
| Coordinate&lt;br /&gt;
|&lt;br /&gt;
 Failed to find expected overlapping mates for XX records.&lt;br /&gt;
 Completed ClipOverlap Successfully.&lt;br /&gt;
|-&lt;br /&gt;
| Ran out of pooled Records with &amp;lt;code&amp;gt;--poolSkipClip&amp;lt;/code&amp;gt; setting&lt;br /&gt;
| Coordinate&lt;br /&gt;
|&lt;br /&gt;
 Due to hitting the max record poolSize, had to skip clipping XX records.&lt;br /&gt;
 Completed ClipOverlap.&lt;br /&gt;
|-&lt;br /&gt;
| Ran out of pooled Records without &amp;lt;code&amp;gt;--poolSkipClip&amp;lt;/code&amp;gt; setting&lt;br /&gt;
| Coordinate&lt;br /&gt;
|&lt;br /&gt;
 Due to hitting the max record poolSize, had to default clip XX records.&lt;br /&gt;
 Completed ClipOverlap.&lt;br /&gt;
|-&lt;br /&gt;
| Any other error&lt;br /&gt;
| Coordinate&lt;br /&gt;
|&lt;br /&gt;
 Failed to complete ClipOverlap.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Example Output == &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Failed to find expected overlapping mates for 2 records.&lt;br /&gt;
Due to hitting the max record poolSize, had to default clip 9 records.&lt;br /&gt;
Completed ClipOverlap.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Mktrost</name></author>
	</entry>
	<entry>
		<id>http://genome.sph.umich.edu/w/index.php?title=BamUtil:_clipOverlap&amp;diff=14120</id>
		<title>BamUtil: clipOverlap</title>
		<link rel="alternate" type="text/html" href="http://genome.sph.umich.edu/w/index.php?title=BamUtil:_clipOverlap&amp;diff=14120"/>
		<updated>2016-03-06T03:59:46Z</updated>

		<summary type="html">&lt;p&gt;Mktrost: /* Skip Records with any of the Specified Flags (--excludeFlags) */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:BamUtil|clipOverlap]]&lt;br /&gt;
[[Category:BAM Software]]&lt;br /&gt;
[[Category:Software]]&lt;br /&gt;
&lt;br /&gt;
= Overview of the &amp;lt;code&amp;gt;clipOverlap&amp;lt;/code&amp;gt; function of &amp;lt;code&amp;gt;bamUtil&amp;lt;/code&amp;gt; =&lt;br /&gt;
The &amp;lt;code&amp;gt;clipOverlap&amp;lt;/code&amp;gt; option on the [[bamUtil]] executable clips overlapping read pairs.&lt;br /&gt;
&lt;br /&gt;
The input file and resulting output file are sorted by coordinate (or readName if specified in the options).&lt;br /&gt;
&lt;br /&gt;
When a read is clipped from the front:&lt;br /&gt;
* the read start position is updated to reflect the clipping.&lt;br /&gt;
* the mate&#039;s mate start position is updated to reflect the record&#039;s new position.&lt;br /&gt;
* the record is placed in the output file in the correct location based on the updated position.&lt;br /&gt;
&lt;br /&gt;
To handle coordinate-sorted files, SAM/BAM records are buffered up until it is known that all following records will have a later start position.  To prevent the program from running away with memory, a limit is set to the number of records that can be buffered, see [[#Set the SAM/BAMs record buffer size (--poolSize)|&amp;lt;code&amp;gt;--poolSize&amp;lt;/code&amp;gt;]] for more information.&lt;br /&gt;
&lt;br /&gt;
When two mates overlap, this tool will clip the record&#039;s whose clipped region would have the lowest average quality.&lt;br /&gt;
&lt;br /&gt;
It also checks strand. If a forward strand extends past the end of a reverse strand, that will be clipped.  Similarly, if a reverse strand starts before the forward strand, the region prior to the forward strand will be clipped. If the reverse strand occurs entirely before the forward strand, both strands will be entirely clipped.  If the [[#Mark entirely clipped reads as unmapped (--unmapped)|&amp;lt;code&amp;gt;--unmapped&amp;lt;/code&amp;gt;]] option is specified, then rather than clipping an entire read, it will be marked as unmapped.&lt;br /&gt;
&lt;br /&gt;
The qualities on the two strands remain unchanged even with clipping.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== ASSUMPTIONS/RESTRICTIONS ==&lt;br /&gt;
&lt;br /&gt;
*Assumes the file is sorted by Coordinate (or ReadName if using &amp;lt;code&amp;gt;--readName&amp;lt;/code&amp;gt; option)&lt;br /&gt;
*Assumes only 2 reads have matching ReadNames&lt;br /&gt;
**It matches in pairs, so if there are 3, the first 2 will be matched and compared, but the 3rd won&#039;t.  If there are 4, the first 2 will be matched and the last 2 will be matched and compared.&lt;br /&gt;
*Only mapped reads will be clipped&lt;br /&gt;
*Assumes that mate information in records are accurate&lt;br /&gt;
&lt;br /&gt;
= Rules for Clipping =&lt;br /&gt;
&lt;br /&gt;
== Clipping from the front==&lt;br /&gt;
The first operation after the softclip will be a Match/Mismatch, meaning that any trailing pads, deletions, insertions, or skips will also be soft clipped.&lt;br /&gt;
{|border=&amp;quot;1&amp;quot; cellspacing=&amp;quot;0&amp;quot; cellpadding=&amp;quot;2&amp;quot;&lt;br /&gt;
! Clip Location !! How it is handled&lt;br /&gt;
|-&lt;br /&gt;
|If the clip position falls in a skip/deletion&lt;br /&gt;
| Removes the entire skip/deletion&lt;br /&gt;
|-&lt;br /&gt;
|If the position immediately after the clip is a skip/deletion&lt;br /&gt;
| Also removes the skip/deletion&lt;br /&gt;
|-&lt;br /&gt;
|If the position immediately after the clip is an Insert&lt;br /&gt;
| Softclips the insert&lt;br /&gt;
|-&lt;br /&gt;
|If the position immediately after the clip is a Pad&lt;br /&gt;
| Removes the pad&lt;br /&gt;
|-&lt;br /&gt;
| Clip occurs at the last match/mismatch position of the read (the entire read is clipped)&lt;br /&gt;
| Entire read is soft clipped, 0-based position is left as the original (not modified)&lt;br /&gt;
|-&lt;br /&gt;
| Clip occurs after the read ends&lt;br /&gt;
| Entire read is soft clipped, 0-based position is left as the original (not modified)&lt;br /&gt;
|-&lt;br /&gt;
| Clip occurs before the read starts&lt;br /&gt;
| Nothing is clipped.  The read is not changed.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Clipping from the back==&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;1&amp;quot; cellspacing=&amp;quot;0&amp;quot; cellpadding=&amp;quot;2&amp;quot;&lt;br /&gt;
! Clip Location !! How it is handled&lt;br /&gt;
|-&lt;br /&gt;
|If the clip position falls in a skip/deletion&lt;br /&gt;
| Removes the entire skip/deletion&lt;br /&gt;
|-&lt;br /&gt;
|If the position immediately before the clip is a deletion/skip/pad&lt;br /&gt;
| Remove the deletion/skip/pad&lt;br /&gt;
|-&lt;br /&gt;
|If the position immediately before the clip is an insertion&lt;br /&gt;
| Leave the insertion, even if it results in a 70M3I27S&lt;br /&gt;
|-&lt;br /&gt;
|Clip occurs at the first position of the read (the entire read is clipped)&lt;br /&gt;
| Entire read is soft clipped, preceding insertions remain, 0-based position is left as the original (not modified)&lt;br /&gt;
|-&lt;br /&gt;
| Clip occurs before the read starts&lt;br /&gt;
| Entire read is soft clipped, 0-based position is left as the original (not modified)&lt;br /&gt;
|-&lt;br /&gt;
| Clip occurs after the read ends&lt;br /&gt;
| Nothing is clipped.  The read is not changed.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= Usage =&lt;br /&gt;
 ./bam clipOverlap --in &amp;lt;inputFile&amp;gt; --out &amp;lt;outputFile&amp;gt; [--storeOrig &amp;lt;tag&amp;gt;] [--readName] [--stats] [--overlapsOnly] [--excludeFlags &amp;lt;flag&amp;gt;] [--poolSize &amp;lt;numRecords allowed to allocate&amp;gt;] [--poolSkipOverlap] [--noeof] [--params]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Parameters =&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
	Required Parameters:&lt;br /&gt;
		--in           : the SAM/BAM file to clip overlaping read pairs for&lt;br /&gt;
		--out          : the SAM/BAM file to be written&lt;br /&gt;
	Optional Parameters:&lt;br /&gt;
		--storeOrig    : Store the original cigar in the specified tag.&lt;br /&gt;
		--readName     : Original file is sorted by Read Name instead of coordinate.&lt;br /&gt;
		--stats        : Print some statistics on the overlaps.&lt;br /&gt;
		--overlapsOnly : Only output overlapping read pairs&lt;br /&gt;
		--excludeFlags : Skip records with any of the specified flags set, default 0x70C&lt;br /&gt;
                --unmapped     : Mark records that would be completely clipped as unmapped&lt;br /&gt;
 		--noeof        : Do not expect an EOF block on a bam file.&lt;br /&gt;
		--params       : Print the parameter settings to stderr&lt;br /&gt;
	Clipping By Coordinate Optional Parameters:&lt;br /&gt;
		--poolSize     : Maximum number of records the program is allowed to allocate&lt;br /&gt;
		                 for clipping on Coordinate sorted files. (Default: 1000000)&lt;br /&gt;
		--poolSkipClip : Skip clipping reads to free of usable records when the&lt;br /&gt;
		                 poolSize is hit. The default action is to just clip the&lt;br /&gt;
		                 first read in a pair to free up the record.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
{{PhoneHomeParamDesc}}&lt;br /&gt;
&lt;br /&gt;
== Required Parameters==&lt;br /&gt;
{{inBAMInputFile}}&lt;br /&gt;
{{outBAMOutputFile}}&lt;br /&gt;
&lt;br /&gt;
== Optional Parameters ==&lt;br /&gt;
=== Store the original cigar string in a tag (&amp;lt;code&amp;gt;--storeOrig&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
Use &amp;lt;code&amp;gt;--storeOrig&amp;lt;/code&amp;gt; followed by the two character TAG to store the original CIGAR.&lt;br /&gt;
&lt;br /&gt;
It will be stored with the specified tag as a &amp;quot;Z&amp;quot; tag type.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Work on SAM/BAMs sorted by Read Name instead of by coordinate (&amp;lt;code&amp;gt;--readName&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
If your file is sorted by read name rather than by coordinate, specify &amp;lt;code&amp;gt;--readName&amp;lt;/code&amp;gt;.  The resulting file will still be sorted by read name.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Print Overlap Statistics (&amp;lt;code&amp;gt;--stats&amp;lt;/code&amp;gt;)===&lt;br /&gt;
Print some basic overlap statistics to stderr.&lt;br /&gt;
&lt;br /&gt;
Output values&lt;br /&gt;
* count of the number of overlapping pairs that are clipped&lt;br /&gt;
* average of the number of overlapping reference bases that are clipped&lt;br /&gt;
* variance of the number of overlapping reference bases that are clipped&lt;br /&gt;
* number of times the forward strand is clipped when read pairs overlap&lt;br /&gt;
* number of times the reverse strand is clipped when read pairs overlap&lt;br /&gt;
* number of times the orientation causes clipping/additional clipping&lt;br /&gt;
** reads that are only clipped due to orientation are not counted in the other stats&lt;br /&gt;
&lt;br /&gt;
==== Example Output ====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Overlap Statistics:&lt;br /&gt;
Number of overlapping pairs: 14&lt;br /&gt;
Average # Reference Bases Overlapped: 18.3571&lt;br /&gt;
Variance of Reference Bases overlapped: 39.1703&lt;br /&gt;
Number of times the forward strand was clipped: 6&lt;br /&gt;
Number of times the reverse strand was clipped: 8&lt;br /&gt;
Number of times orientation causes additional clipping: 4&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Print Only Overlaping Reads (&amp;lt;code&amp;gt;--overlapsOnly&amp;lt;/code&amp;gt;)===&lt;br /&gt;
Only output Read Pairs that overlap.  Drop all other records.&lt;br /&gt;
&lt;br /&gt;
=== Skip Records with any of the Specified Flags (&amp;lt;code&amp;gt;--excludeFlags&amp;lt;/code&amp;gt;)===&lt;br /&gt;
Skip records with any of the specified flags set, default 0xF0C&lt;br /&gt;
&lt;br /&gt;
By default skips reads with any of the following flags set:&lt;br /&gt;
* unmapped&lt;br /&gt;
* mate unmapped&lt;br /&gt;
* secondary alignment&lt;br /&gt;
* fails QC checks&lt;br /&gt;
* duplicate&lt;br /&gt;
* supplementary&lt;br /&gt;
&lt;br /&gt;
=== Mark entirely clipped reads as unmapped (&amp;lt;code&amp;gt;--unmapped&amp;lt;/code&amp;gt;)===&lt;br /&gt;
Specify this option if instead of marking reads as entirely clipped, mark them as unmapped.&lt;br /&gt;
&lt;br /&gt;
When marking a read as unmapped, it will:&lt;br /&gt;
* Set CIGAR to 0&lt;br /&gt;
* Set MapQ to 0&lt;br /&gt;
* Clear N/A flag fields:&lt;br /&gt;
** Proper pair&lt;br /&gt;
** Secondary Alignment&lt;br /&gt;
** Supplementary Alignment&lt;br /&gt;
* Update the Mate&#039;s flag to indicate:&lt;br /&gt;
** Mate Unmapped&lt;br /&gt;
** Not proper pair&lt;br /&gt;
&lt;br /&gt;
{{noeofBGZFParameter}}&lt;br /&gt;
{{paramsParameter}}&lt;br /&gt;
&lt;br /&gt;
==Clipping By Coordinate Optional Parameters==&lt;br /&gt;
=== Set the SAM/BAMs record buffer size (&amp;lt;code&amp;gt;--poolSize&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
To handle coordinate sorted files, SAM/BAM records are buffered until it is known that all following records will have a later start position.  To prevent the program from running away with memory, a limit is set to the number of records that can be buffered (defaults to 1000000).&lt;br /&gt;
&lt;br /&gt;
If the poolSize is exhausted, the code will write the earliest record awaiting its overlapping mate and any previous records that are being buffered.&lt;br /&gt;
&lt;br /&gt;
Depending on whether or not &amp;lt;code&amp;gt;--poolSkipClip&amp;lt;/code&amp;gt; is set, it will either, clip the end of the read at the position where the mate is supposed to start or it will not clip either read.  An error message is written to stderr to indicate that one of these has happened and an unsuccessful return value is returned (2: NO_MORE_RECS).&lt;br /&gt;
&lt;br /&gt;
The resulting file will still be sorted by coordinate.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Skip Clipping Coordinate Sorted Files When Out of Records (&amp;lt;code&amp;gt;--poolSkipClip&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
When clipping coordinate sorted SAM/BAM files, we can run out of buffers available in the pool (&amp;lt;code&amp;gt;--poolSize&amp;lt;/code&amp;gt;).&lt;br /&gt;
&lt;br /&gt;
By default when we run out of pooled records, we can no longer read in new records, so instead we release some of the stored records.  We do this by dropping the first record that is being held awaiting its mate.&lt;br /&gt;
&lt;br /&gt;
This record can either be:&lt;br /&gt;
* Clipped starting at its mate&#039;s start position until the end of the read (DEFAULT)&lt;br /&gt;
* Left as is with no clipping, leaving the mates mates overlapping (specify &amp;lt;code&amp;gt;--poolSkipClip&amp;lt;/code&amp;gt;)&lt;br /&gt;
&lt;br /&gt;
With either option, the resulting file will still be sorted by coordinate.&lt;br /&gt;
&lt;br /&gt;
{{PhoneHomeParameters}}&lt;br /&gt;
&lt;br /&gt;
= Return Value =&lt;br /&gt;
&lt;br /&gt;
Returns -1 if input parameters are invalid.&lt;br /&gt;
&lt;br /&gt;
Returns the SamStatus for the reads/writes (0 for success, non-0 for failure).&lt;br /&gt;
&lt;br /&gt;
Returns SamStatus::NO_MORE_RECS, 2, if it was clipping files sorted by coordinate and it ran out of records in the pool so had to clip based on the &amp;lt;code&amp;gt;--poolSkipClip&amp;lt;/code&amp;gt; setting.&lt;br /&gt;
&lt;br /&gt;
= Output =&lt;br /&gt;
&lt;br /&gt;
All status messages are written to stderr.&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;1&amp;quot; cellspacing=&amp;quot;0&amp;quot; cellpadding=&amp;quot;2&amp;quot;&lt;br /&gt;
! Situation !! Sorted Type !! Output Message&lt;br /&gt;
|-&lt;br /&gt;
| Everything ran successfully&lt;br /&gt;
| ReadName/Coordinate&lt;br /&gt;
|&lt;br /&gt;
 Completed ClipOverlap Successfully.&lt;br /&gt;
|-&lt;br /&gt;
| Failed to allocate any records&lt;br /&gt;
| ReadName/Coordinate&lt;br /&gt;
|&lt;br /&gt;
 Failed to allocate any records.&lt;br /&gt;
 Failed to complete ClipOverlap.&lt;br /&gt;
|-&lt;br /&gt;
| Error writing a record&lt;br /&gt;
| ReadName&lt;br /&gt;
|&lt;br /&gt;
 Failed to complete ClipOverlap.&lt;br /&gt;
|-&lt;br /&gt;
| Expected pair to overlap, but 2nd read was not found in the specified position (may be combined with output for running out of pooled records)&lt;br /&gt;
| Coordinate&lt;br /&gt;
|&lt;br /&gt;
 Failed to find expected overlapping mates for XX records.&lt;br /&gt;
 Completed ClipOverlap Successfully.&lt;br /&gt;
|-&lt;br /&gt;
| Ran out of pooled Records with &amp;lt;code&amp;gt;--poolSkipClip&amp;lt;/code&amp;gt; setting&lt;br /&gt;
| Coordinate&lt;br /&gt;
|&lt;br /&gt;
 Due to hitting the max record poolSize, had to skip clipping XX records.&lt;br /&gt;
 Completed ClipOverlap.&lt;br /&gt;
|-&lt;br /&gt;
| Ran out of pooled Records without &amp;lt;code&amp;gt;--poolSkipClip&amp;lt;/code&amp;gt; setting&lt;br /&gt;
| Coordinate&lt;br /&gt;
|&lt;br /&gt;
 Due to hitting the max record poolSize, had to default clip XX records.&lt;br /&gt;
 Completed ClipOverlap.&lt;br /&gt;
|-&lt;br /&gt;
| Any other error&lt;br /&gt;
| Coordinate&lt;br /&gt;
|&lt;br /&gt;
 Failed to complete ClipOverlap.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Example Output == &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Failed to find expected overlapping mates for 2 records.&lt;br /&gt;
Due to hitting the max record poolSize, had to default clip 9 records.&lt;br /&gt;
Completed ClipOverlap.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Mktrost</name></author>
	</entry>
	<entry>
		<id>http://genome.sph.umich.edu/w/index.php?title=BamUtil:_bam2FastQ&amp;diff=14119</id>
		<title>BamUtil: bam2FastQ</title>
		<link rel="alternate" type="text/html" href="http://genome.sph.umich.edu/w/index.php?title=BamUtil:_bam2FastQ&amp;diff=14119"/>
		<updated>2016-03-06T03:53:50Z</updated>

		<summary type="html">&lt;p&gt;Mktrost: /* Parameters */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Overview of the &amp;lt;code&amp;gt;bam2FastQ&amp;lt;/code&amp;gt; function of &amp;lt;code&amp;gt;[[bamUtil]]&amp;lt;/code&amp;gt; =&lt;br /&gt;
The &amp;lt;code&amp;gt;bam2FastQ&amp;lt;/code&amp;gt; option on the [[bamUtil]] converts a BAM file into FastQ files. This is necessary when only BAM files are delivered but a new alignment is desired. By converting BAM to FastQ files new alignments can be done using FastQ files&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;NOTE: Secondary and Supplementary reads are skipped when converting to FastQ.  It assumes that there will only be 2 reads (the 2 primary mates) with the same read name that are not secondary or supplementary.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;NOTE: Use the --splitRG option to split reads into read group specific FASTQs.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== How to use it ==&lt;br /&gt;
&lt;br /&gt;
When bam2FastQ is invoked without any arguments the usage information is displayed as described below under [[#Usage|Usage]].&lt;br /&gt;
&lt;br /&gt;
The input BAM file is required, [[#input File (--in)|input File (--in)]].&lt;br /&gt;
&lt;br /&gt;
It works on both read/query name and coordinate sorted SAM/BAM files.  &lt;br /&gt;
&lt;br /&gt;
If you want to convert a SAM/BAM that is read/query name sorted but the SO field of the header does not specify &amp;quot;queryname&amp;quot;, then use the [[#BAM File Is Sorted By Read Name (--readname)|--readName]] option.&lt;br /&gt;
&lt;br /&gt;
When processing files sorted by read name, the only requirement is that matching read names are next to each other.  It does not need to be in strict alphabetical order.&lt;br /&gt;
&lt;br /&gt;
Read Names in paired-end FASTQ files are appended with &amp;quot;/1&amp;quot; for the first in the pair, and &amp;quot;/2&amp;quot; for the second in the pair.  Override these defaults using [[#First in Pair FastQ ReadName Extension (--firstRNExt)|--firstRNExt]] and [[#Second in Pair FastQ ReadName Extension (--secondRNExt)|--secondRNExt]]&lt;br /&gt;
&lt;br /&gt;
Sequences marked as Reverse strands in the SAM/BAM file are reverse complemented prior to writing to the FASTQ files.  To skip this step, specify [[#Do Not Reverse Complement Reverse Strands (--noReverseComp)|--noReverseComp]]&lt;br /&gt;
&lt;br /&gt;
Any errors and a summary of how many pairs and unpaired reads were processed are written to stderr.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;NOTE: This tool does not work on templates that have more than 2 segments.  It does not properly match reads when more than 2 reads have the same read name.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;NOTE: This tool does not split reads into read group specific FASTQs.  If you want Read Group specific FASTQ files, first run [[BamUtil: splitBam]] to first split the BAM into 1 BAM per Read Group.  Then run bam2FastQ on each bam.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
=== Output Files ===&lt;br /&gt;
By default, this program produces 3 output fastq files.&lt;br /&gt;
# unpaired reads&lt;br /&gt;
# first end of paired reads&lt;br /&gt;
# second end of paired reads&lt;br /&gt;
&lt;br /&gt;
If the [[#Generate 1 Paired-End Output File (--merge)|&amp;lt;code&amp;gt;--merge&amp;lt;/code&amp;gt;]] option is specified, the program produces 2 output fastq files.&lt;br /&gt;
# unpaired reads&lt;br /&gt;
# interleaved paired-end reads&lt;br /&gt;
&lt;br /&gt;
The default fastq file names are determined by taking the base name of the input file and adding an extension for each filetype.  &lt;br /&gt;
{|border=&amp;quot;1&amp;quot; cellspacing=&amp;quot;0&amp;quot; cellpadding=&amp;quot;2&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot;|Default !!colspan=&amp;quot;2&amp;quot;|[[#Generate 1 Paired-End Output File (--merge)|&amp;lt;code&amp;gt;--merge&amp;lt;/code&amp;gt;]] &lt;br /&gt;
|-&lt;br /&gt;
! Output File Contents !! Extension !! Output File Contents !! Extension&lt;br /&gt;
|-&lt;br /&gt;
|unpaired reads&lt;br /&gt;
| .fastq&lt;br /&gt;
|unpaired reads&lt;br /&gt;
| .fastq&lt;br /&gt;
|-&lt;br /&gt;
|first end of paired reads&lt;br /&gt;
| _1.fastq&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot;|interleaved paired-end reads&lt;br /&gt;
(both first &amp;amp; second end)&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot;|_interleaved.fastq&lt;br /&gt;
|-&lt;br /&gt;
|second end of paired reads&lt;br /&gt;
| _2.fastq&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
If the inputFile was &amp;quot;myPath/myFile.bam&amp;quot;, the resulting fastqs would be:&lt;br /&gt;
#myPath/myFile.fastq&lt;br /&gt;
#myPath/myFile_1.fastq&lt;br /&gt;
#myPath/myFile_2.fastq&lt;br /&gt;
&lt;br /&gt;
With the [[#Generate 1 Paired-End Output File (--merge)|&amp;lt;code&amp;gt;--merge&amp;lt;/code&amp;gt;]] option, the resulting fastqs would be:&lt;br /&gt;
#myPath/myFile.fastq&lt;br /&gt;
#myPath/myFile_interleaved.fastq&lt;br /&gt;
&lt;br /&gt;
Instead of using the inputFile base name as the output file base, you can specify a different base name by using the [[#Output FastQ File Base Name (--outBase)|--outBase]] option.&lt;br /&gt;
&lt;br /&gt;
You can optionally directly specify the output fastq filenames using:&lt;br /&gt;
* --firstOut firstReadInAPair.fastq (also used for the interleaved filename with [[#Generate 1 Paired-End Output File (--merge)|&amp;lt;code&amp;gt;--merge&amp;lt;/code&amp;gt;]])&lt;br /&gt;
* --secondOut secondReadInAPair.fastq&lt;br /&gt;
* --unpairedOut unpairedReads.fastq&lt;br /&gt;
If any of these are not specified, the &amp;lt;code&amp;gt;--outBase&amp;lt;/code&amp;gt; or default is used for that file.&lt;br /&gt;
&lt;br /&gt;
= Usage =&lt;br /&gt;
 ./bam bam2FastQ --in &amp;lt;inputFile&amp;gt; [--readName] [--splitRG] [--qualField &amp;lt;tag&amp;gt;] [--refFile &amp;lt;referenceFile&amp;gt;] [--outBase &amp;lt;outputFileBase&amp;gt;] [--firstOut &amp;lt;1stReadInPairOutFile&amp;gt;] [--merge|--secondOut &amp;lt;2ndReadInPairOutFile&amp;gt;] [--unpairedOut &amp;lt;unpairedOutFile&amp;gt;] [--firstRNExt &amp;lt;firstInPairReadNameEx                           t&amp;gt;] [--secondRNExt &amp;lt;secondInPairReadNameExt&amp;gt;] [--rnPlus] [--noReverseComp] [--region &amp;lt;chr&amp;gt;[:&amp;lt;pos&amp;gt;[:&amp;lt;base&amp;gt;]]] [--gzip] [--noeof] [--params]&lt;br /&gt;
&lt;br /&gt;
= Parameters =&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
        Required Parameters:&lt;br /&gt;
                --in       : the SAM/BAM file to convert to FastQ&lt;br /&gt;
        Optional Parameters:&lt;br /&gt;
                --readname      : Process the BAM as readName sorted instead&lt;br /&gt;
                                  of coordinate if the header does not indicate a sort order.&lt;br /&gt;
                --splitRG       : Split into RG specific fastqs.&lt;br /&gt;
                --qualField     : Use the base quality from the specified tag&lt;br /&gt;
                                  rather than from the Quality field (default)&lt;br /&gt;
                --merge         : Generate 1 interleaved (merged) FASTQ for paired-ends (unpaired in a separate file)&lt;br /&gt;
                                  use firstOut to override the filename of the interleaved file.&lt;br /&gt;
                --refFile       : Reference file for converting &#039;=&#039; in the sequence to the actual base&lt;br /&gt;
                                  if &#039;=&#039; are found and the refFile is not specified, &#039;N&#039; is written to the FASTQ&lt;br /&gt;
                --firstRNExt    : read name extension to use for first read in a pair&lt;br /&gt;
                                  default is &amp;quot;/1&amp;quot;&lt;br /&gt;
                --secondRNExt   : read name extension to use for second read in a pair&lt;br /&gt;
                                  default is &amp;quot;/2&amp;quot;&lt;br /&gt;
                --rnPlus        : Add the Read Name/extension to the &#039;+&#039; line of the fastq records&lt;br /&gt;
                --noReverseComp : Do not reverse complement reads marked as reverse&lt;br /&gt;
                --region        : Only convert reads containing the specified region/nucleotide.&lt;br /&gt;
                                  Position formatted as: chr:pos:base&lt;br /&gt;
                                  pos (0-based) &amp;amp; base are optional.&lt;br /&gt;
                --gzip          : Compress the output FASTQ files using gzip&lt;br /&gt;
                --noeof         : Do not expect an EOF block on a bam file.&lt;br /&gt;
                --params        : Print the parameter settings to stderr&lt;br /&gt;
        Optional OutputFile Names:&lt;br /&gt;
                --outBase       : Base output name for generated output files&lt;br /&gt;
                --firstOut      : Output name for the first in pair file&lt;br /&gt;
                                  over-rides setting of outBase&lt;br /&gt;
                --secondOut     : Output name for the second in pair file&lt;br /&gt;
                                  over-rides setting of outBase&lt;br /&gt;
                --unpairedOut   : Output name for unpaired reads&lt;br /&gt;
                                  over-rides setting of outBase&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Required Parameters ==&lt;br /&gt;
{{inBAMInputFile}}&lt;br /&gt;
&lt;br /&gt;
== Optional Parameters ==&lt;br /&gt;
=== BAM File Is Sorted By Read Name (&amp;lt;code&amp;gt;--readname&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
The bam2FastQ program by default checks the sort order in the SAM/BAM header when converting to FASTQ, and if that is not specified, assumes it is sorted by coordinate.&lt;br /&gt;
&lt;br /&gt;
To override the default and force it to assume the file is sorted by readname, specify the &amp;lt;code&amp;gt;--readName&amp;lt;/code&amp;gt; option&lt;br /&gt;
&lt;br /&gt;
The file does not need to be strictly sorted by read name.  The only requirement is that matching read names are next to each other.&lt;br /&gt;
&lt;br /&gt;
=== Split into RG Specific FASTQs (&amp;lt;code&amp;gt;--splitRG&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
Create RG specific FASTQ files.&lt;br /&gt;
&lt;br /&gt;
Cannot be specified with firstOut/secondOut/unpairedOut since there will be a different filename for each RG. &lt;br /&gt;
&lt;br /&gt;
Cannot write to stdout when &amp;lt;code&amp;gt;--splitRG&amp;lt;/code&amp;gt; is specified.&lt;br /&gt;
&lt;br /&gt;
Output filenames will be &amp;lt;outBase&amp;gt;.&amp;lt;RG&amp;gt;_1.fastq, &amp;lt;outBase&amp;gt;.&amp;lt;RG&amp;gt;_2.fastq, and &amp;lt;outBase&amp;gt;.&amp;lt;RG&amp;gt;.fastq.  A fastq list file &amp;lt;outBase&amp;gt;.list will be created containing MERGE_NAME (the RG tag&#039;s SM value or outBase if the value is empty), fastq 1, fastq 2 (or . if it is a single ended fastq), and the RG tag string.&lt;br /&gt;
&lt;br /&gt;
=== Use the Base Quality from the Specified Tag (&amp;lt;code&amp;gt;--qualField&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
By default, the quality field is used for the Base Qualities in the FASTQ file.  Specify &amp;lt;code&amp;gt;--qualField &amp;lt;tagName&amp;gt;&amp;lt;/code&amp;gt; to use the base qualities from the specified tag instead of the quality field.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Generate 1 Paired-End Output File (&amp;lt;code&amp;gt;--merge&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
Use the &amp;lt;code&amp;gt;--merge&amp;lt;/code&amp;gt; option to generate 1 interleaved (merged) FASTQ for paired-ends instead of 2 files.  Unpaired reads are still written to a separate file.&lt;br /&gt;
&lt;br /&gt;
The default extension for the output file is &amp;quot;_interleaved&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Use [[#Output FastQ File Name For the First End of Paired End (--firstOut)|&amp;lt;code&amp;gt;--firstOut&amp;lt;/code&amp;gt;]] to override the filename of the interleaved file.&lt;br /&gt;
&lt;br /&gt;
This parameter was added in version 1.0.10.&lt;br /&gt;
&lt;br /&gt;
=== Reference File for Converting &#039;=&#039; in the Sequence to Bases (&amp;lt;code&amp;gt;--refFile&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
If the SAM/BAM file contains &#039;=&#039; in the sequence instead of the actual bases, the bam2FastQ program needs to convert the &#039;=&#039; back to the bases.  To do that it needs the reference.  Specify the reference by using &amp;lt;code&amp;gt;--refFile&amp;lt;/code&amp;gt; followed by the reference filename.&lt;br /&gt;
&lt;br /&gt;
For example:&lt;br /&gt;
 ./bam bam2FastQ --in myFile.bam --refFile myPath/myRefFile.fa&lt;br /&gt;
&lt;br /&gt;
=== First in Pair FastQ ReadName Extension (&amp;lt;code&amp;gt;--firstRNExt&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;--firstRNExt&amp;lt;/code&amp;gt; overrides the default &amp;quot;/1&amp;quot; that is appended to the Read Name of the first-end of a read pair with the specified value.&lt;br /&gt;
&lt;br /&gt;
=== Second in Pair FastQ ReadName Extension (&amp;lt;code&amp;gt;--secondRNExt&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;--secondRNExt&amp;lt;/code&amp;gt; overrides the default &amp;quot;/2&amp;quot; that is appended to the Read Name of the second-end of a read pair with the specified value.&lt;br /&gt;
&lt;br /&gt;
=== Include the Read Name on the &amp;quot;+&amp;quot; line of the FASTQ (&amp;lt;code&amp;gt;--rnPlus&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
By default the read name is not included on the &amp;quot;+&amp;quot; line of the FASTQ files.  To include the read name and the extension for paired-end reads, specify &amp;lt;code&amp;gt;--rnPlus&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Do Not Reverse Complement Reverse Strands (&amp;lt;code&amp;gt;--noReverseComp&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
By default, reads marked as reverse in the BAM file are reverse complemented prior to writing to the FASTQ files.  &amp;lt;code&amp;gt;--noReverseComp&amp;lt;/code&amp;gt; disables this feature, and skips the reverse complement step.&lt;br /&gt;
&lt;br /&gt;
For example, if a sequence is ACCGTG marked as reverse, the default FASTQ record will be written as: CACGGT&lt;br /&gt;
&lt;br /&gt;
Specifying &amp;lt;code&amp;gt;--noReverseComp&amp;lt;/code&amp;gt; would result in a FASTQ sequence of ACCGTG&lt;br /&gt;
&lt;br /&gt;
=== Only Convert the Specified Region (&amp;lt;code&amp;gt;--region&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
Only convert reads containing the specified region/nucleotide.&lt;br /&gt;
&lt;br /&gt;
Position formatted as: chr:pos:base&lt;br /&gt;
&lt;br /&gt;
pos (0-based) &amp;amp; base are optional.&lt;br /&gt;
&lt;br /&gt;
{{noeofBGZFParameter}}&lt;br /&gt;
{{paramsParameter}}&lt;br /&gt;
&lt;br /&gt;
== Optional Output Filenames ==&lt;br /&gt;
&lt;br /&gt;
=== Output FastQ File Base Name (&amp;lt;code&amp;gt;--outBase&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
You can replace the default output base name by using the &amp;lt;code&amp;gt;--outBase&amp;lt;/code&amp;gt; option.&lt;br /&gt;
If the outBase was &amp;quot;myNewPath/myFastQBase&amp;quot;, the resulting fastq&#039;s would be:&lt;br /&gt;
#myNewPath/myFastQBase.fastq&lt;br /&gt;
#myNewPath/myFastQBase_1.fastq&lt;br /&gt;
#myNewPath/myFastQBase_2.fastq&lt;br /&gt;
&lt;br /&gt;
The value specified by this parameter is overridden by &amp;lt;code&amp;gt;--firstOut&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;--secondOut&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;--unpairedOut&amp;lt;/code&amp;gt;, but is used for whichever output files are not specified.&lt;br /&gt;
&lt;br /&gt;
With the [[#Generate 1 Paired-End Output File (--merge)|&amp;lt;code&amp;gt;--merge&amp;lt;/code&amp;gt;]] option, the resulting fastq&#039;s would instead be:&lt;br /&gt;
#myNewPath/myFastQBase.fastq&lt;br /&gt;
#myNewPath/myFastQBase_interleaved.fastq&lt;br /&gt;
&lt;br /&gt;
=== Output FastQ File Name For the First End of Paired End (&amp;lt;code&amp;gt;--firstOut&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
This setting overides the default and &amp;lt;code&amp;gt;--outBase&amp;lt;/code&amp;gt; file name. &lt;br /&gt;
&lt;br /&gt;
The entire filename and extension must be specified.&lt;br /&gt;
&lt;br /&gt;
Does not affect the filenames for the second end or for unpaired reads.&lt;br /&gt;
&lt;br /&gt;
For example:&lt;br /&gt;
 ./bam bam2FastQ --in myFile.bam --firstOut myFileEnd1.fastq&lt;br /&gt;
&lt;br /&gt;
=== Output FastQ File Name For the Second End of Paired End (&amp;lt;code&amp;gt;--secondOut&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
This setting overides the default and &amp;lt;code&amp;gt;--outBase&amp;lt;/code&amp;gt; file name. &lt;br /&gt;
&lt;br /&gt;
The entire filename and extension must be specified.&lt;br /&gt;
&lt;br /&gt;
Does not affect the filenames for the first end or for unpaired reads.&lt;br /&gt;
&lt;br /&gt;
For example:&lt;br /&gt;
 ./bam bam2FastQ --in myFile.bam --secondOut myFileEnd2.fastq&lt;br /&gt;
&lt;br /&gt;
=== Output FastQ File Name For Unpaired Reads (&amp;lt;code&amp;gt;--unpairedOut&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
This setting overides the default and &amp;lt;code&amp;gt;--outBase&amp;lt;/code&amp;gt; file names. &lt;br /&gt;
&lt;br /&gt;
The entire filename and extension must be specified.&lt;br /&gt;
&lt;br /&gt;
Does not affect the filenames for the paired-end fastq files.&lt;br /&gt;
&lt;br /&gt;
For example:&lt;br /&gt;
 ./bam bam2FastQ --in myFile.bam --unpairedOut myFileUnpaired.fastq&lt;br /&gt;
&lt;br /&gt;
{{PhoneHomeParameters}}&lt;br /&gt;
&lt;br /&gt;
= Return Value =&lt;br /&gt;
&lt;br /&gt;
Returns -1 if input parameters are invalid.&lt;br /&gt;
&lt;br /&gt;
Returns the SamStatus for the reads/writes (0 on success, non-0 on failure).&lt;/div&gt;</summary>
		<author><name>Mktrost</name></author>
	</entry>
	<entry>
		<id>http://genome.sph.umich.edu/w/index.php?title=BamUtil:_bam2FastQ&amp;diff=14118</id>
		<title>BamUtil: bam2FastQ</title>
		<link rel="alternate" type="text/html" href="http://genome.sph.umich.edu/w/index.php?title=BamUtil:_bam2FastQ&amp;diff=14118"/>
		<updated>2016-03-06T03:36:19Z</updated>

		<summary type="html">&lt;p&gt;Mktrost: /* Usage */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Overview of the &amp;lt;code&amp;gt;bam2FastQ&amp;lt;/code&amp;gt; function of &amp;lt;code&amp;gt;[[bamUtil]]&amp;lt;/code&amp;gt; =&lt;br /&gt;
The &amp;lt;code&amp;gt;bam2FastQ&amp;lt;/code&amp;gt; option on the [[bamUtil]] converts a BAM file into FastQ files. This is necessary when only BAM files are delivered but a new alignment is desired. By converting BAM to FastQ files new alignments can be done using FastQ files&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;NOTE: Secondary and Supplementary reads are skipped when converting to FastQ.  It assumes that there will only be 2 reads (the 2 primary mates) with the same read name that are not secondary or supplementary.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;NOTE: Use the --splitRG option to split reads into read group specific FASTQs.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== How to use it ==&lt;br /&gt;
&lt;br /&gt;
When bam2FastQ is invoked without any arguments the usage information is displayed as described below under [[#Usage|Usage]].&lt;br /&gt;
&lt;br /&gt;
The input BAM file is required, [[#input File (--in)|input File (--in)]].&lt;br /&gt;
&lt;br /&gt;
It works on both read/query name and coordinate sorted SAM/BAM files.  &lt;br /&gt;
&lt;br /&gt;
If you want to convert a SAM/BAM that is read/query name sorted but the SO field of the header does not specify &amp;quot;queryname&amp;quot;, then use the [[#BAM File Is Sorted By Read Name (--readname)|--readName]] option.&lt;br /&gt;
&lt;br /&gt;
When processing files sorted by read name, the only requirement is that matching read names are next to each other.  It does not need to be in strict alphabetical order.&lt;br /&gt;
&lt;br /&gt;
Read Names in paired-end FASTQ files are appended with &amp;quot;/1&amp;quot; for the first in the pair, and &amp;quot;/2&amp;quot; for the second in the pair.  Override these defaults using [[#First in Pair FastQ ReadName Extension (--firstRNExt)|--firstRNExt]] and [[#Second in Pair FastQ ReadName Extension (--secondRNExt)|--secondRNExt]]&lt;br /&gt;
&lt;br /&gt;
Sequences marked as Reverse strands in the SAM/BAM file are reverse complemented prior to writing to the FASTQ files.  To skip this step, specify [[#Do Not Reverse Complement Reverse Strands (--noReverseComp)|--noReverseComp]]&lt;br /&gt;
&lt;br /&gt;
Any errors and a summary of how many pairs and unpaired reads were processed are written to stderr.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;NOTE: This tool does not work on templates that have more than 2 segments.  It does not properly match reads when more than 2 reads have the same read name.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;NOTE: This tool does not split reads into read group specific FASTQs.  If you want Read Group specific FASTQ files, first run [[BamUtil: splitBam]] to first split the BAM into 1 BAM per Read Group.  Then run bam2FastQ on each bam.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
=== Output Files ===&lt;br /&gt;
By default, this program produces 3 output fastq files.&lt;br /&gt;
# unpaired reads&lt;br /&gt;
# first end of paired reads&lt;br /&gt;
# second end of paired reads&lt;br /&gt;
&lt;br /&gt;
If the [[#Generate 1 Paired-End Output File (--merge)|&amp;lt;code&amp;gt;--merge&amp;lt;/code&amp;gt;]] option is specified, the program produces 2 output fastq files.&lt;br /&gt;
# unpaired reads&lt;br /&gt;
# interleaved paired-end reads&lt;br /&gt;
&lt;br /&gt;
The default fastq file names are determined by taking the base name of the input file and adding an extension for each filetype.  &lt;br /&gt;
{|border=&amp;quot;1&amp;quot; cellspacing=&amp;quot;0&amp;quot; cellpadding=&amp;quot;2&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot;|Default !!colspan=&amp;quot;2&amp;quot;|[[#Generate 1 Paired-End Output File (--merge)|&amp;lt;code&amp;gt;--merge&amp;lt;/code&amp;gt;]] &lt;br /&gt;
|-&lt;br /&gt;
! Output File Contents !! Extension !! Output File Contents !! Extension&lt;br /&gt;
|-&lt;br /&gt;
|unpaired reads&lt;br /&gt;
| .fastq&lt;br /&gt;
|unpaired reads&lt;br /&gt;
| .fastq&lt;br /&gt;
|-&lt;br /&gt;
|first end of paired reads&lt;br /&gt;
| _1.fastq&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot;|interleaved paired-end reads&lt;br /&gt;
(both first &amp;amp; second end)&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot;|_interleaved.fastq&lt;br /&gt;
|-&lt;br /&gt;
|second end of paired reads&lt;br /&gt;
| _2.fastq&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
If the inputFile was &amp;quot;myPath/myFile.bam&amp;quot;, the resulting fastqs would be:&lt;br /&gt;
#myPath/myFile.fastq&lt;br /&gt;
#myPath/myFile_1.fastq&lt;br /&gt;
#myPath/myFile_2.fastq&lt;br /&gt;
&lt;br /&gt;
With the [[#Generate 1 Paired-End Output File (--merge)|&amp;lt;code&amp;gt;--merge&amp;lt;/code&amp;gt;]] option, the resulting fastqs would be:&lt;br /&gt;
#myPath/myFile.fastq&lt;br /&gt;
#myPath/myFile_interleaved.fastq&lt;br /&gt;
&lt;br /&gt;
Instead of using the inputFile base name as the output file base, you can specify a different base name by using the [[#Output FastQ File Base Name (--outBase)|--outBase]] option.&lt;br /&gt;
&lt;br /&gt;
You can optionally directly specify the output fastq filenames using:&lt;br /&gt;
* --firstOut firstReadInAPair.fastq (also used for the interleaved filename with [[#Generate 1 Paired-End Output File (--merge)|&amp;lt;code&amp;gt;--merge&amp;lt;/code&amp;gt;]])&lt;br /&gt;
* --secondOut secondReadInAPair.fastq&lt;br /&gt;
* --unpairedOut unpairedReads.fastq&lt;br /&gt;
If any of these are not specified, the &amp;lt;code&amp;gt;--outBase&amp;lt;/code&amp;gt; or default is used for that file.&lt;br /&gt;
&lt;br /&gt;
= Usage =&lt;br /&gt;
 ./bam bam2FastQ --in &amp;lt;inputFile&amp;gt; [--readName] [--splitRG] [--qualField &amp;lt;tag&amp;gt;] [--refFile &amp;lt;referenceFile&amp;gt;] [--outBase &amp;lt;outputFileBase&amp;gt;] [--firstOut &amp;lt;1stReadInPairOutFile&amp;gt;] [--merge|--secondOut &amp;lt;2ndReadInPairOutFile&amp;gt;] [--unpairedOut &amp;lt;unpairedOutFile&amp;gt;] [--firstRNExt &amp;lt;firstInPairReadNameEx                           t&amp;gt;] [--secondRNExt &amp;lt;secondInPairReadNameExt&amp;gt;] [--rnPlus] [--noReverseComp] [--region &amp;lt;chr&amp;gt;[:&amp;lt;pos&amp;gt;[:&amp;lt;base&amp;gt;]]] [--gzip] [--noeof] [--params]&lt;br /&gt;
&lt;br /&gt;
= Parameters =&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
	Required Parameters:&lt;br /&gt;
		--in       : the SAM/BAM file to convert to FastQ&lt;br /&gt;
	Optional Parameters:&lt;br /&gt;
		--readname      : Process the BAM as readName sorted instead&lt;br /&gt;
		                  of coordinate if the header does not indicate a sort order.&lt;br /&gt;
		--merge         : Generate 1 interleaved (merged) FASTQ for paired-ends (unpaired in a separate file)&lt;br /&gt;
		                  use firstOut to override the filename of the interleaved file.&lt;br /&gt;
		--refFile       : Reference file for converting &#039;=&#039; in the sequence to the actual base&lt;br /&gt;
		                  if &#039;=&#039; are found and the refFile is not specified, &#039;N&#039; is written to the FASTQ&lt;br /&gt;
		--firstRNExt    : read name extension to use for first read in a pair&lt;br /&gt;
		                  default is &amp;quot;/1&amp;quot;&lt;br /&gt;
		--secondRNExt   : read name extension to use for second read in a pair&lt;br /&gt;
		                  default is &amp;quot;/2&amp;quot;&lt;br /&gt;
		--rnPlus        : Add the Read Name/extension to the &#039;+&#039; line of the fastq records&lt;br /&gt;
		--noReverseComp : Do not reverse complement reads marked as reverse&lt;br /&gt;
		--noeof         : Do not expect an EOF block on a bam file.&lt;br /&gt;
		--params        : Print the parameter settings to stderr&lt;br /&gt;
	Optional OutputFile Names:&lt;br /&gt;
		--outBase       : Base output name for generated output files&lt;br /&gt;
		--firstOut      : Output name for the first in pair file&lt;br /&gt;
		                  over-rides setting of outBase&lt;br /&gt;
		--secondOut     : Output name for the second in pair file&lt;br /&gt;
		                  over-rides setting of outBase&lt;br /&gt;
		--unpairedOut   : Output name for unpaired reads&lt;br /&gt;
		                  over-rides setting of outBase&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Required Parameters ==&lt;br /&gt;
{{inBAMInputFile}}&lt;br /&gt;
&lt;br /&gt;
== Optional Parameters ==&lt;br /&gt;
=== BAM File Is Sorted By Read Name (&amp;lt;code&amp;gt;--readname&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
The bam2FastQ program by default checks the sort order in the SAM/BAM header when converting to FASTQ, and if that is not specified, assumes it is sorted by coordinate.&lt;br /&gt;
&lt;br /&gt;
To override the default and force it to assume the file is sorted by readname, specify the &amp;lt;code&amp;gt;--readName&amp;lt;/code&amp;gt; option&lt;br /&gt;
&lt;br /&gt;
The file does not need to be strictly sorted by read name.  The only requirement is that matching read names are next to each other.&lt;br /&gt;
&lt;br /&gt;
=== Generate 1 Paired-End Output File (&amp;lt;code&amp;gt;--merge&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
Use the &amp;lt;code&amp;gt;--merge&amp;lt;/code&amp;gt; option to generate 1 interleaved (merged) FASTQ for paired-ends instead of 2 files.  Unpaired reads are still written to a separate file.&lt;br /&gt;
&lt;br /&gt;
The default extension for the output file is &amp;quot;_interleaved&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Use [[#Output FastQ File Name For the First End of Paired End (--firstOut)|&amp;lt;code&amp;gt;--firstOut&amp;lt;/code&amp;gt;]] to override the filename of the interleaved file.&lt;br /&gt;
&lt;br /&gt;
This parameter was added in version 1.0.10.&lt;br /&gt;
&lt;br /&gt;
=== Reference File for Converting &#039;=&#039; in the Sequence to Bases (&amp;lt;code&amp;gt;--refFile&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
If the SAM/BAM file contains &#039;=&#039; in the sequence instead of the actual bases, the bam2FastQ program needs to convert the &#039;=&#039; back to the bases.  To do that it needs the reference.  Specify the reference by using &amp;lt;code&amp;gt;--refFile&amp;lt;/code&amp;gt; followed by the reference filename.&lt;br /&gt;
&lt;br /&gt;
For example:&lt;br /&gt;
 ./bam bam2FastQ --in myFile.bam --refFile myPath/myRefFile.fa&lt;br /&gt;
&lt;br /&gt;
=== First in Pair FastQ ReadName Extension (&amp;lt;code&amp;gt;--firstRNExt&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;--firstRNExt&amp;lt;/code&amp;gt; overrides the default &amp;quot;/1&amp;quot; that is appended to the Read Name of the first-end of a read pair with the specified value.&lt;br /&gt;
&lt;br /&gt;
=== Second in Pair FastQ ReadName Extension (&amp;lt;code&amp;gt;--secondRNExt&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;--secondRNExt&amp;lt;/code&amp;gt; overrides the default &amp;quot;/2&amp;quot; that is appended to the Read Name of the second-end of a read pair with the specified value.&lt;br /&gt;
&lt;br /&gt;
=== Include the Read Name on the &amp;quot;+&amp;quot; line of the FASTQ (&amp;lt;code&amp;gt;--rnPlus&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
By default the read name is not included on the &amp;quot;+&amp;quot; line of the FASTQ files.  To include the read name and the extension for paired-end reads, specify &amp;lt;code&amp;gt;--rnPlus&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Do Not Reverse Complement Reverse Strands (&amp;lt;code&amp;gt;--noReverseComp&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
By default, reads marked as reverse in the BAM file are reverse complemented prior to writing to the FASTQ files.  &amp;lt;code&amp;gt;--noReverseComp&amp;lt;/code&amp;gt; disables this feature, and skips the reverse complement step.&lt;br /&gt;
&lt;br /&gt;
For example, if a sequence is ACCGTG marked as reverse, the default FASTQ record will be written as: CACGGT&lt;br /&gt;
&lt;br /&gt;
Specifying &amp;lt;code&amp;gt;--noReverseComp&amp;lt;/code&amp;gt; would result in a FASTQ sequence of ACCGTG&lt;br /&gt;
&lt;br /&gt;
{{noeofBGZFParameter}}&lt;br /&gt;
{{paramsParameter}}&lt;br /&gt;
&lt;br /&gt;
== Optional Output Filenames ==&lt;br /&gt;
&lt;br /&gt;
=== Output FastQ File Base Name (&amp;lt;code&amp;gt;--outBase&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
You can replace the default output base name by using the &amp;lt;code&amp;gt;--outBase&amp;lt;/code&amp;gt; option.&lt;br /&gt;
If the outBase was &amp;quot;myNewPath/myFastQBase&amp;quot;, the resulting fastq&#039;s would be:&lt;br /&gt;
#myNewPath/myFastQBase.fastq&lt;br /&gt;
#myNewPath/myFastQBase_1.fastq&lt;br /&gt;
#myNewPath/myFastQBase_2.fastq&lt;br /&gt;
&lt;br /&gt;
The value specified by this parameter is overridden by &amp;lt;code&amp;gt;--firstOut&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;--secondOut&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;--unpairedOut&amp;lt;/code&amp;gt;, but is used for whichever output files are not specified.&lt;br /&gt;
&lt;br /&gt;
With the [[#Generate 1 Paired-End Output File (--merge)|&amp;lt;code&amp;gt;--merge&amp;lt;/code&amp;gt;]] option, the resulting fastq&#039;s would instead be:&lt;br /&gt;
#myNewPath/myFastQBase.fastq&lt;br /&gt;
#myNewPath/myFastQBase_interleaved.fastq&lt;br /&gt;
&lt;br /&gt;
=== Output FastQ File Name For the First End of Paired End (&amp;lt;code&amp;gt;--firstOut&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
This setting overides the default and &amp;lt;code&amp;gt;--outBase&amp;lt;/code&amp;gt; file name. &lt;br /&gt;
&lt;br /&gt;
The entire filename and extension must be specified.&lt;br /&gt;
&lt;br /&gt;
Does not affect the filenames for the second end or for unpaired reads.&lt;br /&gt;
&lt;br /&gt;
For example:&lt;br /&gt;
 ./bam bam2FastQ --in myFile.bam --firstOut myFileEnd1.fastq&lt;br /&gt;
&lt;br /&gt;
=== Output FastQ File Name For the Second End of Paired End (&amp;lt;code&amp;gt;--secondOut&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
This setting overides the default and &amp;lt;code&amp;gt;--outBase&amp;lt;/code&amp;gt; file name. &lt;br /&gt;
&lt;br /&gt;
The entire filename and extension must be specified.&lt;br /&gt;
&lt;br /&gt;
Does not affect the filenames for the first end or for unpaired reads.&lt;br /&gt;
&lt;br /&gt;
For example:&lt;br /&gt;
 ./bam bam2FastQ --in myFile.bam --secondOut myFileEnd2.fastq&lt;br /&gt;
&lt;br /&gt;
=== Output FastQ File Name For Unpaired Reads (&amp;lt;code&amp;gt;--unpairedOut&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
This setting overides the default and &amp;lt;code&amp;gt;--outBase&amp;lt;/code&amp;gt; file names. &lt;br /&gt;
&lt;br /&gt;
The entire filename and extension must be specified.&lt;br /&gt;
&lt;br /&gt;
Does not affect the filenames for the paired-end fastq files.&lt;br /&gt;
&lt;br /&gt;
For example:&lt;br /&gt;
 ./bam bam2FastQ --in myFile.bam --unpairedOut myFileUnpaired.fastq&lt;br /&gt;
&lt;br /&gt;
{{PhoneHomeParameters}}&lt;br /&gt;
&lt;br /&gt;
= Return Value =&lt;br /&gt;
&lt;br /&gt;
Returns -1 if input parameters are invalid.&lt;br /&gt;
&lt;br /&gt;
Returns the SamStatus for the reads/writes (0 on success, non-0 on failure).&lt;/div&gt;</summary>
		<author><name>Mktrost</name></author>
	</entry>
	<entry>
		<id>http://genome.sph.umich.edu/w/index.php?title=BamUtil:_bam2FastQ&amp;diff=14117</id>
		<title>BamUtil: bam2FastQ</title>
		<link rel="alternate" type="text/html" href="http://genome.sph.umich.edu/w/index.php?title=BamUtil:_bam2FastQ&amp;diff=14117"/>
		<updated>2016-03-06T03:35:04Z</updated>

		<summary type="html">&lt;p&gt;Mktrost: /* Overview of the bam2FastQ function of bamUtil */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Overview of the &amp;lt;code&amp;gt;bam2FastQ&amp;lt;/code&amp;gt; function of &amp;lt;code&amp;gt;[[bamUtil]]&amp;lt;/code&amp;gt; =&lt;br /&gt;
The &amp;lt;code&amp;gt;bam2FastQ&amp;lt;/code&amp;gt; option on the [[bamUtil]] converts a BAM file into FastQ files. This is necessary when only BAM files are delivered but a new alignment is desired. By converting BAM to FastQ files new alignments can be done using FastQ files&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;NOTE: Secondary and Supplementary reads are skipped when converting to FastQ.  It assumes that there will only be 2 reads (the 2 primary mates) with the same read name that are not secondary or supplementary.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;NOTE: Use the --splitRG option to split reads into read group specific FASTQs.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== How to use it ==&lt;br /&gt;
&lt;br /&gt;
When bam2FastQ is invoked without any arguments the usage information is displayed as described below under [[#Usage|Usage]].&lt;br /&gt;
&lt;br /&gt;
The input BAM file is required, [[#input File (--in)|input File (--in)]].&lt;br /&gt;
&lt;br /&gt;
It works on both read/query name and coordinate sorted SAM/BAM files.  &lt;br /&gt;
&lt;br /&gt;
If you want to convert a SAM/BAM that is read/query name sorted but the SO field of the header does not specify &amp;quot;queryname&amp;quot;, then use the [[#BAM File Is Sorted By Read Name (--readname)|--readName]] option.&lt;br /&gt;
&lt;br /&gt;
When processing files sorted by read name, the only requirement is that matching read names are next to each other.  It does not need to be in strict alphabetical order.&lt;br /&gt;
&lt;br /&gt;
Read Names in paired-end FASTQ files are appended with &amp;quot;/1&amp;quot; for the first in the pair, and &amp;quot;/2&amp;quot; for the second in the pair.  Override these defaults using [[#First in Pair FastQ ReadName Extension (--firstRNExt)|--firstRNExt]] and [[#Second in Pair FastQ ReadName Extension (--secondRNExt)|--secondRNExt]]&lt;br /&gt;
&lt;br /&gt;
Sequences marked as Reverse strands in the SAM/BAM file are reverse complemented prior to writing to the FASTQ files.  To skip this step, specify [[#Do Not Reverse Complement Reverse Strands (--noReverseComp)|--noReverseComp]]&lt;br /&gt;
&lt;br /&gt;
Any errors and a summary of how many pairs and unpaired reads were processed are written to stderr.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;NOTE: This tool does not work on templates that have more than 2 segments.  It does not properly match reads when more than 2 reads have the same read name.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;NOTE: This tool does not split reads into read group specific FASTQs.  If you want Read Group specific FASTQ files, first run [[BamUtil: splitBam]] to first split the BAM into 1 BAM per Read Group.  Then run bam2FastQ on each bam.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
=== Output Files ===&lt;br /&gt;
By default, this program produces 3 output fastq files.&lt;br /&gt;
# unpaired reads&lt;br /&gt;
# first end of paired reads&lt;br /&gt;
# second end of paired reads&lt;br /&gt;
&lt;br /&gt;
If the [[#Generate 1 Paired-End Output File (--merge)|&amp;lt;code&amp;gt;--merge&amp;lt;/code&amp;gt;]] option is specified, the program produces 2 output fastq files.&lt;br /&gt;
# unpaired reads&lt;br /&gt;
# interleaved paired-end reads&lt;br /&gt;
&lt;br /&gt;
The default fastq file names are determined by taking the base name of the input file and adding an extension for each filetype.  &lt;br /&gt;
{|border=&amp;quot;1&amp;quot; cellspacing=&amp;quot;0&amp;quot; cellpadding=&amp;quot;2&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot;|Default !!colspan=&amp;quot;2&amp;quot;|[[#Generate 1 Paired-End Output File (--merge)|&amp;lt;code&amp;gt;--merge&amp;lt;/code&amp;gt;]] &lt;br /&gt;
|-&lt;br /&gt;
! Output File Contents !! Extension !! Output File Contents !! Extension&lt;br /&gt;
|-&lt;br /&gt;
|unpaired reads&lt;br /&gt;
| .fastq&lt;br /&gt;
|unpaired reads&lt;br /&gt;
| .fastq&lt;br /&gt;
|-&lt;br /&gt;
|first end of paired reads&lt;br /&gt;
| _1.fastq&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot;|interleaved paired-end reads&lt;br /&gt;
(both first &amp;amp; second end)&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot;|_interleaved.fastq&lt;br /&gt;
|-&lt;br /&gt;
|second end of paired reads&lt;br /&gt;
| _2.fastq&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
If the inputFile was &amp;quot;myPath/myFile.bam&amp;quot;, the resulting fastqs would be:&lt;br /&gt;
#myPath/myFile.fastq&lt;br /&gt;
#myPath/myFile_1.fastq&lt;br /&gt;
#myPath/myFile_2.fastq&lt;br /&gt;
&lt;br /&gt;
With the [[#Generate 1 Paired-End Output File (--merge)|&amp;lt;code&amp;gt;--merge&amp;lt;/code&amp;gt;]] option, the resulting fastqs would be:&lt;br /&gt;
#myPath/myFile.fastq&lt;br /&gt;
#myPath/myFile_interleaved.fastq&lt;br /&gt;
&lt;br /&gt;
Instead of using the inputFile base name as the output file base, you can specify a different base name by using the [[#Output FastQ File Base Name (--outBase)|--outBase]] option.&lt;br /&gt;
&lt;br /&gt;
You can optionally directly specify the output fastq filenames using:&lt;br /&gt;
* --firstOut firstReadInAPair.fastq (also used for the interleaved filename with [[#Generate 1 Paired-End Output File (--merge)|&amp;lt;code&amp;gt;--merge&amp;lt;/code&amp;gt;]])&lt;br /&gt;
* --secondOut secondReadInAPair.fastq&lt;br /&gt;
* --unpairedOut unpairedReads.fastq&lt;br /&gt;
If any of these are not specified, the &amp;lt;code&amp;gt;--outBase&amp;lt;/code&amp;gt; or default is used for that file.&lt;br /&gt;
&lt;br /&gt;
= Usage =&lt;br /&gt;
 ./bam bam2FastQ --in &amp;lt;inputFile&amp;gt; [--readName] [--refFile &amp;lt;referenceFile&amp;gt;] [--outBase &amp;lt;outputFileBase&amp;gt;] [--firstOut &amp;lt;1stReadInPairOutFile&amp;gt;] [--merge|--secondOut &amp;lt;2ndReadInPairOutFile&amp;gt;] [--unpairedOut &amp;lt;unpairedOutFile&amp;gt;] [--firstRNExt &amp;lt;firstInPairReadNameExt&amp;gt;] [--secondRNExt &amp;lt;secondInPairReadNameExt&amp;gt;] [--rnPlus] [--noReverseComp] [--noeof] [--params]&lt;br /&gt;
&lt;br /&gt;
= Parameters =&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
	Required Parameters:&lt;br /&gt;
		--in       : the SAM/BAM file to convert to FastQ&lt;br /&gt;
	Optional Parameters:&lt;br /&gt;
		--readname      : Process the BAM as readName sorted instead&lt;br /&gt;
		                  of coordinate if the header does not indicate a sort order.&lt;br /&gt;
		--merge         : Generate 1 interleaved (merged) FASTQ for paired-ends (unpaired in a separate file)&lt;br /&gt;
		                  use firstOut to override the filename of the interleaved file.&lt;br /&gt;
		--refFile       : Reference file for converting &#039;=&#039; in the sequence to the actual base&lt;br /&gt;
		                  if &#039;=&#039; are found and the refFile is not specified, &#039;N&#039; is written to the FASTQ&lt;br /&gt;
		--firstRNExt    : read name extension to use for first read in a pair&lt;br /&gt;
		                  default is &amp;quot;/1&amp;quot;&lt;br /&gt;
		--secondRNExt   : read name extension to use for second read in a pair&lt;br /&gt;
		                  default is &amp;quot;/2&amp;quot;&lt;br /&gt;
		--rnPlus        : Add the Read Name/extension to the &#039;+&#039; line of the fastq records&lt;br /&gt;
		--noReverseComp : Do not reverse complement reads marked as reverse&lt;br /&gt;
		--noeof         : Do not expect an EOF block on a bam file.&lt;br /&gt;
		--params        : Print the parameter settings to stderr&lt;br /&gt;
	Optional OutputFile Names:&lt;br /&gt;
		--outBase       : Base output name for generated output files&lt;br /&gt;
		--firstOut      : Output name for the first in pair file&lt;br /&gt;
		                  over-rides setting of outBase&lt;br /&gt;
		--secondOut     : Output name for the second in pair file&lt;br /&gt;
		                  over-rides setting of outBase&lt;br /&gt;
		--unpairedOut   : Output name for unpaired reads&lt;br /&gt;
		                  over-rides setting of outBase&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Required Parameters ==&lt;br /&gt;
{{inBAMInputFile}}&lt;br /&gt;
&lt;br /&gt;
== Optional Parameters ==&lt;br /&gt;
=== BAM File Is Sorted By Read Name (&amp;lt;code&amp;gt;--readname&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
The bam2FastQ program by default checks the sort order in the SAM/BAM header when converting to FASTQ, and if that is not specified, assumes it is sorted by coordinate.&lt;br /&gt;
&lt;br /&gt;
To override the default and force it to assume the file is sorted by readname, specify the &amp;lt;code&amp;gt;--readName&amp;lt;/code&amp;gt; option&lt;br /&gt;
&lt;br /&gt;
The file does not need to be strictly sorted by read name.  The only requirement is that matching read names are next to each other.&lt;br /&gt;
&lt;br /&gt;
=== Generate 1 Paired-End Output File (&amp;lt;code&amp;gt;--merge&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
Use the &amp;lt;code&amp;gt;--merge&amp;lt;/code&amp;gt; option to generate 1 interleaved (merged) FASTQ for paired-ends instead of 2 files.  Unpaired reads are still written to a separate file.&lt;br /&gt;
&lt;br /&gt;
The default extension for the output file is &amp;quot;_interleaved&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Use [[#Output FastQ File Name For the First End of Paired End (--firstOut)|&amp;lt;code&amp;gt;--firstOut&amp;lt;/code&amp;gt;]] to override the filename of the interleaved file.&lt;br /&gt;
&lt;br /&gt;
This parameter was added in version 1.0.10.&lt;br /&gt;
&lt;br /&gt;
=== Reference File for Converting &#039;=&#039; in the Sequence to Bases (&amp;lt;code&amp;gt;--refFile&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
If the SAM/BAM file contains &#039;=&#039; in the sequence instead of the actual bases, the bam2FastQ program needs to convert the &#039;=&#039; back to the bases.  To do that it needs the reference.  Specify the reference by using &amp;lt;code&amp;gt;--refFile&amp;lt;/code&amp;gt; followed by the reference filename.&lt;br /&gt;
&lt;br /&gt;
For example:&lt;br /&gt;
 ./bam bam2FastQ --in myFile.bam --refFile myPath/myRefFile.fa&lt;br /&gt;
&lt;br /&gt;
=== First in Pair FastQ ReadName Extension (&amp;lt;code&amp;gt;--firstRNExt&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;--firstRNExt&amp;lt;/code&amp;gt; overrides the default &amp;quot;/1&amp;quot; that is appended to the Read Name of the first-end of a read pair with the specified value.&lt;br /&gt;
&lt;br /&gt;
=== Second in Pair FastQ ReadName Extension (&amp;lt;code&amp;gt;--secondRNExt&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;--secondRNExt&amp;lt;/code&amp;gt; overrides the default &amp;quot;/2&amp;quot; that is appended to the Read Name of the second-end of a read pair with the specified value.&lt;br /&gt;
&lt;br /&gt;
=== Include the Read Name on the &amp;quot;+&amp;quot; line of the FASTQ (&amp;lt;code&amp;gt;--rnPlus&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
By default the read name is not included on the &amp;quot;+&amp;quot; line of the FASTQ files.  To include the read name and the extension for paired-end reads, specify &amp;lt;code&amp;gt;--rnPlus&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Do Not Reverse Complement Reverse Strands (&amp;lt;code&amp;gt;--noReverseComp&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
By default, reads marked as reverse in the BAM file are reverse complemented prior to writing to the FASTQ files.  &amp;lt;code&amp;gt;--noReverseComp&amp;lt;/code&amp;gt; disables this feature, and skips the reverse complement step.&lt;br /&gt;
&lt;br /&gt;
For example, if a sequence is ACCGTG marked as reverse, the default FASTQ record will be written as: CACGGT&lt;br /&gt;
&lt;br /&gt;
Specifying &amp;lt;code&amp;gt;--noReverseComp&amp;lt;/code&amp;gt; would result in a FASTQ sequence of ACCGTG&lt;br /&gt;
&lt;br /&gt;
{{noeofBGZFParameter}}&lt;br /&gt;
{{paramsParameter}}&lt;br /&gt;
&lt;br /&gt;
== Optional Output Filenames ==&lt;br /&gt;
&lt;br /&gt;
=== Output FastQ File Base Name (&amp;lt;code&amp;gt;--outBase&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
You can replace the default output base name by using the &amp;lt;code&amp;gt;--outBase&amp;lt;/code&amp;gt; option.&lt;br /&gt;
If the outBase was &amp;quot;myNewPath/myFastQBase&amp;quot;, the resulting fastq&#039;s would be:&lt;br /&gt;
#myNewPath/myFastQBase.fastq&lt;br /&gt;
#myNewPath/myFastQBase_1.fastq&lt;br /&gt;
#myNewPath/myFastQBase_2.fastq&lt;br /&gt;
&lt;br /&gt;
The value specified by this parameter is overridden by &amp;lt;code&amp;gt;--firstOut&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;--secondOut&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;--unpairedOut&amp;lt;/code&amp;gt;, but is used for whichever output files are not specified.&lt;br /&gt;
&lt;br /&gt;
With the [[#Generate 1 Paired-End Output File (--merge)|&amp;lt;code&amp;gt;--merge&amp;lt;/code&amp;gt;]] option, the resulting fastq&#039;s would instead be:&lt;br /&gt;
#myNewPath/myFastQBase.fastq&lt;br /&gt;
#myNewPath/myFastQBase_interleaved.fastq&lt;br /&gt;
&lt;br /&gt;
=== Output FastQ File Name For the First End of Paired End (&amp;lt;code&amp;gt;--firstOut&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
This setting overides the default and &amp;lt;code&amp;gt;--outBase&amp;lt;/code&amp;gt; file name. &lt;br /&gt;
&lt;br /&gt;
The entire filename and extension must be specified.&lt;br /&gt;
&lt;br /&gt;
Does not affect the filenames for the second end or for unpaired reads.&lt;br /&gt;
&lt;br /&gt;
For example:&lt;br /&gt;
 ./bam bam2FastQ --in myFile.bam --firstOut myFileEnd1.fastq&lt;br /&gt;
&lt;br /&gt;
=== Output FastQ File Name For the Second End of Paired End (&amp;lt;code&amp;gt;--secondOut&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
This setting overides the default and &amp;lt;code&amp;gt;--outBase&amp;lt;/code&amp;gt; file name. &lt;br /&gt;
&lt;br /&gt;
The entire filename and extension must be specified.&lt;br /&gt;
&lt;br /&gt;
Does not affect the filenames for the first end or for unpaired reads.&lt;br /&gt;
&lt;br /&gt;
For example:&lt;br /&gt;
 ./bam bam2FastQ --in myFile.bam --secondOut myFileEnd2.fastq&lt;br /&gt;
&lt;br /&gt;
=== Output FastQ File Name For Unpaired Reads (&amp;lt;code&amp;gt;--unpairedOut&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
This setting overides the default and &amp;lt;code&amp;gt;--outBase&amp;lt;/code&amp;gt; file names. &lt;br /&gt;
&lt;br /&gt;
The entire filename and extension must be specified.&lt;br /&gt;
&lt;br /&gt;
Does not affect the filenames for the paired-end fastq files.&lt;br /&gt;
&lt;br /&gt;
For example:&lt;br /&gt;
 ./bam bam2FastQ --in myFile.bam --unpairedOut myFileUnpaired.fastq&lt;br /&gt;
&lt;br /&gt;
{{PhoneHomeParameters}}&lt;br /&gt;
&lt;br /&gt;
= Return Value =&lt;br /&gt;
&lt;br /&gt;
Returns -1 if input parameters are invalid.&lt;br /&gt;
&lt;br /&gt;
Returns the SamStatus for the reads/writes (0 on success, non-0 on failure).&lt;/div&gt;</summary>
		<author><name>Mktrost</name></author>
	</entry>
	<entry>
		<id>http://genome.sph.umich.edu/w/index.php?title=GotCloud:_Alignment_Pipeline&amp;diff=14062</id>
		<title>GotCloud: Alignment Pipeline</title>
		<link rel="alternate" type="text/html" href="http://genome.sph.umich.edu/w/index.php?title=GotCloud:_Alignment_Pipeline&amp;diff=14062"/>
		<updated>2016-01-28T22:39:14Z</updated>

		<summary type="html">&lt;p&gt;Mktrost: /* Optional Configurable Settings */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
Back to parent: [[GotCloud]] &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Overview of Alignment Pipeline Steps == &lt;br /&gt;
The Alignment/Mapping Pipeline takes [http://en.wikipedia.org/wiki/FASTQ_format FASTQ files] and generates recalibrated [[BAM|BAM (Binary Sequence Alignment/Map format) files]] from them. &lt;br /&gt;
&lt;br /&gt;
[[File:MappingSteps.png]] &lt;br /&gt;
&lt;br /&gt;
== Running the GotCloud Alignment Pipeline == &lt;br /&gt;
&lt;br /&gt;
The alignment pipeline is run using the &amp;lt;code&amp;gt;align&amp;lt;/code&amp;gt; option of the &amp;lt;code&amp;gt;gotcloud&amp;lt;/code&amp;gt; script.  This option calls &amp;lt;code&amp;gt;align.pl&amp;lt;/code&amp;gt; found in the &amp;lt;code&amp;gt;bin/&amp;lt;/code&amp;gt; directory under the &amp;lt;code&amp;gt;gotcloud&amp;lt;/code&amp;gt; installation. &lt;br /&gt;
&lt;br /&gt;
Use the &amp;lt;code&amp;gt;--conf&amp;lt;/code&amp;gt; parameter followed by the configuration file to specify the configuration to use for this run of the alignment pipeline.&lt;br /&gt;
&lt;br /&gt;
You must specify the input list of FASTQs mapped to sample id to tell the alignment pipeline what files to process.  You can do this by setting either:&lt;br /&gt;
* &amp;lt;code&amp;gt;FASTQ_LIST&amp;lt;/code&amp;gt; in the configuration file&lt;br /&gt;
* &amp;lt;code&amp;gt;--list&amp;lt;/code&amp;gt; on the command-line&lt;br /&gt;
&lt;br /&gt;
You must specify an output directory to tell the alignment pipeline where to write its output by either setting:&lt;br /&gt;
* &amp;lt;code&amp;gt;OUT_DIR&amp;lt;/code&amp;gt; in the configuration file&lt;br /&gt;
* &amp;lt;code&amp;gt;--outdir&amp;lt;/code&amp;gt; on the command-line&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Example of a Basic Alignment Command&#039;&#039;&#039;&lt;br /&gt;
 gotcloud align --conf myAlignTest.conf --outdir ~/gotcloudOutput/align/&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Running the Automated Test=== &lt;br /&gt;
&lt;br /&gt;
The automated test runs the alignment pipeline on a small set of test data and checks that the results against expected results validating that GotCloud is installed correctly. &lt;br /&gt;
&lt;br /&gt;
*Run alignment pipeline test: &lt;br /&gt;
 gotcloud align --test OUTPUT_DIR &lt;br /&gt;
where OUTPUT_DIR is the directory where you want to store the test results &lt;br /&gt;
&lt;br /&gt;
If you see &amp;quot;Successfully ran the test case, congratulations!&amp;quot;, then you are ready to align samples.&lt;br /&gt;
&lt;br /&gt;
== Input Data:== &lt;br /&gt;
*Raw Sequence (FASTQ) files &lt;br /&gt;
*FASTQ List file mapping fastq pairs to sample (optional: Read Group information) &lt;br /&gt;
*Reference files &lt;br /&gt;
*(Optional) Configuration file to override default options &lt;br /&gt;
&lt;br /&gt;
=== Raw Sequence (FASTQ) files === &lt;br /&gt;
&lt;br /&gt;
These are the FASTQ files that need to be mapped to BAM files. &lt;br /&gt;
&lt;br /&gt;
These files are specified in the [[#FASTQ List File|FASTQ List File]]. &lt;br /&gt;
&lt;br /&gt;
=== FASTQ List File === &lt;br /&gt;
This file specifies the FASTQ files that need to be processed.  It maps the FASTQ pairs to the associated Sample ID.  Optionally Read Group information for the FASTQ pairs can be specified.  If the Read Group information is not specified, it is inferred. &lt;br /&gt;
&lt;br /&gt;
This file is specified either via the command line parameter &amp;lt;code&amp;gt;--list&amp;lt;/code&amp;gt; or via the configuration file setting &amp;lt;code&amp;gt;FASTQ_LIST&amp;lt;/code&amp;gt;.  &lt;br /&gt;
&lt;br /&gt;
The command-line setting takes precedence over the configuration file setting. &lt;br /&gt;
&lt;br /&gt;
The FASTQ list is a tab delimited file that starts with a header line.  The columns may be in any order. &lt;br /&gt;
&lt;br /&gt;
Following the header line, there is one line per single-end read and one line per paired-end read (only 1 line per pair). &lt;br /&gt;
&lt;br /&gt;
Required Column Names: &lt;br /&gt;
* MERGE_NAME - base name for the resulting BAM file for the sample (used to group multiple fastqs or fastq pairs into a single BAM)&lt;br /&gt;
** The SAMPLE column can be specified instead of MERGE_NAME.  SAMPLE will be used for both the sample and the base name.&lt;br /&gt;
* FASTQ1 - name of the fastq or the first in the pair if paired-end.  (Only 1 line per pair) &lt;br /&gt;
&lt;br /&gt;
Optional Column Names: &lt;br /&gt;
* FASTQ2 - name of the 2nd fastq in paired-end reads.  Specify &#039;.&#039; if the column exists, but this line is single-ended. &lt;br /&gt;
* RGID - Read Group ID for this entry&lt;br /&gt;
** If this field is not specified, the first line of the fastq will be used to determine the RG.&lt;br /&gt;
*** If the first line does not match the expected format for determining RG, incrementing numbers per fastq file will be used.&lt;br /&gt;
* SAMPLE - Sample Name for this entry &lt;br /&gt;
** If SAMPLE is not specified, MERGE_NAME will be used for the sample name&lt;br /&gt;
* LIBRARY - Library for this entry &lt;br /&gt;
** If LIBRARY is not specified, the sample name will be used&lt;br /&gt;
* CENTER - Center Name for this entry &lt;br /&gt;
** If CENTER is not specified, it will default to &amp;quot;unknown&amp;quot;&lt;br /&gt;
* PLATFORM - Platform for this entry &lt;br /&gt;
** If PLATFORM is not specified, it will default to ILLUMINA&lt;br /&gt;
&lt;br /&gt;
The RGID, SAMPLE, LIBRARY, CENTER, and PLATFORM are used to populate the Read Group information for this entry.  &lt;br /&gt;
&lt;br /&gt;
 MERGE_NAME	FASTQ1	FASTQ2	RGID	SAMPLE	LIBRARY	CENTER	PLATFORM &lt;br /&gt;
 Sample1	fastq/S1/F1_R1.fastq.gz	fastq/S1/F1_R2.fastq.gz	RGID1	SampleID1	Lib1	UM	ILLUMINA &lt;br /&gt;
 Sample1	fastq/S1/F2_R1.fastq.gz	fastq/S1/F2_R2.fastq.gz	RGID1a	SampleID1	Lib1	UM	ILLUMINA &lt;br /&gt;
 Sample2	fastq/S2/F1_R1.fastq.gz	fastq/S2/F1_R2.fastq.gz	RGID2	SampleID2	Lib2	UM	ILLUMINA &lt;br /&gt;
 Sample2	fastq/S2/F2.fastq.gz	.	RGID2	SampleID2	Lib2	UM	ILLUMINA &lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;--fastq_prefix&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;FASTQ_PREFIX&amp;lt;/code&amp;gt; setting can be used to specify a prefix to the FASTQ1/FASTQ2 file paths that should be applied before using the files.&lt;br /&gt;
&lt;br /&gt;
=== Reference Files === &lt;br /&gt;
See [[GotCloud: Genetic Reference and Resource Files]] for detailed information about the multiple required reference files for the alignment pipeline, including:&lt;br /&gt;
* How to obtain default references&lt;br /&gt;
* Configuration keys &amp;amp; default values&lt;br /&gt;
* How to generate your own references&lt;br /&gt;
* How to point GotCloud to your reference files&lt;br /&gt;
&lt;br /&gt;
Required Reference File Types:&lt;br /&gt;
* [[GotCloud: Genetic Reference and Resource Files#Reference fasta Files|Reference fasta Files]]&lt;br /&gt;
* [[GotCloud: Genetic Reference and Resource Files#DBSNP VCF Files|DBSNP VCF Files]]&lt;br /&gt;
* [[GotCloud: Genetic Reference and Resource Files#HapMap3 VCF Files|HapMap3 VCF Files]]&lt;br /&gt;
&lt;br /&gt;
=== Configuration File === &lt;br /&gt;
{{:GotCloud: Configuration}}&lt;br /&gt;
&lt;br /&gt;
==== Recommended Settings ==== &lt;br /&gt;
&lt;br /&gt;
As of GotCloud version 1.16, the alignment pipeline uses &amp;lt;code&amp;gt;bwa mem&amp;lt;/code&amp;gt; by default.  Prior to version 1.16, the default aligner was &amp;lt;code&amp;gt;bwa aln&amp;lt;/code&amp;gt;.  &lt;br /&gt;
&lt;br /&gt;
You can override the defaults by setting in your configuration file:&lt;br /&gt;
* to use &amp;lt;code&amp;gt;bwa mem&amp;lt;/code&amp;gt; (you do not need to set this in version 1.16 and later since it is the default)&lt;br /&gt;
 MAP_TYPE = BWA_MEM&lt;br /&gt;
* to use &amp;lt;code&amp;gt;bwa aln&amp;lt;/code&amp;gt; (you do not need to set this prior to version 1.16 since it is the default)&lt;br /&gt;
 MAP_TYPE = BWA&lt;br /&gt;
&lt;br /&gt;
==== Additional Required Settings ==== &lt;br /&gt;
&lt;br /&gt;
See [[#FASTQ List File|FASTQ List File]] for how to set the index file either via command line options or via configuration.&lt;br /&gt;
&lt;br /&gt;
==== Turning Off Optional Steps==== &lt;br /&gt;
Quality Control steps can be disabled. &lt;br /&gt;
&lt;br /&gt;
To Disable QPLOT, remove qplot from the PER_MERGE_STEPS configuration by setting: &lt;br /&gt;
 PER_MERGE_STEPS = verifyBamID index recab&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To Disable VerifyBamID, remove qplot from the PER_MERGE_STEPS configuration by setting: &lt;br /&gt;
 PER_MERGE_STEPS = qplot index recab&lt;br /&gt;
&lt;br /&gt;
==== Optional Configurable Settings ==== &lt;br /&gt;
You may want to adjust the amount of memory/threads that are used: &lt;br /&gt;
&lt;br /&gt;
There are additional configurable settings, but these are the ones most likely to be adjusted. &lt;br /&gt;
&lt;br /&gt;
* BWA_THREADS = -t N &lt;br /&gt;
** Fill in the N with the number of threads you want BWA to run with, default is 1&lt;br /&gt;
* BWA_QUAL = -q N &lt;br /&gt;
** Fill in the N with the trim quality you want BWA aln to run with, default is 15.  This parameter is only applied to bwa aln.  It is not used for BWA_MEM.&lt;br /&gt;
* BWA_MEM_OPTS = &lt;br /&gt;
** Specify any additional bwa mem options using this parameter.&lt;br /&gt;
* SORT_MAX_MEM = 2000000000 &lt;br /&gt;
** Maximum amount of memory used by samtools sort after running bwa&lt;br /&gt;
&lt;br /&gt;
== Running the Alignment Pipeline == &lt;br /&gt;
&lt;br /&gt;
=== Command-Line Options === &lt;br /&gt;
* help - print usage &lt;br /&gt;
* test OUTPUT_DIR - run the test example placing the output in a user specified OUTPUT_DIR.  No other options are required. &lt;br /&gt;
* outdir OUTPUT_DIR - directory for the output &lt;br /&gt;
** May also be specified via OUT_DIR in the configuration file &lt;br /&gt;
** Required to be set either via command-line or configuration &lt;br /&gt;
* conf CONFIG_FILE - configuration file &lt;br /&gt;
* list FASTQ_LIST_FILE_NAME  - name of the fastq list file &lt;br /&gt;
** May also be specified via FASTQ_LIST in the configuration file &lt;br /&gt;
** Required to be set either via command-line or configuration &lt;br /&gt;
* ref_dir REFERENCE_DIR - value to set config key REF_DIR to, overriding other values, REF_DIR can then be used inside config files. &lt;br /&gt;
** May also be specified via REF_DIR in the configuration file &lt;br /&gt;
* ref_prefix REFERENCE_DIR - path to prepend to non-absolute REF paths.&lt;br /&gt;
** May also be specified via REF_PREFIX in the configuration file &lt;br /&gt;
* fastq_prefix FASTQ_PATH - prefix path to the fastq files specified in the FASTQ_LIST &lt;br /&gt;
** May also be specified via FASTQ_PREFIX in the configuration file &lt;br /&gt;
* base_prefix BASE_PATH - prefix path to the prepend to fastq/ref files without absolute paths&lt;br /&gt;
** May also be specified via BASE_PREFIX in the configuration file &lt;br /&gt;
* keepTmp - Do not remove the temporary files (removed by default) &lt;br /&gt;
** May also be specified via KEEP_TMP in the configuration file &lt;br /&gt;
* keepLog - Do not remove the intermediate log files (removed by default) &lt;br /&gt;
** May also be specified via KEEP_LOG in the configuration file &lt;br /&gt;
* numjobs N - Replace N with the number of samples that should be processed in parallel&lt;br /&gt;
* threads N - Replace N with the number of targets in each makefile that should be run in parallel &lt;br /&gt;
* dryrun - Create the Makefile, but do not run it&lt;br /&gt;
* maxlocaljobs N - Replace N with the maximum number of jobs that can be run locally (no batchtype specified).  Default is 10.&lt;br /&gt;
* batchtype TYPE - Tells GotCloud the specified batch type to send jobs to the client nodes&lt;br /&gt;
** May also be specified via BATCH_TYPE in the configuration file&lt;br /&gt;
** Can be: mosix, slurm, slurmi, pbs, sge, sgei&lt;br /&gt;
* batchopts OPTS - Tells GotCloud the options to pass onto the batch system&lt;br /&gt;
** May also be specified via BATCH_OPTS in the configuration file&lt;br /&gt;
* noPhoneHome - disable the phone home logic&lt;br /&gt;
* gotcloudroot DIR - Specifies an alternate path to other gotcloud files rather than using the path to the gotcloud/align.pl.&lt;br /&gt;
Note: Command-line options take priority over configuration file settings&lt;br /&gt;
&lt;br /&gt;
===Running the Alignment Pipeline=== &lt;br /&gt;
Run &amp;lt;code&amp;gt;gotcloud align&amp;lt;/code&amp;gt; with the appropriate command-line parameters. &lt;br /&gt;
&lt;br /&gt;
Example: &lt;br /&gt;
 gotcloud align --conf config.txt --outdir output &lt;br /&gt;
&lt;br /&gt;
This step generates 1 Makefile per sample in the output/Makefiles/ directory and then automatically runs them.  The Makefiles contain all of the information to run each sample. &lt;br /&gt;
&lt;br /&gt;
If you only want to generate the makefiles and not run them, use the &amp;lt;code&amp;gt;--dryrun&amp;lt;/code&amp;gt; option.  It will generate the Makefiles and print instructions for running the Makefiles. &lt;br /&gt;
&lt;br /&gt;
Each Makefile is independent and can be run in parallel and across a cloud. &lt;br /&gt;
&lt;br /&gt;
On success, you will see:&lt;br /&gt;
 Processing finished in nn secs with no errors reported&lt;br /&gt;
&lt;br /&gt;
If processing fails part way through, you can pick up where you left off by rerunning gotcloud or the make command.&lt;br /&gt;
&lt;br /&gt;
=== Alignment Pipeline Output ===&lt;br /&gt;
Upon successful completion of the alignment pipeline, you should see the following files/ subdirectories under the user specified output directory: &lt;br /&gt;
* &#039;&#039;&#039;bam.list&#039;&#039;&#039; - file containing sample-&amp;gt;BAM mapping that can be used in other GotCloud pipelines&lt;br /&gt;
* &#039;&#039;&#039;bams/&#039;&#039;&#039; - contains the final BAM and bai (BAM index) files&lt;br /&gt;
** &#039;&#039;&#039;*.recal.bam&#039;&#039;&#039;&lt;br /&gt;
** &#039;&#039;&#039;*.recal.bam.bai&#039;&#039;&#039;&lt;br /&gt;
** &#039;&#039;*.recal.bam.bai.done&#039;&#039; - temp file indicating this step completed successfully&lt;br /&gt;
** &#039;&#039;*.recal.bam.done&#039;&#039; - temp file indicating this step completed successfully&lt;br /&gt;
** *.recal.bam.metrics - dedup &amp;amp; recalibration log&lt;br /&gt;
** *.recal.bam.qemp - recalibration tables&lt;br /&gt;
* Makefiles/ - contains the Makefiles and logs used by GotCloud to run the alignment pipeline&lt;br /&gt;
* &#039;&#039;&#039;QCFiles/&#039;&#039;&#039; - contains quality control results if quality control is not disabled&lt;br /&gt;
** VerifyBamID Output - see [[VerifyBamID#A_guideline_to_interpret_output_files|VerifyBamID: A guideline to interpret output files]] for more information&lt;br /&gt;
*** *.genoCheck.depthRG - depth distribution of the sequence reads per read group&lt;br /&gt;
*** *.genoCheck.depthSM - depth distribution of the sequence reads per sample&lt;br /&gt;
*** &#039;&#039;*.genoCheck.done&#039;&#039; - temp file indicating this step completed successfully&lt;br /&gt;
*** *.genoCheck.selfRG - per-readGroup statistics describing how well each lane matches to the annotated sample&lt;br /&gt;
*** &#039;&#039;&#039;*.genoCheck.selfSM&#039;&#039;&#039; - main output file containing the contamination estimate; per-sample statistics describing how well the sample matches to the annotated sample&lt;br /&gt;
**** Check the &#039;FREEMIX&#039; column for genotype-free estimate of contamination 0-1 scale, the lower, the better&lt;br /&gt;
**** If [FREEMIX] &amp;gt;= 0.03 and [FREELK1]-[FREELK0] is large, possible contamination&lt;br /&gt;
** Qplot Output - see: [[QPLOT#Diagnose_sequencing_quality|QPLOT: Diagnose sequencing quality]] for more info on how to use QPLOT results&lt;br /&gt;
*** &#039;&#039;*.qplot.done&#039;&#039; - temp file indicating this step completed successfully&lt;br /&gt;
*** &#039;&#039;&#039;*.qplot.R&#039;&#039;&#039; - Rscript that can be used to generate the pdf graphs&lt;br /&gt;
*** &#039;&#039;&#039;*.qplot.stats&#039;&#039;&#039; - sample statistics&lt;br /&gt;
* tmp/ - contains intermediate files (most are deleted unless --keepTmp is specified)&lt;br /&gt;
* *.OK - one OK file per sample; indicates the Sample successfully completed alignment&lt;br /&gt;
&lt;br /&gt;
You should also see a &amp;lt;code&amp;gt;.OK&amp;lt;/code&amp;gt; for each Sample in the index file. &lt;br /&gt;
&lt;br /&gt;
If you do not see these &amp;lt;code&amp;gt;.OK&amp;lt;/code&amp;gt; files, then your Alignment Pipeline failed. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;On success, the bams/ directory contains the final BAMs and bais.&#039;&#039;&#039;&lt;/div&gt;</summary>
		<author><name>Mktrost</name></author>
	</entry>
	<entry>
		<id>http://genome.sph.umich.edu/w/index.php?title=Releasing_GotCloud&amp;diff=13880</id>
		<title>Releasing GotCloud</title>
		<link rel="alternate" type="text/html" href="http://genome.sph.umich.edu/w/index.php?title=Releasing_GotCloud&amp;diff=13880"/>
		<updated>2015-10-29T03:00:38Z</updated>

		<summary type="html">&lt;p&gt;Mktrost: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Back to parent: [[GotCloud]]&lt;br /&gt;
&lt;br /&gt;
Software for GotCloud is kept in a &#039;&#039;&#039;git&#039;&#039;&#039; repository on &#039;&#039;&#039;github&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
We also create a Debian package and tar file for GotCloud.&lt;br /&gt;
&lt;br /&gt;
To release a new version of GotCloud:&lt;br /&gt;
# I recommend creating a new directory:&lt;br /&gt;
#: &amp;lt;code&amp;gt; cd ~/dev&amp;lt;/code&amp;gt;&lt;br /&gt;
#: &amp;lt;code&amp;gt; git clone git://github.com/statgen/gotcloud.git&amp;lt;/code&amp;gt;&lt;br /&gt;
#: &amp;lt;code&amp;gt; cd gotcloud&amp;lt;/code&amp;gt;&lt;br /&gt;
# Build the source&lt;br /&gt;
#: &amp;lt;code&amp;gt; cd src&amp;lt;/code&amp;gt;&lt;br /&gt;
#: &amp;lt;code&amp;gt; make&amp;lt;/code&amp;gt;&lt;br /&gt;
# Run the tests, ensure they all succeed&lt;br /&gt;
#: &amp;lt;code&amp;gt;./gotcloud align --test testDir&amp;lt;/code&amp;gt;&lt;br /&gt;
#: &amp;lt;code&amp;gt;./gotcloud snpcall --test testDir&amp;lt;/code&amp;gt;&lt;br /&gt;
#: &amp;lt;code&amp;gt;./gotcloud ldrefine --test testDir&amp;lt;/code&amp;gt;&lt;br /&gt;
#: &amp;lt;code&amp;gt;./gotcloud indel --test testDir&amp;lt;/code&amp;gt;&lt;br /&gt;
# Update the version number (if you have not already).&lt;br /&gt;
#* Edit release_version.txt&lt;br /&gt;
#* Commit the new release number&lt;br /&gt;
#*: &amp;lt;code&amp;gt;git add release_version.txt&amp;lt;/code&amp;gt;&lt;br /&gt;
#*: &amp;lt;code&amp;gt;git commit -m &amp;quot;Release 1.XX&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
#* Push to github&lt;br /&gt;
#*: &amp;lt;code&amp;gt;git push&amp;lt;/code&amp;gt;&lt;br /&gt;
# Checkout latest branch and merge master &amp;amp; push&lt;br /&gt;
#: &amp;lt;code&amp;gt;git checkout latest&amp;lt;/code&amp;gt;&lt;br /&gt;
#: &amp;lt;code&amp;gt;git merge master&amp;lt;/code&amp;gt;&lt;br /&gt;
#: &amp;lt;code&amp;gt;git checkout master&amp;lt;/code&amp;gt;&lt;br /&gt;
#: &amp;lt;code&amp;gt;git push&amp;lt;/code&amp;gt;&lt;br /&gt;
# Create a release tag&lt;br /&gt;
#: &amp;lt;code&amp;gt;git tag -a gotcloud.1.XX -m &#039;version 1.XX&#039;&amp;lt;/code&amp;gt;&lt;br /&gt;
# Push tag&lt;br /&gt;
#: &amp;lt;code&amp;gt; git push origin gotcloud.1.XX&amp;lt;/code&amp;gt;&lt;br /&gt;
# Create the debian packages&lt;br /&gt;
#* Generate the packages&lt;br /&gt;
#*: &amp;lt;code&amp;gt; debian/makedeb.sh bin =&amp;lt;/code&amp;gt;&lt;br /&gt;
#*: &amp;lt;code&amp;gt; debian/makedeb.sh test =&amp;lt;/code&amp;gt;&lt;br /&gt;
# Generate the release notes on github&lt;br /&gt;
#: On github, login		&lt;br /&gt;
#::Goto Tags, Select &amp;quot;Draft New Release&amp;quot;&lt;br /&gt;
#::* Select the &amp;quot;Tag version&amp;quot; you created&lt;br /&gt;
#::* Fill in the release notes&lt;br /&gt;
# Update wiki release documentation (for full release)&lt;br /&gt;
#* http://genome.sph.umich.edu/wiki/GotCloud:_Versions&lt;br /&gt;
# Send Email to google group (for full release)&lt;br /&gt;
#* gotcloud@googlegroups.com &lt;br /&gt;
#* I usually do it from the groups site as an announcement &amp;amp; post on behalf of GotCloud (I may need to modify your permissions to do this)&lt;br /&gt;
#** https://groups.google.com/forum/?hl=en#!forum/gotcloud&lt;br /&gt;
# Install on mario&lt;br /&gt;
#* In the gotcloud directory where you generated the deb files, run:&lt;br /&gt;
#*: &amp;lt;code&amp;gt;debian/install_gotcloud_without_root.sh 1.16 /net/mario&amp;lt;/code&amp;gt;&lt;br /&gt;
#* Install the latest gotcloud in the gotcloud.old directory (named by version) so someone can run a specific version&lt;br /&gt;
#*: &amp;lt;code&amp;gt;debian/install_gotcloud_without_root.sh 1.16 /net/mario/gotcloud.old&amp;lt;/code&amp;gt;&lt;br /&gt;
#* Rename to the version name:&lt;br /&gt;
#*: &amp;lt;code&amp;gt;mv /net/mario/gotcloud.old/gotcloud /net/mario/gotcloud.old/gotcloud.1.XX&amp;lt;/code&amp;gt;&lt;br /&gt;
# Send email to csg group to inform them of the newly installed version on the cluster and of any relevant changes&lt;br /&gt;
#* gotcloudUsers@umich.edu&lt;/div&gt;</summary>
		<author><name>Mktrost</name></author>
	</entry>
	<entry>
		<id>http://genome.sph.umich.edu/w/index.php?title=User_talk:Pjvh&amp;diff=13674</id>
		<title>User talk:Pjvh</title>
		<link rel="alternate" type="text/html" href="http://genome.sph.umich.edu/w/index.php?title=User_talk:Pjvh&amp;diff=13674"/>
		<updated>2015-08-19T19:00:59Z</updated>

		<summary type="html">&lt;p&gt;Mktrost: Welcome!&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;&#039;Welcome to &#039;&#039;Genome Analysis Wiki&#039;&#039;!&#039;&#039;&#039;&lt;br /&gt;
We hope you will contribute much and well.&lt;br /&gt;
You will probably want to read the [[Help:Contents|help pages]].&lt;br /&gt;
Again, welcome and have fun! [[User:Mktrost|Mktrost]] ([[User talk:Mktrost|talk]]) 15:00, 19 August 2015 (EDT)&lt;/div&gt;</summary>
		<author><name>Mktrost</name></author>
	</entry>
	<entry>
		<id>http://genome.sph.umich.edu/w/index.php?title=User:Pjvh&amp;diff=13673</id>
		<title>User:Pjvh</title>
		<link rel="alternate" type="text/html" href="http://genome.sph.umich.edu/w/index.php?title=User:Pjvh&amp;diff=13673"/>
		<updated>2015-08-19T19:00:58Z</updated>

		<summary type="html">&lt;p&gt;Mktrost: Creating user page for new user.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.&lt;/div&gt;</summary>
		<author><name>Mktrost</name></author>
	</entry>
	<entry>
		<id>http://genome.sph.umich.edu/w/index.php?title=GotCloud:_Creating_a_New_Pipeline&amp;diff=13592</id>
		<title>GotCloud: Creating a New Pipeline</title>
		<link rel="alternate" type="text/html" href="http://genome.sph.umich.edu/w/index.php?title=GotCloud:_Creating_a_New_Pipeline&amp;diff=13592"/>
		<updated>2015-06-30T18:56:30Z</updated>

		<summary type="html">&lt;p&gt;Mktrost: /* Example Pipelines Created */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Creating a New BAM Processing Pipeline ==&lt;br /&gt;
&lt;br /&gt;
GotCloud allows you to configure new basic BAM processing pipelines via configuration.&lt;br /&gt;
&lt;br /&gt;
To define new processing pipelines, you will use Configuration sections to define both the pipeline and each of the steps.  So first you need to understand how configuration sections work.&lt;br /&gt;
&lt;br /&gt;
=== GotCloud Configuration Sections ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
GotCloud configuration files can be broken into sections:&lt;br /&gt;
* Section names are specified between square brakets (&amp;lt;code&amp;gt;[]&amp;lt;/code&amp;gt;)&lt;br /&gt;
*: &amp;lt;pre&amp;gt;[sectionName]&amp;lt;/pre&amp;gt;&lt;br /&gt;
** Any configuration settings specified after the section header belong to that section&lt;br /&gt;
** A section can be specified multiple times in the file and the configuration settings are accumulated&lt;br /&gt;
** To access a value for a key defined in another section, use &amp;lt;code&amp;gt;$(otherSectionName/keyName)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* If a section is not specified, the configuration settings belong to the &amp;lt;code&amp;gt;global&amp;lt;/code&amp;gt; section&lt;br /&gt;
** The &amp;lt;code&amp;gt;global&amp;lt;/code&amp;gt; section does not need to be specified at the beginning of the file (it is the default section).&lt;br /&gt;
** Additional &amp;lt;code&amp;gt;global&amp;lt;/code&amp;gt; settings can be set later in the file after other settings, by defining the explicitly section:&lt;br /&gt;
**: &amp;lt;pre&amp;gt;[global]&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* Sections can be derived from another section&lt;br /&gt;
** All sections automatically derive from &amp;lt;code&amp;gt;[global]&amp;lt;/code&amp;gt;&lt;br /&gt;
** A derived section inherits all the configuration settings from its parent sections&lt;br /&gt;
*** Parent settings are overridden by redefining the configuration key/value pair&lt;br /&gt;
** A parent section is specified following a semicolon &amp;lt;code&amp;gt;:&amp;lt;/code&amp;gt; on the section definition line:&lt;br /&gt;
**: &amp;lt;pre&amp;gt;[childSectionName] : parentSectionName&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Section specific configuration settings are specified on the lines following the section definition:&lt;br /&gt;
&amp;lt;dd&amp;gt;&amp;lt;pre&amp;gt;[section1]&lt;br /&gt;
KEY1 = VAL1&lt;br /&gt;
KEY2 = VAL2&lt;br /&gt;
&lt;br /&gt;
[section2]&lt;br /&gt;
KEY1 = VAL1_2&lt;br /&gt;
KEY3 = VAL3&amp;lt;/pre&amp;gt;&amp;lt;/dd&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
=== Defining a New Pipeline ===&lt;br /&gt;
&lt;br /&gt;
There are 2 parts for creating a new pipeline&lt;br /&gt;
# [[#Overall Pipeline Definition|Overall Pipeline Definition]]&lt;br /&gt;
#* Basics for the overall pipeline&lt;br /&gt;
#* &#039;&#039;&#039;NOTE: Currently, configurations set in the overall pipeline&#039;s section do not by default pass onto the step&#039;s configurations&#039;&#039;&#039;&lt;br /&gt;
# [[#Configure Each Step|Configure Each Step]]&lt;br /&gt;
&lt;br /&gt;
==== Overall Pipeline Definition ====&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Define a new configuration section for your pipeline&lt;br /&gt;
&amp;lt;ul&amp;gt;&amp;lt;li&amp;gt; Example:&amp;lt;/li&amp;gt;&amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;dd&amp;gt; &amp;lt;pre&amp;gt;[pipelineName]&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Define the steps in this pipeline using the key &amp;lt;code&amp;gt;STEPS&amp;lt;/code&amp;gt; under that section&lt;br /&gt;
&amp;lt;ul&amp;gt;&amp;lt;li&amp;gt; Example:&amp;lt;/li&amp;gt;&amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;dd&amp;gt;&amp;lt;pre&amp;gt;[pipelineName]&lt;br /&gt;
STEPS = stepName1 stepName2 stepName3&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;ul&amp;gt;&amp;lt;li&amp;gt; Note: each step must have its own configuration section&amp;lt;/li&amp;gt;&amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Optional Overall Pipeline Settings:&lt;br /&gt;
* BATCH_OPTS&lt;br /&gt;
* BATCH_TYPE&lt;br /&gt;
* IGNORE_SM_CHECK - turn off the default validation that the @RG SM tag matches the bam list sample name.&lt;br /&gt;
* IGNORE_REF_CHR_CHECK - turn off the default validation that checks that all of the BAM&#039;s chromosomes are in the reference file - eventually we may update to just validate those in CHRS.&lt;br /&gt;
* OUT_DIR&lt;br /&gt;
* BAM_LIST&lt;br /&gt;
* REF&lt;br /&gt;
* REF_FAI&lt;br /&gt;
* MULTIPLE_TARGET_MAP&lt;br /&gt;
* UNIFORM_TARGET_BED&lt;br /&gt;
* OFFSET_OFF_TARET&lt;br /&gt;
* CHRS - defines which chromosomes to run.&lt;br /&gt;
* UNIT_CHUNK&lt;br /&gt;
* NO_CRAM - do not allow CRAM files as input&lt;br /&gt;
* MAKE_BASE_NAME_PIPE - base makefile name&lt;br /&gt;
* MAKE_OPTS - otpions to pass to the make command that runs the jobs.&lt;br /&gt;
* BAM_DEPEND - set to TRUE if you want the BAM file to be included as a make dependency&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
NOTES:&lt;br /&gt;
* The BAM_LIST file can contain config values within it - the overall pipeline section will be checked for those config values.&lt;br /&gt;
* By default if a value is not defined in the section, it will check global.&lt;br /&gt;
&lt;br /&gt;
==== Configure Each Step ====&lt;br /&gt;
&#039;&#039;&#039;Create a section for each step&#039;&#039;&#039;&lt;br /&gt;
* Example: &amp;lt;code&amp;gt;[stepName1]&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Required keys for each step:====&lt;br /&gt;
&lt;br /&gt;
# &amp;lt;code&amp;gt;DEPEND&amp;lt;/code&amp;gt; - dependencies for this step&lt;br /&gt;
#: Valid Values (separate multiple dependencies with a space):&lt;br /&gt;
#:*&amp;lt;code&amp;gt;BAM&amp;lt;/code&amp;gt;&lt;br /&gt;
#:*Name of step that must complete prior to this step&lt;br /&gt;
#:*PER_SAMPLE_BAM??? can only be BAM or PER_SAMPLE_BAM&lt;br /&gt;
#&amp;lt;code&amp;gt;OUTPUT&amp;lt;/code&amp;gt; - name of output file&lt;br /&gt;
#* See below for temporary keys for step iteration&lt;br /&gt;
#&amp;lt;code&amp;gt;CMD&amp;lt;/code&amp;gt; - command for running the step&lt;br /&gt;
#* See below for temporary keys for step iteration&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Optional Step Settings:====&lt;br /&gt;
General Settings:&lt;br /&gt;
* &amp;lt;code&amp;gt;LOCAL&amp;lt;/code&amp;gt; - run the step locally rather than on the cluster&lt;br /&gt;
* &amp;lt;code&amp;gt;NEED_BAI&amp;lt;/code&amp;gt; - Set if a step requires a BAI file&lt;br /&gt;
** Per chromosome steps always require a BAI file&lt;br /&gt;
** Tells GotCloud to fail if a BAI can&#039;t be found&lt;br /&gt;
* &amp;lt;code&amp;gt;BAM_DEPEND&amp;lt;/code&amp;gt; - Add the BAM file as a Makefile dependency for this step&lt;br /&gt;
&lt;br /&gt;
Settings to limit which samples this step runs on:&lt;br /&gt;
* &amp;lt;code&amp;gt;SAMPLES&amp;lt;/code&amp;gt; - use this to define a step to run only for samples with a single BAM or multiple BAMs (merging)&lt;br /&gt;
*: Possible values:&lt;br /&gt;
*:* &amp;lt;code&amp;gt;MULTI_BAM&amp;lt;/code&amp;gt; - run the step only for samples that have multiple BAMs&lt;br /&gt;
*:* &amp;lt;code&amp;gt;SINGLE_BAM&amp;lt;/code&amp;gt; - run the step only for samples that have one BAM&lt;br /&gt;
*Deprecated settings - still in pipeline.pl and may or may not work:&lt;br /&gt;
** &amp;lt;code&amp;gt;MULTI_ONLY&amp;lt;/code&amp;gt; - set to non-blank if step should run if there are more than 1 input per output.&lt;br /&gt;
** &amp;lt;code&amp;gt;SINGLE_ONLY&amp;lt;/code&amp;gt; - set to non-blank if step should run if there is only 1 input per output.&lt;br /&gt;
&lt;br /&gt;
Joining multiple inputs for a single output:&lt;br /&gt;
* Can occur if there are multiple dependencies&lt;br /&gt;
* Can occur if a step runs at a more generic iteration level than a dependency&lt;br /&gt;
* &amp;lt;code&amp;gt;INPUT_JOIN&amp;lt;/code&amp;gt; - value to pass to perl &amp;quot;join&amp;quot; command for joining multiple inputs for each output.&lt;br /&gt;
** Looks across all dependencies&lt;br /&gt;
* &amp;lt;code&amp;gt;dependStepName_JOIN&amp;lt;/code&amp;gt; - how to join the &amp;quot;dependStepName&amp;quot;&#039;s output into the command line for a step that depends on it if there are multiple outputs per input of this step&lt;br /&gt;
** Substitutes &amp;lt;code&amp;gt;?(${depend}/OUTPUT)&amp;lt;/code&amp;gt; with perl &amp;quot;join&amp;quot; using the specified value to join multiple outputs for that dependency&lt;br /&gt;
&lt;br /&gt;
Log Output filenames&lt;br /&gt;
* &amp;lt;code&amp;gt;FILELIST&amp;lt;/code&amp;gt; - writes/appends the iteration&#039;s output file name into the specified file list.&lt;br /&gt;
** Typically will be used in a later &amp;quot;merge&amp;quot; step&lt;br /&gt;
** See below for temporary keys for step iteration that can be used in this filename&lt;br /&gt;
*** Temporary keys can be more general than those in OUTPUT, but cannot be more specific.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Iterating a command for each Bam/Sample/Chromosome/Region====&lt;br /&gt;
Temporary keys are used when iterating a command per BAM/sample/chromosome/region.&lt;br /&gt;
* Specify using &amp;lt;code&amp;gt;?()&amp;lt;/code&amp;gt; rather than &amp;lt;code&amp;gt;$()&amp;lt;/code&amp;gt;&lt;br /&gt;
* Temporary keys can be used in:&lt;br /&gt;
** &amp;lt;code&amp;gt;OUTPUT&amp;lt;/code&amp;gt;&lt;br /&gt;
** &amp;lt;code&amp;gt;CMD&amp;lt;/code&amp;gt;&lt;br /&gt;
** &amp;lt;code&amp;gt;FILELIST&amp;lt;/code&amp;gt;&lt;br /&gt;
* They will be substituted as it iterates&lt;br /&gt;
* How to iterate a command is determined by the temporary keys in &amp;lt;code&amp;gt;OUTPUT&amp;lt;/code&amp;gt;&lt;br /&gt;
* Temporary Keys for determining iterations:&lt;br /&gt;
** &amp;lt;code&amp;gt;?(BAM)&amp;lt;/code&amp;gt; - per BAM per sample&lt;br /&gt;
** &amp;lt;code&amp;gt;?(SAMPLE)&amp;lt;/code&amp;gt; - per sample&lt;br /&gt;
** &amp;lt;code&amp;gt;?(CHR)&amp;lt;/code&amp;gt; - per chromosome&lt;br /&gt;
** &amp;lt;code&amp;gt;?(START)&amp;lt;/code&amp;gt; - Per region of a Chromosome (must also include &amp;lt;code&amp;gt;?(CHR)&amp;lt;/code&amp;gt;):&lt;br /&gt;
* Additional Temporary Keys:&lt;br /&gt;
** &amp;lt;code&amp;gt;?(END)&amp;lt;/code&amp;gt; - end of the region - only used if &amp;lt;code&amp;gt;?(START)&amp;lt;/code&amp;gt; is also specified.&lt;br /&gt;
** &amp;lt;code&amp;gt;?(INPUT)&amp;lt;/code&amp;gt;&lt;br /&gt;
** &amp;lt;code&amp;gt;?(${depend}/OUTPUT)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Notes:&#039;&#039;&#039;&lt;br /&gt;
* Currently each step iteration will:&lt;br /&gt;
** be its own Makefile target/.OK file&lt;br /&gt;
** run independently on the cluster&lt;br /&gt;
&lt;br /&gt;
== Command Line Parameters ==&lt;br /&gt;
Required Parameters:&lt;br /&gt;
* &amp;lt;code&amp;gt;--name&amp;lt;/code&amp;gt; &amp;lt;pipelineName&amp;gt; - name of the pipeline to run&lt;br /&gt;
* &amp;lt;code&amp;gt;--conf&amp;lt;/code&amp;gt; &amp;lt;configuration file&amp;gt; - configuration file to use&lt;br /&gt;
&lt;br /&gt;
NOTE: Currently, any &amp;quot;overrides&amp;quot; are for the global setting only - not for the pipeline/step.&lt;br /&gt;
* this needs to be fixed so they can override the pipeline settings&lt;br /&gt;
&lt;br /&gt;
Optional Parameters:&lt;br /&gt;
* &amp;lt;code&amp;gt;--ignoreSmCheck&amp;lt;/code&amp;gt; - overrides &amp;lt;code&amp;gt;IGNORE_SM_CHECK&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;--ignoreRefChrCheck&amp;lt;/code&amp;gt; - overrides &amp;lt;code&amp;gt;IGNORE_REF_CHR_CHECK&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;--verbose&amp;lt;/code&amp;gt; &amp;lt;number&amp;gt; - verbose value passed to the loadConf method&lt;br /&gt;
&lt;br /&gt;
Optional Parameters like SnpCall:&lt;br /&gt;
* &amp;lt;code&amp;gt;--numjobs|numjobs&amp;lt;/code&amp;gt; &amp;lt;number&amp;gt; - number of jobs to run in parallel&lt;br /&gt;
* &amp;lt;code&amp;gt;--maxlocaljobs&amp;lt;/code&amp;gt; &amp;lt;number&amp;gt; - number of jobs to allow to run when batchtype is local (default 10) - does not validate for commands running LOCAL&lt;br /&gt;
* &amp;lt;code&amp;gt;--region&amp;lt;/code&amp;gt; &amp;lt;region to process&amp;gt; - like snpcall, specifies a single region to process&lt;br /&gt;
* &amp;lt;code&amp;gt;--bam_list|list|bamlist|bam_index|bamindex&amp;lt;/code&amp;gt; &amp;lt;bam list file&amp;gt; - overrides &lt;br /&gt;
&amp;lt;code&amp;gt;BAM_LIST&amp;lt;/code&amp;gt; list of sample\tbam to process&lt;br /&gt;
* &amp;lt;code&amp;gt;--out_dir|outdir&amp;lt;/code&amp;gt; &amp;lt;output directory&amp;gt; - overrides &amp;lt;code&amp;gt;OUT_DIR&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;--batchtype&amp;lt;/code&amp;gt; &amp;lt;type&amp;gt; - overrides &amp;lt;code&amp;gt;BATCHTYPE&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;--batchopts&amp;lt;/code&amp;gt; &amp;lt;options&amp;gt; - overrides &amp;lt;code&amp;gt;BATCHOPTS&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;--chrs|chroms&amp;lt;/code&amp;gt; &amp;lt;comma separated chromosomes&amp;gt; - overrides &amp;lt;code&amp;gt;CHRS&amp;lt;/code&amp;gt; (CHRS is space separated - commas are converted to spaces)&lt;br /&gt;
* &amp;lt;code&amp;gt;--ref_dir|refdir&amp;lt;/code&amp;gt; &amp;lt;reference directory&amp;gt; - overrides &amp;lt;code&amp;gt;REF_DIR&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;--ref_prefix|refprefix&amp;lt;/code&amp;gt; &amp;lt;prefix&amp;gt; - overrides &amp;lt;code&amp;gt;REF_PREFIX&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;--bam_prefix|bamprefix&amp;lt;/code&amp;gt; &amp;lt;prefix&amp;gt; - overrides &amp;lt;code&amp;gt;BAM_PREFIX&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;--base_prefix|baseprefix&amp;lt;/code&amp;gt; &amp;lt;prefix&amp;gt; - overrides &amp;lt;code&amp;gt;BASE_PREFIX&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;--gotcloudroot|gcroot&amp;lt;/code&amp;gt; &amp;lt;path to gotcloud&amp;gt; - by default gotcloud root is determined from the path to the pipeline script, but this setting overrides that.&lt;br /&gt;
* &amp;lt;code&amp;gt;--help&amp;lt;/code&amp;gt; - print Usage&lt;br /&gt;
* &amp;lt;code&amp;gt;--test&amp;lt;/code&amp;gt; &amp;lt;test directory&amp;gt; - run the test code (just for indel right now)&lt;br /&gt;
&lt;br /&gt;
Unused command line options:&lt;br /&gt;
* In the code, but are not actually used:&lt;br /&gt;
* &amp;lt;code&amp;gt;--keeptmp&amp;lt;/code&amp;gt; - overrides &amp;lt;code&amp;gt;KEEP_TMP&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;--keeplog&amp;lt;/code&amp;gt; - overrides &amp;lt;code&amp;gt;KEEP_LOG&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Example Pipelines Created ==&lt;br /&gt;
Look for sections &amp;amp; &amp;lt;code&amp;gt;STEPS&amp;lt;/code&amp;gt; in the defaults.&lt;br /&gt;
 https://github.com/statgen/gotcloud/blob/master/bin/gotcloudDefaults.conf&lt;br /&gt;
 https://github.com/statgen/gotcloud/blob/alignPrep/bin/gotcloudDefaults.conf&lt;/div&gt;</summary>
		<author><name>Mktrost</name></author>
	</entry>
	<entry>
		<id>http://genome.sph.umich.edu/w/index.php?title=GotCloud:_Creating_a_New_Pipeline&amp;diff=13591</id>
		<title>GotCloud: Creating a New Pipeline</title>
		<link rel="alternate" type="text/html" href="http://genome.sph.umich.edu/w/index.php?title=GotCloud:_Creating_a_New_Pipeline&amp;diff=13591"/>
		<updated>2015-06-30T18:51:55Z</updated>

		<summary type="html">&lt;p&gt;Mktrost: /* Overall Pipeline Definition */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Creating a New BAM Processing Pipeline ==&lt;br /&gt;
&lt;br /&gt;
GotCloud allows you to configure new basic BAM processing pipelines via configuration.&lt;br /&gt;
&lt;br /&gt;
To define new processing pipelines, you will use Configuration sections to define both the pipeline and each of the steps.  So first you need to understand how configuration sections work.&lt;br /&gt;
&lt;br /&gt;
=== GotCloud Configuration Sections ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
GotCloud configuration files can be broken into sections:&lt;br /&gt;
* Section names are specified between square brakets (&amp;lt;code&amp;gt;[]&amp;lt;/code&amp;gt;)&lt;br /&gt;
*: &amp;lt;pre&amp;gt;[sectionName]&amp;lt;/pre&amp;gt;&lt;br /&gt;
** Any configuration settings specified after the section header belong to that section&lt;br /&gt;
** A section can be specified multiple times in the file and the configuration settings are accumulated&lt;br /&gt;
** To access a value for a key defined in another section, use &amp;lt;code&amp;gt;$(otherSectionName/keyName)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* If a section is not specified, the configuration settings belong to the &amp;lt;code&amp;gt;global&amp;lt;/code&amp;gt; section&lt;br /&gt;
** The &amp;lt;code&amp;gt;global&amp;lt;/code&amp;gt; section does not need to be specified at the beginning of the file (it is the default section).&lt;br /&gt;
** Additional &amp;lt;code&amp;gt;global&amp;lt;/code&amp;gt; settings can be set later in the file after other settings, by defining the explicitly section:&lt;br /&gt;
**: &amp;lt;pre&amp;gt;[global]&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* Sections can be derived from another section&lt;br /&gt;
** All sections automatically derive from &amp;lt;code&amp;gt;[global]&amp;lt;/code&amp;gt;&lt;br /&gt;
** A derived section inherits all the configuration settings from its parent sections&lt;br /&gt;
*** Parent settings are overridden by redefining the configuration key/value pair&lt;br /&gt;
** A parent section is specified following a semicolon &amp;lt;code&amp;gt;:&amp;lt;/code&amp;gt; on the section definition line:&lt;br /&gt;
**: &amp;lt;pre&amp;gt;[childSectionName] : parentSectionName&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Section specific configuration settings are specified on the lines following the section definition:&lt;br /&gt;
&amp;lt;dd&amp;gt;&amp;lt;pre&amp;gt;[section1]&lt;br /&gt;
KEY1 = VAL1&lt;br /&gt;
KEY2 = VAL2&lt;br /&gt;
&lt;br /&gt;
[section2]&lt;br /&gt;
KEY1 = VAL1_2&lt;br /&gt;
KEY3 = VAL3&amp;lt;/pre&amp;gt;&amp;lt;/dd&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
=== Defining a New Pipeline ===&lt;br /&gt;
&lt;br /&gt;
There are 2 parts for creating a new pipeline&lt;br /&gt;
# [[#Overall Pipeline Definition|Overall Pipeline Definition]]&lt;br /&gt;
#* Basics for the overall pipeline&lt;br /&gt;
#* &#039;&#039;&#039;NOTE: Currently, configurations set in the overall pipeline&#039;s section do not by default pass onto the step&#039;s configurations&#039;&#039;&#039;&lt;br /&gt;
# [[#Configure Each Step|Configure Each Step]]&lt;br /&gt;
&lt;br /&gt;
==== Overall Pipeline Definition ====&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Define a new configuration section for your pipeline&lt;br /&gt;
&amp;lt;ul&amp;gt;&amp;lt;li&amp;gt; Example:&amp;lt;/li&amp;gt;&amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;dd&amp;gt; &amp;lt;pre&amp;gt;[pipelineName]&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Define the steps in this pipeline using the key &amp;lt;code&amp;gt;STEPS&amp;lt;/code&amp;gt; under that section&lt;br /&gt;
&amp;lt;ul&amp;gt;&amp;lt;li&amp;gt; Example:&amp;lt;/li&amp;gt;&amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;dd&amp;gt;&amp;lt;pre&amp;gt;[pipelineName]&lt;br /&gt;
STEPS = stepName1 stepName2 stepName3&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;ul&amp;gt;&amp;lt;li&amp;gt; Note: each step must have its own configuration section&amp;lt;/li&amp;gt;&amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Optional Overall Pipeline Settings:&lt;br /&gt;
* BATCH_OPTS&lt;br /&gt;
* BATCH_TYPE&lt;br /&gt;
* IGNORE_SM_CHECK - turn off the default validation that the @RG SM tag matches the bam list sample name.&lt;br /&gt;
* IGNORE_REF_CHR_CHECK - turn off the default validation that checks that all of the BAM&#039;s chromosomes are in the reference file - eventually we may update to just validate those in CHRS.&lt;br /&gt;
* OUT_DIR&lt;br /&gt;
* BAM_LIST&lt;br /&gt;
* REF&lt;br /&gt;
* REF_FAI&lt;br /&gt;
* MULTIPLE_TARGET_MAP&lt;br /&gt;
* UNIFORM_TARGET_BED&lt;br /&gt;
* OFFSET_OFF_TARET&lt;br /&gt;
* CHRS - defines which chromosomes to run.&lt;br /&gt;
* UNIT_CHUNK&lt;br /&gt;
* NO_CRAM - do not allow CRAM files as input&lt;br /&gt;
* MAKE_BASE_NAME_PIPE - base makefile name&lt;br /&gt;
* MAKE_OPTS - otpions to pass to the make command that runs the jobs.&lt;br /&gt;
* BAM_DEPEND - set to TRUE if you want the BAM file to be included as a make dependency&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
NOTES:&lt;br /&gt;
* The BAM_LIST file can contain config values within it - the overall pipeline section will be checked for those config values.&lt;br /&gt;
* By default if a value is not defined in the section, it will check global.&lt;br /&gt;
&lt;br /&gt;
==== Configure Each Step ====&lt;br /&gt;
&#039;&#039;&#039;Create a section for each step&#039;&#039;&#039;&lt;br /&gt;
* Example: &amp;lt;code&amp;gt;[stepName1]&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Required keys for each step:====&lt;br /&gt;
&lt;br /&gt;
# &amp;lt;code&amp;gt;DEPEND&amp;lt;/code&amp;gt; - dependencies for this step&lt;br /&gt;
#: Valid Values (separate multiple dependencies with a space):&lt;br /&gt;
#:*&amp;lt;code&amp;gt;BAM&amp;lt;/code&amp;gt;&lt;br /&gt;
#:*Name of step that must complete prior to this step&lt;br /&gt;
#:*PER_SAMPLE_BAM??? can only be BAM or PER_SAMPLE_BAM&lt;br /&gt;
#&amp;lt;code&amp;gt;OUTPUT&amp;lt;/code&amp;gt; - name of output file&lt;br /&gt;
#* See below for temporary keys for step iteration&lt;br /&gt;
#&amp;lt;code&amp;gt;CMD&amp;lt;/code&amp;gt; - command for running the step&lt;br /&gt;
#* See below for temporary keys for step iteration&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Optional Step Settings:====&lt;br /&gt;
General Settings:&lt;br /&gt;
* &amp;lt;code&amp;gt;LOCAL&amp;lt;/code&amp;gt; - run the step locally rather than on the cluster&lt;br /&gt;
* &amp;lt;code&amp;gt;NEED_BAI&amp;lt;/code&amp;gt; - Set if a step requires a BAI file&lt;br /&gt;
** Per chromosome steps always require a BAI file&lt;br /&gt;
** Tells GotCloud to fail if a BAI can&#039;t be found&lt;br /&gt;
* &amp;lt;code&amp;gt;BAM_DEPEND&amp;lt;/code&amp;gt; - Add the BAM file as a Makefile dependency for this step&lt;br /&gt;
&lt;br /&gt;
Settings to limit which samples this step runs on:&lt;br /&gt;
* &amp;lt;code&amp;gt;SAMPLES&amp;lt;/code&amp;gt; - use this to define a step to run only for samples with a single BAM or multiple BAMs (merging)&lt;br /&gt;
*: Possible values:&lt;br /&gt;
*:* &amp;lt;code&amp;gt;MULTI_BAM&amp;lt;/code&amp;gt; - run the step only for samples that have multiple BAMs&lt;br /&gt;
*:* &amp;lt;code&amp;gt;SINGLE_BAM&amp;lt;/code&amp;gt; - run the step only for samples that have one BAM&lt;br /&gt;
*Deprecated settings - still in pipeline.pl and may or may not work:&lt;br /&gt;
** &amp;lt;code&amp;gt;MULTI_ONLY&amp;lt;/code&amp;gt; - set to non-blank if step should run if there are more than 1 input per output.&lt;br /&gt;
** &amp;lt;code&amp;gt;SINGLE_ONLY&amp;lt;/code&amp;gt; - set to non-blank if step should run if there is only 1 input per output.&lt;br /&gt;
&lt;br /&gt;
Joining multiple inputs for a single output:&lt;br /&gt;
* Can occur if there are multiple dependencies&lt;br /&gt;
* Can occur if a step runs at a more generic iteration level than a dependency&lt;br /&gt;
* &amp;lt;code&amp;gt;INPUT_JOIN&amp;lt;/code&amp;gt; - value to pass to perl &amp;quot;join&amp;quot; command for joining multiple inputs for each output.&lt;br /&gt;
** Looks across all dependencies&lt;br /&gt;
* &amp;lt;code&amp;gt;dependStepName_JOIN&amp;lt;/code&amp;gt; - how to join the &amp;quot;dependStepName&amp;quot;&#039;s output into the command line for a step that depends on it if there are multiple outputs per input of this step&lt;br /&gt;
** Substitutes &amp;lt;code&amp;gt;?(${depend}/OUTPUT)&amp;lt;/code&amp;gt; with perl &amp;quot;join&amp;quot; using the specified value to join multiple outputs for that dependency&lt;br /&gt;
&lt;br /&gt;
Log Output filenames&lt;br /&gt;
* &amp;lt;code&amp;gt;FILELIST&amp;lt;/code&amp;gt; - writes/appends the iteration&#039;s output file name into the specified file list.&lt;br /&gt;
** Typically will be used in a later &amp;quot;merge&amp;quot; step&lt;br /&gt;
** See below for temporary keys for step iteration that can be used in this filename&lt;br /&gt;
*** Temporary keys can be more general than those in OUTPUT, but cannot be more specific.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Iterating a command for each Bam/Sample/Chromosome/Region====&lt;br /&gt;
Temporary keys are used when iterating a command per BAM/sample/chromosome/region.&lt;br /&gt;
* Specify using &amp;lt;code&amp;gt;?()&amp;lt;/code&amp;gt; rather than &amp;lt;code&amp;gt;$()&amp;lt;/code&amp;gt;&lt;br /&gt;
* Temporary keys can be used in:&lt;br /&gt;
** &amp;lt;code&amp;gt;OUTPUT&amp;lt;/code&amp;gt;&lt;br /&gt;
** &amp;lt;code&amp;gt;CMD&amp;lt;/code&amp;gt;&lt;br /&gt;
** &amp;lt;code&amp;gt;FILELIST&amp;lt;/code&amp;gt;&lt;br /&gt;
* They will be substituted as it iterates&lt;br /&gt;
* How to iterate a command is determined by the temporary keys in &amp;lt;code&amp;gt;OUTPUT&amp;lt;/code&amp;gt;&lt;br /&gt;
* Temporary Keys for determining iterations:&lt;br /&gt;
** &amp;lt;code&amp;gt;?(BAM)&amp;lt;/code&amp;gt; - per BAM per sample&lt;br /&gt;
** &amp;lt;code&amp;gt;?(SAMPLE)&amp;lt;/code&amp;gt; - per sample&lt;br /&gt;
** &amp;lt;code&amp;gt;?(CHR)&amp;lt;/code&amp;gt; - per chromosome&lt;br /&gt;
** &amp;lt;code&amp;gt;?(START)&amp;lt;/code&amp;gt; - Per region of a Chromosome (must also include &amp;lt;code&amp;gt;?(CHR)&amp;lt;/code&amp;gt;):&lt;br /&gt;
* Additional Temporary Keys:&lt;br /&gt;
** &amp;lt;code&amp;gt;?(END)&amp;lt;/code&amp;gt; - end of the region - only used if &amp;lt;code&amp;gt;?(START)&amp;lt;/code&amp;gt; is also specified.&lt;br /&gt;
** &amp;lt;code&amp;gt;?(INPUT)&amp;lt;/code&amp;gt;&lt;br /&gt;
** &amp;lt;code&amp;gt;?(${depend}/OUTPUT)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Notes:&#039;&#039;&#039;&lt;br /&gt;
* Currently each step iteration will:&lt;br /&gt;
** be its own Makefile target/.OK file&lt;br /&gt;
** run independently on the cluster&lt;br /&gt;
&lt;br /&gt;
== Command Line Parameters ==&lt;br /&gt;
Required Parameters:&lt;br /&gt;
* &amp;lt;code&amp;gt;--name&amp;lt;/code&amp;gt; &amp;lt;pipelineName&amp;gt; - name of the pipeline to run&lt;br /&gt;
* &amp;lt;code&amp;gt;--conf&amp;lt;/code&amp;gt; &amp;lt;configuration file&amp;gt; - configuration file to use&lt;br /&gt;
&lt;br /&gt;
NOTE: Currently, any &amp;quot;overrides&amp;quot; are for the global setting only - not for the pipeline/step.&lt;br /&gt;
* this needs to be fixed so they can override the pipeline settings&lt;br /&gt;
&lt;br /&gt;
Optional Parameters:&lt;br /&gt;
* &amp;lt;code&amp;gt;--ignoreSmCheck&amp;lt;/code&amp;gt; - overrides &amp;lt;code&amp;gt;IGNORE_SM_CHECK&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;--ignoreRefChrCheck&amp;lt;/code&amp;gt; - overrides &amp;lt;code&amp;gt;IGNORE_REF_CHR_CHECK&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;--verbose&amp;lt;/code&amp;gt; &amp;lt;number&amp;gt; - verbose value passed to the loadConf method&lt;br /&gt;
&lt;br /&gt;
Optional Parameters like SnpCall:&lt;br /&gt;
* &amp;lt;code&amp;gt;--numjobs|numjobs&amp;lt;/code&amp;gt; &amp;lt;number&amp;gt; - number of jobs to run in parallel&lt;br /&gt;
* &amp;lt;code&amp;gt;--maxlocaljobs&amp;lt;/code&amp;gt; &amp;lt;number&amp;gt; - number of jobs to allow to run when batchtype is local (default 10) - does not validate for commands running LOCAL&lt;br /&gt;
* &amp;lt;code&amp;gt;--region&amp;lt;/code&amp;gt; &amp;lt;region to process&amp;gt; - like snpcall, specifies a single region to process&lt;br /&gt;
* &amp;lt;code&amp;gt;--bam_list|list|bamlist|bam_index|bamindex&amp;lt;/code&amp;gt; &amp;lt;bam list file&amp;gt; - overrides &lt;br /&gt;
&amp;lt;code&amp;gt;BAM_LIST&amp;lt;/code&amp;gt; list of sample\tbam to process&lt;br /&gt;
* &amp;lt;code&amp;gt;--out_dir|outdir&amp;lt;/code&amp;gt; &amp;lt;output directory&amp;gt; - overrides &amp;lt;code&amp;gt;OUT_DIR&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;--batchtype&amp;lt;/code&amp;gt; &amp;lt;type&amp;gt; - overrides &amp;lt;code&amp;gt;BATCHTYPE&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;--batchopts&amp;lt;/code&amp;gt; &amp;lt;options&amp;gt; - overrides &amp;lt;code&amp;gt;BATCHOPTS&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;--chrs|chroms&amp;lt;/code&amp;gt; &amp;lt;comma separated chromosomes&amp;gt; - overrides &amp;lt;code&amp;gt;CHRS&amp;lt;/code&amp;gt; (CHRS is space separated - commas are converted to spaces)&lt;br /&gt;
* &amp;lt;code&amp;gt;--ref_dir|refdir&amp;lt;/code&amp;gt; &amp;lt;reference directory&amp;gt; - overrides &amp;lt;code&amp;gt;REF_DIR&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;--ref_prefix|refprefix&amp;lt;/code&amp;gt; &amp;lt;prefix&amp;gt; - overrides &amp;lt;code&amp;gt;REF_PREFIX&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;--bam_prefix|bamprefix&amp;lt;/code&amp;gt; &amp;lt;prefix&amp;gt; - overrides &amp;lt;code&amp;gt;BAM_PREFIX&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;--base_prefix|baseprefix&amp;lt;/code&amp;gt; &amp;lt;prefix&amp;gt; - overrides &amp;lt;code&amp;gt;BASE_PREFIX&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;--gotcloudroot|gcroot&amp;lt;/code&amp;gt; &amp;lt;path to gotcloud&amp;gt; - by default gotcloud root is determined from the path to the pipeline script, but this setting overrides that.&lt;br /&gt;
* &amp;lt;code&amp;gt;--help&amp;lt;/code&amp;gt; - print Usage&lt;br /&gt;
* &amp;lt;code&amp;gt;--test&amp;lt;/code&amp;gt; &amp;lt;test directory&amp;gt; - run the test code (just for indel right now)&lt;br /&gt;
&lt;br /&gt;
Unused command line options:&lt;br /&gt;
* In the code, but are not actually used:&lt;br /&gt;
* &amp;lt;code&amp;gt;--keeptmp&amp;lt;/code&amp;gt; - overrides &amp;lt;code&amp;gt;KEEP_TMP&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;--keeplog&amp;lt;/code&amp;gt; - overrides &amp;lt;code&amp;gt;KEEP_LOG&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Example Pipelines Created ==&lt;br /&gt;
Look for sections &amp;amp; &amp;lt;code&amp;gt;STEPS&amp;lt;/code&amp;gt; in the defaults.&lt;br /&gt;
 https://github.com/statgen/gotcloud/blob/master/bin/gotcloudDefaults.conf&lt;/div&gt;</summary>
		<author><name>Mktrost</name></author>
	</entry>
	<entry>
		<id>http://genome.sph.umich.edu/w/index.php?title=GotCloud:_Creating_a_New_Pipeline&amp;diff=13590</id>
		<title>GotCloud: Creating a New Pipeline</title>
		<link rel="alternate" type="text/html" href="http://genome.sph.umich.edu/w/index.php?title=GotCloud:_Creating_a_New_Pipeline&amp;diff=13590"/>
		<updated>2015-06-30T18:50:33Z</updated>

		<summary type="html">&lt;p&gt;Mktrost: /* Defining a New Pipeline */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Creating a New BAM Processing Pipeline ==&lt;br /&gt;
&lt;br /&gt;
GotCloud allows you to configure new basic BAM processing pipelines via configuration.&lt;br /&gt;
&lt;br /&gt;
To define new processing pipelines, you will use Configuration sections to define both the pipeline and each of the steps.  So first you need to understand how configuration sections work.&lt;br /&gt;
&lt;br /&gt;
=== GotCloud Configuration Sections ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
GotCloud configuration files can be broken into sections:&lt;br /&gt;
* Section names are specified between square brakets (&amp;lt;code&amp;gt;[]&amp;lt;/code&amp;gt;)&lt;br /&gt;
*: &amp;lt;pre&amp;gt;[sectionName]&amp;lt;/pre&amp;gt;&lt;br /&gt;
** Any configuration settings specified after the section header belong to that section&lt;br /&gt;
** A section can be specified multiple times in the file and the configuration settings are accumulated&lt;br /&gt;
** To access a value for a key defined in another section, use &amp;lt;code&amp;gt;$(otherSectionName/keyName)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* If a section is not specified, the configuration settings belong to the &amp;lt;code&amp;gt;global&amp;lt;/code&amp;gt; section&lt;br /&gt;
** The &amp;lt;code&amp;gt;global&amp;lt;/code&amp;gt; section does not need to be specified at the beginning of the file (it is the default section).&lt;br /&gt;
** Additional &amp;lt;code&amp;gt;global&amp;lt;/code&amp;gt; settings can be set later in the file after other settings, by defining the explicitly section:&lt;br /&gt;
**: &amp;lt;pre&amp;gt;[global]&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* Sections can be derived from another section&lt;br /&gt;
** All sections automatically derive from &amp;lt;code&amp;gt;[global]&amp;lt;/code&amp;gt;&lt;br /&gt;
** A derived section inherits all the configuration settings from its parent sections&lt;br /&gt;
*** Parent settings are overridden by redefining the configuration key/value pair&lt;br /&gt;
** A parent section is specified following a semicolon &amp;lt;code&amp;gt;:&amp;lt;/code&amp;gt; on the section definition line:&lt;br /&gt;
**: &amp;lt;pre&amp;gt;[childSectionName] : parentSectionName&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Section specific configuration settings are specified on the lines following the section definition:&lt;br /&gt;
&amp;lt;dd&amp;gt;&amp;lt;pre&amp;gt;[section1]&lt;br /&gt;
KEY1 = VAL1&lt;br /&gt;
KEY2 = VAL2&lt;br /&gt;
&lt;br /&gt;
[section2]&lt;br /&gt;
KEY1 = VAL1_2&lt;br /&gt;
KEY3 = VAL3&amp;lt;/pre&amp;gt;&amp;lt;/dd&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
=== Defining a New Pipeline ===&lt;br /&gt;
&lt;br /&gt;
There are 2 parts for creating a new pipeline&lt;br /&gt;
# [[#Overall Pipeline Definition|Overall Pipeline Definition]]&lt;br /&gt;
#* Basics for the overall pipeline&lt;br /&gt;
#* &#039;&#039;&#039;NOTE: Currently, configurations set in the overall pipeline&#039;s section do not by default pass onto the step&#039;s configurations&#039;&#039;&#039;&lt;br /&gt;
# [[#Configure Each Step|Configure Each Step]]&lt;br /&gt;
&lt;br /&gt;
==== Overall Pipeline Definition ====&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Define a new configuration section for your pipeline&lt;br /&gt;
&amp;lt;ul&amp;gt;&amp;lt;li&amp;gt; Example:&amp;lt;/li&amp;gt;&amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;dd&amp;gt; &amp;lt;pre&amp;gt;[pipelineName]&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Define the steps in this pipeline using the key &amp;lt;code&amp;gt;STEPS&amp;lt;/code&amp;gt; under that section&lt;br /&gt;
&amp;lt;ul&amp;gt;&amp;lt;li&amp;gt; Example:&amp;lt;/li&amp;gt;&amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;dd&amp;gt;&amp;lt;pre&amp;gt;[pipelineName]&lt;br /&gt;
STEPS = stepName1 stepName2 stepName3&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;ul&amp;gt;&amp;lt;li&amp;gt; Note: each step must have its own configuration section&amp;lt;/li&amp;gt;&amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Optional Overall Pipeline Settings:&lt;br /&gt;
* BATCH_OPTS&lt;br /&gt;
* BATCH_TYPE&lt;br /&gt;
* IGNORE_SM_CHECK - turn off the default validation that the @RG SM tag matches the bam list sample name.&lt;br /&gt;
* IGNORE_REF_CHR_CHECK&lt;br /&gt;
* OUT_DIR&lt;br /&gt;
* BAM_LIST&lt;br /&gt;
* REF&lt;br /&gt;
* REF_FAI&lt;br /&gt;
* MULTIPLE_TARGET_MAP&lt;br /&gt;
* UNIFORM_TARGET_BED&lt;br /&gt;
* OFFSET_OFF_TARET&lt;br /&gt;
* CHRS - defines which chromosomes to run.&lt;br /&gt;
* UNIT_CHUNK&lt;br /&gt;
* NO_CRAM - do not allow CRAM files as input&lt;br /&gt;
* MAKE_BASE_NAME_PIPE - base makefile name&lt;br /&gt;
* MAKE_OPTS - otpions to pass to the make command that runs the jobs.&lt;br /&gt;
* BAM_DEPEND - set to TRUE if you want the BAM file to be included as a make dependency&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
NOTES:&lt;br /&gt;
* The BAM_LIST file can contain config values within it - the overall pipeline section will be checked for those config values.&lt;br /&gt;
* By default if a value is not defined in the section, it will check global.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Configure Each Step ====&lt;br /&gt;
&#039;&#039;&#039;Create a section for each step&#039;&#039;&#039;&lt;br /&gt;
* Example: &amp;lt;code&amp;gt;[stepName1]&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Required keys for each step:====&lt;br /&gt;
&lt;br /&gt;
# &amp;lt;code&amp;gt;DEPEND&amp;lt;/code&amp;gt; - dependencies for this step&lt;br /&gt;
#: Valid Values (separate multiple dependencies with a space):&lt;br /&gt;
#:*&amp;lt;code&amp;gt;BAM&amp;lt;/code&amp;gt;&lt;br /&gt;
#:*Name of step that must complete prior to this step&lt;br /&gt;
#:*PER_SAMPLE_BAM??? can only be BAM or PER_SAMPLE_BAM&lt;br /&gt;
#&amp;lt;code&amp;gt;OUTPUT&amp;lt;/code&amp;gt; - name of output file&lt;br /&gt;
#* See below for temporary keys for step iteration&lt;br /&gt;
#&amp;lt;code&amp;gt;CMD&amp;lt;/code&amp;gt; - command for running the step&lt;br /&gt;
#* See below for temporary keys for step iteration&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Optional Step Settings:====&lt;br /&gt;
General Settings:&lt;br /&gt;
* &amp;lt;code&amp;gt;LOCAL&amp;lt;/code&amp;gt; - run the step locally rather than on the cluster&lt;br /&gt;
* &amp;lt;code&amp;gt;NEED_BAI&amp;lt;/code&amp;gt; - Set if a step requires a BAI file&lt;br /&gt;
** Per chromosome steps always require a BAI file&lt;br /&gt;
** Tells GotCloud to fail if a BAI can&#039;t be found&lt;br /&gt;
* &amp;lt;code&amp;gt;BAM_DEPEND&amp;lt;/code&amp;gt; - Add the BAM file as a Makefile dependency for this step&lt;br /&gt;
&lt;br /&gt;
Settings to limit which samples this step runs on:&lt;br /&gt;
* &amp;lt;code&amp;gt;SAMPLES&amp;lt;/code&amp;gt; - use this to define a step to run only for samples with a single BAM or multiple BAMs (merging)&lt;br /&gt;
*: Possible values:&lt;br /&gt;
*:* &amp;lt;code&amp;gt;MULTI_BAM&amp;lt;/code&amp;gt; - run the step only for samples that have multiple BAMs&lt;br /&gt;
*:* &amp;lt;code&amp;gt;SINGLE_BAM&amp;lt;/code&amp;gt; - run the step only for samples that have one BAM&lt;br /&gt;
*Deprecated settings - still in pipeline.pl and may or may not work:&lt;br /&gt;
** &amp;lt;code&amp;gt;MULTI_ONLY&amp;lt;/code&amp;gt; - set to non-blank if step should run if there are more than 1 input per output.&lt;br /&gt;
** &amp;lt;code&amp;gt;SINGLE_ONLY&amp;lt;/code&amp;gt; - set to non-blank if step should run if there is only 1 input per output.&lt;br /&gt;
&lt;br /&gt;
Joining multiple inputs for a single output:&lt;br /&gt;
* Can occur if there are multiple dependencies&lt;br /&gt;
* Can occur if a step runs at a more generic iteration level than a dependency&lt;br /&gt;
* &amp;lt;code&amp;gt;INPUT_JOIN&amp;lt;/code&amp;gt; - value to pass to perl &amp;quot;join&amp;quot; command for joining multiple inputs for each output.&lt;br /&gt;
** Looks across all dependencies&lt;br /&gt;
* &amp;lt;code&amp;gt;dependStepName_JOIN&amp;lt;/code&amp;gt; - how to join the &amp;quot;dependStepName&amp;quot;&#039;s output into the command line for a step that depends on it if there are multiple outputs per input of this step&lt;br /&gt;
** Substitutes &amp;lt;code&amp;gt;?(${depend}/OUTPUT)&amp;lt;/code&amp;gt; with perl &amp;quot;join&amp;quot; using the specified value to join multiple outputs for that dependency&lt;br /&gt;
&lt;br /&gt;
Log Output filenames&lt;br /&gt;
* &amp;lt;code&amp;gt;FILELIST&amp;lt;/code&amp;gt; - writes/appends the iteration&#039;s output file name into the specified file list.&lt;br /&gt;
** Typically will be used in a later &amp;quot;merge&amp;quot; step&lt;br /&gt;
** See below for temporary keys for step iteration that can be used in this filename&lt;br /&gt;
*** Temporary keys can be more general than those in OUTPUT, but cannot be more specific.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Iterating a command for each Bam/Sample/Chromosome/Region====&lt;br /&gt;
Temporary keys are used when iterating a command per BAM/sample/chromosome/region.&lt;br /&gt;
* Specify using &amp;lt;code&amp;gt;?()&amp;lt;/code&amp;gt; rather than &amp;lt;code&amp;gt;$()&amp;lt;/code&amp;gt;&lt;br /&gt;
* Temporary keys can be used in:&lt;br /&gt;
** &amp;lt;code&amp;gt;OUTPUT&amp;lt;/code&amp;gt;&lt;br /&gt;
** &amp;lt;code&amp;gt;CMD&amp;lt;/code&amp;gt;&lt;br /&gt;
** &amp;lt;code&amp;gt;FILELIST&amp;lt;/code&amp;gt;&lt;br /&gt;
* They will be substituted as it iterates&lt;br /&gt;
* How to iterate a command is determined by the temporary keys in &amp;lt;code&amp;gt;OUTPUT&amp;lt;/code&amp;gt;&lt;br /&gt;
* Temporary Keys for determining iterations:&lt;br /&gt;
** &amp;lt;code&amp;gt;?(BAM)&amp;lt;/code&amp;gt; - per BAM per sample&lt;br /&gt;
** &amp;lt;code&amp;gt;?(SAMPLE)&amp;lt;/code&amp;gt; - per sample&lt;br /&gt;
** &amp;lt;code&amp;gt;?(CHR)&amp;lt;/code&amp;gt; - per chromosome&lt;br /&gt;
** &amp;lt;code&amp;gt;?(START)&amp;lt;/code&amp;gt; - Per region of a Chromosome (must also include &amp;lt;code&amp;gt;?(CHR)&amp;lt;/code&amp;gt;):&lt;br /&gt;
* Additional Temporary Keys:&lt;br /&gt;
** &amp;lt;code&amp;gt;?(END)&amp;lt;/code&amp;gt; - end of the region - only used if &amp;lt;code&amp;gt;?(START)&amp;lt;/code&amp;gt; is also specified.&lt;br /&gt;
** &amp;lt;code&amp;gt;?(INPUT)&amp;lt;/code&amp;gt;&lt;br /&gt;
** &amp;lt;code&amp;gt;?(${depend}/OUTPUT)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Notes:&#039;&#039;&#039;&lt;br /&gt;
* Currently each step iteration will:&lt;br /&gt;
** be its own Makefile target/.OK file&lt;br /&gt;
** run independently on the cluster&lt;br /&gt;
&lt;br /&gt;
== Command Line Parameters ==&lt;br /&gt;
Required Parameters:&lt;br /&gt;
* &amp;lt;code&amp;gt;--name&amp;lt;/code&amp;gt; &amp;lt;pipelineName&amp;gt; - name of the pipeline to run&lt;br /&gt;
* &amp;lt;code&amp;gt;--conf&amp;lt;/code&amp;gt; &amp;lt;configuration file&amp;gt; - configuration file to use&lt;br /&gt;
&lt;br /&gt;
NOTE: Currently, any &amp;quot;overrides&amp;quot; are for the global setting only - not for the pipeline/step.&lt;br /&gt;
* this needs to be fixed so they can override the pipeline settings&lt;br /&gt;
&lt;br /&gt;
Optional Parameters:&lt;br /&gt;
* &amp;lt;code&amp;gt;--ignoreSmCheck&amp;lt;/code&amp;gt; - overrides &amp;lt;code&amp;gt;IGNORE_SM_CHECK&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;--ignoreRefChrCheck&amp;lt;/code&amp;gt; - overrides &amp;lt;code&amp;gt;IGNORE_REF_CHR_CHECK&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;--verbose&amp;lt;/code&amp;gt; &amp;lt;number&amp;gt; - verbose value passed to the loadConf method&lt;br /&gt;
&lt;br /&gt;
Optional Parameters like SnpCall:&lt;br /&gt;
* &amp;lt;code&amp;gt;--numjobs|numjobs&amp;lt;/code&amp;gt; &amp;lt;number&amp;gt; - number of jobs to run in parallel&lt;br /&gt;
* &amp;lt;code&amp;gt;--maxlocaljobs&amp;lt;/code&amp;gt; &amp;lt;number&amp;gt; - number of jobs to allow to run when batchtype is local (default 10) - does not validate for commands running LOCAL&lt;br /&gt;
* &amp;lt;code&amp;gt;--region&amp;lt;/code&amp;gt; &amp;lt;region to process&amp;gt; - like snpcall, specifies a single region to process&lt;br /&gt;
* &amp;lt;code&amp;gt;--bam_list|list|bamlist|bam_index|bamindex&amp;lt;/code&amp;gt; &amp;lt;bam list file&amp;gt; - overrides &lt;br /&gt;
&amp;lt;code&amp;gt;BAM_LIST&amp;lt;/code&amp;gt; list of sample\tbam to process&lt;br /&gt;
* &amp;lt;code&amp;gt;--out_dir|outdir&amp;lt;/code&amp;gt; &amp;lt;output directory&amp;gt; - overrides &amp;lt;code&amp;gt;OUT_DIR&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;--batchtype&amp;lt;/code&amp;gt; &amp;lt;type&amp;gt; - overrides &amp;lt;code&amp;gt;BATCHTYPE&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;--batchopts&amp;lt;/code&amp;gt; &amp;lt;options&amp;gt; - overrides &amp;lt;code&amp;gt;BATCHOPTS&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;--chrs|chroms&amp;lt;/code&amp;gt; &amp;lt;comma separated chromosomes&amp;gt; - overrides &amp;lt;code&amp;gt;CHRS&amp;lt;/code&amp;gt; (CHRS is space separated - commas are converted to spaces)&lt;br /&gt;
* &amp;lt;code&amp;gt;--ref_dir|refdir&amp;lt;/code&amp;gt; &amp;lt;reference directory&amp;gt; - overrides &amp;lt;code&amp;gt;REF_DIR&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;--ref_prefix|refprefix&amp;lt;/code&amp;gt; &amp;lt;prefix&amp;gt; - overrides &amp;lt;code&amp;gt;REF_PREFIX&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;--bam_prefix|bamprefix&amp;lt;/code&amp;gt; &amp;lt;prefix&amp;gt; - overrides &amp;lt;code&amp;gt;BAM_PREFIX&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;--base_prefix|baseprefix&amp;lt;/code&amp;gt; &amp;lt;prefix&amp;gt; - overrides &amp;lt;code&amp;gt;BASE_PREFIX&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;--gotcloudroot|gcroot&amp;lt;/code&amp;gt; &amp;lt;path to gotcloud&amp;gt; - by default gotcloud root is determined from the path to the pipeline script, but this setting overrides that.&lt;br /&gt;
* &amp;lt;code&amp;gt;--help&amp;lt;/code&amp;gt; - print Usage&lt;br /&gt;
* &amp;lt;code&amp;gt;--test&amp;lt;/code&amp;gt; &amp;lt;test directory&amp;gt; - run the test code (just for indel right now)&lt;br /&gt;
&lt;br /&gt;
Unused command line options:&lt;br /&gt;
* In the code, but are not actually used:&lt;br /&gt;
* &amp;lt;code&amp;gt;--keeptmp&amp;lt;/code&amp;gt; - overrides &amp;lt;code&amp;gt;KEEP_TMP&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;--keeplog&amp;lt;/code&amp;gt; - overrides &amp;lt;code&amp;gt;KEEP_LOG&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Example Pipelines Created ==&lt;br /&gt;
Look for sections &amp;amp; &amp;lt;code&amp;gt;STEPS&amp;lt;/code&amp;gt; in the defaults.&lt;br /&gt;
 https://github.com/statgen/gotcloud/blob/master/bin/gotcloudDefaults.conf&lt;/div&gt;</summary>
		<author><name>Mktrost</name></author>
	</entry>
	<entry>
		<id>http://genome.sph.umich.edu/w/index.php?title=GotCloud:_Creating_a_New_Pipeline&amp;diff=13589</id>
		<title>GotCloud: Creating a New Pipeline</title>
		<link rel="alternate" type="text/html" href="http://genome.sph.umich.edu/w/index.php?title=GotCloud:_Creating_a_New_Pipeline&amp;diff=13589"/>
		<updated>2015-06-30T18:50:18Z</updated>

		<summary type="html">&lt;p&gt;Mktrost: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Creating a New BAM Processing Pipeline ==&lt;br /&gt;
&lt;br /&gt;
GotCloud allows you to configure new basic BAM processing pipelines via configuration.&lt;br /&gt;
&lt;br /&gt;
To define new processing pipelines, you will use Configuration sections to define both the pipeline and each of the steps.  So first you need to understand how configuration sections work.&lt;br /&gt;
&lt;br /&gt;
=== GotCloud Configuration Sections ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
GotCloud configuration files can be broken into sections:&lt;br /&gt;
* Section names are specified between square brakets (&amp;lt;code&amp;gt;[]&amp;lt;/code&amp;gt;)&lt;br /&gt;
*: &amp;lt;pre&amp;gt;[sectionName]&amp;lt;/pre&amp;gt;&lt;br /&gt;
** Any configuration settings specified after the section header belong to that section&lt;br /&gt;
** A section can be specified multiple times in the file and the configuration settings are accumulated&lt;br /&gt;
** To access a value for a key defined in another section, use &amp;lt;code&amp;gt;$(otherSectionName/keyName)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* If a section is not specified, the configuration settings belong to the &amp;lt;code&amp;gt;global&amp;lt;/code&amp;gt; section&lt;br /&gt;
** The &amp;lt;code&amp;gt;global&amp;lt;/code&amp;gt; section does not need to be specified at the beginning of the file (it is the default section).&lt;br /&gt;
** Additional &amp;lt;code&amp;gt;global&amp;lt;/code&amp;gt; settings can be set later in the file after other settings, by defining the explicitly section:&lt;br /&gt;
**: &amp;lt;pre&amp;gt;[global]&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* Sections can be derived from another section&lt;br /&gt;
** All sections automatically derive from &amp;lt;code&amp;gt;[global]&amp;lt;/code&amp;gt;&lt;br /&gt;
** A derived section inherits all the configuration settings from its parent sections&lt;br /&gt;
*** Parent settings are overridden by redefining the configuration key/value pair&lt;br /&gt;
** A parent section is specified following a semicolon &amp;lt;code&amp;gt;:&amp;lt;/code&amp;gt; on the section definition line:&lt;br /&gt;
**: &amp;lt;pre&amp;gt;[childSectionName] : parentSectionName&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Section specific configuration settings are specified on the lines following the section definition:&lt;br /&gt;
&amp;lt;dd&amp;gt;&amp;lt;pre&amp;gt;[section1]&lt;br /&gt;
KEY1 = VAL1&lt;br /&gt;
KEY2 = VAL2&lt;br /&gt;
&lt;br /&gt;
[section2]&lt;br /&gt;
KEY1 = VAL1_2&lt;br /&gt;
KEY3 = VAL3&amp;lt;/pre&amp;gt;&amp;lt;/dd&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
=== Defining a New Pipeline ===&lt;br /&gt;
&lt;br /&gt;
There are 2 parts for creating a new pipeline&lt;br /&gt;
# [[#Overall Pipeline Definition|Overall Pipeline Definition]]&lt;br /&gt;
#* Basics for the overall pipeline&lt;br /&gt;
#* &#039;&#039;&#039;NOTE: Curretnly, configurations set in the overall pipeline&#039;s section do not by default pass onto the step&#039;s configurations&#039;&#039;&#039;&lt;br /&gt;
# [[#Configure Each Step|Configure Each Step]]&lt;br /&gt;
&lt;br /&gt;
==== Overall Pipeline Definition ====&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Define a new configuration section for your pipeline&lt;br /&gt;
&amp;lt;ul&amp;gt;&amp;lt;li&amp;gt; Example:&amp;lt;/li&amp;gt;&amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;dd&amp;gt; &amp;lt;pre&amp;gt;[pipelineName]&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Define the steps in this pipeline using the key &amp;lt;code&amp;gt;STEPS&amp;lt;/code&amp;gt; under that section&lt;br /&gt;
&amp;lt;ul&amp;gt;&amp;lt;li&amp;gt; Example:&amp;lt;/li&amp;gt;&amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;dd&amp;gt;&amp;lt;pre&amp;gt;[pipelineName]&lt;br /&gt;
STEPS = stepName1 stepName2 stepName3&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;ul&amp;gt;&amp;lt;li&amp;gt; Note: each step must have its own configuration section&amp;lt;/li&amp;gt;&amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Optional Overall Pipeline Settings:&lt;br /&gt;
* BATCH_OPTS&lt;br /&gt;
* BATCH_TYPE&lt;br /&gt;
* IGNORE_SM_CHECK - turn off the default validation that the @RG SM tag matches the bam list sample name.&lt;br /&gt;
* IGNORE_REF_CHR_CHECK&lt;br /&gt;
* OUT_DIR&lt;br /&gt;
* BAM_LIST&lt;br /&gt;
* REF&lt;br /&gt;
* REF_FAI&lt;br /&gt;
* MULTIPLE_TARGET_MAP&lt;br /&gt;
* UNIFORM_TARGET_BED&lt;br /&gt;
* OFFSET_OFF_TARET&lt;br /&gt;
* CHRS - defines which chromosomes to run.&lt;br /&gt;
* UNIT_CHUNK&lt;br /&gt;
* NO_CRAM - do not allow CRAM files as input&lt;br /&gt;
* MAKE_BASE_NAME_PIPE - base makefile name&lt;br /&gt;
* MAKE_OPTS - otpions to pass to the make command that runs the jobs.&lt;br /&gt;
* BAM_DEPEND - set to TRUE if you want the BAM file to be included as a make dependency&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
NOTES:&lt;br /&gt;
* The BAM_LIST file can contain config values within it - the overall pipeline section will be checked for those config values.&lt;br /&gt;
* By default if a value is not defined in the section, it will check global.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Configure Each Step ====&lt;br /&gt;
&#039;&#039;&#039;Create a section for each step&#039;&#039;&#039;&lt;br /&gt;
* Example: &amp;lt;code&amp;gt;[stepName1]&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Required keys for each step:====&lt;br /&gt;
&lt;br /&gt;
# &amp;lt;code&amp;gt;DEPEND&amp;lt;/code&amp;gt; - dependencies for this step&lt;br /&gt;
#: Valid Values (separate multiple dependencies with a space):&lt;br /&gt;
#:*&amp;lt;code&amp;gt;BAM&amp;lt;/code&amp;gt;&lt;br /&gt;
#:*Name of step that must complete prior to this step&lt;br /&gt;
#:*PER_SAMPLE_BAM??? can only be BAM or PER_SAMPLE_BAM&lt;br /&gt;
#&amp;lt;code&amp;gt;OUTPUT&amp;lt;/code&amp;gt; - name of output file&lt;br /&gt;
#* See below for temporary keys for step iteration&lt;br /&gt;
#&amp;lt;code&amp;gt;CMD&amp;lt;/code&amp;gt; - command for running the step&lt;br /&gt;
#* See below for temporary keys for step iteration&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Optional Step Settings:====&lt;br /&gt;
General Settings:&lt;br /&gt;
* &amp;lt;code&amp;gt;LOCAL&amp;lt;/code&amp;gt; - run the step locally rather than on the cluster&lt;br /&gt;
* &amp;lt;code&amp;gt;NEED_BAI&amp;lt;/code&amp;gt; - Set if a step requires a BAI file&lt;br /&gt;
** Per chromosome steps always require a BAI file&lt;br /&gt;
** Tells GotCloud to fail if a BAI can&#039;t be found&lt;br /&gt;
* &amp;lt;code&amp;gt;BAM_DEPEND&amp;lt;/code&amp;gt; - Add the BAM file as a Makefile dependency for this step&lt;br /&gt;
&lt;br /&gt;
Settings to limit which samples this step runs on:&lt;br /&gt;
* &amp;lt;code&amp;gt;SAMPLES&amp;lt;/code&amp;gt; - use this to define a step to run only for samples with a single BAM or multiple BAMs (merging)&lt;br /&gt;
*: Possible values:&lt;br /&gt;
*:* &amp;lt;code&amp;gt;MULTI_BAM&amp;lt;/code&amp;gt; - run the step only for samples that have multiple BAMs&lt;br /&gt;
*:* &amp;lt;code&amp;gt;SINGLE_BAM&amp;lt;/code&amp;gt; - run the step only for samples that have one BAM&lt;br /&gt;
*Deprecated settings - still in pipeline.pl and may or may not work:&lt;br /&gt;
** &amp;lt;code&amp;gt;MULTI_ONLY&amp;lt;/code&amp;gt; - set to non-blank if step should run if there are more than 1 input per output.&lt;br /&gt;
** &amp;lt;code&amp;gt;SINGLE_ONLY&amp;lt;/code&amp;gt; - set to non-blank if step should run if there is only 1 input per output.&lt;br /&gt;
&lt;br /&gt;
Joining multiple inputs for a single output:&lt;br /&gt;
* Can occur if there are multiple dependencies&lt;br /&gt;
* Can occur if a step runs at a more generic iteration level than a dependency&lt;br /&gt;
* &amp;lt;code&amp;gt;INPUT_JOIN&amp;lt;/code&amp;gt; - value to pass to perl &amp;quot;join&amp;quot; command for joining multiple inputs for each output.&lt;br /&gt;
** Looks across all dependencies&lt;br /&gt;
* &amp;lt;code&amp;gt;dependStepName_JOIN&amp;lt;/code&amp;gt; - how to join the &amp;quot;dependStepName&amp;quot;&#039;s output into the command line for a step that depends on it if there are multiple outputs per input of this step&lt;br /&gt;
** Substitutes &amp;lt;code&amp;gt;?(${depend}/OUTPUT)&amp;lt;/code&amp;gt; with perl &amp;quot;join&amp;quot; using the specified value to join multiple outputs for that dependency&lt;br /&gt;
&lt;br /&gt;
Log Output filenames&lt;br /&gt;
* &amp;lt;code&amp;gt;FILELIST&amp;lt;/code&amp;gt; - writes/appends the iteration&#039;s output file name into the specified file list.&lt;br /&gt;
** Typically will be used in a later &amp;quot;merge&amp;quot; step&lt;br /&gt;
** See below for temporary keys for step iteration that can be used in this filename&lt;br /&gt;
*** Temporary keys can be more general than those in OUTPUT, but cannot be more specific.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Iterating a command for each Bam/Sample/Chromosome/Region====&lt;br /&gt;
Temporary keys are used when iterating a command per BAM/sample/chromosome/region.&lt;br /&gt;
* Specify using &amp;lt;code&amp;gt;?()&amp;lt;/code&amp;gt; rather than &amp;lt;code&amp;gt;$()&amp;lt;/code&amp;gt;&lt;br /&gt;
* Temporary keys can be used in:&lt;br /&gt;
** &amp;lt;code&amp;gt;OUTPUT&amp;lt;/code&amp;gt;&lt;br /&gt;
** &amp;lt;code&amp;gt;CMD&amp;lt;/code&amp;gt;&lt;br /&gt;
** &amp;lt;code&amp;gt;FILELIST&amp;lt;/code&amp;gt;&lt;br /&gt;
* They will be substituted as it iterates&lt;br /&gt;
* How to iterate a command is determined by the temporary keys in &amp;lt;code&amp;gt;OUTPUT&amp;lt;/code&amp;gt;&lt;br /&gt;
* Temporary Keys for determining iterations:&lt;br /&gt;
** &amp;lt;code&amp;gt;?(BAM)&amp;lt;/code&amp;gt; - per BAM per sample&lt;br /&gt;
** &amp;lt;code&amp;gt;?(SAMPLE)&amp;lt;/code&amp;gt; - per sample&lt;br /&gt;
** &amp;lt;code&amp;gt;?(CHR)&amp;lt;/code&amp;gt; - per chromosome&lt;br /&gt;
** &amp;lt;code&amp;gt;?(START)&amp;lt;/code&amp;gt; - Per region of a Chromosome (must also include &amp;lt;code&amp;gt;?(CHR)&amp;lt;/code&amp;gt;):&lt;br /&gt;
* Additional Temporary Keys:&lt;br /&gt;
** &amp;lt;code&amp;gt;?(END)&amp;lt;/code&amp;gt; - end of the region - only used if &amp;lt;code&amp;gt;?(START)&amp;lt;/code&amp;gt; is also specified.&lt;br /&gt;
** &amp;lt;code&amp;gt;?(INPUT)&amp;lt;/code&amp;gt;&lt;br /&gt;
** &amp;lt;code&amp;gt;?(${depend}/OUTPUT)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Notes:&#039;&#039;&#039;&lt;br /&gt;
* Currently each step iteration will:&lt;br /&gt;
** be its own Makefile target/.OK file&lt;br /&gt;
** run independently on the cluster&lt;br /&gt;
&lt;br /&gt;
== Command Line Parameters ==&lt;br /&gt;
Required Parameters:&lt;br /&gt;
* &amp;lt;code&amp;gt;--name&amp;lt;/code&amp;gt; &amp;lt;pipelineName&amp;gt; - name of the pipeline to run&lt;br /&gt;
* &amp;lt;code&amp;gt;--conf&amp;lt;/code&amp;gt; &amp;lt;configuration file&amp;gt; - configuration file to use&lt;br /&gt;
&lt;br /&gt;
NOTE: Currently, any &amp;quot;overrides&amp;quot; are for the global setting only - not for the pipeline/step.&lt;br /&gt;
* this needs to be fixed so they can override the pipeline settings&lt;br /&gt;
&lt;br /&gt;
Optional Parameters:&lt;br /&gt;
* &amp;lt;code&amp;gt;--ignoreSmCheck&amp;lt;/code&amp;gt; - overrides &amp;lt;code&amp;gt;IGNORE_SM_CHECK&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;--ignoreRefChrCheck&amp;lt;/code&amp;gt; - overrides &amp;lt;code&amp;gt;IGNORE_REF_CHR_CHECK&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;--verbose&amp;lt;/code&amp;gt; &amp;lt;number&amp;gt; - verbose value passed to the loadConf method&lt;br /&gt;
&lt;br /&gt;
Optional Parameters like SnpCall:&lt;br /&gt;
* &amp;lt;code&amp;gt;--numjobs|numjobs&amp;lt;/code&amp;gt; &amp;lt;number&amp;gt; - number of jobs to run in parallel&lt;br /&gt;
* &amp;lt;code&amp;gt;--maxlocaljobs&amp;lt;/code&amp;gt; &amp;lt;number&amp;gt; - number of jobs to allow to run when batchtype is local (default 10) - does not validate for commands running LOCAL&lt;br /&gt;
* &amp;lt;code&amp;gt;--region&amp;lt;/code&amp;gt; &amp;lt;region to process&amp;gt; - like snpcall, specifies a single region to process&lt;br /&gt;
* &amp;lt;code&amp;gt;--bam_list|list|bamlist|bam_index|bamindex&amp;lt;/code&amp;gt; &amp;lt;bam list file&amp;gt; - overrides &lt;br /&gt;
&amp;lt;code&amp;gt;BAM_LIST&amp;lt;/code&amp;gt; list of sample\tbam to process&lt;br /&gt;
* &amp;lt;code&amp;gt;--out_dir|outdir&amp;lt;/code&amp;gt; &amp;lt;output directory&amp;gt; - overrides &amp;lt;code&amp;gt;OUT_DIR&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;--batchtype&amp;lt;/code&amp;gt; &amp;lt;type&amp;gt; - overrides &amp;lt;code&amp;gt;BATCHTYPE&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;--batchopts&amp;lt;/code&amp;gt; &amp;lt;options&amp;gt; - overrides &amp;lt;code&amp;gt;BATCHOPTS&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;--chrs|chroms&amp;lt;/code&amp;gt; &amp;lt;comma separated chromosomes&amp;gt; - overrides &amp;lt;code&amp;gt;CHRS&amp;lt;/code&amp;gt; (CHRS is space separated - commas are converted to spaces)&lt;br /&gt;
* &amp;lt;code&amp;gt;--ref_dir|refdir&amp;lt;/code&amp;gt; &amp;lt;reference directory&amp;gt; - overrides &amp;lt;code&amp;gt;REF_DIR&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;--ref_prefix|refprefix&amp;lt;/code&amp;gt; &amp;lt;prefix&amp;gt; - overrides &amp;lt;code&amp;gt;REF_PREFIX&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;--bam_prefix|bamprefix&amp;lt;/code&amp;gt; &amp;lt;prefix&amp;gt; - overrides &amp;lt;code&amp;gt;BAM_PREFIX&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;--base_prefix|baseprefix&amp;lt;/code&amp;gt; &amp;lt;prefix&amp;gt; - overrides &amp;lt;code&amp;gt;BASE_PREFIX&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;--gotcloudroot|gcroot&amp;lt;/code&amp;gt; &amp;lt;path to gotcloud&amp;gt; - by default gotcloud root is determined from the path to the pipeline script, but this setting overrides that.&lt;br /&gt;
* &amp;lt;code&amp;gt;--help&amp;lt;/code&amp;gt; - print Usage&lt;br /&gt;
* &amp;lt;code&amp;gt;--test&amp;lt;/code&amp;gt; &amp;lt;test directory&amp;gt; - run the test code (just for indel right now)&lt;br /&gt;
&lt;br /&gt;
Unused command line options:&lt;br /&gt;
* In the code, but are not actually used:&lt;br /&gt;
* &amp;lt;code&amp;gt;--keeptmp&amp;lt;/code&amp;gt; - overrides &amp;lt;code&amp;gt;KEEP_TMP&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;--keeplog&amp;lt;/code&amp;gt; - overrides &amp;lt;code&amp;gt;KEEP_LOG&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Example Pipelines Created ==&lt;br /&gt;
Look for sections &amp;amp; &amp;lt;code&amp;gt;STEPS&amp;lt;/code&amp;gt; in the defaults.&lt;br /&gt;
 https://github.com/statgen/gotcloud/blob/master/bin/gotcloudDefaults.conf&lt;/div&gt;</summary>
		<author><name>Mktrost</name></author>
	</entry>
	<entry>
		<id>http://genome.sph.umich.edu/w/index.php?title=GotCloud:_Creating_a_New_Pipeline&amp;diff=13588</id>
		<title>GotCloud: Creating a New Pipeline</title>
		<link rel="alternate" type="text/html" href="http://genome.sph.umich.edu/w/index.php?title=GotCloud:_Creating_a_New_Pipeline&amp;diff=13588"/>
		<updated>2015-06-30T18:12:30Z</updated>

		<summary type="html">&lt;p&gt;Mktrost: /* Configure Each Step */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Creating a New BAM Processing Pipeline ==&lt;br /&gt;
&lt;br /&gt;
GotCloud allows you to configure new basic BAM processing pipelines via configuration.&lt;br /&gt;
&lt;br /&gt;
To define new processing pipelines, you will use Configuration sections to define both the pipeline and each of the steps.  So first you need to understand how configuration sections work.&lt;br /&gt;
&lt;br /&gt;
=== GotCloud Configuration Sections ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
GotCloud configuration files can be broken into sections:&lt;br /&gt;
* Section names are specified between square brakets (&amp;lt;code&amp;gt;[]&amp;lt;/code&amp;gt;)&lt;br /&gt;
*: &amp;lt;pre&amp;gt;[sectionName]&amp;lt;/pre&amp;gt;&lt;br /&gt;
** Any configuration settings specified after the section header belong to that section&lt;br /&gt;
** A section can be specified multiple times in the file and the configuration settings are accumulated&lt;br /&gt;
** To access a value for a key defined in another section, use &amp;lt;code&amp;gt;$(otherSectionName/keyName)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* If a section is not specified, the configuration settings belong to the &amp;lt;code&amp;gt;global&amp;lt;/code&amp;gt; section&lt;br /&gt;
** The &amp;lt;code&amp;gt;global&amp;lt;/code&amp;gt; section does not need to be specified at the beginning of the file (it is the default section).&lt;br /&gt;
** Additional &amp;lt;code&amp;gt;global&amp;lt;/code&amp;gt; settings can be set later in the file after other settings, by defining the explicitly section:&lt;br /&gt;
**: &amp;lt;pre&amp;gt;[global]&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* Sections can be derived from another section&lt;br /&gt;
** All sections automatically derive from &amp;lt;code&amp;gt;[global]&amp;lt;/code&amp;gt;&lt;br /&gt;
** A derived section inherits all the configuration settings from its parent sections&lt;br /&gt;
*** Parent settings are overridden by redefining the configuration key/value pair&lt;br /&gt;
** A parent section is specified following a semicolon &amp;lt;code&amp;gt;:&amp;lt;/code&amp;gt; on the section definition line:&lt;br /&gt;
**: &amp;lt;pre&amp;gt;[childSectionName] : parentSectionName&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Section specific configuration settings are specified on the lines following the section definition:&lt;br /&gt;
&amp;lt;dd&amp;gt;&amp;lt;pre&amp;gt;[section1]&lt;br /&gt;
KEY1 = VAL1&lt;br /&gt;
KEY2 = VAL2&lt;br /&gt;
&lt;br /&gt;
[section2]&lt;br /&gt;
KEY1 = VAL1_2&lt;br /&gt;
KEY3 = VAL3&amp;lt;/pre&amp;gt;&amp;lt;/dd&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
=== Defining a New Pipeline ===&lt;br /&gt;
&lt;br /&gt;
There are 2 parts for creating a new pipeline&lt;br /&gt;
# [[#Overall Pipeline Definition|Overall Pipeline Definition]]&lt;br /&gt;
#* Basics for the overall pipeline&lt;br /&gt;
#* &#039;&#039;&#039;NOTE: Curretnly, configurations set in the overall pipeline&#039;s section do not by default pass onto the step&#039;s configurations&#039;&#039;&#039;&lt;br /&gt;
# [[#Configure Each Step|Configure Each Step]]&lt;br /&gt;
&lt;br /&gt;
==== Overall Pipeline Definition ====&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Define a new configuration section for your pipeline&lt;br /&gt;
&amp;lt;ul&amp;gt;&amp;lt;li&amp;gt; Example:&amp;lt;/li&amp;gt;&amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;dd&amp;gt; &amp;lt;pre&amp;gt;[pipelineName]&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Define the steps in this pipeline using the key &amp;lt;code&amp;gt;STEPS&amp;lt;/code&amp;gt; under that section&lt;br /&gt;
&amp;lt;ul&amp;gt;&amp;lt;li&amp;gt; Example:&amp;lt;/li&amp;gt;&amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;dd&amp;gt;&amp;lt;pre&amp;gt;[pipelineName]&lt;br /&gt;
STEPS = stepName1 stepName2 stepName3&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;ul&amp;gt;&amp;lt;li&amp;gt; Note: each step must have its own configuration section&amp;lt;/li&amp;gt;&amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Optional Overall Pipeline Settings:&lt;br /&gt;
* BATCH_OPTS&lt;br /&gt;
* BATCH_TYPE&lt;br /&gt;
* IGNORE_SM_CHECK - turn off the default validation that the @RG SM tag matches the bam list sample name.&lt;br /&gt;
* IGNORE_REF_CHR_CHECK&lt;br /&gt;
* OUT_DIR&lt;br /&gt;
* BAM_LIST&lt;br /&gt;
* REF&lt;br /&gt;
* REF_FAI&lt;br /&gt;
* MULTIPLE_TARGET_MAP&lt;br /&gt;
* UNIFORM_TARGET_BED&lt;br /&gt;
* OFFSET_OFF_TARET&lt;br /&gt;
* CHRS&lt;br /&gt;
* UNIT_CHUNK&lt;br /&gt;
* NO_CRAM - do not allow CRAM files as input&lt;br /&gt;
* MAKE_BASE_NAME_PIPE - base makefile name&lt;br /&gt;
* MAKE_OPTS - otpions to pass to the make command that runs the jobs.&lt;br /&gt;
* BAM_DEPEND - set to TRUE if you want the BAM file to be included as a make dependency&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
NOTES:&lt;br /&gt;
* The BAM_LIST file can contain config values within it - the overall pipeline section will be checked for those config values.&lt;br /&gt;
* By default if a value is not defined in the section, it will check global.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Configure Each Step ====&lt;br /&gt;
&#039;&#039;&#039;Create a section for each step&#039;&#039;&#039;&lt;br /&gt;
* Example: &amp;lt;code&amp;gt;[stepName1]&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Required keys for each step:====&lt;br /&gt;
&lt;br /&gt;
# &amp;lt;code&amp;gt;DEPEND&amp;lt;/code&amp;gt; - dependencies for this step&lt;br /&gt;
#: Valid Values (separate multiple dependencies with a space):&lt;br /&gt;
#:*&amp;lt;code&amp;gt;BAM&amp;lt;/code&amp;gt;&lt;br /&gt;
#:*Name of step that must complete prior to this step&lt;br /&gt;
#:*PER_SAMPLE_BAM??? can only be BAM or PER_SAMPLE_BAM&lt;br /&gt;
#&amp;lt;code&amp;gt;OUTPUT&amp;lt;/code&amp;gt; - name of output file&lt;br /&gt;
#* See below for temporary keys for step iteration&lt;br /&gt;
#&amp;lt;code&amp;gt;CMD&amp;lt;/code&amp;gt; - command for running the step&lt;br /&gt;
#* See below for temporary keys for step iteration&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Optional Step Settings:====&lt;br /&gt;
General Settings:&lt;br /&gt;
* &amp;lt;code&amp;gt;LOCAL&amp;lt;/code&amp;gt; - run the step locally rather than on the cluster&lt;br /&gt;
* &amp;lt;code&amp;gt;NEED_BAI&amp;lt;/code&amp;gt; - Set if a step requires a BAI file&lt;br /&gt;
** Per chromosome steps always require a BAI file&lt;br /&gt;
** Tells GotCloud to fail if a BAI can&#039;t be found&lt;br /&gt;
* &amp;lt;code&amp;gt;BAM_DEPEND&amp;lt;/code&amp;gt; - Add the BAM file as a Makefile dependency for this step&lt;br /&gt;
&lt;br /&gt;
Settings to limit which samples this step runs on:&lt;br /&gt;
* &amp;lt;code&amp;gt;SAMPLES&amp;lt;/code&amp;gt; - use this to define a step to run only for samples with a single BAM or multiple BAMs (merging)&lt;br /&gt;
*: Possible values:&lt;br /&gt;
*:* &amp;lt;code&amp;gt;MULTI_BAM&amp;lt;/code&amp;gt; - run the step only for samples that have multiple BAMs&lt;br /&gt;
*:* &amp;lt;code&amp;gt;SINGLE_BAM&amp;lt;/code&amp;gt; - run the step only for samples that have one BAM&lt;br /&gt;
*Deprecated settings - still in pipeline.pl and may or may not work:&lt;br /&gt;
** &amp;lt;code&amp;gt;MULTI_ONLY&amp;lt;/code&amp;gt; - set to non-blank if step should run if there are more than 1 input per output.&lt;br /&gt;
** &amp;lt;code&amp;gt;SINGLE_ONLY&amp;lt;/code&amp;gt; - set to non-blank if step should run if there is only 1 input per output.&lt;br /&gt;
&lt;br /&gt;
Joining multiple inputs for a single output:&lt;br /&gt;
* Can occur if there are multiple dependencies&lt;br /&gt;
* Can occur if a step runs at a more generic iteration level than a dependency&lt;br /&gt;
* &amp;lt;code&amp;gt;INPUT_JOIN&amp;lt;/code&amp;gt; - value to pass to perl &amp;quot;join&amp;quot; command for joining multiple inputs for each output.&lt;br /&gt;
** Looks across all dependencies&lt;br /&gt;
* &amp;lt;code&amp;gt;dependStepName_JOIN&amp;lt;/code&amp;gt; - how to join the &amp;quot;dependStepName&amp;quot;&#039;s output into the command line for a step that depends on it if there are multiple outputs per input of this step&lt;br /&gt;
** Substitutes &amp;lt;code&amp;gt;?(${depend}/OUTPUT)&amp;lt;/code&amp;gt; with perl &amp;quot;join&amp;quot; using the specified value to join multiple outputs for that dependency&lt;br /&gt;
&lt;br /&gt;
Log Output filenames&lt;br /&gt;
* &amp;lt;code&amp;gt;FILELIST&amp;lt;/code&amp;gt; - writes/appends the iteration&#039;s output file name into the specified file list.&lt;br /&gt;
** Typically will be used in a later &amp;quot;merge&amp;quot; step&lt;br /&gt;
** See below for temporary keys for step iteration that can be used in this filename&lt;br /&gt;
*** Temporary keys can be more general than those in OUTPUT, but cannot be more specific.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Iterating a command for each Bam/Sample/Chromosome/Region====&lt;br /&gt;
Temporary keys are used when iterating a command per BAM/sample/chromosome/region.&lt;br /&gt;
* Specify using &amp;lt;code&amp;gt;?()&amp;lt;/code&amp;gt; rather than &amp;lt;code&amp;gt;$()&amp;lt;/code&amp;gt;&lt;br /&gt;
* Temporary keys can be used in:&lt;br /&gt;
** &amp;lt;code&amp;gt;OUTPUT&amp;lt;/code&amp;gt;&lt;br /&gt;
** &amp;lt;code&amp;gt;CMD&amp;lt;/code&amp;gt;&lt;br /&gt;
** &amp;lt;code&amp;gt;FILELIST&amp;lt;/code&amp;gt;&lt;br /&gt;
* They will be substituted as it iterates&lt;br /&gt;
* How to iterate a command is determined by the temporary keys in &amp;lt;code&amp;gt;OUTPUT&amp;lt;/code&amp;gt;&lt;br /&gt;
* Temporary Keys for determining iterations:&lt;br /&gt;
** &amp;lt;code&amp;gt;?(BAM)&amp;lt;/code&amp;gt; - per BAM per sample&lt;br /&gt;
** &amp;lt;code&amp;gt;?(SAMPLE)&amp;lt;/code&amp;gt; - per sample&lt;br /&gt;
** &amp;lt;code&amp;gt;?(CHR)&amp;lt;/code&amp;gt; - per chromosome&lt;br /&gt;
** &amp;lt;code&amp;gt;?(START)&amp;lt;/code&amp;gt; - Per region of a Chromosome (must also include &amp;lt;code&amp;gt;?(CHR)&amp;lt;/code&amp;gt;):&lt;br /&gt;
* Additional Temporary Keys:&lt;br /&gt;
** &amp;lt;code&amp;gt;?(END)&amp;lt;/code&amp;gt; - end of the region - only used if &amp;lt;code&amp;gt;?(START)&amp;lt;/code&amp;gt; is also specified.&lt;br /&gt;
** &amp;lt;code&amp;gt;?(INPUT)&amp;lt;/code&amp;gt;&lt;br /&gt;
** &amp;lt;code&amp;gt;?(${depend}/OUTPUT)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Notes:&#039;&#039;&#039;&lt;br /&gt;
* Currently each step iteration will:&lt;br /&gt;
** be its own Makefile target/.OK file&lt;br /&gt;
** run independently on the cluster&lt;/div&gt;</summary>
		<author><name>Mktrost</name></author>
	</entry>
	<entry>
		<id>http://genome.sph.umich.edu/w/index.php?title=GotCloud:_Creating_a_New_Pipeline&amp;diff=13587</id>
		<title>GotCloud: Creating a New Pipeline</title>
		<link rel="alternate" type="text/html" href="http://genome.sph.umich.edu/w/index.php?title=GotCloud:_Creating_a_New_Pipeline&amp;diff=13587"/>
		<updated>2015-06-30T17:08:18Z</updated>

		<summary type="html">&lt;p&gt;Mktrost: /* Defining a New Pipeline */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Creating a New BAM Processing Pipeline ==&lt;br /&gt;
&lt;br /&gt;
GotCloud allows you to configure new basic BAM processing pipelines via configuration.&lt;br /&gt;
&lt;br /&gt;
To define new processing pipelines, you will use Configuration sections to define both the pipeline and each of the steps.  So first you need to understand how configuration sections work.&lt;br /&gt;
&lt;br /&gt;
=== GotCloud Configuration Sections ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
GotCloud configuration files can be broken into sections:&lt;br /&gt;
* Section names are specified between square brakets (&amp;lt;code&amp;gt;[]&amp;lt;/code&amp;gt;)&lt;br /&gt;
*: &amp;lt;pre&amp;gt;[sectionName]&amp;lt;/pre&amp;gt;&lt;br /&gt;
** Any configuration settings specified after the section header belong to that section&lt;br /&gt;
** A section can be specified multiple times in the file and the configuration settings are accumulated&lt;br /&gt;
** To access a value for a key defined in another section, use &amp;lt;code&amp;gt;$(otherSectionName/keyName)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* If a section is not specified, the configuration settings belong to the &amp;lt;code&amp;gt;global&amp;lt;/code&amp;gt; section&lt;br /&gt;
** The &amp;lt;code&amp;gt;global&amp;lt;/code&amp;gt; section does not need to be specified at the beginning of the file (it is the default section).&lt;br /&gt;
** Additional &amp;lt;code&amp;gt;global&amp;lt;/code&amp;gt; settings can be set later in the file after other settings, by defining the explicitly section:&lt;br /&gt;
**: &amp;lt;pre&amp;gt;[global]&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* Sections can be derived from another section&lt;br /&gt;
** All sections automatically derive from &amp;lt;code&amp;gt;[global]&amp;lt;/code&amp;gt;&lt;br /&gt;
** A derived section inherits all the configuration settings from its parent sections&lt;br /&gt;
*** Parent settings are overridden by redefining the configuration key/value pair&lt;br /&gt;
** A parent section is specified following a semicolon &amp;lt;code&amp;gt;:&amp;lt;/code&amp;gt; on the section definition line:&lt;br /&gt;
**: &amp;lt;pre&amp;gt;[childSectionName] : parentSectionName&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Section specific configuration settings are specified on the lines following the section definition:&lt;br /&gt;
&amp;lt;dd&amp;gt;&amp;lt;pre&amp;gt;[section1]&lt;br /&gt;
KEY1 = VAL1&lt;br /&gt;
KEY2 = VAL2&lt;br /&gt;
&lt;br /&gt;
[section2]&lt;br /&gt;
KEY1 = VAL1_2&lt;br /&gt;
KEY3 = VAL3&amp;lt;/pre&amp;gt;&amp;lt;/dd&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
=== Defining a New Pipeline ===&lt;br /&gt;
&lt;br /&gt;
There are 2 parts for creating a new pipeline&lt;br /&gt;
# [[#Overall Pipeline Definition|Overall Pipeline Definition]]&lt;br /&gt;
#* Basics for the overall pipeline&lt;br /&gt;
#* &#039;&#039;&#039;NOTE: Curretnly, configurations set in the overall pipeline&#039;s section do not by default pass onto the step&#039;s configurations&#039;&#039;&#039;&lt;br /&gt;
# [[#Configure Each Step|Configure Each Step]]&lt;br /&gt;
&lt;br /&gt;
==== Overall Pipeline Definition ====&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Define a new configuration section for your pipeline&lt;br /&gt;
&amp;lt;ul&amp;gt;&amp;lt;li&amp;gt; Example:&amp;lt;/li&amp;gt;&amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;dd&amp;gt; &amp;lt;pre&amp;gt;[pipelineName]&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Define the steps in this pipeline using the key &amp;lt;code&amp;gt;STEPS&amp;lt;/code&amp;gt; under that section&lt;br /&gt;
&amp;lt;ul&amp;gt;&amp;lt;li&amp;gt; Example:&amp;lt;/li&amp;gt;&amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;dd&amp;gt;&amp;lt;pre&amp;gt;[pipelineName]&lt;br /&gt;
STEPS = stepName1 stepName2 stepName3&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;ul&amp;gt;&amp;lt;li&amp;gt; Note: each step must have its own configuration section&amp;lt;/li&amp;gt;&amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Optional Overall Pipeline Settings:&lt;br /&gt;
* BATCH_OPTS&lt;br /&gt;
* BATCH_TYPE&lt;br /&gt;
* IGNORE_SM_CHECK - turn off the default validation that the @RG SM tag matches the bam list sample name.&lt;br /&gt;
* IGNORE_REF_CHR_CHECK&lt;br /&gt;
* OUT_DIR&lt;br /&gt;
* BAM_LIST&lt;br /&gt;
* REF&lt;br /&gt;
* REF_FAI&lt;br /&gt;
* MULTIPLE_TARGET_MAP&lt;br /&gt;
* UNIFORM_TARGET_BED&lt;br /&gt;
* OFFSET_OFF_TARET&lt;br /&gt;
* CHRS&lt;br /&gt;
* UNIT_CHUNK&lt;br /&gt;
* NO_CRAM - do not allow CRAM files as input&lt;br /&gt;
* MAKE_BASE_NAME_PIPE - base makefile name&lt;br /&gt;
* MAKE_OPTS - otpions to pass to the make command that runs the jobs.&lt;br /&gt;
* BAM_DEPEND - set to TRUE if you want the BAM file to be included as a make dependency&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
NOTES:&lt;br /&gt;
* The BAM_LIST file can contain config values within it - the overall pipeline section will be checked for those config values.&lt;br /&gt;
* By default if a value is not defined in the section, it will check global.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Configure Each Step ====&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Create a section for each step&lt;br /&gt;
&amp;lt;ul&amp;gt;&amp;lt;li&amp;gt; Example:&lt;br /&gt;
&amp;lt;dd&amp;gt; &amp;lt;pre&amp;gt;[stepName1]&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Set required keys for each step:&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;code&amp;gt;DEPEND&amp;lt;/code&amp;gt; - dependencies for this step&lt;br /&gt;
&amp;lt;dd&amp;gt; Valid Values (separate multiple dependencies with a space):&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;code&amp;gt;BAM&amp;lt;/code&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Name of step that must complete prior to this step&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;code&amp;gt;OUTPUT&amp;lt;/code&amp;gt; - name of output file&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;code&amp;gt;CMD&amp;lt;/code&amp;gt; - command for running the step&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;/div&gt;</summary>
		<author><name>Mktrost</name></author>
	</entry>
	<entry>
		<id>http://genome.sph.umich.edu/w/index.php?title=GotCloud:_FAQs&amp;diff=13552</id>
		<title>GotCloud: FAQs</title>
		<link rel="alternate" type="text/html" href="http://genome.sph.umich.edu/w/index.php?title=GotCloud:_FAQs&amp;diff=13552"/>
		<updated>2015-06-23T14:54:30Z</updated>

		<summary type="html">&lt;p&gt;Mktrost: /* Variant Calling Pipeline FAQs */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= GotCloud Frequently Asked Questions (FAQs) =&lt;br /&gt;
&lt;br /&gt;
This page hopes to answer some of the FAQs about [[GotCloud]].&lt;br /&gt;
&lt;br /&gt;
If you cannot find the answer to your question here, please [[GotCloud#Getting Help with GotCloud|contact us]].&lt;br /&gt;
&lt;br /&gt;
== General FAQs ==&lt;br /&gt;
&lt;br /&gt;
== Compiling FAQs ==&lt;br /&gt;
; How do I compile&lt;br /&gt;
: &amp;lt;pre&amp;gt;cd src/; make;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
;bam_tview_curses.c&amp;lt;nowiki&amp;gt;:5:20: error: curses.h: No such file or directory&amp;lt;/nowiki&amp;gt;&amp;lt;br /&amp;gt;bam_tview_curses.c&amp;lt;nowiki&amp;gt;:7:2: warning: #warning &amp;quot;_CURSES_LIB=1 but NCURSES_VERSION not defined; tview is NOT compiled&amp;quot;&amp;lt;/nowiki&amp;gt;&amp;lt;br /&amp;gt;bam_tview_curses.c&amp;lt;nowiki&amp;gt;:287:2: warning: #warning &amp;quot;No curses library is available; tview with curses is disabled.&amp;quot;&amp;lt;/nowiki&amp;gt;&amp;lt;br /&amp;gt;make[2]&amp;lt;nowiki&amp;gt;:&amp;lt;/nowiki&amp;gt; *** [bam_tview_curses.o] Error 1&amp;lt;br /&amp;gt;make[2]&amp;lt;nowiki&amp;gt;:&amp;lt;/nowiki&amp;gt; Leaving directory `/group/onel-lab/GeneticResources/bin/gotcloud/1.16/gotcloud-gotcloud.1.16/src/samtools&#039;&amp;lt;br /&amp;gt;make[1]&amp;lt;nowiki&amp;gt;:&amp;lt;/nowiki&amp;gt; *** [all-recur] Error 1&amp;lt;br /&amp;gt;make[1]&amp;lt;nowiki&amp;gt;:&amp;lt;/nowiki&amp;gt; Leaving directory `/group/onel-lab/GeneticResources/bin/gotcloud/1.16/gotcloud-gotcloud.1.16/src/samtools&#039;&amp;lt;br /&amp;gt;make&amp;lt;nowiki&amp;gt;:&amp;lt;/nowiki&amp;gt; *** [samtools] Error 2&lt;br /&gt;
: This error is due to curses not being installed on your machine.  To fix this error, you need to disable curses in samtools &amp;amp; samtools-hybrid&lt;br /&gt;
:* Modify: &amp;lt;code&amp;gt;gotcloud/src/samtools/Makefile&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;gotcloud/src/samtools-hybrid/Makefile&amp;lt;/code&amp;gt;&lt;br /&gt;
:*# Replace:&lt;br /&gt;
:*#: &amp;lt;code&amp;gt;-D_CURSES_LIB=1&amp;lt;/code&amp;gt;&lt;br /&gt;
:*#: with:&lt;br /&gt;
:*#: &amp;lt;code&amp;gt;-D_CURSES_LIB=0&amp;lt;/code&amp;gt;&lt;br /&gt;
:*# Replace:&lt;br /&gt;
:*#: &amp;lt;code&amp;gt;LIBCURSES=	-lcurses # -lXCurses&amp;lt;/code&amp;gt;&lt;br /&gt;
:*#: with:&lt;br /&gt;
:*#: &amp;lt;code&amp;gt;LIBCURSES=	# -lcurses # -lXCurses&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
;mkdir -p premo/build; cd premo/build; cmake ..&amp;lt;br /&amp;gt;/bin/sh&amp;lt;nowiki&amp;gt;: cmake:&amp;lt;/nowiki&amp;gt; command not found&amp;lt;br /&amp;gt;make&amp;lt;nowiki&amp;gt;:&amp;lt;/nowiki&amp;gt; *** [premo] Error 127&lt;br /&gt;
: This occurs if you do not have cmake installed on your machine.&lt;br /&gt;
:* Since premo is not used by default, just remove premo from the build&lt;br /&gt;
:** premo is only used for the mosaik aligner (non-default) and for MEI calling (which is not yet implemented)&lt;br /&gt;
:* Modify: &amp;lt;code&amp;gt;gotcloud/src/Makefile&amp;lt;/code&amp;gt;&lt;br /&gt;
:** Remove &amp;lt;code&amp;gt;premo&amp;lt;/code&amp;gt; from the &amp;lt;code&amp;gt;EXES = &amp;lt;/code&amp;gt;... line&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
; &amp;lt;nowiki&amp;gt;bed.cpp:62: error: call of overloaded ‘to_string(int32_t&amp;amp;)’ is ambiguous&amp;lt;/nowiki&amp;gt;&amp;lt;br /&amp;gt;&amp;lt;nowiki&amp;gt;/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/bits/basic_string.h:2604: note: candidates are: std::string std::to_string(long long int)&amp;lt;/nowiki&amp;gt;&amp;lt;br /&amp;gt;&amp;lt;nowiki&amp;gt;/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/bits/basic_string.h:2610: note:                 std::string std::to_string(long long unsigned int)&amp;lt;/nowiki&amp;gt;&amp;lt;br /&amp;gt;&amp;lt;nowiki&amp;gt;/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/bits/basic_string.h:2616: note:                 std::string std::to_string(long double)&amp;lt;/nowiki&amp;gt;&amp;lt;br /&amp;gt;&amp;lt;nowiki&amp;gt;make[1]: *** [bed.o] Error 1&amp;lt;/nowiki&amp;gt;&amp;lt;br /&amp;gt;&amp;lt;nowiki&amp;gt;make[1]: Leaving directory `/group/onel-lab/GeneticResources/bin/gotcloud/1.16/gotcloud-gotcloud.1.16/src/vt&#039;&amp;lt;/nowiki&amp;gt;&amp;lt;br /&amp;gt;&amp;lt;nowiki&amp;gt;make: *** [vt] Error 2&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
: std::to_string is defined in c++11.  However, not all compilers have updated to accept all overloads of to_string.&lt;br /&gt;
:* You need to cast the integer to an overload that is defined:&lt;br /&gt;
:** Edit line 62 of &amp;lt;code&amp;gt;gotcloud/src/vt/bed.cpp&amp;lt;/code&amp;gt;&lt;br /&gt;
:**:From:&lt;br /&gt;
:**::&amp;lt;code&amp;gt;return  this-&amp;gt;chrom + &amp;quot;:&amp;quot; + std::to_string(this-&amp;gt;start1) + &amp;quot;-&amp;quot; + std::to_string(this-&amp;gt;end1);&amp;lt;/code&amp;gt;&lt;br /&gt;
:**:To:&lt;br /&gt;
:**::&amp;lt;code&amp;gt;return  this-&amp;gt;chrom + &amp;quot;:&amp;quot; + std::to_string(static_cast&amp;lt;long long&amp;gt;(this-&amp;gt;start1)) + &amp;quot;-&amp;quot; + std::to_string(static_cast&amp;lt;long long&amp;gt;(this-&amp;gt;end1));&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
;CMake Error&amp;lt;nowiki&amp;gt;:&amp;lt;/nowiki&amp;gt; The current CMakeCache.txt directory /path1/gotcloud/src/premo/build/CMakeCache.txt is different than the directory /path2/gotcloud/src/premo/build where CMakeCache.txt was created. This may result in binaries being created in the wrong place. If you are not sure, reedit the CMakeCache.txt&amp;lt;br /&amp;gt;&amp;lt;nowiki&amp;gt;CMake Error: The source &amp;quot;/path1/gotcloud/src/premo/CMakeLists.txt&amp;quot; does not match the source &amp;quot;/path2/gotcloud/src/premo/CMakeLists.txt&amp;quot; used to generate cache.  Re-run cmake with a different source directory.&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
: This compilation error likely occurred because you moved GotCloud to a new directory and premo (one of the tools included in GotCloud) was still pointing to the old location. &lt;br /&gt;
:*Remove src/premo/build/CMakeCache.txt and recompile.&lt;br /&gt;
&lt;br /&gt;
== Amazon FAQs ==&lt;br /&gt;
&lt;br /&gt;
== Alignment Pipeline FAQs ==&lt;br /&gt;
; Error &amp;quot;read &amp;lt;&amp;gt; mapped to &#039;chr1&#039; at POS 0 to -1, flag 69,0 has BIN 4680 but should be 266824&amp;quot;.&amp;lt;br /&amp;gt;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;quot;Fix it by using BAM-&amp;gt;SAM-&amp;gt;BAM to force a recalculation of the BIN field.&amp;quot;&amp;lt;br /&amp;gt;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;quot;Fail to index the BAM file&amp;quot;&lt;br /&gt;
:This error appears to be due to BWA reference files that do not match the version of BWA used to run GotCloud align.  Run the following to regenerate the BWA reference files with the GotCloud version of BWA.&lt;br /&gt;
::&amp;lt;pre&amp;gt;gotcloud/bin/bwa index path/to/your/ref.fa&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Variant Calling Pipeline FAQs ==&lt;br /&gt;
; make&amp;lt;nowiki&amp;gt;: *** [outdir/vcfs/chr20/chr20.hardfiltered.vcf.gz.OK] Error 1&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
: Check the log file at: &amp;lt;code&amp;gt;outdir/vcfs/chr20/chr20.hardfiltered.sites.vcf.summary.log&amp;lt;/code&amp;gt;&lt;br /&gt;
: If it says:&lt;br /&gt;
:: &#039;&#039;&#039;[tabix] the index file either does not exist or is older than the vcf file. Please reindex.&amp;lt;br /&amp;gt;ERROR: vcf-summary, failed to open &#039;&#039;/path/to/refVcf.vcf.gz&#039;&#039;, exit code: 1&#039;&#039;&#039;&lt;br /&gt;
: It means that your VCF file is newer than the associated index (.tbi) file.&lt;br /&gt;
:* If you are using a downloaded set of reference files, and the time stamps are similar, you just need to mark the .tbi file as newer (replace with the correct .tbi file):&lt;br /&gt;
:** &amp;lt;code&amp;gt;touch &#039;&#039;/path/to/refVcf.vcf.gz.tbi&#039;&#039;&amp;lt;/code&amp;gt;&lt;br /&gt;
:* If you are using your own reference files, and you think your vcf file is newer than your .tbi file, regenerate the .tbi file using (replace with the correct .vcf.gz file):&lt;br /&gt;
:** &amp;lt;code&amp;gt;gotcloud/bin/tabix -f /path/to/refVcf.vcf.gz&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Targetted/Exome ===&lt;br /&gt;
; Exiting due to ERROR&amp;lt;nowiki&amp;gt;:&amp;lt;/nowiki&amp;gt;&amp;lt;br /&amp;gt;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;INVALID_SORT&amp;lt;nowiki&amp;gt;:&amp;lt;/nowiki&amp;gt; ERROR&amp;lt;nowiki&amp;gt;:&amp;lt;/nowiki&amp;gt; File is not coordinate sorted at record 1003&amp;lt;br /&amp;gt;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;PreviousRecord was 1&amp;lt;nowiki&amp;gt;:&amp;lt;/nowiki&amp;gt;15347, but this record is 1&amp;lt;nowiki&amp;gt;:&amp;lt;/nowiki&amp;gt;15328&lt;br /&gt;
&lt;br /&gt;
: This error occurs if you have &amp;lt;code&amp;gt;SAMTOOLS_VIEW_TARGET_ONLY = TRUE&amp;lt;/code&amp;gt; in your configuration file and a read(s) in your BAM file overlaps multiple regions in your BED file.  &lt;br /&gt;
: To fix this, set&amp;lt;nowiki&amp;gt;:&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
:: &amp;lt;pre&amp;gt;SAMTOOLS_VIEW_TARGET_ONLY = FALSE&amp;lt;/pre&amp;gt;&lt;br /&gt;
:Further Explanation of the issue&amp;lt;nowiki&amp;gt;:&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
::The SAMTOOLS_VIEW_TARGET_ONLY set to TRUE tells our pipeline to pass to SAMTOOLS view all of the regions in the BED file that fall into a single segment of our processing.  &lt;br /&gt;
::It appears that samtools view will then go through each of those regions independently and one at a time, selecting just the records that fall within that region.  &lt;br /&gt;
::A problem occurs if records fall within multiple regions from the BED file.  Since samtools view process the regions independently, it will write those records multiple times and they will end up out of order.&lt;br /&gt;
&lt;br /&gt;
::For example&amp;lt;nowiki&amp;gt;:&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
::: If we have BED with regions chr20 20300049-20300050 and chr20 20300052-20300053&lt;br /&gt;
:::The resulting call to samtools view looks like this:&lt;br /&gt;
::: &amp;lt;pre&amp;gt;gotcloud/bin/samtools-hybrid view -q 20 -F 0x0704 bamFile.bam 20:20300049-20300050 20:20300052-20300053&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:::Say there are reads at positions 20299969 and 20299994 that are each 76 bases long, they will end up being output twice by the samtools view call and in this order:&lt;br /&gt;
::::20299969&lt;br /&gt;
::::20299994&lt;br /&gt;
::::20299969&lt;br /&gt;
::::20299994&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Does Not Run ===&lt;br /&gt;
;&amp;quot;make_path&amp;quot; is not exported by the &amp;lt;nowiki&amp;gt;File::Path&amp;lt;/nowiki&amp;gt; module&amp;lt;br /&amp;gt;Can&#039;t continue after import errors at /home/chengu/program/gotcloud/bin/umake.pl line 21&amp;lt;br /&amp;gt;BEGIN failed--compilation aborted at /home/chengu/program/gotcloud/bin/umake.pl line 21.&lt;br /&gt;
&lt;br /&gt;
: This error occurs if you have an older version of Perl&#039;s &amp;lt;code&amp;gt;File::Path&amp;lt;/code&amp;gt; module.&lt;br /&gt;
::Two solutions&lt;br /&gt;
::# Upgrade to the latest Perl File::Path module.&lt;br /&gt;
::# Replace all occurrances of &amp;lt;code&amp;gt;make_path&amp;lt;/code&amp;gt; in &amp;lt;code&amp;gt;gotcloud/bin/&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;gotcloud/scripts/&amp;lt;/code&amp;gt; with &amp;lt;code&amp;gt;mkpath&amp;lt;/code&amp;gt;:&lt;br /&gt;
::#* &#039;&#039;&#039;gotcloud/bin/umake.pl&#039;&#039;&#039; - required to run snpcall&lt;br /&gt;
::#* &#039;&#039;&#039;gotcloud/scripts/vcfSplitChr.pl&#039;&#039;&#039; - required to run snpcall&lt;br /&gt;
::#* gotcloud/bin/genomestrip.pl - you only need to update this one if you want to run genomestrip&lt;br /&gt;
::#* gotcloud/scripts/bed-diff.pl - you only need to update this one if you plan to run bed-diff.pl&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== ldrefine Pipeline FAQs ==&lt;br /&gt;
; make&amp;lt;nowiki&amp;gt;: *** [outdir/beagle/chr#/split/bgl.#.chr#.PASS.#.vcf.gz.tbi] Error 1&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
: Check the log file at: &amp;lt;code&amp;gt;outdir/beagle/chr#/split/bgl.#.err&amp;lt;/code&amp;gt;&lt;br /&gt;
: If it says:&lt;br /&gt;
:: &#039;&#039;&#039;Exception in thread &amp;quot;main&amp;quot; java.lang.ArrayIndexOutOfBoundsException: -2&#039;&#039;&#039;&lt;br /&gt;
:::        &#039;&#039;&#039;at phaser.j.a(Unknown Source)&amp;lt;br /&amp;gt;        at phaser.j.c(Unknown Source)&amp;lt;br /&amp;gt;        at phaser.h.a(Unknown Source)&amp;lt;br /&amp;gt;        at phaser.E.a(Unknown Source)&amp;lt;br /&amp;gt;        at phaser.Y.a(Unknown Source)&amp;lt;br /&amp;gt;        at phaser.PhaseMain.&amp;lt;init&amp;gt;(Unknown Source)&amp;lt;br /&amp;gt;        at phaser.PhaseMain.main(Unknown Source)&#039;&#039;&#039;&lt;br /&gt;
: You need to change the seed for running beagle.&lt;br /&gt;
:* In your configuration file, set:&lt;br /&gt;
:** &amp;lt;code&amp;gt;BEAGLE = java -Xmx4g -jar $(BIN_DIR)/beagle.20101226.jar seed=993470 gprobs=true niterations=50 lowmem=true&amp;lt;/code&amp;gt;&lt;br /&gt;
:* If it fails again, change the seed in the above command to something else, and rerun.&lt;br /&gt;
&lt;br /&gt;
== Tutorial FAQs ==&lt;br /&gt;
&lt;br /&gt;
= Version Problems =&lt;br /&gt;
&lt;br /&gt;
== Prior to Version 1.16 ==&lt;br /&gt;
; perl is not found in &amp;lt;code&amp;gt;/usr/bin/perl&amp;lt;/code&amp;gt;&lt;br /&gt;
: Modify all of the .pl scripts in gotcloud/, gotcloud/bin/, and gotcloud/scripts/&lt;br /&gt;
:* If the first line contains: &amp;lt;code&amp;gt;#!/usr/bin/perl&amp;lt;/code&amp;gt;&lt;br /&gt;
:** Replace it with: &amp;lt;code&amp;gt;#!/usr/bin/env perl&amp;lt;/code&amp;gt;&lt;br /&gt;
:* Also, remove &amp;lt;code&amp;gt;-w&amp;lt;/code&amp;gt; if it occurs on that first line of the perl scripts.&lt;br /&gt;
:** If it is not already specified in the script, add the following line later in the script: &amp;lt;code&amp;gt;use warnings;&amp;lt;/code&amp;gt;&lt;br /&gt;
: This issues has been fixed in version 1.16.&lt;br /&gt;
&lt;br /&gt;
== Version 1.08 ==&lt;br /&gt;
; ERROR&amp;lt;nowiki&amp;gt;:&amp;lt;/nowiki&amp;gt; Could not find umake/&#039;&#039;&#039;outputDir&#039;&#039;&#039; in &#039;&#039;&#039;currentDirectory&#039;&#039;&#039;&lt;br /&gt;
: To work around this bug, specify an absolute path for OUT_DIR/--outdir&lt;br /&gt;
: This is due to the aligner trying to use OUT_PREFIX to transform the output directory  to an absolute path, by prepending OUT_PREFIX.  But, OUT_PREFIX is a snpcall setting that sets the snpcall Makefile filename.  OUT_PREFIX will be deprecated in the next release.  The current OUT_PREFIX which refers to the snpcall Makefile filename will be renamed to something else.&lt;br /&gt;
&lt;br /&gt;
== Version 1.07 ==&lt;br /&gt;
&lt;br /&gt;
;Type of arg 1 to keys must be hash (not hash element) at gotcloud/bin/Conf.pm line 155, near &amp;quot;}) &amp;quot;&amp;lt;br /&amp;gt;Compilation failed in require at gotcloud/bin/align.pl line 56.&lt;br /&gt;
&lt;br /&gt;
: To fix this bug, you need to edit gotcloud/bin/Conf.pm, line 155.  This error only occurs with certain versions of perl.&lt;br /&gt;
:Change&lt;br /&gt;
:&amp;lt;syntaxhighlight lang=&amp;quot;perl&amp;quot;&amp;gt;foreach my $key (keys $CONF_HASH{$section}) {&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
:to&lt;br /&gt;
:&amp;lt;syntaxhighlight lang=&amp;quot;perl&amp;quot;&amp;gt;foreach my $key (keys %{$CONF_HASH{$section}}) {&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
;Illegal division by zero at gotcloud/scripts/vcf-summary line 388.&amp;lt;br /&amp;gt;make&amp;lt;nowiki&amp;gt;:&amp;lt;/nowiki&amp;gt; *** [vcfs/chrY/chrY.hardfiltered.vcf.gz.OK] Error 255&amp;lt;br /&amp;gt;make&amp;lt;nowiki&amp;gt;:&amp;lt;/nowiki&amp;gt; *** Waiting for unfinished jobs....&amp;lt;br /&amp;gt;Commands finished in xxxxx secs WITH ERRORS.  Check the logs&lt;br /&gt;
: The current version does not gracefully handle a chromosome with no variants.&lt;br /&gt;
: By default, GotCloud assumes all samples are female, producing no chr Y variants, which will produce this error.&lt;br /&gt;
&lt;br /&gt;
: Work arounds:&lt;br /&gt;
::* Disable Chromosome Y by adding the following to your configuration file:&lt;br /&gt;
::: &amp;lt;pre&amp;gt;CHRS = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 X&amp;lt;/pre&amp;gt;&lt;br /&gt;
::: You may also want to disable chr X since it may be slightly misleading due to the assumption that all samples are female.&lt;br /&gt;
::* Specify a pedigree file that tells GotCloud which individuals are Male &amp;amp; which are Female by adding the following to your configuration file:&lt;br /&gt;
::: &amp;lt;pre&amp;gt;PED_INDEX = pedigreeFile.ped&amp;lt;/pre&amp;gt;&lt;br /&gt;
::: GotCloud only looks at the 2nd &amp;amp; 5th columns of the pedigree file (white-space delimited)&lt;br /&gt;
:::* 2nd column is the individual ID which should match the 1st column of the BAM_INDEX file.&lt;br /&gt;
:::* 5th column is the sex, use: 1 for male and 2 for female.&lt;/div&gt;</summary>
		<author><name>Mktrost</name></author>
	</entry>
	<entry>
		<id>http://genome.sph.umich.edu/w/index.php?title=GotCloud&amp;diff=13449</id>
		<title>GotCloud</title>
		<link rel="alternate" type="text/html" href="http://genome.sph.umich.edu/w/index.php?title=GotCloud&amp;diff=13449"/>
		<updated>2015-05-26T16:52:34Z</updated>

		<summary type="html">&lt;p&gt;Mktrost: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
&lt;br /&gt;
== Genomes on the Cloud (GotCloud) Introduction==&lt;br /&gt;
&lt;br /&gt;
To handle the increasing volume of next generation sequencing and genotyping data, we created and developed software pipelines called &#039;&#039;&#039;Genomes on the Cloud (GotCloud).&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
GotCloud contains Mapping &amp;amp; Variant Calling Pipelines.&lt;br /&gt;
&lt;br /&gt;
Key Features:&lt;br /&gt;
* Connects sequence analysis tools together in automated pipeline&lt;br /&gt;
** Alignment, quality control, variant calling&lt;br /&gt;
* Robust against unexpected system failure using GNU make&lt;br /&gt;
** easy restart after failure&lt;br /&gt;
* Massively parallel, can run hundreds of jobs&lt;br /&gt;
** Splits large jobs into many pieces&lt;br /&gt;
** Simplifies running on clusters&lt;br /&gt;
* Scalable to tens of thousands of samples&lt;br /&gt;
* Easy to use - Automates series of configurable steps&lt;br /&gt;
** user doesn&#039;t have to understand/configure/know the many tools required to create high quality results&lt;br /&gt;
* Available on Amazon Web Services (AWS) Elastic Compute Cloud (EC2)&lt;br /&gt;
* Run on local machines/clusters&lt;br /&gt;
&lt;br /&gt;
GotCloud incorporates the alignment and variant calling pipelines that we have been using at UM into one easy to use, publicly available tool.  GotCloud can run on a user&#039;s computer, on an instance in a &lt;br /&gt;
compute cloud, and/or can split the work up onto a cluster of machines or instances. &lt;br /&gt;
&lt;br /&gt;
[[File:Gotcloud.puzzles.v2.png|500px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Getting Help with GotCloud ===&lt;br /&gt;
&lt;br /&gt;
Please join in the [http://groups.google.com/group/GotCloud GotCloud Google Group] to ask / discuss / comment about these pipelines.&lt;br /&gt;
&lt;br /&gt;
Currently the &amp;quot;join&amp;quot; button appears to be missing.  Click &amp;quot;NEW TOPIC&amp;quot;, then select &amp;quot;Join this group&amp;quot;.  You can then cancel the message post (or post a message).&lt;br /&gt;
&lt;br /&gt;
See [[GotCloud: FAQs]] if you have any questions.  If your questions are not answered there, join the google group and ask, or email Mary Kate Wing (mktrost@umich.edu).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Sequence Analysis Background Information ===&lt;br /&gt;
&lt;br /&gt;
There are many essential steps in the analysis of next generation sequence data. &lt;br /&gt;
&lt;br /&gt;
Next generation sequence data analysis starts with [http://en.wikipedia.org/wiki/FASTQ_format FASTQ files], the typical format provided from your sequencing center containing the sequence &amp;amp; base quality information for your data.&lt;br /&gt;
&lt;br /&gt;
The fastq files are processed using the [[GotCloud: Alignment Pipeline|alignment pipeline]] which finds the most likely genomic location for each read and stores that information in a [[BAM|BAM (Binary Sequence Alignment/Map format) file]].  In addition to the sequence and base quality information contained in FASTQ files, a BAM file also contains the genomic location and some additional information about the mapping.  As part of the [[GotCloud: Alignment Pipeline|alignment pipeline]], the base qualities are adjusted to more accurately reflect the likelihood that the base is correct. &lt;br /&gt;
&lt;br /&gt;
The [[GotCloud: Alignment Pipeline|alignment pipeline]] can be skipped if you already have Deduped and Recalibrated BAM files.  If you have BAMs, but they needed to be deduped and recalibrated, you can use our [[GotCloud:_Alignment_Sub-Pipelines#recabQC_2|recabQC pipeline]].&lt;br /&gt;
&lt;br /&gt;
The [[GotCloud: Variant Calling Pipeline|variant calling pipeline]] processes the deduped and recalibrated BAM files produced by the alignment pipeline or that you provide it, generating an initial list of polymorphic sites and genotypes stored in a [http://www.1000genomes.org/wiki/Analysis/Variant%20Call%20Format/vcf-variant-call-format-version-41 VCF (Variant Call Format) file].  The [[GotCloud: Variant Calling Pipeline|variant calling pipeline]] then filters the  variants using both hard filters and a [[SVM Filtering|Support Vector Machine (SVM)]].  It then uses haplotype information to refine these genotypes in an updated VCF file.&lt;br /&gt;
&lt;br /&gt;
After completing the GotCloud Variant Calling Pipeline, [[EPACTS|EPACTS (Efficient and Parallelizable Association Container Toolbox)]] can be used to perform statistical tests to identify genome-wide association from sequence data.&lt;br /&gt;
&lt;br /&gt;
[[File:GotCloudDiagram.jpg|500px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Publication ==&lt;br /&gt;
If you use GotCloud, please cite our publication: &lt;br /&gt;
[http://genome.cshlp.org/content/early/2015/04/14/gr.176552.114.abstract Jun, Goo, et al. &amp;quot;An efficient and scalable analysis framework for variant extraction and refinement from population scale DNA sequence data.&amp;quot; Genome research (2015): gr-176552.]&lt;br /&gt;
&lt;br /&gt;
== GotCloud Setup ==&lt;br /&gt;
&lt;br /&gt;
You may run the GotCloud software in several modes:&lt;br /&gt;
* On your own hardware running Ubuntu or Redhat/CentOS. See the instructions about installing the software below.&lt;br /&gt;
* On an Amazon Elastic Compute Cloud using Ubuntu or Redhat/CentOS if you do not have your own set of machines.&lt;br /&gt;
** See [[GotCloud: Amazon]] for more information.&lt;br /&gt;
** You can run on an EC2 cluster instance created by StarCluster. &lt;br /&gt;
&lt;br /&gt;
GotCloud has been developed and tested on Linux Ubuntu 12.10 and 12.04.2 LTS.  While it should work on other Linux systems, they have not yet been tested. &lt;br /&gt;
&lt;br /&gt;
=== GotCloud on Amazon ===&lt;br /&gt;
You can take advantage of GotCloud AMI&#039;s when running on Amazon.  The GotCloud already includes GotCloud and default reference files.&lt;br /&gt;
&lt;br /&gt;
See [[GotCloud: Amazon]] for instructions on using GotCloud on Amazon.&lt;br /&gt;
&lt;br /&gt;
=== GotCloud Setup on Any Linux Machine ===&lt;br /&gt;
&lt;br /&gt;
==== GotCloud Dependencies ====&lt;br /&gt;
&lt;br /&gt;
GotCloud requires certain things to be installed in order to run:&lt;br /&gt;
* perl - gotcloud is a perl script and it calls many other perl scripts&lt;br /&gt;
** Zlib.pm - required for perl scripts to read compressed files.&lt;br /&gt;
* make - GNU make is used to run the pipelines&lt;br /&gt;
* java - required to run the beagle step of the ld-aware genotype refinement&lt;br /&gt;
* curses/ncurses (required for samtools)&lt;br /&gt;
** On Ubuntu: &amp;lt;code&amp;gt;sudo apt-get install libncurses5 libncurses5-dev&amp;lt;/code&amp;gt;&lt;br /&gt;
* cmake (required for premo)&lt;br /&gt;
** On Ubuntu: &amp;lt;code&amp;gt;sudo apt-get install cmake&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can check if your system has the proper software installed by invoking the command&lt;br /&gt;
 [gotcloud_path]/scripts/check_requirements.sh&lt;br /&gt;
&lt;br /&gt;
==== Install GotCloud Software ====&lt;br /&gt;
&lt;br /&gt;
You can install gotCloud on your system as (follow the links for the appropriate instructions):&lt;br /&gt;
* [[GotCloud: Source Releases|source release]] - contains the scripts and uncompiled source&lt;br /&gt;
* [[GotCloud: Binary Releases|binary release]] - contains the scripts and pre-compiled binaries (no source)&lt;br /&gt;
&lt;br /&gt;
[[GotCloud: Versions]] describes the changes added to each version.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Alternatively if you are using Amazon EC2, you can use one of the following sets of instructions:&lt;br /&gt;
* Create a machine instance based on the AMI we provide: [[Amazon Single Node]]&lt;br /&gt;
* Create an EC2 cluster instance using [[StarCluster|StarCluster]]&lt;br /&gt;
For more information on using GotCloud on Amazon, see: [[GotCloud: Amazon]]&lt;br /&gt;
&lt;br /&gt;
For more information on Amazon Web Services, see: https://aws.amazon.com/&lt;br /&gt;
&lt;br /&gt;
==== GotCloud Reference/Resource Files ====&lt;br /&gt;
In order to run gotCloud, you need to provide Genetic Reference and Resource Files.&lt;br /&gt;
&lt;br /&gt;
These include information about the reference sequence and dbnsp positions.&lt;br /&gt;
&lt;br /&gt;
See: [[GotCloud: Genetic Reference and Resource Files]] for information about the required files.  It contains a description of the required files, information about generating your own versions, as well as a downloadable set of files.&lt;br /&gt;
* When running on Amazon, a default set of reference files are included in the GotCloud AMI.&lt;br /&gt;
&lt;br /&gt;
==== Configure GotCloud ====&lt;br /&gt;
* [[Configure GotCloud|Configure Gotcloud]] for your installation&lt;br /&gt;
&lt;br /&gt;
== Running GotCloud Software ==&lt;br /&gt;
&lt;br /&gt;
* [[GotCloud: Alignment Pipeline|Alignment Pipeline]] &lt;br /&gt;
** [[GotCloud: Alignment Sub-Pipelines|Alignment Sub-Pipelines]] - for if you do not want to run the entire Alignment Pipeline&lt;br /&gt;
* [[GotCloud: Variant Calling Pipeline|Variant Calling Pipeline]]&lt;br /&gt;
* [[GotCloud: Indel Calling Pipeline|Indel Calling Pipeline]]&lt;br /&gt;
* [[GotCloud: GenomeSTRiP Pipeline|GenomeSTRiP Pipeline]] (Structural Variation) - &#039;&#039;Coming Soon&#039;&#039;&lt;br /&gt;
* [[GotCloud: MEI Calling Pipeline|MEI Calling Pipeline]] - &#039;&#039;Coming Soon&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
You can also create your own pipelines.  Instructions are here:&lt;br /&gt;
* [[GotCloud: Creating a New Pipeline]] &lt;br /&gt;
&lt;br /&gt;
=== GotCloud Demos ===&lt;br /&gt;
GotCloud Demos (originally from our sequencing workshop):&lt;br /&gt;
* [[SeqShop: Sequence Mapping and Assembly Practical]]&lt;br /&gt;
* [[SeqShop: Variant Calling and Filtering for SNPs Practical]]&lt;br /&gt;
* [[SeqShop: Variant Calling and Filtering for INDELs Practical]]&lt;br /&gt;
* [[SeqShop: Analysis of Structural Variation Practical]]&lt;br /&gt;
&lt;br /&gt;
GotCloud on Amazon Demo (snpcall &amp;amp; indel):&lt;br /&gt;
* [[GotCloud: Amazon Demo]]&lt;br /&gt;
&lt;br /&gt;
Deprecated: [[Tutorial: GotCloud]]&lt;br /&gt;
&lt;br /&gt;
== UMich Development/Release How-To Notes ==&lt;br /&gt;
* [[Releasing GotCloud]]&lt;br /&gt;
* Amazon EC2&lt;br /&gt;
** [[Creating an AMI on EC2]]&lt;br /&gt;
** [[Creating a Snapshot on EC2]] (deprecated)&lt;br /&gt;
** [[Mount S3 Volume]]&lt;br /&gt;
** Notes on sequence data preparation in [[Amazon Storage|Amazon Storage]].&lt;br /&gt;
&lt;br /&gt;
* [[Git_FAQs#Subtrees|Upgrade Git Subtree]]&lt;/div&gt;</summary>
		<author><name>Mktrost</name></author>
	</entry>
</feed>