rdkit.Chem.rdSynthonSpaceSearch module

Module containing implementation of SynthonSpace search of Synthon-based chemical libraries such as Enamine REAL.

NOTE: This functionality is experimental and the API

and/or results may change in future releases.

class rdkit.Chem.rdSynthonSpaceSearch.ShapeBuildParams(self)

Bases: object

Parameters for building shape objects for SynthonSpaceSearch.

property interimFile

Interim file to write the SynthonSpace to during shape generation. In the event of a failure, a restart from this file will be possible.

property interimWrites

If an interim file has been given, every this many shapes write a new version of the file. Default=1000.

property maxEmbedAttempts

Maximum number of attempts for embedding a single synthon. Default=10.

property maxSynthonAtoms

If >0, sets a maximum number of heavy atoms, excluding dummies, for synthon to have a shape made. Default=0.

property numConfs

Maximum number of conformers per synthon or query. Default=10

property numThreads

The number of threads to use for shape building. If > 0, will use that number. If <= 0, will use the number of hardware threads plus this number.Default=1.

property randomSeed

Seed for random number generator. Default=-1 means use system random seed.

property rmsThreshold

RMS threshold to use when pruning conformations. Default=1.0.

setUserConformerGenerator(self, func: object) None
Allows you to provide a function that will be called instead of the default

conformer generator to generate conformers for the synthons. The function should take a SMILES string and the maximum number of conformers to generated and return a molecule object.

property shapeSimThreshold

When generating shapes, similarity threshold for pruning. No 2 shapes for each synthon or query will be more similar than this threshold. Default=1.9.

property stereoEnumOpts

Options for stereoisomer enumeration.

property timeOut

Maximum time in seconds to spend on each synthon when generating conformers. Default=600 means no timeout.

property useProgressBar

Makes a progress bar of given width. The number given is the number of ‘*’ characters in a full bar. There will be about another 35 characters or so depending on the size of the job. Default=0 means no bar.

class rdkit.Chem.rdSynthonSpaceSearch.SubstructureResult

Bases: object

Used to return results of SynthonSpace searches.

GetBestHit(self) object

Returns the best hit found in the similarity search, even when none were under the search threshold. May be empty if not a similarity search or nothing came close to a match.

GetCancelled(self) bool

Returns whether the search was cancelled or not.

GetHitMolecules(self) list

A function returning hits from the search

GetMaxNumResults(self) int

The upper bound on number of results possible. There may be fewer than this in practice for several reasons such as duplicate reagent sets being removed or the final product not matching the query even though the synthons suggested they would.

GetTimedOut(self) bool

Returns whether the search timed out or not.

class rdkit.Chem.rdSynthonSpaceSearch.SynthonSpace(self)

Bases: object

SynthonSpaceSearch object.

BuildSynthonFingerprints(self, fingerprintGenerator: rdkit.Chem.rdFingerprintGenerator.FingerprintGenerator64, progressBarWidth: int = 0) None

Build the synthon fingerprints ready for similarity searching. This is done automatically when the first similarity search is done, but if converting a text file to binary format it might need to be done explicitly. If progressBarWidth is > 0, a progress bar of that width plus about 35 characters is displayed.

BuildSynthonShapes(self, py_params: rdkit.Chem.rdSynthonSpaceSearch.ShapeBuildParams | None = None) None

Build shapes for the synthons. The conformations are generated, pruned with the given threshold, which is passed directly to EmbedMultipleConfs.

FingerprintSearch(self, query: rdkit.Chem.rdchem.Mol, fingerprintGenerator: object, params: rdkit.Chem.rdSynthonSpaceSearch.SynthonSpaceSearchParams | None = None) rdkit.Chem.rdSynthonSpaceSearch.SubstructureResult
FingerprintSearch(self, query: rdkit.Chem.rdchem.Mol, fingerprintGenerator: object, params: rdkit.Chem.rdSynthonSpaceSearch.SynthonSpaceSearchParams | None, startLine: int, finishLine: int) rdkit.Chem.rdSynthonSpaceSearch.SubstructureResult

