mkt.schema.utils.group_name_homologs

mkt.schema.utils.group_name_homologs(names: list[str], min_prefix: int = 3, show_count: bool = True) list[tuple[str, list[str]]][source]

Collapse prefix-homologous kinase names into compact labeled groups.

Names are grouped when they share a common base stem of at least min_prefix characters, each member’s remaining variant is a single letter or a pure number (so distinct subfamilies such as EPHA10 / EPHB6 stay apart), and they carry the same multi-domain suffix (see split_domain_suffix()). The stem is trimmed back off any mid-number boundary so a shorter member number is not split out of a longer one (NEK1 vs NEK10/NEK11), and numeric variants are sorted numerically. Each group is labeled by factoring out the stem, e.g. ["JAK1_1", "JAK2_1", "JAK3_1"] -> ("JAK1/2/3_1 (3)", [...]) or ["NEK1", "NEK10", "NEK2"] -> ("NEK1/2/10", [...]). The default min_prefix of 3 keeps coincidental two-character matches apart (e.g. the unrelated ATM, ATR). A complete gene name and its stem + "R" receptor paralog are never merged (e.g. INSR / INSRR stay apart), and any pair in SET_HOMOLOG_DO_NOT_MERGE is held apart by hand (BUB1 / BUB1B).

Parameters:
  • names (list[str]) – Kinase names to group. Order is not significant: names are sorted by (domain_suffix, name) internally so homologs are adjacent.

  • min_prefix (int, optional) – Minimum shared base-stem length required to merge, by default 3.

  • show_count (bool, optional) – Append a " (N)" member count to each merged group’s label, by default True.

Returns:

(label, members) pairs in sorted order; a singleton is (name, [name]).

Return type:

list[tuple[str, list[str]]]