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_fragment_seniority_impl(), memoised for the life of the process: the score is a pure function offrag_smiles(an RDKit parse, the functional groups it carries and its ring/heavy-atom counts; no provenance, no budget), so one process computes it once per string.ORTHONYM_MEMO=off|verifyandORTHONYM_PROCESS_CACHE=0bypass the memo exactly as forfg_detect.
- 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