Overloaded function.

  1. FingerprintSearch(self, query: rdkit.Chem.rdchem.Mol, fingerprintGenerator: object, params: rdkit.Chem.rdSynthonSpaceSearch.SynthonSpaceSearchParams | None = None) -> rdkit.Chem.rdSynthonSpaceSearch.SubstructureResult

Does a fingerprint search in the SynthonSpace using the FingerprintGenerator passed in.

  1. FingerprintSearch(self, query: rdkit.Chem.rdchem.Mol, fingerprintGenerator: object, params: rdkit.Chem.rdSynthonSpaceSearch.SynthonSpaceSearchParams | None, startLine: int, finishLine: int) -> rdkit.Chem.rdSynthonSpaceSearch.SubstructureResult

Take the contents of params.possibleHitsFile, which is assumed to have been written by an earlier search, and extract those that are indeed hits. It makes sense that params is the same as the one used to generate the possible hits, but this is not essential. You could search at a higher similarity threshold than used to create the possible hits, for example. Duplicate SMILES strings produced by different reactions will be returned.

FingerprintSearchIncremental(self, query: rdkit.Chem.rdchem.Mol, fingerprintGenerator: object, callback: object, params: rdkit.Chem.rdSynthonSpaceSearch.SynthonSpaceSearchParams | None = None) None

Does a fingerprint search in the SynthonSpace using the FingerprintGenerator passed in, returning results the callback.

GetNumProducts(self) int

Returns number of products in the SynthonSpace, with multiple counting of any duplicates.

GetNumReactions(self) int

Returns number of reactions in the SynthonSpace.

GetNumSynthons(self) int

Returns number of synthons in the SynthonSpace.

GetNumSynthonsWithShapes(self) int

Returns the number of synthons in the SynthonSpace that have a shape.

GetSynthonFingerprintType(self) str

Returns the information string for the fingerprint generator used to create this space.

RascalSearch(self, query: rdkit.Chem.rdchem.Mol, rascalOptions: object, params: rdkit.Chem.rdSynthonSpaceSearch.SynthonSpaceSearchParams | None = None) rdkit.Chem.rdSynthonSpaceSearch.SubstructureResult
RascalSearch(self, query: rdkit.Chem.rdchem.Mol, rascalOptions: object, params: rdkit.Chem.rdSynthonSpaceSearch.SynthonSpaceSearchParams | None, startLine: int, finishLine: int) rdkit.Chem.rdSynthonSpaceSearch.SubstructureResult

Overloaded function.

  1. RascalSearch(self, query: rdkit.Chem.rdchem.Mol, rascalOptions: object, params: rdkit.Chem.rdSynthonSpaceSearch.SynthonSpaceSearchParams | None = None) -> rdkit.Chem.rdSynthonSpaceSearch.SubstructureResult

Does a search using the Rascal similarity score. The similarity threshold used is provided by rascalOptions, and the one in params is ignored.

  1. RascalSearch(self, query: rdkit.Chem.rdchem.Mol, rascalOptions: object, params: rdkit.Chem.rdSynthonSpaceSearch.SynthonSpaceSearchParams | None, startLine: int, finishLine: int) -> rdkit.Chem.rdSynthonSpaceSearch.SubstructureResult

Take the contents of params.possibleHitsFile, which is assumed to have been written by an earlier search, and extract those that are indeed hits. It makes sense that params is the same as the one used to generate the possible hits, but this is not essential. You could search at a higher similarity threshold than used to create the possible hits, for example. Duplicate SMILES strings produced by different reactions will be returned.

RascalSearchIncremental(self, query: rdkit.Chem.rdchem.Mol, rascalOptions: rdkit.Chem.rdRascalMCES.RascalOptions | None, callback: object, params: rdkit.Chem.rdSynthonSpaceSearch.SynthonSpaceSearchParams | None = None) None

