chemaxon.search.molsearch

class SearchType(enum.Enum):

Supported molecule search types

SUBSTRUCTURE = <SearchType.SUBSTRUCTURE: 2>
DUPLICATE = <SearchType.DUPLICATE: 5>
mol_search_constant
class SearchHit:

Search hit result object

SearchHit( cresult: chemaxon.search.molsearch._CSearchHitWithExceptionData, return_colored_hit: bool)
hit_indexes: list[int]

List of atom indexes in the target molecule that were matched by the query molecule

colored_mol: chemaxon.molecule.Molecule | None

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

@dataclass()
class MoleculeSearch:

Search object to perform molecule searches

MoleculeSearch( search_type=<SearchType.SUBSTRUCTURE: 2>, standardizer: str | chemaxon.standardizer.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 Standardizer object. Default is general aromatization, if None or empty string is provided, no standardization will be applied

def find_hit( self, query_mol: chemaxon.molecule.Molecule, target_mol: chemaxon.molecule.Molecule, return_colored_hit=False) -> SearchHit | None:

Molecule searching.

Parameters
  • query_mol: Molecule - The Molecule to match
  • target_mol: Molecule - The target Molecule to which the query_mol is being matched
  • return_colored_hit: bool - If true, colored target is returned showing the matched atoms and bonds. Default is False.
Returns

Search hit, or None if there was no match.

def find_hits_in_list( self, query_mol: chemaxon.molecule.Molecule, target_mol_list: list[chemaxon.molecule.Molecule], return_colored_hit: bool = False) -> list[SearchHit]:

Molecule searching in list.

Get a list of SearchHits or None(s).

Parameters
  • query_mol: Molecule - The Molecule to search with
  • target_mol_list: list[Molecule] - The list of Molecules to match against
  • return_colored_hit: bool -If true, colored targets are returned showing the matched atoms and bonds. Default is False.
Raises
  • RuntimeError: In case of exception (unrecoverable errors) the function will exit and stop the searching.
Returns

list[Molecule] - List of SearchHit (s) 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.