Add variant calling to workflow, if configured.

def _variant_vc(checkpoints):
    """Add variant calling to workflow, if configured.
    """
    if not checkpoints.get("vc"):
        return [], []
    vc_wf = [s("get_parallel_regions", "batch-split",
               [["batch_rec"]],
               [cwlout(["region_block"], {"type": "array", "items": "string"})],
               "bcbio-vc",
               disk={"files": 2.0}, cores=1),
             s("variantcall_batch_region", "batch-parallel",
               [["batch_rec"], ["region_block"]],
               [cwlout(["vrn_file_region"], ["File", "null"], [".tbi"]),
                cwlout(["region_block"], {"type": "array", "items": "string"})],
               "bcbio-vc", ["bcftools", "bedtools", "freebayes=1.1.0.46",
                            "gatk4", "vqsr_cnn", "deepvariant;env=dv", "sentieon;env=python2",
                            "htslib", "octopus", "picard", "platypus-variant;env=python2", "pythonpy",
                            "samtools", "pysam>=0.13.0", "strelka;env=python2", "vardict", "vardict-java",
                            "varscan", "moreutils", "vcfanno", "vcflib", "vt", "r=3.5.1", "r-base",
                            "perl"],
               disk={"files": 2.0}),
             s("concat_batch_variantcalls", "batch-merge",
               [["batch_rec"], ["region_block"], ["vrn_file_region"]],
               [cwlout(["vrn_file"], "File", [".tbi"])],
               "bcbio-vc", ["bcftools", "htslib", "gatk4"],
               disk={"files": 1.5}, cores=1)]
    if not checkpoints.get("jointvc"):
        vc_wf += [s("postprocess_variants", "batch-single",
                    [["batch_rec"], ["vrn_file"]],
                    [cwlout(["vrn_file"], "File", [".tbi"])],
                    "bcbio-vc", ["snpeff=4.3.1t"], disk={"files": 0.5})]
    vc_rec_exclude = [["align_bam"]]
    if not checkpoints.get("jointvc"):
        vc_rec_exclude.append(["genome_resources", "variation"])
    vc_wf += [s("compare_to_rm", "batch-single",
                [["batch_rec"], ["vrn_file"]],
                [cwlout("vc_rec", "record",
                        fields=[cwlout(["batch_samples"], ["null", {"type": "array", "items": "string"}]),
                                cwlout(["validate", "summary"], ["File", "null"]),
                                cwlout(["validate", "tp"], ["File", "null"], [".tbi"]),
                                cwlout(["validate", "fp"], ["File", "null"], [".tbi"]),
                                cwlout(["validate", "fn"], ["File", "null"], [".tbi"]),
                                cwlout("inherit", exclude=vc_rec_exclude)])],
                "bcbio-vc", ["bcftools", "bedtools", "pythonpy", "gvcf-regions;env=python2",
                             "htslib", "rtg-tools", "vcfanno"],
                disk={"files": 1.5})]
    batch_in = [["analysis"], ["genome_build"], ["align_bam"], ["vrn_file"],
                ["metadata", "batch"], ["metadata", "phenotype"],
                ["config", "algorithm", "callable_regions"], ["regions", "sample_callable"],
                ["config", "algorithm", "variantcaller"],
                ["config", "algorithm", "ensemble"],
                ["config", "algorithm", "vcfanno"],
                ["config", "algorithm", "coverage_interval"],
                ["config", "algorithm", "effects"],
                ["config", "algorithm", "min_allele_fraction"],
                ["config", "algorithm", "exclude_regions"],
                ["config", "algorithm", "variant_regions"],
                ["config", "algorithm", "variant_regions_merged"],
                ["config", "algorithm", "validate"], ["config", "algorithm", "validate_regions"],
                ["config", "algorithm", "tools_on"],
                ["config", "algorithm", "tools_off"],
                ["reference", "fasta", "base"],
                ["reference", "rtg"], ["reference", "genome_context"],
                ["genome_resources", "variation", "clinvar"],
                ["genome_resources", "variation", "cosmic"], ["genome_resources", "variation", "dbsnp"],
                ["genome_resources", "variation", "esp"], ["genome_resources", "variation", "exac"],
                ["genome_resources", "variation", "gnomad_exome"],
                ["genome_resources", "variation", "1000g"],
                ["genome_resources", "variation", "lcr"], ["genome_resources", "variation", "polyx"],
                ["genome_resources", "variation", "encode_blacklist"],
                ["genome_resources", "aliases", "ensembl"], ["genome_resources", "aliases", "human"],
                ["genome_resources", "aliases", "snpeff"], ["reference", "snpeff", "genome_build"]]
    if checkpoints.get("umi"):
        batch_in.append(["config", "algorithm", "umi_type"])
    if checkpoints.get("rnaseq"):
        batch_in += [["genome_resources", "variation", "editing"]]
    else:
        batch_in += [["genome_resources", "variation", "train_hapmap"],
                     ["genome_resources", "variation", "train_indels"]]
    vc = [s("batch_for_variantcall", "multi-batch", batch_in,
            [cwlout("batch_rec", "record",
                    fields=[cwlout(["config", "algorithm", "variantcaller_order"], "int"),
                            cwlout("inherit")])],
            "bcbio-vc",
            disk={"files": 2.0}, cores=1,
            unlist=[["config", "algorithm", "variantcaller"]], no_files=True),
          w("variantcall", "multi-parallel", vc_wf,
            [["region"], ["region_block"], ["vrn_file_region"], ["vrn_file"], ["validate", "summary"]])]
    if checkpoints.get("jointvc"):
        vc += _variant_jointvc()
    if checkpoints.get("ensemble"):
        vc += _variant_ensemble(checkpoints)
    summarize_in = [["jointvc_rec" if checkpoints.get("jointvc") else "vc_rec"]]
    if checkpoints.get("ensemble"):
        summarize_in += [["ensemble_rec"]]
    vc += [s("summarize_vc", "multi-combined", summarize_in,
             [cwlout(["variants", "calls"], {"type": "array", "items": ["File", "null"]}),
              cwlout(["variants", "gvcf"], ["null", {"type": "array", "items": ["File", "null"]}]),
              cwlout(["variants", "samples"], {"type": "array", "items": {"type": "array",
                                                                          "items": ["File", "null"]}}),
              cwlout(["validate", "grading_summary"], ["File", "null"]),
              cwlout(["validate", "grading_plots"], {"type": "array", "items": ["File", "null"]})],
             "bcbio-vc",
             disk={"files": 2.0}, cores=1)]
    return vc, [["validate", "grading_summary"], ["variants", "calls"], ["variants", "gvcf"]]