Example #1
0
def compare_to_rm(data):
    """Compare final variant calls against reference materials of known calls.
    """
    if _has_validate(data):
        if isinstance(data["vrn_file"], (list, tuple)):
            vrn_file = [os.path.abspath(x) for x in data["vrn_file"]]
        else:
            vrn_file = os.path.abspath(data["vrn_file"])
        rm_file = normalize_input_path(data["config"]["algorithm"]["validate"], data)
        rm_interval_file = normalize_input_path(data["config"]["algorithm"].get("validate_regions"),
                                               data)
        rm_genome = data["config"]["algorithm"].get("validate_genome_build")
        sample = data["name"][-1].replace(" ", "_")
        caller = data["config"]["algorithm"].get("variantcaller")
        if not caller:
            caller = "precalled"
        base_dir = utils.safe_makedir(os.path.join(data["dirs"]["work"], "validate", sample, caller))
        val_config_file = _create_validate_config_file(vrn_file, rm_file, rm_interval_file,
                                                       rm_genome, base_dir, data)
        work_dir = os.path.join(base_dir, "work")
        out = {"summary": os.path.join(work_dir, "validate-summary.csv"),
               "grading": os.path.join(work_dir, "validate-grading.yaml"),
               "concordant": os.path.join(work_dir, "%s-ref-eval-concordance.vcf" % sample),
               "discordant": os.path.join(work_dir, "%s-eval-ref-discordance-annotate.vcf" % sample)}
        if not utils.file_exists(out["concordant"]) or not utils.file_exists(out["grading"]):
            ensemble.bcbio_variation_comparison(val_config_file, base_dir, data)
        data["validate"] = out
    return [[data]]
Example #2
0
def compare_to_rm(data):
    """Compare final variant calls against reference materials of known calls.
    """
    if _has_validate(data):
        if isinstance(data["vrn_file"], (list, tuple)):
            vrn_file = [os.path.abspath(x) for x in data["vrn_file"]]
        else:
            vrn_file = os.path.abspath(data["vrn_file"])
        rm_file = normalize_input_path(data["config"]["algorithm"]["validate"],
                                       data)
        rm_interval_file = normalize_input_path(
            data["config"]["algorithm"].get("validate_regions"), data)
        rm_genome = data["config"]["algorithm"].get("validate_genome_build")
        sample = data["name"][-1].replace(" ", "_")
        caller = data["config"]["algorithm"].get("variantcaller")
        if not caller:
            caller = "precalled"
        base_dir = utils.safe_makedir(
            os.path.join(data["dirs"]["work"], "validate", sample, caller))
        val_config_file = _create_validate_config_file(vrn_file, rm_file,
                                                       rm_interval_file,
                                                       rm_genome, base_dir,
                                                       data)
        work_dir = os.path.join(base_dir, "work")
        out = {
            "summary":
            os.path.join(work_dir, "validate-summary.csv"),
            "grading":
            os.path.join(work_dir, "validate-grading.yaml"),
            "concordant":
            os.path.join(work_dir, "%s-ref-eval-concordance.vcf" % sample),
            "discordant":
            os.path.join(work_dir,
                         "%s-eval-ref-discordance-annotate.vcf" % sample)
        }
        if not utils.file_exists(out["concordant"]) or not utils.file_exists(
                out["grading"]):
            ensemble.bcbio_variation_comparison(val_config_file, base_dir,
                                                data)
        data["validate"] = out
    return [[data]]