SS = config['strelka2_tumor_normal_se']
rule strelka2_tumor_normal_se:
    input:
        # Required input.
        tumor = str(RESULT_DIR / config['bwa_result_dir'] / 'se' / '{tumor}' / '{tumor}.duplicates_marked.sorted.bam'),
        tumor_index = str(RESULT_DIR / config['bwa_result_dir'] / 'se' / '{tumor}' / '{tumor}.duplicates_marked.sorted.bam.bai'),
        normal = str(RESULT_DIR / config['bwa_result_dir'] / 'se' / '{normal}' / '{normal}.duplicates_marked.sorted.bam'),
        normal_index = str(RESULT_DIR / config['bwa_result_dir'] / 'se' / '{normal}' / '{normal}.duplicates_marked.sorted.bam.bai'),
        reference = config['reference']['fasta'],
        reference_index = config['reference']['index'],
    output:
        # Required output.
        snv = str(RESULT_DIR / config['strelka2_result_dir'] / 'se' / '{tumor}' / '{tumor}_vs_{normal}.snvs.strelka.vcf.gz'),
        indel = str(RESULT_DIR / config['strelka2_result_dir'] / 'se' / '{tumor}' / '{tumor}_vs_{normal}.indels.strelka.vcf.gz'),
    params:
        extra = SS['extra'],
        # Output a bed file describing somatic callable regions of the genome.
        # Default: False
        outputCallableRegions = SS['outputCallableRegions'],
        # Specify a VCF of candidate indel alleles. These alleles are always evaluated but only reported
        # in the output when they are inferred to exist in the sample. The VCF must be tabix indexed. All
        # indel alleles must be left-shifted/normalized, any unnormalized alleles will be ignored. This
        # option may be specified more than once, multiple input VCFs will be merged.
        # Default: False
        indelCandidates = SS['indelCandidates'],
        # Specify a VCF of candidate alleles. These alleles are always evaluated and reported even if they
        # are unlikely to exist in the sample. The VCF must be tabix indexed. All indel alleles must be
        # left-shifted/normalzed, any unnormalized allele will trigger runtime error. This option may be 
        # specified more than once, multiple input VCFs will be merged. Note that for any SNVs provided in
        # the VCF, the SNV site will be reported (and for gVCF, excluded from block compression), but the
        # specific SNV alleles are ignored.
        # Default: None
        forcedGT = SS['forcedGT'],
        # Set options for exome or other targeted input: note in particular that this flag turns off
        # high-depth filters.
        # Default: False
        exome = SS['exome'],
        # Optionally provide a bgzip-compressed/tabix-indexed BED file containing the set of regions to call.
        # No VCF output will be provided outside of these regions. The full genome will still be used to 
        # estimabe statistics from the input (such as expected depth per chromosome). Only one BED file
        # may be specified.
        # Default: False (call the entire genome)
        callRegions = SS['callRegions'],
        # Extended options:
        # These options are either unlikely to be reset after initial site configuration or only of interest
        # for workflow development/debugging. They will not be printed here if a default exists unless
        # --allHelp is specified.
        # Noise vcf file (submit argument multiple times for more than one file)
        # Default: False
        noiseVcf = SS['noiseVcf'],
        # Maximum sequence region size (in megabases) scanned by each task during genome variant calling. 
        # Default: 12
        scanSizeMb = SS['scanSizeMb'],
        # Limit the analysis to one or more genome region(s) for debugging purposes. If this arugment is 
        # provided multiple times the union of all specified regions will be analyzed. All regions must be
        # non-overlapping to get meaningful result.
        # Examples: '--region chr20' (whole chromosome), '--region chr2:100-2000 --region chr3:2500-3000'
        # (two regions).
        # If this option is specified (one or more times) together with the --callRegions BED file,
        # then all region arguments will be intersected with the callRegions BED track.
        # Default: False
        region = SS['region'],
        # Set variant calling task memory limit (in megabytes). It is not recommended to change the default
        # in most cases, but this might be required for a sample of unusual depth.
        # Default: False
        callMemMb = SS['callMemMb'],
        # Keep all temporary files (for workflow debugging).
        # Default: False
        retainTempFiles = SS['retainTempFiles'],
        # Disable empirical variant scoring (EVS).
        # Default: False
        disableEVS = SS['disableEVS'],
        # Report all empirical variant scoring features in VCF output.
        # Default: False
        reportEVSFeatures = SS['reportEVSFeatures'],
        # Provide a custom empirical scoring model file for SNVs.
        # Default: False,
        snvScoringModelFile = SS['snvScoringModelFile'],
        # Provide a custome empirical scoring model file for indels.
        # Default: False
        indelScoringModelFile = SS['indelScoringModelFile'],
    threads: config['threads']['strelka2_tumor_normal_se']
    log: 'logs/strelka2/tumor-normal/{tumor}_vs_{normal}.log'
    benchmark: 'benchmarks/strelka2/tumor-normal/{tumor}_vs_{normal}.benchmark'
    conda: 'strelka_env.yaml'
    wrapper:
        'http://dohlee-bio.info:9193/strelka2/tumor-normal'

