Remove Molecules
- class RemoveMolecules(remover, selector)[source]
Bases:
Selector
Prevents a
Selector
from selecting some molecules.Examples
Removing Molecules From Selection
import stk selector = stk.RemoveMolecules( # Do not select any molecules from the top 5 batches # of size 3. remover=stk.Best(num_batches=5, batch_size=3), # Select the ret of the molecules using roulette. selector=stk.Roulette(num_batches=20, batch_size=3), ) population = tuple( stk.MoleculeRecord( topology_graph=stk.polymer.Linear( building_blocks=( stk.BuildingBlock( smiles='BrCCBr', functional_groups=[stk.BromoFactory()], ), ), repeating_unit='A', num_repeating_units=2, ), ).with_fitness_value(i) for i in range(10) ) for batch in selector.select(population): # Do stuff with batch. The batch is guaranteed not to # contain any molecules which are found in the best 5 # batches of size 3. pass
Methods
select
(population[, included_batches, ...])Yield batches of molecule records from population.
- __init__(remover, selector)[source]
Initialize a
RemoveMolecules
instance.
- select(population, included_batches=None, excluded_batches=None)[source]
Yield batches of molecule records from population.
- Parameters:
population (
tuple
ofMoleculeRecord
) – A collection of molecules from which batches are selected.included_batches (
set
, optional) – The identity keys of batches which are allowed to be yielded, ifNone
all batches can be yielded. If notNone
only batches included_batches will be yielded.excluded_batches (class:set, optional) – The identity keys of batches which are not allowed to be yielded. If
None
, no batch is forbidden from being yielded.
- Yields:
Batch
ofMoleculeRecord
– A batch of selected molecule records.