Does a search using the Rascal similarity score. The similarity threshold used is provided by rascalOptions, and the one in params is ignored. Returns results iteratively in the callback.

ReadDBFile(self, inFile: str | os.PathLike, numThreads: int = 1) None

Reads binary database file. Takes optional number of threads,default=1.

ReadTextFile(self, inFile: str | os.PathLike) None

Reads text file of the sort used by ChemSpace/Enamine.

ReportSynthonUsage(self) None

Writes a summary of the synthon usage in the SynthonSpace to stdout.

ShapeSearch(self, query: rdkit.Chem.rdchem.Mol, params: rdkit.Chem.rdSynthonSpaceSearch.SynthonSpaceSearchParams | None = None) rdkit.Chem.rdSynthonSpaceSearch.SubstructureResult
ShapeSearch(self, query: rdkit.Chem.rdchem.Mol, params: rdkit.Chem.rdSynthonSpaceSearch.SynthonSpaceSearchParams, startLine: int, finishLine: int) rdkit.Chem.rdSynthonSpaceSearch.SubstructureResult

Overloaded function.

  1. ShapeSearch(self, query: rdkit.Chem.rdchem.Mol, params: rdkit.Chem.rdSynthonSpaceSearch.SynthonSpaceSearchParams | None = None) -> rdkit.Chem.rdSynthonSpaceSearch.SubstructureResult

Perform a shape similarity search with the given query molecule across the synthonspace library. Duplicate SMILES strings produced by different reactions will be returned. Requires a query with at least 1 3D conformer. Only the first conformer will be used in the search.

  1. ShapeSearch(self, query: rdkit.Chem.rdchem.Mol, params: rdkit.Chem.rdSynthonSpaceSearch.SynthonSpaceSearchParams, startLine: int, finishLine: int) -> rdkit.Chem.rdSynthonSpaceSearch.SubstructureResult

Take the contents of params.possibleHitsFile, which is assumed to have been written by an earlier search, and extract those that are indeed hits. It makes sense that params is the same as the one used to generate the possible hits, but this is not essential. You could search at a higher similarity threshold than used to create the possible hits, for example. Duplicate SMILES strings produced by different reactions will be returned. Requires a query with at least 1 3D conformer. Only the first conformer will be used in the search.

SubstructureSearch(self, query: rdkit.Chem.rdchem.Mol, substructMatchParams: rdkit.Chem.rdchem.SubstructMatchParameters | None = None, params: rdkit.Chem.rdSynthonSpaceSearch.SynthonSpaceSearchParams | None = None) rdkit.Chem.rdSynthonSpaceSearch.SubstructureResult
SubstructureSearch(self, query: rdkit.Chem.rdGeneralizedSubstruct.ExtendedQueryMol, substructMatchParams: rdkit.Chem.rdchem.SubstructMatchParameters | None = None, params: rdkit.Chem.rdSynthonSpaceSearch.SynthonSpaceSearchParams | None = None) rdkit.Chem.rdSynthonSpaceSearch.SubstructureResult
SubstructureSearch(self, query: rdkit.Chem.rdchem.Mol, substructMatchParams: rdkit.Chem.rdchem.SubstructMatchParameters | None = None, params: rdkit.Chem.rdSynthonSpaceSearch.SynthonSpaceSearchParams | None = None, startLine: int, finishLine: int) rdkit.Chem.rdSynthonSpaceSearch.SubstructureResult
SubstructureSearch(self, query: rdkit.Chem.rdGeneralizedSubstruct.ExtendedQueryMol, substructMatchParams: rdkit.Chem.rdchem.SubstructMatchParameters | None = None, params: rdkit.Chem.rdSynthonSpaceSearch.SynthonSpaceSearchParams | None = None, startLine: int, finishLine: int) rdkit.Chem.rdSynthonSpaceSearch.SubstructureResult

