stk.RandomTopologyGraph

class stk.RandomTopologyGraph(replacement_funcs, name='RandomTopologyGraph', random_seed=None)[source]

Bases: object

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)
Parameters:

Methods

mutate

Return a mutant of record.

mutate(record)[source]

Return a mutant of record.

Parameters:

record (MoleculeRecord[Any]) – The molecule to be mutated.

Returns:

A record of the mutation or None if record cannot be mutated.

Return type:

MutationRecord[MoleculeRecord[Any]]