def test_flexible_pedigree_read_from_filesystem(filepath, fixture_dirname):
    expected_df = expected_pedigree_df.copy()
    expected_df["sample_id"] = expected_df["person_id"]

    absolute_filepath = fixture_dirname("pedigrees/{}".format(filepath))
    pedigree_df = FamiliesLoader.flexible_pedigree_read(absolute_filepath)
    assert pedigree_df.equals(expected_df)
Beispiel #2
0
def test_ped_prepare_simple(test_config, fake_ped_file):
    test_config.person.role.mapping = "INTERNAL"
    prep = PreparePersons(test_config)
    ped_df = FamiliesLoader.flexible_pedigree_read(fake_ped_file)

    assert ped_df is not None

    ped_df = prep.prepare_pedigree(ped_df)
    prep.save_pedigree(ped_df)
def test_flexible_pedigree_read(infile, pedigree):
    loaded_pedigree = FamiliesLoader.flexible_pedigree_read(infile, sep="\t")
    print(loaded_pedigree)
    columns = [
        "family_id",
        "person_id",
        "dad_id",
        "mom_id",
        "sex",
        "status",
        "role",
        "layout",
        "sample_id",
    ]
    for column in columns:
        assert (
            loaded_pedigree[column].values == pedigree[column].values).all()
def test_flexible_pedigree_read_do_not_override_sample_id_column(
    fixture_dirname, ):
    expected_df = expected_pedigree_df.copy()
    expected_df["sample_id"] = [
        "f1_father",
        "f1_mother",
        "f1_sibling1",
        "f1_proband",
        "f1_sibling2",
        "f2_mother",
        "f2_father",
        "f2_proband",
        "f2_sibling1",
    ]

    absolute_filepath = fixture_dirname("pedigrees/pedigree_E.ped")
    pedigree_df = FamiliesLoader.flexible_pedigree_read(absolute_filepath)
    assert pedigree_df.equals(expected_df)
def test_flexible_pedigree_read_additional_columns(fixture_dirname):
    expected_df = expected_pedigree_df.copy()
    expected_df["phenotype"] = [
        "healthy",
        "healthy",
        "healthy",
        "disease",
        "disease",
        "healthy",
        "healthy",
        "disease",
        "healthy",
    ]
    expected_df["sample_id"] = expected_df["person_id"]

    absolute_filepath = fixture_dirname("pedigrees/pedigree_D.ped")
    pedigree_df = FamiliesLoader.flexible_pedigree_read(absolute_filepath)
    assert pedigree_df.equals(expected_df)
def test_flexible_pedigree_read_no_header(fixture_dirname):
    expected_df = expected_pedigree_df.copy()
    expected_df["sample_id"] = expected_df["person_id"]

    absolute_filepath = fixture_dirname("pedigrees/pedigree_no_header.ped")
    pedigree_df = FamiliesLoader.flexible_pedigree_read(
        absolute_filepath,
        ped_no_header=True,
        ped_family=0,
        ped_person=1,
        ped_dad=2,
        ped_mom=3,
        ped_sex=4,
        ped_status=5,
        ped_role=6,
    )
    print(pedigree_df)
    print(expected_df)
    assert pedigree_df.equals(expected_df)
Beispiel #7
0
def fake_families(fixture_dirname):
    ped_df = FamiliesLoader.flexible_pedigree_read(
        fixture_dirname("denovo_import/fake_pheno.ped"))
    fake_families = FamiliesData.from_pedigree_df(ped_df)
    return fake_families
Beispiel #8
0
 def build_pedigree(self, pedfile):
     ped_df = FamiliesLoader.flexible_pedigree_read(pedfile)
     ped_df = self.prepare_pedigree(ped_df)
     self.save_pedigree(ped_df)
     self.pedigree_df = ped_df
     return ped_df