Skip to content

Commit 846b40a

Browse files
committed
fix: correctly check that swap mothers result in no G1 cycle
1 parent a2e987f commit 846b40a

1 file changed

Lines changed: 17 additions & 6 deletions

File tree

cellacdc/gui.py

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9736,7 +9736,9 @@ def warnBudAnnotatedDividedInFuture(
97369736
msg.warning(self, 'Swap mothers not possible', txt)
97379737
return
97389738

9739-
def _checkMothInG1beforeBudEmergence(self, motherID, budID, start_frame_i):
9739+
def _checkMothInG1beforeBudEmergence(
9740+
self, motherID, budID, wrongBudID, start_frame_i
9741+
):
97409742
"""Check that mother is in G1 on the frame before bud emergence
97419743

97429744
Parameters
@@ -9751,8 +9753,13 @@ def _checkMothInG1beforeBudEmergence(self, motherID, budID, start_frame_i):
97519753
for past_i in range(start_frame_i, -1, -1):
97529754
cca_df_i = self.get_cca_df(frame_i=past_i, return_df=True)
97539755
if budID not in cca_df_i.index:
9754-
if cca_df_i.at[motherID, 'cell_cycle_stage'] != 'G1':
9755-
return past_i
9756+
if cca_df_i.at[motherID, 'cell_cycle_stage'] == 'G1':
9757+
return
9758+
9759+
budID_prev_cycle = cca_df_i.at[motherID, 'relative_ID']
9760+
if budID_prev_cycle != wrongBudID:
9761+
return past_i + 1
9762+
97569763
break
97579764

97589765
def warnMotherNotAtLeastOneFrameG1(self, budID, motherID, frame_no_G1):
@@ -9793,16 +9800,20 @@ def checkSwapMothersEligibility(self):
97939800
return
97949801

97959802
correct_pairings = {
9796-
otherBudID: mothID,
9797-
budID: otherMothID
9803+
otherBudID: mothID, budID: otherMothID
9804+
}
9805+
wrong_pairings = {
9806+
mothID: budID, otherMothID: otherBudID
97989807
}
97999808
for correctBudID, correctMothID in correct_pairings.items():
9809+
wrongBudID = wrong_pairings[correctMothID]
98009810
frame_no_G1 = self._checkMothInG1beforeBudEmergence(
9801-
correctMothID, correctBudID, posData.frame_i
9811+
correctMothID, correctBudID, wrongBudID, posData.frame_i
98029812
)
98039813
if frame_no_G1 is None:
98049814
continue
98059815

9816+
printl(correctMothID, correctBudID, frame_no_G1, posData.frame_i)
98069817
self.warnMotherNotAtLeastOneFrameG1(
98079818
correctBudID, correctMothID, frame_no_G1
98089819
)

0 commit comments

Comments
 (0)