stk.FunctionalGroupFactory
- class stk.FunctionalGroupFactory[source]
Bases:
object
An abstract base class for functional group factories.
The purpose of a functional group factory is to create
FunctionalGroup
instances. It allows the user to avoid creatingFunctionalGroup
instances manually. The user will useget_functional_groups()
to achieve this. Subclasses of this class are made to customize the automatic creation process.Examples
Using a Single Functional Group From a Factory
You have a building block with two functional groups, but you want to use just one.
import stk amino_factory = stk.PrimaryAminoFactory() building_block = stk.BuildingBlock('NCCN') amino_group1, *rest = amino_factory.get_functional_groups( molecule=building_block, ) building_block = building_block.with_functional_groups( functional_groups=(amino_group1, ), )
Using a Subset of Functional Groups From a Factory
You have multiple functional groups, but you want the building block to use a specific subset.
import stk bromo_factory = stk.BromoFactory() building_block = stk.BuildingBlock('BrCC(Br)CC(Br)CC(Br)CCBr') bromo_groups = tuple(bromo_factory.get_functional_groups( molecule=building_block, )) building_block = building_block.with_functional_groups( functional_groups=( bromo_groups[0], bromo_groups[3], bromo_groups[4], ), )
More usage examples can be found in the docstrings of the various subclasses.
Subclass Implementation
The source of the subclasses, listed in
functional_group_factory
, can serve as good examples.Methods
Yield functional groups in molecule.
- get_functional_groups(molecule)[source]
Yield functional groups in molecule.
- Parameters:
molecule (
Molecule
) – The molecule, whose functional groups are to be found.- Yields:
FunctionalGroup
– A functional group in molecule.
Examples