<tool id="gatk4_mutect2" name="GATK4 Mutect2" version="@TOOL_VERSION@+galaxy@VERSION_SUFFIX@" profile="@PROFILE@">
    <description>- Call somatic SNVs and indels via local assembly of haplotypes</description>
    <macros>
        <import>macros.xml</import>
    </macros>
    <expand macro="requirements"/>
    <expand macro="version_cmd"/>
    <command detect_errors="exit_code">
        <![CDATA[
        #include source=$set_sections#
        #include source=$pre_gatk_excl_ints_chth#
        #include source=$pre_gatk_ints_chth#

        #set ref_flag='-R reference.fa'

        #if str($reference_source.reference_source_selector) == 'history'
            ln -s '$reference_source.reference_sequence' reference.fa &&
            samtools faidx reference.fa &&
            gatk CreateSequenceDictionary -R reference.fa -O reference.dict &&
        #else if str($reference_source.reference_source_selector) == 'cached'
            ln -s '$reference_source.reference_sequence.fields.path' reference.fa &&
            samtools faidx reference.fa &&
            gatk CreateSequenceDictionary -R reference.fa -O reference.dict &&
        #else
            #set ref_flag=''
        #end if
	
        #if str($mode.mode_parameters) == 'tumor_only'
            ln -s $mode.tumor tumor.bam &&
            ln -s $mode.tumor.metadata.bam_index tumor.bam.bai &&
        #else
            ln -s $mode.tumor tumor.bam &&
            ln -s $mode.tumor.metadata.bam_index tumor.bam.bai &&
            ln -s $mode.normal normal.bam &&
            ln -s $mode.normal.metadata.bam_index normal.bam.bai &&
        #end if
	
	#if str($outputs.output_parameters) == 'yes'
            #if str($outputs.debug_assembly) == 'yes'
                ln -s '$assembly_region_out' assembly-region.tab &&
            #end if
            #if str($outputs.debug_bam) == 'yes'
                ln -s '$bam_output' debug.bam &&
            #end if
        #end if

        gatk GetSampleName -I tumor.bam -O samplename.txt &&
        sample=`cat samplename.txt | sed 's/"//g'` &&

        #if str($optional.optional_parameters) == 'yes'
            #if $optional.panel_of_normals
                #set datatype = $optional.panel_of_normals.datatype
                #if $optional.panel_of_normals.is_of_type("vcf_bgzip")
                    ln -s '$optional.panel_of_normals' panel_of_normals.vcf.gz &&
                    tabix panel_of_normals.vcf.gz &&
                #else
                    ln -s '$optional.panel_of_normals' panel_of_normals.vcf &&
                #end if
            #end if

            #if $optional.germline_resource
                #set datatype = $optional.germline_resource.datatype
                #if $optional.germline_resource.is_of_type("vcf_bgzip")
                    ln -s '$optional.germline_resource' germline_resource.vcf.gz &&
                    tabix germline_resource.vcf.gz &&
                #else
                    ln -s '$optional.germline_resource' germline_resource.vcf &&
                #end if
            #end if

            #if $optional.alleles
                #set datatype = $optional.alleles.datatype
                #if $optional.alleles.is_of_type("vcf_bgzip")
                    ln -s '$optional.alleles' alleles.vcf.gz &&
                    tabix alleles.vcf.gz &&
                    @CMD_BEGIN@ IndexFeatureFile --feature-file alleles.vcf.gz &&
                #else
                    ln -s '$optional.alleles' alleles.vcf &&
                    @CMD_BEGIN@ IndexFeatureFile --feature-file alleles.vcf &&
                #end if
            #end if

        #end if

        gatk Mutect2 --QUIET $ref_flag --tumor-sample "\$sample"

        #if str($mode.mode_parameters) == 'tumor_only'
            --input tumor.bam
        #else
            --input tumor.bam
            --input normal.bam
        #end if

        ## OPTIONAL PARAMETERS ##

        #if str($optional.optional_parameters) == 'yes'

            #if $optional.panel_of_normals
                #if $optional.panel_of_normals.is_of_type("vcf_bgzip")
                    --panel-of-normals panel_of_normals.vcf.gz
                #else
                    --panel-of-normals panel_of_normals.vcf
                #end if
            #end if

            #if $optional.pedigree
                --pedigree "$optional.pedigree"
            #end if

            #if $optional.germline_resource
                #if $optional.germline_resource.is_of_type("vcf_bgzip")
                    --germline-resource germline_resource.vcf.gz
                #else
                    --germline-resource germline_resource.vcf
                #end if
            #end if

            #if $optional.annotation
                #for $annot in str($optional.annotation).split(',')
                    --annotation "$annot"
                #end for
            #end if

            #if $optional.annotation_group
                #for $annot in str($optional.annotation_group).split(',')
                    --annotation-group "$annot"
                #end for
            #end if

            #if $optional.annotations_to_exclude
                #for $annot in str($optional.annotations_to_exclude).split(',')
                    --annotations-to-exclude "$annot"
                #end for
            #end if

            #if $optional.founder_id
                --founder-id "$optional.founder_id"
            #end if

            #if $optional.normal_sample
                --normal-sample "$optional.normal_sample"
            #end if

            #if $optional.alleles
                --alleles alleles.vcf
            #end if

            #if $optional.f1r2_max_depth:
                --f1r2-max-depth "$optional.f1r2_max_depth"
            #end if

            #if $optional.f1r2_median_mq:
                --f1r2-median-mq "$optional.f1r2_median_mq"
            #end if

            #if $optional.f1r2_min_bq:
                --f1r2-min-bq "$optional.f1r2_min_bq"
            #end if

            #if $optional.interval_merging_rule:
                --interval-merging-rule "$optional.interval_merging_rule"
            #end if

            #if $optional.interval_set_rule:
                --interval-set-rule "$optional.interval_set_rule"
            #end if

            #if $optional.pcr_indel_qual:
                --pcr-indel-qual "$optional.pcr_indel_qual"
            #end if

            #if $optional.pcr_snv_qual:
                --pcr-snv-qual "$optional.pcr_snv_qual"
            #end if

            #if $optional.read_filter
                #for $filter in str($optional.read_filter).split(',')
                    --read-filter "$filter"
                #end for
            #end if

            #if $optional.disable_read_filter
                #for $filter in str($optional.disable_read_filter).split(',')
                    --disable-read-filter "$filter"
                #end for
            #end if

            --base-quality-score-threshold "$optional.base_quality_score_threshold"
            --af-of-alleles-not-in-resource "$optional.af_of_alleles_not_in_resource"
            --downsampling-stride "$optional.downsampling_stride"
            --gcs-max-retries "$optional.gcs_max_retries"
            --initial-tumor-lod "$optional.initial_tumor_lod"
            --max-population-af "$optional.max_population_af"
            --max-reads-per-alignment-start "$optional.max_reads_per_alignment_start"
            --min-base-quality-score "$optional.min_base_quality_score"
            --native-pair-hmm-threads "\${GALAXY_SLOTS:-1}"
            --normal-lod "$optional.normal_lod"
            --read-validation-stringency "$optional.read_validation_stringency"
            --tumor-lod-to-emit "$optional.tumor_lod_to_emit"
            --verbosity "ERROR"
            $optional.lenient
            $optional.annotate_with_num_discovered_alleles
            $optional.add_output_sam_program_record
            $optional.disable_bam_index_caching
            $optional.disable_sequence_dictionary_validation
            $optional.genotype_germline_sites
            $optional.genotype_pon_sites
            $optional.ignore_itr_artifacts
            $optional.mitochondria_mode
            $optional.native_pair_hmm_use_double_precision
            $optional.sites_only_vcf_output
            $optional.add_output_vcf_command_line
        #end if

        ## END OPTIONAL PARAMETERS ##

        ## ADVANCED PARAMETERS ##

        #if str($advanced.advanced_parameters) == 'yes'

            #if $advanced.kmer_size
                --kmer-size "$advanced.kmer_size"
            #end if

            #if $advanced.gvcf_lod_band
                --gvcf-lod-band "$advanced.gvcf_lod_band"
            #end if

            #if $advanced.emit_ref_confidence
                --emit-ref-confidence "$advanced.emit_ref_confidence"
            #end if

            #if $advanced.max_unpruned_variants
                --max-unpruned-variants "$advanced.max_unpruned_variants"
            #end if
            --allele-informative-reads-overlap-margin "$advanced.allele_informative_reads_overlap_margin"
            --active-probability-threshold "$advanced.active_probability_threshold"
            --assembly-region-padding "$advanced.assembly_region_padding"
            --bam-writer-type "$advanced.bam_writer_type"
            --max-assembly-region-size "$advanced.max_assembly_region_size"
            --max-mnp-distance "$advanced.max_mnp_distance"
            --max-num-haplotypes-in-population "$advanced.max_num_haplotypes_in_population"
            --max-prob-propagation-distance "$advanced.max_prob_propagation_distance"
            --max-suspicious-reads-per-alignment-start "$advanced.max_suspicious_reads_per_alignment_start"
            --min-assembly-region-size "$advanced.min_assembly_region_size"
            --min-dangling-branch-length "$advanced.min_dangling_branch_length"
            --min-pruning "$advanced.min_pruning"
            --minimum-allele-fraction "$advanced.minimum_allele_fraction"
            --num-pruning-samples "$advanced.num_pruning_samples"
            --pair-hmm-gap-continuation-penalty "$advanced.pair_hmm_gap_continuation_penalty"
            --callable-depth "$advanced.callable_depth"
            --pair-hmm-implementation "$advanced.pair_hmm_implementation"
            --pcr-indel-model "$advanced.pcr_indel_model"
            --phred-scaled-global-read-mismapping-rate "$advanced.phred_scaled_global_read_mismapping_rate"
            --pruning-lod-threshold "$advanced.pruning_lod_threshold"
            --smith-waterman "$advanced.smith_waterman"
            $advanced.allow_non_unique_kmers_in_ref
            $advanced.disable_adaptive_pruning
            $advanced.disable_tool_default_annotations
            $advanced.disable_tool_default_read_filters
            $advanced.dont_increase_kmer_sizes_for_cycles
            $advanced.dont_use_soft_clipped_bases
            $advanced.enable_all_annotations
            $advanced.force_active
            $advanced.force_call_filtered_alleles
            $advanced.independent_mates
            $advanced.recover_all_dangling_branches
            $advanced.use_filtered_reads_for_annotations

        #end if

        ## END ADVANCED PARAMETERS ##

        ## ADDITIONAL OUTPUT PARAMETERS ##

        #if str($outputs.output_parameters) == 'yes'
            #if str($outputs.debug_assembly) == 'yes'
                --assembly-region-out "assembly-region.tab"
            #end if
            #if str($outputs.debug_bam) == 'yes'
                --bam-output "debug.bam"
            #end if
        #end if

        #include source=$gatk_excl_ints_chth#
        #include source=$gatk_ints_chth#
        #include source=$vcf_output_opts#
        #include source=$gatk_seqdict#
        ]]>
    </command>
    <inputs>
        <conditional name="mode">
            <param name="mode_parameters" type="select" label="Type of analysis">
                <option value="tumor_only">Tumor-only</option>
                <option value="somatic">Somatic</option>
            </param>
            <when value="tumor_only">
                <param name="tumor" argument="--tumor" type="data" format="bam" label="Input Tumor BAM file" />
            </when>
            <when value="somatic">
                <param name="tumor" argument="--tumor" type="data" format="bam" label="Input Tumor BAM file" />
                <param name="normal" argument="--normal" type="data" format="bam" label="Input Normal BAM file" />
            </when>
        </conditional>
        <expand macro="gzip_vcf_params"/>
        <expand macro="ref_sel"/>
        <conditional name="optional">
            <param name="optional_parameters" type="select" label="Optional parameters">
                <option value="no">Use internal defaults</option>
                <option value="yes">Specify parameters</option>
            </param>
            <when value="yes">
                <expand macro="gatk_excl_ints"/>
                <expand macro="gatk_ints"/>
                <expand macro="seq_dict_sel"/>
                <param name="add_output_sam_program_record" argument="--add-output-sam-program-record" type="boolean" truevalue="--add-output-sam-program-record" falsevalue="" optional="true" checked="true" label="Add Output Sam Program Record" help="If true, adds a PG tag to created SAM/BAM/CRAM files."/>
                <param name="add_output_vcf_command_line" argument="--add-output-vcf-command-line" type="boolean" truevalue="--add-output-vcf-command-line" falsevalue="" optional="true" checked="true" label="Add Output Vcf Command Line" help="If true, adds a command line header line to created VCF files."/>
                <param name="af_of_alleles_not_in_resource" argument="--af-of-alleles-not-in-resource" type="float" optional="true" value="-1.0" label="Af Of Alleles Not In Resource" help="Population allele fraction assigned to alleles not found in germline resource.  Please see docs/mutect/mutect2.pdf fora derivation of the default value."/>
                <param name="annotate_with_num_discovered_alleles" argument="--annotate-with-num-discovered-alleles" type="boolean" truevalue="--annotate-with-num-discovered-alleles" falsevalue="" optional="true" checked="false" label="Annotate With Num Discovered Alleles" help="If provided, we will annotate records with the number of alternate alleles that were discovered (but not necessarily genotyped) at a given site"/>
                <param argument="--annotation" type="select" multiple="true" label="Annotations" help="One or more specific annotations to add to variant calls">
                    <option value="AlleleFraction">AlleleFraction</option>
                    <option value="AS_BaseQualityRankSumTest">AS_BaseQualityRankSumTest</option>
                    <option value="AS_FisherStrand">AS_FisherStrand</option>
                    <option value="AS_InbreedingCoeff">AS_InbreedingCoeff</option>
                    <option value="AS_MappingQualityRankSumTest">AS_MappingQualityRankSumTest</option>
                    <option value="AS_QualByDepth">AS_QualByDepth</option>
                    <option value="AS_ReadPosRankSumTest">AS_ReadPosRankSumTest</option>
                    <option value="AS_RMSMappingQuality">AS_RMSMappingQuality</option>
                    <option value="AS_StrandOddsRatio">AS_StrandOddsRatio</option>
                    <option value="BaseQuality">BaseQuality</option>
                    <option value="BaseQualityHistogram">BaseQualityHistogram</option>
                    <option value="BaseQualityRankSumTest">BaseQualityRankSumTest</option>
                    <option value="ChromosomeCounts">ChromosomeCounts</option>
                    <option value="ClippingRankSumTest">ClippingRankSumTest</option>
                    <option value="CountNs">CountNs</option>
                    <option value="Coverage">Coverage</option>
                    <option value="DepthPerAlleleBySample">DepthPerAlleleBySample</option>
                    <option value="DepthPerSampleHC">DepthPerSampleHC</option>
                    <option value="ExcessHet">ExcessHet</option>
                    <option value="FisherStrand">FisherStrand</option>
                    <option value="FragmentLength">FragmentLength</option>
                    <option value="GenotypeSummaries">GenotypeSummaries</option>
                    <option value="InbreedingCoeff">InbreedingCoeff</option>
                    <option value="LikelihoodRankSumTest">LikelihoodRankSumTest</option>
                    <option value="MappingQuality">MappingQuality</option>
                    <option value="MappingQualityRankSumTest">MappingQualityRankSumTest</option>
                    <option value="MappingQualityZero">MappingQualityZero</option>
                    <option value="OrientationBiasReadCounts">OrientationBiasReadCounts</option>
                    <option value="OriginalAlignment">OriginalAlignment</option>
                    <option value="PossibleDeNovo">PossibleDeNovo</option>
                    <option value="QualByDepth">QualByDepth</option>
                    <option value="ReadPosition">ReadPosition</option>
                    <option value="ReadPosRankSumTest">ReadPosRankSumTest</option>
                    <option value="ReferenceBases">ReferenceBases</option>
                    <option value="RMSMappingQuality">RMSMappingQuality</option>
                    <option value="SampleList">SampleList</option>
                    <option value="StrandBiasBySample">StrandBiasBySample</option>
                    <option value="StrandOddsRatio">StrandOddsRatio</option>
                    <option value="TandemRepeat">TandemRepeat</option>
                    <option value="UniqueAltReadCount">UniqueAltReadCount</option>
                </param>
                <param name="annotation_group" argument="--annotation-group" type="select" multiple="true" label="Annotation groups" help="One or more annotation groups to add to variant calls">
                    <option value="AlleleSpecificAnnotation">AlleleSpecificAnnotation</option>
                    <option value="AS_StandardAnnotation">AS_StandardAnnotation</option>
                    <option value="ReducibleAnnotation">ReducibleAnnotation</option>
                    <option value="StandardAnnotation">StandardAnnotation</option>
                    <option value="StandardHCAnnotation">StandardHCAnnotation</option>
                    <option value="StandardMutectAnnotation">StandardMutectAnnotation</option>
                </param>
                <param name="annotations_to_exclude" argument="--annotations-to-exclude" type="select" multiple="true" label="Annotations to exclude" help="Specific annotations to exclude from variant calls">
                    <option value="AlleleFraction">AlleleFraction</option>
                    <option value="AS_BaseQualityRankSumTest">AS_BaseQualityRankSumTest</option>
                    <option value="AS_FisherStrand">AS_FisherStrand</option>
                    <option value="AS_InbreedingCoeff">AS_InbreedingCoeff</option>
                    <option value="AS_MappingQualityRankSumTest">AS_MappingQualityRankSumTest</option>
                    <option value="AS_QualByDepth">AS_QualByDepth</option>
                    <option value="AS_ReadPosRankSumTest">AS_ReadPosRankSumTest</option>
                    <option value="AS_RMSMappingQuality">AS_RMSMappingQuality</option>
                    <option value="AS_StrandOddsRatio">AS_StrandOddsRatio</option>
                    <option value="BaseQuality">BaseQuality</option>
                    <option value="BaseQualityHistogram">BaseQualityHistogram</option>
                    <option value="BaseQualityRankSumTest">BaseQualityRankSumTest</option>
                    <option value="ChromosomeCounts">ChromosomeCounts</option>
                    <option value="ClippingRankSumTest">ClippingRankSumTest</option>
                    <option value="CountNs">CountNs</option>
                    <option value="Coverage">Coverage</option>
                    <option value="DepthPerAlleleBySample">DepthPerAlleleBySample</option>
                    <option value="DepthPerSampleHC">DepthPerSampleHC</option>
                    <option value="ExcessHet">ExcessHet</option>
                    <option value="FisherStrand">FisherStrand</option>
                    <option value="FragmentLength">FragmentLength</option>
                    <option value="GenotypeSummaries">GenotypeSummaries</option>
                    <option value="InbreedingCoeff">InbreedingCoeff</option>
                    <option value="LikelihoodRankSumTest">LikelihoodRankSumTest</option>
                    <option value="MappingQuality">MappingQuality</option>
                    <option value="MappingQualityRankSumTest">MappingQualityRankSumTest</option>
                    <option value="MappingQualityZero">MappingQualityZero</option>
                    <option value="OrientationBiasReadCounts">OrientationBiasReadCounts</option>
                    <option value="OriginalAlignment">OriginalAlignment</option>
                    <option value="PossibleDeNovo">PossibleDeNovo</option>
                    <option value="QualByDepth">QualByDepth</option>
                    <option value="ReadPosition">ReadPosition</option>
                    <option value="ReadPosRankSumTest">ReadPosRankSumTest</option>
                    <option value="ReferenceBases">ReferenceBases</option>
                    <option value="RMSMappingQuality">RMSMappingQuality</option>
                    <option value="SampleList">SampleList</option>
                    <option value="StrandBiasBySample">StrandBiasBySample</option>
                    <option value="StrandOddsRatio">StrandOddsRatio</option>
                    <option value="TandemRepeat">TandemRepeat</option>
                    <option value="UniqueAltReadCount">UniqueAltReadCount</option>
                </param>
                <param name="pedigree" argument="--pedigree" type="data" optional="true" format="vcf,vcf_bgzip" label="Pedigree" help="Pedigree file for determining the population &quot;founders&quot;. If a file is provided here, a pedigree-based annotation must be added above."/>
                <param name="base_quality_score_threshold" argument="--base-quality-score-threshold" type="integer" optional="true" value="18" label="Base Quality Score Threshold" help="Base qualities below this threshold will be reduced to the minimum (6)"/>
                <param name="callable_depth" argument="--callable-depth" type="integer" optional="true" value="10" label="Minimum depth to be considered callable" help="Does not affect genotyping"/>
                <param name="disable_bam_index_caching" argument="--disable-bam-index-caching" type="boolean" truevalue="--disable-bam-index-caching" falsevalue="" optional="true" checked="false" label="Disable Bam Index Caching" help="If true, don&amp;apos;t cache bam indexes, this will reduce memory requirements but may harm performance if many intervals are specified.  Caching is automatically disabled if there are no intervals specified."/>
                <param name="disable_read_filter" argument="--disable-read-filter" type="select" multiple="true" value="" label="Disable Read Filter" help="Read filters to be disabled before analysis">
                    <option value="GoodCigarReadFilter">Good cigar string</option>
                    <option value="MappedReadFilter">Mapped read</option>
                    <option value="MappingQualityAvailableReadFilter">Mapping quality available</option>
                    <option value="MappingQualityNotZeroReadFilter">Mapping quality not zero</option>
                    <option value="NonChimericOriginalAlignmentReadFilter">Non-chimeric original alignment</option>
                    <option value="NonZeroReferenceLengthAlignmentReadFilter">Non-zero reference length alignment</option>
                    <option value="NotDuplicateReadFilter">Not a duplicate read</option>
                    <option value="NotSecondaryAlignmentReadFilter">Not a secondary alignment</option>
                    <option value="PassesVendorQualityCheckReadFilter">Passes vendor quality check</option>
                    <option value="WellformedReadFilter">Well-formed read</option>
                </param>
                <param name="read_filter" argument="--read-filter" type="select" multiple="true" value="" label="Read Filter" help="Read filters to be applied before analysis">
                    <option value="AlignmentAgreesWithHeaderReadFilter">Alignment agrees with header</option>
                    <option value="AllowAllReadsReadFilter">Allow all reads</option>
                    <option value="AmbiguousBaseReadFilter">Ambiguous base</option>
                    <option value="CigarContainsNoNOperator">Cigar contains no NO operator</option>
                    <option value="FirstOfPairReadFilter">First of pair</option>
                    <option value="GoodCigarReadFilter">Good cigar string</option>
                    <option value="HasReadGroupReadFilter">Has read group</option>
                    <option value="MappedReadFilter">Mapped read</option>
                    <option value="MappingQualityAvailableReadFilter">Mapping quality available</option>
                    <option value="MappingQualityNotZeroReadFilter">Mapping quality not zero</option>
                    <option value="MatchingBasesAndQualsReadFilter">Matching bases and quals</option>
                    <option value="MateDifferentStrandReadFilter">Mate different strand</option>
                    <option value="MateOnSameContigOrNoMappedMateReadFilter">Mate on same contig or no mapped mate</option>
                    <option value="MateUnmappedAndUnmappedReadFilter">Mate unmapped and mapped</option>
                    <option value="MetricsReadFilter">Metrics</option>
                    <option value="NonChimericOriginalAlignmentReadFilter">Non-chimeric original alignment</option>
                    <option value="NonZeroFragmentLengthReadFilter">Non-zero fragment length</option>
                    <option value="NonZeroReferenceLengthAlignmentReadFilter">Non-zero reference length alignment</option>
                    <option value="NotDuplicateReadFilter">Not duplicate</option>
                    <option value="NotOpticalDuplicateReadFilter">Not optical duplicate</option>
                    <option value="NotSecondaryAlignmentReadFilter">Not a secondary alignment</option>
                    <option value="NotSupplementaryAlignmentReadFilter">Not a supplementary alignment</option>
                    <option value="OverclippedReadFilter">Overclipped</option>
                    <option value="PairedReadFilter">Paired</option>
                    <option value="PassesVendorQualityCheckReadFilter">Passes vendor quality check</option>
                    <option value="PrimaryLineReadFilter">Primary line</option>
                    <option value="ProperlyPairedReadFilter">Properly paired</option>
                    <option value="ReadLengthEqualsCigarLengthReadFilter">Read length equals cigar length</option>
                    <option value="SecondOfPairReadFilter">Second of pair</option>
                    <option value="SeqIsStoredReadFilter">Sequence is stored</option>
                    <option value="SoftClippedReadFilter">Soft clipped</option>
                    <option value="ValidAlignmentStartReadFilter">Valid alignment start</option>
                    <option value="ValidAlignmentEndReadFilter">Valid alignment end</option>
                    <option value="WellformedReadFilter">Well-formed read</option>
                </param>
                <param name="disable_sequence_dictionary_validation" argument="--disable-sequence-dictionary-validation" type="boolean" truevalue="--disable-sequence-dictionary-validation" falsevalue="" optional="true" checked="false" label="Disable Sequence Dictionary Validation" help="If specified, do not check the sequence dictionaries from our inputs for compatibility. Use at your own risk!"/>
                <param name="downsampling_stride" argument="--downsampling-stride" type="integer" optional="true" value="1" label="Downsampling Stride" help="Downsample a pool of reads starting within a range of one or more bases."/>
                <param name="f1r2_max_depth" argument="--f1r2-max-depth" type="integer" optional="true" value="200" label="Sites with depth higher than this value will be grouped" />
                <param name="f1r2_median_mq" argument="--f1r2-median-mq" type="integer" optional="true" value="50" label="Skip sites with median mapping quality below this value" />
                <param name="f1r2_min_bq" argument="--base-quality-score-threshold" type="integer" optional="true" value="20" label="Exclude bases below this quality from pileup" />
                <param name="founder_id" argument="--founder-id" type="text" optional="true" value="" label="Founder Id" help="Samples representing the population &amp;quot;founders&amp;quot;"/>
                <param name="gcs_max_retries" argument="--gcs-max-retries" type="integer" optional="true" value="20" label="Gcs Max Retries" help="If the GCS bucket channel errors out, how many times it will attempt to re-initiate the connection"/>
                <param name="genotype_germline_sites" argument="--genotype-germline-sites" type="boolean" truevalue="--genotype-germline-sites" falsevalue="" optional="true" checked="false" label="Genotype Germline Sites" help="(EXPERIMENTAL) Call all apparent germline site even though they will ultimately be filtered."/>
                <param name="genotype_pon_sites" argument="--genotype-pon-sites" type="boolean" truevalue="--genotype-pon-sites" falsevalue="" optional="true" checked="false" label="Genotype PoN Sites" help="Call sites in the PoN even though they will ultimately be filtered."/>
                <param name="alleles" argument="--alleles" type="data" optional="true" format="vcf" label="Alleles" help="The set of alleles at which to genotype"/>
                <param name="germline_resource" argument="--germline-resource" type="data" optional="true" format="vcf,vcf_bgzip" label="Germline Resource" help="Population vcf of germline sequencing containing allele fractions."/>
                <param name="ignore_itr_artifacts" argument="--ignore-itr-artifacts" type="boolean" truevalue="--ignore-itr-artifacts" falsevalue="" optional="true" checked="false" label="Turn off read transformer that clips artifacts associated with end repair insertions near inverted tandem repeats" />
                <param name="initial_tumor_lod" argument="--initial-tumor-lod" type="float" optional="true" value="2.0" label="Initial Tumor Lod" help="LOD threshold to consider pileup active."/>
                <param name="interval_exclusion_padding" argument="--interval-exclusion-padding" type="integer" value="0" label="Interval exclusion padding" help="Amount of padding (in bp) to add to each interval you are excluding" />
                <param name="interval_padding" argument="--interval-padding" type="integer" value="0" label="Interval padding" help="Amount of padding (in bp) to add to each interval you are including" />
                <param name="interval_merging_rule" argument="--interval-merging-rule" type="select" optional="true" label="Interval Merging Rule" help="Interval merging rule for abutting intervals">
                    <option selected="true" value="ALL">All</option>
                    <option value="OVERLAPPING_ONLY">Overlapping only</option>
                </param>
                <param name="interval_set_rule" argument="--interval-set-rule" type="select" optional="true" label="Interval Set Rule" help="Set merging approach to use for combining interval inputs">
                    <option selected="true" value="UNION">Union</option>
                    <option value="INTERSECTION">Intersection</option>
                </param>
                <param name="lenient" argument="--lenient" type="boolean" truevalue="--lenient" falsevalue="" optional="true" checked="false" label="Lenient" help="Lenient processing of VCF files"/>
                <param name="max_population_af" argument="--max-population-af" type="float" optional="true" value="0.01" label="Max Population Af" help="Maximum population allele frequency in tumor-only mode."/>
                <param name="max_reads_per_alignment_start" argument="--max-reads-per-alignment-start" type="integer" optional="true" value="50" label="Max Reads Per Alignment Start" help="Maximum number of reads to retain per alignment start position. Reads above this threshold will be downsampled. Set to 0 to disable."/>
                <param name="min_base_quality_score" argument="--min-base-quality-score" type="integer" optional="true" value="10" label="Min Base Quality Score" help="Minimum base quality required to consider a base for calling"/>
                <param name="mitochondria_mode" argument="--mitochondria-mode" type="boolean" truevalue="--mitochondria-mode" falsevalue="" label="Mitochondria mode sets emission and initial LODs to 0" />
                <param name="native_pair_hmm_use_double_precision" argument="--native-pair-hmm-use-double-precision" type="boolean" truevalue="--native-pair-hmm-use-double-precision" falsevalue="" optional="true" checked="false" label="Native Pair Hmm Use Double Precision" help="use double precision in the native pairHmm. This is slower but matches the java implementation better"/>
                <param name="normal_lod" argument="--normal-lod" type="float" optional="true" value="2.2" label="Normal Lod" help="LOD threshold for calling normal variant non-germline."/>
                <param name="normal_sample" argument="--normal-sample" type="text" optional="true" value="" label="Normal Sample" help="BAM sample name of normal.  May be URL-encoded as output by GetSampleName with -encode argument."/>
                <param name="panel_of_normals" argument="--panel-of-normals" type="data" optional="true" format="vcf,vcf_bgzip" label="Panel Of Normals" help="VCF file of sites observed in normal."/>
                <param name="pcr_indel_qual" argument="--pcr-indel-qual" type="integer" optional="true" value="40" label="Phred-scaled PCR indel qual for overlapping fragments" />
                <param name="pcr_snv_qual" argument="--pcr-snv-qual" type="integer" optional="true" value="40" label="Phred-scaled PCR SNV qual for overlapping fragments" />
                <param name="sites_only_vcf_output" argument="--sites-only-vcf-output" type="boolean" truevalue="--sites-only-vcf-output" falsevalue="" optional="true" checked="false" label="Sites Only Vcf Output" help="If true, don&apos;t emit genotype fields when writing vcf file output."/>
                <param name="read_validation_stringency" argument="--read-validation-stringency" type="select" optional="true" label="Read Validation Stringency" help="Validation stringency for all SAM/BAM/CRAM/SRA files read by this program.  The default stringency value SILENT can improve performance when processing a BAM file in which variable-length data (read, qualities, tags) do not otherwise need to be decoded.">
                    <option selected="true" value="SILENT">Silent</option>
                    <option value="STRICT">Strict</option>
                    <option value="LENIENT">Lenient</option>
                </param>
                <param name="tumor_lod_to_emit" argument="--tumor-lod-to-emit" type="float" optional="true" value="3.0" label="Tumor Lod To Emit" help="LOD threshold to emit tumor variant to VCF."/>
            </when>
            <when value="no" />
        </conditional>
        <conditional name="advanced">
            <param name="advanced_parameters" type="select" label="Advanced parameters">
                <option value="no">Use internal defaults</option>
                <option value="yes">Specify parameters</option>
            </param>
            <when value="yes">
                <param name="allele_informative_reads_overlap_margin" argument="--allele-informative-reads-overlap-margin" type="integer" optional="true" value="2" label="Likelihood and read-based annotations will only take into consideration reads that overlap the variant or any base no further than this distance expressed in base pairs" help="Number of overlapping bases around the variant."/>
                <param name="active_probability_threshold" argument="--active-probability-threshold" type="float" optional="true" value="0.002" label="Active Probability Threshold" help="Minimum probability for a locus to be considered active."/>
                <param name="allow_non_unique_kmers_in_ref" argument="--allow-non-unique-kmers-in-ref" type="boolean" truevalue="--allow-non-unique-kmers-in-ref" falsevalue="" optional="true" checked="false" label="Allow Non Unique Kmers In Ref" help="Allow graphs that have non-unique kmers in the reference"/>
                <param name="assembly_region_padding" argument="--assembly-region-padding" type="integer" optional="true" value="100" label="Assembly Region Padding" help="Number of additional bases of context to include around each assembly region"/>
                <param name="bam_writer_type" argument="--bam-writer-type" type="select" optional="true" label="Bam Writer Type" help="Which haplotypes should be written to the BAM">
                    <option selected="true" value="CALLED_HAPLOTYPES">Called haplotypes</option>
                    <option value="ALL_POSSIBLE_HAPLOTYPES">All possible haplotypes</option>
                </param>

                <param name="disable_adaptive_pruning" argument="--disable-adaptive-pruning" type="boolean" truevalue="--disable-adaptive-pruning" falsevalue="" optional="true" checked="false" label="Disable adaptive pruning" help="Disable the adaptive algorithm for pruning paths in the graph"/>
                <param name="disable_tool_default_annotations" argument="--disable-tool-default-annotations" type="boolean" truevalue="--disable-tool-default-annotations" falsevalue="" optional="true" checked="false" label="Disable Default Annotations" help="Disable all tool default annotations"/>
                <param name="disable_tool_default_read_filters" argument="--disable-tool-default-read-filters" type="boolean" truevalue="--disable-tool-default-read-filters" falsevalue="" optional="true" checked="false" label="Disable default read filters" help="WARNING: many tools will not function correctly without their default read filters on"/>
                <param name="dont_increase_kmer_sizes_for_cycles" argument="--dont-increase-kmer-sizes-for-cycles" type="boolean" truevalue="--dont-increase-kmer-sizes-for-cycles" falsevalue="" optional="true" checked="false" label="Dont Increase Kmer Sizes For Cycles" help="Disable iterating over kmer sizes when graph cycles are detected"/>
                <param name="dont_use_soft_clipped_bases" argument="--dont-use-soft-clipped-bases" type="boolean" truevalue="--dont-use-soft-clipped-bases" falsevalue="" optional="true" checked="false" label="Dont Use Soft Clipped Bases" help="Do not analyze soft clipped bases in the reads"/>
                <param name="emit_ref_confidence" argument="--emit-ref-confidence" type="select" label="Mode for emitting reference confidence scores" help="NOTE: This is a beta feature in Mutect2">
                    <option value="NONE">None</option>
                    <option value="BP_RESOLUTION">Basepair resolution</option>
                    <option value="GVCF">Genomic VCF</option>
                </param>
                <param name="enable_all_annotations" argument="--enable-all-annotations" type="boolean" truevalue="--enable-all-annotations" falsevalue="" optional="true" checked="false" label="Enable All Annotations" help="Use all possible annotations (not for the faint of heart)"/>
                <param name="force_active" argument="--force-active" type="boolean" truevalue="--force-active" falsevalue="" optional="true" checked="false" label="Mark all regions active" help="If selected, all regions will be marked as active"/>
                <param name="force_call_filtered_alleles" argument="--force-call-filtered-alleles" type="boolean" truevalue="--force-call-filtered-alleles" falsevalue="" optional="true" checked="false" label="Force-call filtered alleles" help="Force-call filtered alleles included in the resource specified by --alleles"/>
                <param name="gvcf_lod_band" argument="--gvcf-lod-band" type="float" optional="true" label="Upper bounds for reference confidence" help="Exclusive upper bounds for reference confidence LOD bands (must be specified in increasing order)" />
                <param name="independent_mates" argument="--independent-mates" type="boolean" truevalue="--independent-mates" falsevalue="" label="Independent mates" help="Allow paired reads to independently support different haplotypes. Useful for validations with ill-designed synthetic data" />
                <param name="kmer_size" argument="--kmer-size" type="integer" optional="true" value="" label="Kmer Size" help="Kmer size to use in the read threading assembler"/>
                <param name="max_assembly_region_size" argument="--max-assembly-region-size" type="integer" optional="true" value="300" label="Max Assembly Region Size" help="Maximum size of an assembly region"/>
                <param name="max_mnp_distance" argument="--max-mnp-distance" type="integer" optional="true" value="1" label="Max Mnp Distance" help="Two or more phased substitutions separated by this distance or less are merged into MNPs."/>
                <param name="max_num_haplotypes_in_population" argument="--max-num-haplotypes-in-population" type="integer" optional="true" value="128" label="Max Num Haplotypes In Population" help="Maximum number of haplotypes to consider for your population"/>
                <param name="max_prob_propagation_distance" argument="--max-prob-propagation-distance" type="integer" optional="true" value="50" label="Max Prob Propagation Distance" help="Upper limit on how many bases away probability mass can be moved around when calculating the boundaries between active and inactive assembly regions"/>
                <param name="max_suspicious_reads_per_alignment_start" argument="--max-suspicious-reads-per-alignment-start" type="integer" optional="true" value="0" label="Max Suspicious Reads Per Alignment Start" help="Maximum number of suspicious reads (mediocre mapping quality or too many substitutions) allowed in a downsampling stride.  Set to 0 to disable."/>
                <param name="max_unpruned_variants" argument="--max-unpruned-variants" type="integer" optional="true" value="100" label="Maximum number of variants" help="Maximum number of variants in graph the adaptive pruner will allow"/>
                <param name="min_assembly_region_size" argument="--min-assembly-region-size" type="integer" optional="true" value="50" label="Min Assembly Region Size" help="Minimum size of an assembly region"/>
                <param name="min_dangling_branch_length" argument="--min-dangling-branch-length" type="integer" optional="true" value="4" label="Min Dangling Branch Length" help="Minimum length of a dangling branch to attempt recovery"/>
                <param name="min_pruning" argument="--min-pruning" type="integer" optional="true" value="2" label="Min Pruning" help="Minimum support to not prune paths in the graph"/>
                <param name="minimum_allele_fraction" argument="--minimum-allele-fraction" type="float" optional="true" value="0.0" label="Fractions to consider" help="Lower bound of variant allele fractions to consider when calculating variant LOD"/>
                <param name="num_pruning_samples" argument="--num-pruning-samples" type="integer" optional="true" value="1" label="Num Pruning Samples" help="Number of samples that must pass the minPruning threshold"/>
                <param name="pair_hmm_gap_continuation_penalty" argument="--pair-hmm-gap-continuation-penalty" type="integer" optional="true" value="10" label="Pair Hmm Gap Continuation Penalty" help="Flat gap continuation penalty for use in the Pair HMM"/>
                <param name="pair_hmm_implementation" argument="--pair-hmm-implementation" type="select" optional="true" label="Pair Hmm Implementation" help="The PairHMM implementation to use for genotype likelihood calculations">
                    <option selected="true" value="FASTEST_AVAILABLE">Fastest Available</option>
                    <option value="EXACT">Exact</option>
                    <option value="ORIGINAL">Original</option>
                    <option value="LOGLESS_CACHING">Logless Caching</option>
                    <option value="AVX_LOGLESS_CACHING">Logless Caching (AVX)</option>
                    <option value="AVX_LOGLESS_CACHING_OMP">Logless Caching (AVX+OMP)</option>
                    <option value="EXPERIMENTAL_FPGA_LOGLESS_CACHING">Logless Caching (FPGA, Experimental)</option>
                </param>
                <param name="pcr_indel_model" argument="--pcr-indel-model" type="select" optional="true" label="Pcr Indel Model" help="The PCR indel model to use">
                    <option selected="true" value="CONSERVATIVE">Conservative</option>
                    <option value="NONE">None</option>
                    <option value="HOSTILE">Hostile</option>
                    <option value="AGGRESSIVE">Aggressive</option>
                </param>
                <param name="phred_scaled_global_read_mismapping_rate" argument="--phred-scaled-global-read-mismapping-rate" type="integer" optional="true" value="45" label="Phred Scaled Global Read Mismapping Rate" help="The global assumed mismapping rate for reads"/>
                <param name="pruning_lod_threshold" argument="--pruning-lod-threshold" type="float" optional="true" value="2.302585092994046" label="Pruning LOD threshold" help="Likelihood ratio threshold for adaptive pruning algorithm" />
                <param name="recover_all_dangling_branches" argument="--recover-all-dangling-branches" type="boolean" truevalue="--recover-all-dangling-branches" falsevalue="" label="Recover all dangling branches" />
                <param name="smith_waterman" argument="--smith-waterman" type="select" optional="true" label="Smith Waterman" help="Which Smith-Waterman implementation to use, generally 'Fastest available' is the right choice">
                    <option selected="true" value="FASTEST_AVAILABLE">Fastest available</option>
                    <option value="AVX_ENABLED">AVX-Enabled</option>
                    <option value="JAVA">JAVA</option>
                </param>
                <param name="use_filtered_reads_for_annotations" argument="--use-filtered-reads-for-annotations" type="boolean" truevalue="--use-filtered-reads-for-annotations" falsevalue="" optional="true" checked="false" label="Use Filtered Reads For Annotations" help="Use the contamination-filtered read maps for the purposes of annotating variants"/>
            </when>
            <when value="no" />
        </conditional>
        <conditional name="outputs">
            <param name="output_parameters" type="select" label="Output parameters" help="Additional outputs for debugging purposes">
                <option value="no">Output only variants</option>
                <option value="yes">Generate debugging information</option>
            </param>
            <when value="yes">
                <param name="debug_assembly" argument="--assembly-region-out" type="boolean" checked="false" truevalue="yes" falsevalue="" label="Assembly Region Out" help="Output the assembly region to this IGV formatted file"/>
                <param name="debug_bam" argument="--bam-output" type="boolean" checked="false" truevalue="yes" falsevalue="" label="Bam Output" help="The assembled haplotypes and locally realigned reads will be written as BAM to this file if requested. This is intended to be used only for troubleshooting purposes, in specific areas where you want to better understand why the caller is making specific calls"/>
            </when>
            <when value="no" />
        </conditional>
    </inputs>
    <outputs>
        <expand macro="gzip_vcf_output_params"/>
        <data format="tabular" name="assembly_region_out" label="${tool.name} on ${on_string}: Assembly region">
            <filter>str(outputs['output_parameters']) == 'yes' and outputs['debug_assembly']</filter>
        </data>
        <data format="bam" name="bam_output" label="${tool.name} on ${on_string}: Debug BAM output">
            <filter>str(outputs['output_parameters']) == 'yes' and outputs['debug_bam']</filter>
        </data>
    </outputs>
    <tests>
        <test expect_num_outputs='1'>
            <conditional name="mode">
                <param name="mode_parameters" value="tumor_only"/>
                <param name="tumor" ftype="bam" value="Mutect2-in1.bam" />
            </conditional>
            <param name="reference_sequence" ftype="fasta" value="reference.fa" />
            <param name="gzipped_output" value="false" />
            <param name="reference_source_selector" value="history" />
            <param name="optional_parameters" value="no" />
            <param name="advanced_parameters" value="no" />
            <param name="output_parameters" value="no" />
            <output name="output_vcf" file="Mutect2-out1.vcf" lines_diff="48">
                <assert_contents>
                    <has_n_lines n="90"/>
                </assert_contents>
            </output>
        </test>
        <test expect_num_outputs='1'>
            <conditional name="mode">
                <param name="mode_parameters" value="tumor_only"/>
                <param name="tumor" ftype="bam" value="Mutect2-in2.bam" />
            </conditional>
            <param name="reference_sequence" ftype="fasta" value="reference.fa" />
            <param name="gzipped_output" value="false" />
            <param name="reference_source_selector" value="history" />
            <param name="read_filter" value="AmbiguousBaseReadFilter,FirstOfPairReadFilter,GoodCigarReadFilter" />
            <param name="seqdict_source_selector" value="history" />
            <param name="seqdict_sequence" value="Mutect2-in2.dict" />
            <param name="optional_parameters" value="no" />
            <param name="advanced_parameters" value="no" />
            <param name="output_parameters" value="no" />
            <output name="output_vcf" file="Mutect2-out2.vcf" lines_diff="48">
                <assert_contents>
                    <has_n_lines n="128"/>
                </assert_contents>
            </output>
        </test>
        <test expect_num_outputs='1'>
            <conditional name="mode">
                <param name="mode_parameters" value="tumor_only"/>
                <param name="tumor" ftype="bam" value="Mutect2-in3.bam" />
            </conditional>
            <param name="reference_sequence" ftype="fasta" value="reference.fa" />
            <param name="gzipped_output" value="false" />
            <param name="reference_source_selector" value="history" />
            <param name="optional_parameters" value="yes" />
            <param name="annotation" value="StrandBiasBySample,BaseQualityHistogram,OrientationBiasReadCounts" />
            <param name="annotation_group" value="StandardMutectAnnotation" />
            <param name="advanced_parameters" value="no" />
            <param name="output_parameters" value="no" />
            <output name="output_vcf" file="Mutect2-out3.vcf" lines_diff="48">
                <assert_contents>
                    <has_n_lines n="67"/>
                </assert_contents>
            </output>
        </test>
        <test expect_num_outputs='1'>
            <conditional name="mode">
                <param name="mode_parameters" value="tumor_only"/>
                <param name="tumor" ftype="bam" value="Mutect2-in4.bam" />
            </conditional>
            <param name="reference_sequence" value="hg38"/>
            <param name="gzipped_output" value="false" />
	    <param name="reference_source_selector" value="cached" />
	    <param name="reference_sequence" value="hg38"/>
            <param name="optional_parameters" value="no" />
            <param name="advanced_parameters" value="no" />
            <param name="output_parameters" value="no" />
            <output name="output_vcf" file="Mutect2-out4.vcf" lines_diff="48">
                <assert_contents>
                    <has_n_lines n="85"/>
                </assert_contents>
            </output>
        </test>
        <test expect_num_outputs='3'>
            <conditional name="mode">
                <param name="mode_parameters" value="tumor_only"/>
                <param name="tumor" ftype="bam" value="Mutect2-in5.bam" />
            </conditional>
            <param name="reference_sequence" ftype="fasta" value="reference.fa" />
            <param name="gzipped_output" value="false" />
            <param name="reference_source_selector" value="history" />
            <param name="optional_parameters" value="no" />
            <param name="advanced_parameters" value="no" />
            <param name="output_parameters" value="yes" />
            <param name="debug_assembly" value="true" />
            <param name="debug_bam" value="true" />
            <output name="output_vcf" file="Mutect2-out5.vcf" lines_diff="48">
                <assert_contents>
                    <has_n_lines n="97"/>
                </assert_contents>
            </output>
            <output name="assembly_region_out" file="Mutect2-out5-1.tabular" />
            <output name="bam_output" file="Mutect2-out5.bam" ftype="bam" />
        </test>
        <test expect_num_outputs='1'>
            <conditional name="mode">
                <param name="mode_parameters" value="somatic"/>
                <param name="tumor" ftype="bam" value="tumor.bam" />
                <param name="normal" ftype="bam" value="normal.bam" />
            </conditional>
            <param name="reference_sequence" ftype="fasta" value="chr20.fa" />
            <param name="gzipped_output" value="false" />
            <param name="reference_source_selector" value="history" />
            <param name="optional_parameters" value="no" />
            <param name="advanced_parameters" value="no" />
            <param name="output_parameters" value="no" />
            <output name="output_vcf" file="Mutect2-out6.vcf" lines_diff="48">
                <assert_contents>
                    <has_n_lines n="66"/>
                </assert_contents>
            </output>
        </test>
    </tests>
    <help><![CDATA[Call somatic short variants via local assembly of haplotypes. Short
variants include single nucleotide (SNV) and insertion and deletion
(indel) variants. The caller combines the DREAM challenge-winning
somatic genotyping engine of the original MuTect (`Cibulskis et al.,
2013 <http://www.nature.com/nbt/journal/v31/n3/full/nbt.2514.html>`__)
with the assembly-based machinery of
`HaplotypeCaller <https://web.archive.org/web/20230530034638/https://gatk.broadinstitute.org/hc/en-us/articles/360035531412-HaplotypeCaller-in-a-nutshell>`__.

This tool is featured in the *Somatic Short Mutation calling Best
Practice Workflow*. See `this article <https://web.archive.org/web/20230228153229/https://gatk.broadinstitute.org/hc/en-us/articles/360035531132>`__
for an overview of what traditional somatic calling entails, with usage examples. For the
latest pipeline scripts, see the `Mutect2 WDL scripts
directory <https://github.com/broadinstitute/gatk/tree/master/scripts/mutect2_wdl>`__.
Although we present the tool for somatic calling, it may apply to other
contexts, such as mitochondrial variant calling.

Usage examples
~~~~~~~~~~~~~~

Example commands show how to run Mutect2 for typical scenarios. The two
modes are (i) *somatic mode* where a tumor sample is matched with a
normal sample in analysis and (ii) *tumor-only mode* where a single
sample's alignment data undergoes analysis.

(i) Tumor with matched normal
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Given a matched normal, Mutect2 is designed to call somatic variants
only. The tool includes logic to skip emitting variants that are clearly
present in the germline based on provided evidence, e.g. in the matched
normal. This is done at an early stage to avoid spending computational
resources on germline events. If the variant's germline status is
borderline, then Mutect2 will emit the variant to the callset for
subsequent filtering and review.

::

    gatk Mutect2 \
      -R reference.fa \
      -I tumor.bam \
      -tumor tumor_sample_name \
      -I normal.bam \
      -normal normal_sample_name \
      --germline-resource af-only-gnomad.vcf.gz \
      --af-of-alleles-not-in-resource 0.00003125 \
      --panel-of-normals pon.vcf.gz \
      -O somatic.vcf.gz


The --af-of-alleles-not-in-resource argument value should match
expectations for alleles not found in the provided germline resource.
Note the tool does not require a germline resource nor a panel of
normals (PoN) to run. The tool prefilters sites for the matched normal
and the PoN. For the germline resource, the tool prefilters on the
allele. Below is an excerpt of a known variants resource with population
allele frequencies

::

        #CHROM  POS     ID      REF     ALT     QUAL    FILTER  INFO
         1       10067   .       T       TAACCCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCC      30.35   PASS    AC=3;AF=7.384E-5
         1       10108   .       CAACCCT C       46514.32        PASS    AC=6;AF=1.525E-4
         1       10109   .       AACCCTAACCCT    AAACCCT,*       89837.27        PASS    AC=48,5;AF=0.001223,1.273E-4
         1       10114   .       TAACCCTAACCCTAACCCTAACCCTAACCCTAACCCCTAACCCTAACCCTAACCCTAACCCTAACCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCCCTAACCCTAACCCTAAACCCTA  *,CAACCCTAACCCTAACCCTAACCCTAACCCTAACCCCTAACCCTAACCCTAACCCTAACCCTAACCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCCCTAACCCTAACCCTAAACCCTA,T      36728.97        PASS    AC=55,9,1;AF=0.001373,2.246E-4,2.496E-5
         1       10119   .       CT      C,*     251.23  PASS    AC=5,1;AF=1.249E-4,2.498E-5
         1       10120   .       TA      CA,*    14928.74        PASS    AC=10,6;AF=2.5E-4,1.5E-4
         1       10128   .       ACCCTAACCCTAACCCTAAC    A,*     285.71  PASS    AC=3,1;AF=7.58E-5,2.527E-5
         1       10131   .       CT      C,*     378.93  PASS    AC=7,5;AF=1.765E-4,1.261E-4
         1       10132   .       TAACCC  *,T     18025.11        PASS    AC=12,2;AF=3.03E-4,5.049E-5


(ii) Tumor-only mode
^^^^^^^^^^^^^^^^^^^^

This mode runs on a single sample, e.g. single tumor or single normal
sample. To create a PoN, call on each normal sample in this mode, then
use CreateSomaticPanelOfNormals to generate the PoN.

::

     gatk Mutect2 \
      -R reference.fa \
      -I sample.bam \
      -tumor sample_name \
      -O single_sample.vcf.gz


Further points of interest
~~~~~~~~~~~~~~~~~~~~~~~~~~

Additional parameters that factor towards filtering, including
normal-artifact-lod (default threshold 0.0) and tumor-lod (default
threshold 5.3), are available in FilterMutectCalls. While the tool
calculates normal-lod assuming a diploid genotype, it calculates
normal-artifact-lod with the same approach it uses for tumor-lod, i.e.
with a variable ploidy assumption.

- If the normal artifact log odds becomes large, then FilterMutectCalls applies the artifact-in-normal filter. For matched normal samples with tumor contamination, consider increasing the normal-artifact-lod threshold.

- The tumor log odds, which is calculated independently of any matched normal, determines whether to filter a tumor variant. Variants with tumor LODs exceeding the threshold pass filtering.


If a variant is absent from a given germline resource, then the value
for --af-of-alleles-not-in-resource applies. For example, gnomAD's
16,000 samples (~32,000 homologs per locus) becomes a probability of one
in 32,000 or less. Thus, an allele's absence from the germline resource
becomes evidence that it is not a germline variant.

Caveats
~~~~~~~

Although GATK4 Mutect2 accomodates varying coverage depths, further
optimization of parameters may improve calling for extreme high depths,
e.g. 1000X.
]]></help>
    <citations>
        <expand macro="citations"/>
    </citations>
</tool>