SP = config['strelka2_tumor_normal_pe']
rule strelka2_tumor_normal_pe:
    input:
        # Required input.
        tumor = str(RESULT_DIR / config['bwa_result_dir'] / 'pe' / '{tumor}' / '{tumor}.duplicates_marked.sorted.bam'),
        tumor_index = str(RESULT_DIR / config['bwa_result_dir'] / 'pe' / '{tumor}' / '{tumor}.duplicates_marked.sorted.bam.bai'),
        normal = str(RESULT_DIR / config['bwa_result_dir'] / 'pe' / '{normal}' / '{normal}.duplicates_marked.sorted.bam'),
        normal_index = str(RESULT_DIR / config['bwa_result_dir'] / 'pe' / '{normal}' / '{normal}.duplicates_marked.sorted.bam.bai'),
        reference = config['reference']['fasta'],
        reference_index = config['reference']['index'],
    output:
        # Required output.
        snv = str(RESULT_DIR / config['strelka2_result_dir'] / 'pe' / '{tumor}' / '{tumor}_vs_{normal}.snvs.strelka.vcf.gz'),
        indel = str(RESULT_DIR / config['strelka2_result_dir'] / 'pe' / '{tumor}' / '{tumor}_vs_{normal}.indels.strelka.vcf.gz'),
    params:
        extra = SP['extra'],
        # Output a bed file describing somatic callable regions of the genome.
        # Default: False
        outputCallableRegions = SP['outputCallableRegions'],
        # Specify a VCF of candidate indel alleles. These alleles are always evaluated but only reported
        # in the output when they are inferred to exist in the sample. The VCF must be tabix indexed. All
        # indel alleles must be left-shifted/normalized, any unnormalized alleles will be ignored. This
        # option may be specified more than once, multiple input VCFs will be merged.
        # Default: False
        indelCandidates = SP['indelCandidates'],
        # Specify a VCF of candidate alleles. These alleles are always evaluated and reported even if they
        # are unlikely to exist in the sample. The VCF must be tabix indexed. All indel alleles must be
        # left-shifted/normalzed, any unnormalized allele will trigger runtime error. This option may be 
        # specified more than once, multiple input VCFs will be merged. Note that for any SNVs provided in
        # the VCF, the SNV site will be reported (and for gVCF, excluded from block compression), but the
        # specific SNV alleles are ignored.
        # Default: None
        forcedGT = SP['forcedGT'],
        # Set options for exome or other targeted input: note in particular that this flag turns off
        # high-depth filters.
        # Default: False
        exome = SP['exome'],
        # Optionally provide a bgzip-compressed/tabix-indexed BED file containing the set of regions to call.
        # No VCF output will be provided outside of these regions. The full genome will still be used to 
        # estimabe statistics from the input (such as expected depth per chromosome). Only one BED file
        # may be specified.
        # Default: False (call the entire genome)
        callRegions = SP['callRegions'],
        # Extended options:
        # These options are either unlikely to be reset after initial site configuration or only of interest
        # for workflow development/debugging. They will not be printed here if a default exists unless
        # --allHelp is specified.
        # Noise vcf file (submit argument multiple times for more than one file)
        # Default: False
        noiseVcf = SP['noiseVcf'],
        # Maximum sequence region size (in megabases) scanned by each task during genome variant calling. 
        # Default: 12
        scanSizeMb = SP['scanSizeMb'],
        # Limit the analysis to one or more genome region(s) for debugging purposes. If this arugment is 
        # provided multiple times the union of all specified regions will be analyzed. All regions must be
        # non-overlapping to get meaningful result.
        # Examples: '--region chr20' (whole chromosome), '--region chr2:100-2000 --region chr3:2500-3000'
        # (two regions).
        # If this option is specified (one or more times) together with the --callRegions BED file,
        # then all region arguments will be intersected with the callRegions BED track.
        # Default: False
        region = SP['region'],
        # Set variant calling task memory limit (in megabytes). It is not recommended to change the default
        # in most cases, but this might be required for a sample of unusual depth.
        # Default: False
        callMemMb = SP['callMemMb'],
        # Keep all temporary files (for workflow debugging).
        # Default: False
        retainTempFiles = SP['retainTempFiles'],
        # Disable empirical variant scoring (EVS).
        # Default: False
        disableEVS = SP['disableEVS'],
        # Report all empirical variant scoring features in VCF output.
        # Default: False
        reportEVSFeatures = SP['reportEVSFeatures'],
        # Provide a custom empirical scoring model file for SNVs.
        # Default: False,
        snvScoringModelFile = SP['snvScoringModelFile'],
        # Provide a custome empirical scoring model file for indels.
        # Default: False
        indelScoringModelFile = SP['indelScoringModelFile'],
    threads: config['threads']['strelka2_tumor_normal_pe']
    log: 'logs/strelka2/tumor-normal/{tumor}_vs_{normal}.log'
    benchmark: 'benchmarks/strelka2/tumor-normal/{tumor}_vs_{normal}.benchmark'
    conda: 'strelka_env.yaml'
    wrapper:
        'http://dohlee-bio.info:9193/strelka2/tumor-normal'

