whitews / FlowKit

A Python toolkit for flow cytometry analysis supporting GatingML and FlowJo workspaces
https://flowkit.readthedocs.io
BSD 3-Clause "New" or "Revised" License
157 stars 39 forks source link

Rename gate bug when GatingStrategy has more than 1 gate with same name #231

Open catcd opened 3 hours ago

catcd commented 3 hours ago

image

Problem Description:
There is an issue in the rename_gate function at line 259, causing an inconsistency in the gate hierarchy when renaming a gate. The problem arises during the retrieval of successor gates after the initial renaming process.

Steps to Reproduce:

  1. Start with the following gate hierarchy:
    root
    ├── CD4 mémoires
    │   ╰── A
    │       ├── A1
    │       ╰── A2
    ╰── CD4 naifs
        ╰── A
            ├── A1
            ╰── A2
  2. Call the function: rename_gate('A', 'A new', ('root', 'CD4 naifs')).

Observed Behavior:

Potential Root Cause:

Suggested Fix:

s_tuple = tuple(s if s != gate_name else new_gate_name for s in s_tuple)
catcd commented 3 hours ago

This bug does not happen if these is no A1, A2 in ('root', 'CD4 mémoires', 'A'), aka A1, A2 has only 1 note match