Overloaded function.

  1. SubstructureSearch(self, query: rdkit.Chem.rdchem.Mol, substructMatchParams: rdkit.Chem.rdchem.SubstructMatchParameters | None = None, params: rdkit.Chem.rdSynthonSpaceSearch.SynthonSpaceSearchParams | None = None) -> rdkit.Chem.rdSynthonSpaceSearch.SubstructureResult

Does a substructure search in the SynthonSpace.

  1. SubstructureSearch(self, query: rdkit.Chem.rdGeneralizedSubstruct.ExtendedQueryMol, substructMatchParams: rdkit.Chem.rdchem.SubstructMatchParameters | None = None, params: rdkit.Chem.rdSynthonSpaceSearch.SynthonSpaceSearchParams | None = None) -> rdkit.Chem.rdSynthonSpaceSearch.SubstructureResult

Does a substructure search in the SynthonSpace using an extended query.

  1. SubstructureSearch(self, query: rdkit.Chem.rdchem.Mol, substructMatchParams: rdkit.Chem.rdchem.SubstructMatchParameters | None = None, params: rdkit.Chem.rdSynthonSpaceSearch.SynthonSpaceSearchParams | None = None, startLine: int, finishLine: int) -> rdkit.Chem.rdSynthonSpaceSearch.SubstructureResult

Take the contents of params.possibleHitsFile, which is assumed to have been written by an earlier search, and extract those that are indeed hits. It makes sense that params is the same as the one used to generate the possible hits, but this is not essential. You could search at a higher similarity threshold than used to create the possible hits, for example.

  1. SubstructureSearch(self, query: rdkit.Chem.rdGeneralizedSubstruct.ExtendedQueryMol, substructMatchParams: rdkit.Chem.rdchem.SubstructMatchParameters | None = None, params: rdkit.Chem.rdSynthonSpaceSearch.SynthonSpaceSearchParams | None = None, startLine: int, finishLine: int) -> rdkit.Chem.rdSynthonSpaceSearch.SubstructureResult

Take the contents of params.possibleHitsFile, which is assumed to have been written by an earlier search, and extract those that are indeed hits. It makes sense that params is the same as the one used to generate the possible hits, but this is not essential. You could search at a higher similarity threshold than used to create the possible hits, for example.

SubstructureSearchIncremental(self, query: rdkit.Chem.rdchem.Mol, callback: object, substructMatchParams: rdkit.Chem.rdchem.SubstructMatchParameters | None = None, params: rdkit.Chem.rdSynthonSpaceSearch.SynthonSpaceSearchParams | None = None) None

Does a substructure search in the SynthonSpace returning results in the callback.

Summarise(self) None

Writes a summary of the SynthonSpace to stdout.

WriteDBFile(self, outFile: str | os.PathLike) None

Writes binary database file.

WriteEnumeratedFile(self, outFile: str | os.PathLike) None

Writes enumerated library to file.

class rdkit.Chem.rdSynthonSpaceSearch.SynthonSpaceSearchParams(self)

Bases: object

SynthonSpaceSearch parameters.

property approxSimilarityAdjuster

The fingerprint search uses an approximate similarity method before building a product and doing a final check. The similarityCutoff is reduced by this value for the approximate check. A lower value will give faster run times at the risk of missing some hits. The value you use should have a positive correlation with your FOMO. The default of 0.1 is appropriate for Morgan fingerprints. With RDKit fingerprints, 0.05 is adequate, and higher than that has been seen to produce long run times.

property bestHit

If True, when doing a shape search it will return the hit conformer with the best shape match to the query conformer. If False, it just returns the first hit conformer that exceeds the similarity cutoff. The latter will be faster but the returned hit conformations are likely to be less relevant.

property buildHits

If false, reports the maximum number of hits that the search could produce, but doesn’t return them.

