예제 #1
0
def insert_snv_variants(adapter: MongoAdapter, case_obj: Case) -> None:
    """Build variant documents and bulk insert them into database"""
    variants = []
    for variant in VCF(case_obj.vcf_path, threads=settings.cyvcf_threads):
        variant_id = get_variant_id(variant=variant)
        ref = variant.REF
        alt = variant.ALT[0]

        coordinates = get_coords(variant)
        chrom = coordinates["chrom"]
        pos = coordinates["pos"]
        found_homozygote = 0
        found_hemizygote = 0

        for ind_obj in case_obj.individuals:
            ind_pos = ind_obj["ind_index"]
            if int(variant.gt_quals[ind_pos]) < settings.load_gq_threshold:
                continue

            genotype = GENOTYPE_MAP[variant.gt_types[ind_pos]]
            if genotype not in ["het", "hom_alt"]:
                continue

            if genotype == "hom_alt":
                found_homozygote = 1

            if (
                chrom in ["X", "Y"]
                and ind_obj["sex"] == 1
                and not check_par(chrom, pos, genome_build=settings.genome_build)
            ):
                found_hemizygote = 1

            variant_obj = Variant(
                variant_id=variant_id,
                chrom=chrom,
                pos=pos,
                end=coordinates["end"],
                ref=ref,
                alt=alt,
                end_chrom=coordinates["end_chrom"],
                sv_type=coordinates["sv_type"],
                sv_len=coordinates["sv_length"],
                case_id=case_obj.case_id,
                homozygote=found_homozygote,
                hemizygote=found_hemizygote,
                is_sv=False,
                id_column=variant.ID,
            )
            variants.append(variant_obj)
    adapter.add_variants(variants=variants)
예제 #2
0
def test_par_region_X_lower():
    chrom = 'X'
    pos = 60001
    assert check_par(chrom, pos)
예제 #3
0
def test_par_region_Y_second():
    chrom = 'Y'
    pos = 59034050
    assert check_par(chrom, pos)
예제 #4
0
def test_par_region_Y_upper():
    chrom = 'Y'
    pos = 2649520
    assert check_par(chrom, pos)
예제 #5
0
def test_par_region_Y_middle():
    chrom = 'Y'
    pos = 1000000
    assert check_par(chrom, pos)
예제 #6
0
def test_par_region_Y_lower():
    chrom = 'Y'
    pos = 10001
    assert check_par(chrom, pos)
예제 #7
0
def test_par_wrong_chrom():
    chrom = '1'
    pos = 60000
    assert not check_par(chrom, pos)
예제 #8
0
def test_non_par_X_region():
    chrom = 'X'
    pos = 60000
    assert not check_par(chrom, pos)
예제 #9
0
def test_par_region_X_second():
    chrom = 'X'
    pos = 154931044
    assert check_par(chrom, pos)
예제 #10
0
def test_par_region_X_upper():
    chrom = "X"
    pos = 2649520
    assert check_par(chrom, pos)
예제 #11
0
def test_par_region_X_middle():
    chrom = "X"
    pos = 1000000
    assert check_par(chrom, pos)