stk.small.InternalReaction

class stk.small.InternalReaction(building_block, num_reactions, num_processes=1, optimizer=<stk._internal.optimizers.null.NullOptimizer object>, scale_multiplier=1.0, reaction_factory=GenericReactionFactory())[source]

Bases: TopologyGraph

Represents an intramolecular reaction(s).

Here, we designed a way to take a single building block (maybe constructed from another series of building blocks) and perform any number of intramolecular reactions.

Examples

Construction

The number of functional groups in the core building block define the topology graph

import stk

building_block = stk.BuildingBlock(
    smiles="CCCC(CCCCI)CCCCCC(I)CC",
    functional_groups=stk.IodoFactory(),
)

reacted = stk.ConstructedMolecule(stk.small.InternalReaction(
    building_block=building_block,
    num_reactions=1
))

And multiple reactions can be performed, where the closest pairs should react.

import stk

building_block = stk.BuildingBlock(
    smiles="ICCCCC(CCCI)CCCCCC(I)CCI",
    functional_groups=stk.IodoFactory(),
)
reacted = stk.ConstructedMolecule(stk.small.InternalReaction(
    building_block=building_block,
    num_reactions=2,
))

Suggested Optimization

For InternalReaction topologies, no stk optimizer is appropriate, as they all assume distinct building blocks.

Parameters:
  • building_block (BuildingBlock) – The only building block.

  • num_reactions (int) – The number of internal reactions to run.

  • num_processes (int) – The number of parallel processes to create during construct().

  • optimizer (Optimizer) – Used to optimize the structure of the constructed molecule.

  • scale_multiplier (float) – Scales the positions of the vertices.

  • reaction_factory (ReactionFactory) – The factory to use for creating reactions between functional groups of building blocks.

Raises:

ValueError – If the number of reactions does not match the number of pairs of functional groups.

Methods

clone

Return a clone.

construct

Construct a ConstructedMolecule.

get_building_blocks

Yield the building blocks.

get_num_building_block

Get the number of times building_block is present.

with_building_blocks

Return a clone holding different building blocks.

clone()[source]

Return a clone.

Returns:

The clone.

Return type:

Self

construct()

Construct a ConstructedMolecule.

Returns:

The data describing the ConstructedMolecule.

Return type:

ConstructionResult

get_building_blocks()

Yield the building blocks.

Building blocks are yielded in an order based on their position in the topology graph. For two equivalent topology graphs, but with different building blocks, equivalently positioned building blocks will be yielded at the same time.

Yields:

A building block of the topology graph.

Return type:

Iterator[BuildingBlock]

get_num_building_block(building_block)

Get the number of times building_block is present.

Parameters:

building_block (BuildingBlock) – The building block whose frequency in the topology graph is desired.

Returns:

The number of times building_block is present in the topology graph.

Return type:

int

with_building_blocks(building_block_map)[source]

Return a clone holding different building blocks.

Parameters:

building_block_map (dict[BuildingBlock, BuildingBlock]) – Maps a building block in the current topology graph to the building block which should replace it in the clone. If a building block should be not replaced in the clone, it can be omitted from the map.

Returns:

The clone.

Return type:

Self