stk.RemoveMolecules
- class stk.RemoveMolecules(remover, selector)[source]
Bases:
Selector
[T
]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 = { stk.MoleculeRecord( topology_graph=stk.polymer.Linear( building_blocks=[ stk.BuildingBlock('BrCCBr', stk.BromoFactory()), ], repeating_unit='A', num_repeating_units=2, ), ): 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
- Parameters:
Methods
Yield batches of molecule records from population.
- select(population, included_batches=None, excluded_batches=None)[source]
Yield batches of molecule records from population.
- Parameters:
population (dict[T, float]) – A collection of molecules from which batches are selected.
included_batches (set[BatchKey] | None) – The identity keys of batches which are allowed to be yielded, if
None
all batches can be yielded. If notNone
only batches included_batches will be yielded.excluded_batches (set[BatchKey] | None) – The identity keys of batches which are not allowed to be yielded. If
None
, no batch is forbidden from being yielded.
- Yields:
A batch of selected molecule records.
- Return type: