Random Topology Graph
- class RandomTopologyGraph(replacement_funcs, name='RandomTopologyGraph', random_seed=None)[source]
Bases:
stk.ea.mutation.mutators.molecule.mutator.MoleculeMutator
Changes topology graphs at random.
Examples
Constructed Molecule Mutation
import stk # Create a molecule which is to be mutated. bb1 = stk.BuildingBlock('NCCN', [stk.PrimaryAminoFactory()]) bb2 = stk.BuildingBlock( smiles='O=CCC(C=O)CC=O', functional_groups=[stk.AldehydeFactory()], ) cage = stk.MoleculeRecord( topology_graph=stk.cage.FourPlusSix((bb1, bb2)), ) # Create functions which replace the topology graph. replacement_funcs = ( lambda graph: stk.cage.TwoPlusThree(graph.get_building_blocks()), lambda graph: stk.cage.EightPlusTwelve(graph.get_building_blocks()), lambda graph: stk.cage.TwentyPlusThirty(graph.get_building_blocks()), ) # Create the mutator. random_topology = stk.RandomTopologyGraph(replacement_funcs) # Mutate a molecule. mutation_record1 = random_topology.mutate(cage) # Mutate the molecule a second time. mutation_record2 = random_topology.mutate(cage)
Methods
mutate
(record)Return a mutant of record.
- __init__(replacement_funcs, name='RandomTopologyGraph', random_seed=None)[source]
Initialize a
RandomTopology
instance.- Parameters
replacement_funcs (
tuple
ofcallable
) – Eachcallable
takes a single parameter, aTopologyGraph
, and returns theTopologyGraph
which should replace it.name (
str
, optional) – A name to help identify the mutator instance.random_seed (
bool
, optional) – The random seed to use.
- mutate(record)[source]
Return a mutant of record.
- Parameters
record (
MoleculeRecord
) – The molecule to be mutated.- Returns
MutationRecord
– A record of the mutation.None (
NoneType
) – If record cannot be mutated.