Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 3 additions & 10 deletions v03_pipeline/lib/misc/pedigree.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def __hash__(self):
return hash(self.family_guid)

@staticmethod
def parse_direct_lineage(rows: list[hl.Struct]) -> dict[str, Sample]: # noqa: C901
def parse_direct_lineage(rows: list[hl.Struct]) -> dict[str, Sample]:
samples = {}
for row in rows:
samples[row.s] = Sample(
Expand All @@ -94,22 +94,15 @@ def parse_direct_lineage(rows: list[hl.Struct]) -> dict[str, Sample]: # noqa: C
for row in rows:
# Maternal GrandParents
maternal_s = samples[row.s].mother
if maternal_s and maternal_s not in samples:
# A sample id may be referenced for a proband that has been
# removed from the pedigree as an individual. We handle this by
# nulling out the parent here.
samples[row.s].mother = None
elif maternal_s:
if maternal_s and maternal_s in samples:
if samples[maternal_s].mother:
samples[row.s].maternal_grandmother = samples[maternal_s].mother
if samples[maternal_s].father:
samples[row.s].maternal_grandfather = samples[maternal_s].father

# Paternal GrandParents
paternal_s = samples[row.s].father
if paternal_s and paternal_s not in samples:
samples[row.s].father = None
elif paternal_s:
if paternal_s and paternal_s in samples:
if samples[paternal_s].mother:
samples[row.s].paternal_grandmother = samples[paternal_s].mother
if samples[paternal_s].father:
Expand Down
8 changes: 7 additions & 1 deletion v03_pipeline/lib/misc/pedigree_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,13 @@ def test_subsetted_pedigree_with_removed_parent(self) -> None:
),
)
self.assertEqual(len(family.samples), 2)
self.assertIsNone(family.samples['BBL_BC1-000345_01_D1'].father)
self.assertFalse(
'BBL_BC1-000345_02_D1' in family.samples,
)
self.assertEqual(
family.samples['BBL_BC1-000345_01_D1'].father,
'BBL_BC1-000345_02_D1',
)
self.assertEqual(
family.samples['BBL_BC1-000345_01_D1'].mother,
'BBL_BC1-000345_03_D1',
Expand Down
Loading