property confRMSThreshold

When doing a shape search, the RMS threshold to use when pruning conformers. Default=1.0.

property enumerateUnspecifiedStereo

When doing a shape search, if there is unspecified stereochemistry in either the query or potential hit, enumerate test all possibilities. Default=False.

property excludedVolume

Add an excluded volume to use in the shape search. The volume overlap and mean overlap over clashing atoms will be reported.

property fragSimilarityAdjuster

Similarities of fragments are generally low due to low bit densities. For the fragment matching, reduce the similarity cutoff off by this amount. Default=0.1.

property hitStart

The sequence number of the hit to start from. So that you can return the next N hits of a search having already obtained N-1. Default=0

property maxExcludedVolume

Maximum allowed excluded volume for a hit to be accepted. Default -1.0 means no maximum.

property maxHitChiralAtoms

Maximum number of chiral atoms in a hit. Default=-1 means no maximum.

property maxHitHeavyAtoms

Maximum number of heavy atoms in a hit. Default=-1 means no maximum.

property maxHitMolWt

Maximum molecular weight for a hit. Default=0.0 mean no maximum.

property maxHits

The maximum number of hits to return. Default=1000.Use -1 for no maximum.

property maxMeanExcludedVolume

Maximum mean excluded volume for a hit to be accepted. The mean is the total excluded volume divided by the number of clashing atoms (within 2 CARBON_RAD of an excluded volume atom). To try and distinguish between a mild clash over the whole hit and a few atoms having a really bad clash.

property maxNumFrags
The maximum number of fragments the query can be broken into.

Big molecules will create huge numbers of fragments that may cause

excessive memory use. If the number of fragments hits this number, fragmentation stops and the search results will likely be incomplete.

Default=100000.

property maxPossibleHitsToWrite

Maximum number of lines to write to possibleHitsFile. When dealing with huge synthon spaces it’s very easy to fill a disk. Default=10M.

property minHitChiralAtoms

Minimum number of chiral atoms in a hit. Default=0.

property minHitHeavyAtoms

Minimum number of heavy atoms in a hit. Default=0.

property minHitMolWt

Minimum molecular weight for a hit. Default=0.0.

property numConformers

When doing a shape search, the number of conformers to generate for molecules. Default=100.

property numThreads

The number of threads to use for search. If > 0, will use that number. If <= 0, will use the number of hardware threads plus this number. So if the number of hardware threads is 8, and numThreads is -1, it will use 7 threads. Default=1.

property possibleHitsFile

Name of a file to save the possible hits to. These are the combinations of synthons that might match the query but need building and final checking. Each line has a space-separated list of the synthons and the hit’s name. The file will be emptied and re-filled if it already exists.

property randomSample

If True, returns a random sample of the hits, up to maxHits in number. Default=False.

property randomSeed

If using randomSample, this seeds the random number generator so as to give reproducible results. Default=-1 means use a random seed.

setUserConformerGenerator(self, func: object) None
Allows you to provide a function that will be called instead of the default

conformer generator to generate conformers for the synthons. The function should take a SMILES string and the maximum number of conformers to generated and return a molecule object.

property shapeOverlayOptions

Options for the shape overlays.

property similarityCutoff

Similarity cutoff for returning hits by fingerprint similarity. At present the fp is hard-coded to be Morgan, bits, radius=2. Default=0.5.

property stereoEnumOpts

Options for stereoisomer enumeration.

property timeOut

Time limit for search, in seconds. Default is 600s, 0 means no timeout. Requires an integer

property toTryChunkSize

Process possible hits using the given chunk size

property useProgressBar

Makes a progress bar of given width. The number given is the number of ‘*’ characters in a full bar. There will be about another 35 characters or so depending on the size of the job. Default=0 means no bar.

property writePossibleHitsAndStop

If True, creates the possibleHitsFile and stops without doing the final building and checking. Default is False.