orthonym.perception.functional_groups#
Note
Internal API. Names and behaviour may change between releases.
Functional group detection using SMARTS patterns.
Groups are ordered by IUPAC seniority (highest priority first). The principal group (highest seniority) becomes the suffix; all others become prefixes.
- exception orthonym.perception.functional_groups.FGFilterMismatchError#
Bases:
AssertionErrorVerify mode: the element pre-filter would have skipped a pattern that matches.
- orthonym.perception.functional_groups.detect_functional_groups(mol)#
Detect all functional groups in a molecule (memoized per mol object).
Returns a dictionary mapping functional group names to lists of atom index tuples. Each tuple contains the indices of atoms in one instance of that group.
Example
>>> mol = Chem.MolFromSmiles("CC(=O)O") # acetic acid >>> groups = detect_functional_groups(mol) >>> "carboxylic_acid" in groups True >>> len(groups["carboxylic_acid"]) 1
- orthonym.perception.functional_groups.detect_features(mol)#
functional-group perception fix (a phase) — the single shared feature-perception entry point.
The ONE place every route (neutral and charged) reads functional-group classes from, so a mis-route can never produce a DIFFERENT feature set (audit Dim-02 #1: “two parallel detectors with disjoint coverage”). Today it is a thin wrapper over
detect_functional_groups(which now includes the charged + missing-class SMARTS); the orthogonal charge-SITE scan (ions.get_ion_sites) stays separate — it answers “where are the charges”, not “what FG classes are present”. Keeping a single accessor lets future consolidation route through one function.
- orthonym.perception.functional_groups.get_chain_excluded_atoms(mol)#
Return the N/O atom indices of every prefix-only characteristic group (
_CHAIN_EXCLUDED_FG) present in mol.These graph indices, derived from perception’s OWN
detect_functional_groupsmatches (NOT a per-FG SMARTS blocklist — internal notes), are the atoms that must be excluded from skeletal/parent-chain finding. Only the heteroatoms (N=7, O=8) of each match are returned, so the carbon attachment point is preserved (the chain can still terminate there).
- orthonym.perception.functional_groups.has_functional_group(mol, fg_name)#
Check if molecule contains a specific functional group.
- Parameters:
mol – RDKit Mol object
fg_name (str) – Name of functional group (must be in FUNCTIONAL_GROUP_SMARTS)
- Returns:
True if functional group is present
- Return type:
bool
- orthonym.perception.functional_groups.get_functional_group_atoms(mol, fg_name)#
Get atom indices for all instances of a specific functional group.
- Parameters:
mol – RDKit Mol object
fg_name (str) – Name of functional group
- Returns:
List of tuples of atom indices
- Return type:
List[Tuple[int, …]]
- orthonym.perception.functional_groups.count_functional_groups(mol)#
Count occurrences of each functional group.
- Parameters:
mol – RDKit Mol object
- Returns:
Dictionary mapping functional group names to counts
- Return type:
Dict[str, int]