def map_coords_to_ucsc(grc_cosmic, ref_file):
    hg19_ref_file = ref_file.replace("GRCh37", "hg19")
    out_file = grc_cosmic.replace("GRCh37.vcf", "hg19.vcf")
    if not os.path.exists(out_file):
        tmp_file = os.path.splitext(out_file) % "%s-raw%s"
        with open(tmp_file, "w") as out_handle:
            # header
            with open(grc_cosmic) as in_handle:
                for line in in_handle:
                    if line.startswith("#") and not line.startswith("##contig"):
                        out_handle.write(line)
            # chromsome M
            with open(grc_cosmic) as in_handle:
                for line in in_handle:
                    if line.startswith("MT"):
                        line = _rename_to_ucsc(line)
                        out_handle.write(line)
            # rest
            with open(grc_cosmic) as in_handle:
                for line in in_handle:
                    if not line.startswith(("MT", "#")):
                        line = _rename_to_ucsc(line)
                        out_handle.write(line)
        # Create clean VCF and index for upload
        subprocess.check_call(["gatk-framework", "-R", hg19_ref_file, "-T", "SelectVariants",
                               "--variant", tmp_file, "--out", out_file])
    return out_file
dataset/ETHPy150Open chapmanb/cloudbiolinux/utils/prepare_cosmic.py/map_coords_to_ucsc/swapped operands of `%`