Пример #1
0
def test_cnv_loader_alt_best_state(fixture_dirname, genomes_db_2013):
    families_file = fixture_dirname("backends/cnv_ped.txt")
    families = FamiliesLoader.load_simple_families_file(families_file)
    assert families is not None
    variants_file = fixture_dirname(
        "backends/cnv_variants_alt_1_best_state.txt")

    loader = CNVLoader(families,
                       variants_file,
                       genomes_db_2013.get_genome(),
                       params={
                           "cnv_chrom": "Chr",
                           "cnv_start": "Start",
                           "cnv_end": "Stop",
                           "cnv_variant_type": "Del/Dup",
                           "cnv_plus_values": ["Dup", "Dup_Germline"],
                           "cnv_minus_values": ["Del", "Del_Germline"],
                           "cnv_person_id": "personId"
                       })
    assert loader is not None

    svs = []
    fvs = []
    for sv, _fvs in loader.full_variants_iterator():
        print(sv, fvs)
        svs.append(sv)
        for fv in _fvs:
            fvs.append(fv)

    assert len(svs) == 1
    assert len(fvs) == 4
    print(fvs[0].best_state)
Пример #2
0
def test_extra_attributes_serialization_deserialization(
        fixtures_gpf_instance, fixture_dirname):
    families_data = FamiliesLoader.load_simple_families_file(
        fixture_dirname("backends/iossifov_extra_attrs.ped"))

    loader = DenovoLoader(
        families_data, fixture_dirname("backends/iossifov_extra_attrs.tsv"),
        fixtures_gpf_instance.get_genome()
    )

    main_schema = loader.get_attribute("annotation_schema")
    extra_attributes = loader.get_attribute("extra_attributes")

    serializer = AlleleParquetSerializer(main_schema, extra_attributes)
    it = loader.full_variants_iterator()
    variant = next(it)[1][0]
    print(variant.gt)
    summary_blobs = serializer.serialize_summary_data(variant.alleles)
    scores_blob = serializer.serialize_scores_data(variant.alleles)
    variant_blob = serializer.serialize_family_variant(
        variant.alleles, summary_blobs, scores_blob
    )
    extra_blob = serializer.serialize_extra_attributes(variant)
    family = variant.family

    fv = serializer.deserialize_family_variant(
        variant_blob, family, extra_blob)

    assert fv.get_attribute("someAttr")[0] == "asdf"
Пример #3
0
def test_cnv_loader_alt_2(fixture_dirname, genomes_db_2013):
    families_file = fixture_dirname("backends/cnv_ped.txt")
    families = FamiliesLoader.load_simple_families_file(families_file)
    assert families is not None

    variants_file = fixture_dirname("backends/cnv_variants_alt_2.txt")

    loader = CNVLoader(families,
                       variants_file,
                       genomes_db_2013.get_genome(),
                       params={
                           "cnv_location": "location",
                           "cnv_variant_type": "variant",
                           "cnv_plus_values": ["duplication"],
                           "cnv_minus_values": ["deletion"],
                           "cnv_person_id": "personId"
                       })
    assert loader is not None

    svs = []
    fvs = []
    for sv, _fvs in loader.full_variants_iterator():
        print(sv, fvs)
        svs.append(sv)
        for fv in _fvs:
            fvs.append(fv)

    assert len(svs) == 29
    assert len(fvs) == 30
Пример #4
0
def test_load_family_simple(fixture_name, temp_filename, fixture_dirname):
    family_filename = fixture_dirname(fixture_name)
    assert os.path.exists(family_filename)

    families = FamiliesLoader.load_simple_families_file(family_filename)
    assert families is not None

    FamiliesLoader.save_pedigree(families, temp_filename)

    families1 = FamiliesLoader.load_pedigree_file(temp_filename)

    assert set(families.keys()) == set(families1.keys())
Пример #5
0
def test_cnv_loader(fixture_dirname, genomes_db_2013):
    families_file = fixture_dirname("backends/cnv_ped.txt")
    families = FamiliesLoader.load_simple_families_file(families_file)
    assert families is not None

    variants_file = fixture_dirname("backends/cnv_variants.txt")

    loader = CNVLoader(families, variants_file, genomes_db_2013.get_genome())
    assert loader is not None

    svs = []
    for sv, fvs in loader.full_variants_iterator():
        print(sv, fvs)
        svs.append(sv)

    assert len(svs) == 12
Пример #6
0
def denovo_extra_attr_loader(
        fixture_dirname, genome_2013, annotation_pipeline_internal):

    families_filename = fixture_dirname("backends/iossifov_extra_attrs.ped")
    variants_filename = fixture_dirname("backends/iossifov_extra_attrs.tsv")

    families = FamiliesLoader.load_simple_families_file(families_filename)

    variants_loader = DenovoLoader(
        families, variants_filename, genome_2013)

    variants_loader = AnnotationPipelineDecorator(
        variants_loader, annotation_pipeline_internal
    )

    return variants_loader
Пример #7
0
def dae_transmitted(dae_transmitted_config, genome_2013,
                    annotation_pipeline_internal):

    # ped_df = FamiliesLoader.load_simple_family_file(
    #     dae_transmitted_config.family_filename
    # )
    families = FamiliesLoader.load_simple_families_file(
        dae_transmitted_config.family_filename)

    variants_loader = DaeTransmittedLoader(
        families,
        dae_transmitted_config.summary_filename,
        # dae_transmitted_config.toomany_filename,
        genome=genome_2013,
        regions=None,
    )
    variants_loader = AnnotationPipelineDecorator(
        variants_loader, annotation_pipeline_internal)

    return variants_loader