chemaxon.search

This package contains functions for chemical searches with molecules.

GitHub examples: https://github.com/ChemAxon/python-examples/blob/main/jupyter/06_molecule_search.ipynb

@dataclass()
class MoleculeSearch:

Search object to perform molecule searches

@typecheck(SearchType, (str, Standardizer, None))
MoleculeSearch( search_type=<SearchType.SUBSTRUCTURE: 2>, standardizer: str | chemaxon.standardizer.Standardizer = 'aromatize:g')
search_type: SearchType

The type of search to be performed. Default is SearchType.SUBSTRUCTURE

The configuration string of the standardizer to be applied before the search, or the chemaxon.standardizer.standardizer.Standardizer object. Default is general aromatization, if None or empty string is provided, no standardization will be applied

@typecheck(Molecule, Molecule, bool)
def find( self, query: chemaxon.Molecule, target: chemaxon.Molecule, return_colored_hit=False) -> SearchHit | None:

Molecule searching.

Parameters
Returns

SearchHit, or None if there was no match.

@typecheck(Molecule, list, bool)
def find_in_list( self, query: chemaxon.Molecule, target_list: list[chemaxon.Molecule], return_colored_hit: bool = False) -> list[SearchHit | None]:

Molecule searching in list.

Get a list of SearchHits or None.

Parameters
Raises
  • RuntimeError: In case of exception (unrecoverable errors) the function will exit and stop the searching.
Returns

list[SearchHit | None] - List of SearchHit objects in the same order as the input list of targets (target_mol_list). If no hit was found on a given target, None is returned on the corresponding index.

class SearchType(enum.Enum):

Supported molecule search types

SUBSTRUCTURE = <SearchType.SUBSTRUCTURE: 2>

Substructure search that applies both screening and atom-by-atom search. This is the default search type.

DUPLICATE = <SearchType.DUPLICATE: 5>

Duplicate search (formerly called perfect)

@dataclass(frozen=True)
class SearchHit:

Search hit result object

SearchHit( hit_indices: list[int], colored_hit: chemaxon.Molecule | None = None)
hit_indices: list[int]

List of atom indices in the target molecule that were matched by the query molecule. The index of the i-th atom (in the list) is the index of the target atom matched against the ith atom in the query molecule. None if there was no match

colored_hit: chemaxon.Molecule | None = None

Colored target molecule showing the matched atoms and bonds. None if return_colored_hit was False