orthonym.decomposition.fragment_ranker#

Note

Internal API. Names and behaviour may change between releases.

Fragment seniority ranking for decomposition parent/substituent assignment.

Implements IUPAC seniority-based fragment ranking to determine which fragment becomes the parent structure in decomposition naming. Uses existing seniority.py and functional_groups.py infrastructure – this is a thin wrapper.

Ranking criteria (applied in order until tie-broken): 1. Most principal characteristic groups 2. Most senior principal group type 3. Senior heteroatom: N > O > S 4. Ring system present beats chain-only 5. Most heavy atoms size tiebreaker)

Scores are tuples where LOWER = MORE SENIOR (natural sort order).

orthonym.decomposition.fragment_ranker.score_fragment_seniority(frag_smiles)#

Score a fragment SMILES by seniority.

Returns a comparison tuple where LOWER = MORE SENIOR:

(-pg_count, pg_seniority_rank, heteroatom_rank, -has_ring, -num_heavy_atoms)

Parameters:

frag_smiles (str | None) – SMILES string for the fragment. None or invalid SMILES returns the lowest possible seniority.

Returns:

5-tuple of integers for comparison. Lower tuple = more senior fragment.

Return type:

Tuple[int, int, int, int, int]

orthonym.decomposition.fragment_ranker.rank_fragments(fragments)#

Rank fragment dicts by seniority (most senior first).

Parameters:

fragments (List[Dict]) – List of dicts, each must have a “smiles” key. All other keys are preserved.

Returns:

New list sorted by seniority (most senior first = lowest score).

Return type:

List[Dict]

orthonym.decomposition.fragment_ranker.acid_is_more_senior(acid_smiles, other_smiles)#

Check if the acid fragment is more senior or equal to the other fragment.

Convenience function for engine.py assembly decisions. When this returns False, the other fragment (amine/alkyl) is strictly more senior and should become the parent.

Parameters:
  • acid_smiles (str) – SMILES of the acid-side fragment.

  • other_smiles (str) – SMILES of the other fragment (amine/alkyl).

Returns:

True if acid is more senior or equal (normal assembly). False if other is strictly more senior (reverse assembly).

Return type:

bool