Exemplo n.º 1
0
def annotate(ctx, variant_file, sv):
    """Annotate the variants in a VCF"""
    adapter = ctx.obj["adapter"]

    variant_path = os.path.abspath(variant_file)

    expected_type = "sv" if sv else "snv"

    nr_cases = adapter.nr_cases(sv_cases=True)
    LOG.info("Found {0} {1} cases in database".format(nr_cases, expected_type))

    vcf_obj = get_file_handle(variant_path)
    add_headers(vcf_obj, nr_cases=nr_cases, sv=sv)
    # Print the headers
    for header_line in vcf_obj.raw_header.split("\n"):
        if len(header_line) == 0:
            continue
        click.echo(header_line)

    start_inserting = datetime.now()

    if sv:
        annotated_variants = annotate_svs(adapter, vcf_obj)
    else:
        annotated_variants = annotate_snvs(adapter, vcf_obj)
    # try:
    for variant in annotated_variants:
        click.echo(str(variant).rstrip())
Exemplo n.º 2
0
def test_get_vcf_non_existing():
    ## GIVEN the path to a non existing file

    ## WHEN geting the file handle

    ## THEN assert that a IOError is raised
    with pytest.raises(IOError):
        vcf = get_file_handle('hello')
Exemplo n.º 3
0
def test_get_file_handle(vcf_path):
    ## GIVEN the path to a vcf

    ## WHEN geting the file handle
    vcf = get_file_handle(vcf_path)

    ## THEN assert that a VCF object is returned
    assert type(vcf) is VCF
Exemplo n.º 4
0
def test_get_vcf_non_vcf(ped_path):
    ## GIVEN the path to a non vcf

    ## WHEN geting the file handle

    ## THEN assert that a IOError is raised
    with pytest.raises(IOError):
        vcf = get_file_handle(ped_path)