|
| 1 | +# ================================================================================================= |
| 2 | +# Combining Calls |
| 3 | +# ================================================================================================= |
| 4 | + |
| 5 | + |
| 6 | +# Recommended way of GATK to combine GVCFs these days. |
| 7 | +rule genomics_db_import: |
| 8 | + input: |
| 9 | + # Get the reference genome and its indices. Not sure if the indices are needed |
| 10 | + # for this particular rule, but doesn't hurt to include them as an input anyway. |
| 11 | + ref=config["data"]["reference-genome"], |
| 12 | + refidcs=expand( |
| 13 | + config["data"]["reference-genome"] + ".{ext}", |
| 14 | + ext=["amb", "ann", "bwt", "pac", "sa", "fai"], |
| 15 | + ), |
| 16 | + refdict=genome_dict(), |
| 17 | + # Get the sample data, including indices. |
| 18 | + gvcfs=expand( |
| 19 | + "calling/called/{sample}-{{contig}}.g.vcf.gz", sample=config["global"]["sample-names"] |
| 20 | + ), |
| 21 | + indices=expand( |
| 22 | + "calling/called/{sample}-{{contig}}.g.vcf.gz.tbi", |
| 23 | + sample=config["global"]["sample-names"], |
| 24 | + ), |
| 25 | + done=expand( |
| 26 | + "calling/called/{sample}-{{contig}}.g.vcf.gz.done", |
| 27 | + sample=config["global"]["sample-names"], |
| 28 | + ), |
| 29 | + # Same as in the haplotype caller, we need a dummy for the intervals |
| 30 | + # to ensure the files are present. |
| 31 | + intervals_dummy=get_gatk_interval_files, |
| 32 | + output: |
| 33 | + db=directory("calling/genomics_db/{contig}"), |
| 34 | + done=touch("calling/genomics_db/{contig}.done"), |
| 35 | + params: |
| 36 | + # Here, we actually use the intervals to provide them to the wrapper. |
| 37 | + intervals=get_gatk_intervals, |
| 38 | + db_action="create", |
| 39 | + extra=" --reference " |
| 40 | + + config["data"]["reference-genome"] |
| 41 | + + " --sequence-dictionary " |
| 42 | + + genome_dict() |
| 43 | + + " " |
| 44 | + + config["params"]["gatk"].get("GenomicsDBImport-extra", ""), |
| 45 | + java_opts=config["params"]["gatk"].get("GenomicsDBImport-java-opts", ""), |
| 46 | + threads: get_rule_threads("genomics_db_import") |
| 47 | + log: |
| 48 | + "logs/calling/gatk-genomicsdbimport/{contig}.log", |
| 49 | + benchmark: |
| 50 | + "benchmarks/calling/gatk-genomicsdbimport/{contig}.log" |
| 51 | + resources: |
| 52 | + tmpdir=config["params"]["gatk"].get("GenomicsDBImport-temp-dir", ""), |
| 53 | + conda: |
| 54 | + "../envs/gatk.yaml" |
| 55 | + wrapper: |
| 56 | + "v5.7.0/bio/gatk/genomicsdbimport" |
| 57 | + |
| 58 | + |
| 59 | +# ================================================================================================= |
| 60 | +# Genotype Variants |
| 61 | +# ================================================================================================= |
| 62 | + |
| 63 | + |
| 64 | +rule genotype_variants: |
| 65 | + input: |
| 66 | + # Get the reference genome and its indices. Not sure if the indices are needed |
| 67 | + # for this particular rule, but doesn't hurt to include them as an input anyway. |
| 68 | + ref=config["data"]["reference-genome"], |
| 69 | + refidcs=expand( |
| 70 | + config["data"]["reference-genome"] + ".{ext}", |
| 71 | + ext=["amb", "ann", "bwt", "pac", "sa", "fai"], |
| 72 | + ), |
| 73 | + refdict=genome_dict(), |
| 74 | + # Get the GenomicsDB input |
| 75 | + genomicsdb="calling/genomics_db/{contig}", |
| 76 | + genomicsdb_done="calling/genomics_db/{contig}.done", |
| 77 | + # If known variants are set in the config, use them, and require the index file as well. |
| 78 | + known=config["data"]["known-variants"], |
| 79 | + knownidx=( |
| 80 | + config["data"]["known-variants"] + ".tbi" if config["data"]["known-variants"] else [] |
| 81 | + ), |
| 82 | + # Same as above, we need a dummy for the intervals to ensure the files are present. |
| 83 | + intervals_dummy=get_gatk_interval_files, |
| 84 | + output: |
| 85 | + vcf=( |
| 86 | + "calling/genotyped/all.{contig}.vcf.gz" |
| 87 | + if config["settings"]["keep-intermediate"]["calling"] |
| 88 | + else temp("calling/genotyped/all.{contig}.vcf.gz") |
| 89 | + ), |
| 90 | + done=touch("calling/genotyped/all.{contig}.vcf.gz.done"), |
| 91 | + params: |
| 92 | + # Again, we here use the intervals to provide them to the wrapper. |
| 93 | + intervals=get_gatk_intervals, |
| 94 | + extra=" --sequence-dictionary " |
| 95 | + + genome_dict() |
| 96 | + + " " |
| 97 | + + config["params"]["gatk"]["GenotypeGVCFs-extra"], |
| 98 | + java_opts=config["params"]["gatk"]["GenotypeGVCFs-java-opts"], |
| 99 | + threads: get_rule_threads("genotype_variants") |
| 100 | + log: |
| 101 | + "logs/calling/gatk-genotype-gvcfs/{contig}.log", |
| 102 | + benchmark: |
| 103 | + "benchmarks/calling/gatk-genotype-gvcfs/{contig}.log" |
| 104 | + # group: |
| 105 | + # "gatk_calls_combine" |
| 106 | + conda: |
| 107 | + "../envs/gatk.yaml" |
| 108 | + wrapper: |
| 109 | + "v5.7.0/bio/gatk/genotypegvcfs" |
0 commit comments