Functional Groups¶
The purpose of functional groups is to identify which atoms of a
building block are modified during construction. See
FunctionalGroup for more details.
See the documentation of Reactor to see how reactions between
functional groups are performed.
Adding Functional Groups¶
During initialization of a BuildingBlock instance, the
names of FGType instances are supplied. These are used to
create the FunctionalGroup instances
found in BuildingBlock.func_groups and therefore the ones
used in the construction of ConstructedMolecule instances.
If you want to be able to use a new FGType with building
blocks in this way, simply add a new FGType instance to
fg_types. This can be done in this file or externally.
For example, if you want make stk use a new FGType
without touching the source code you can just do
import stk
new_fg_type = FGType(
name='my_fg_type',
func_group_smarts='[N]([H])[H]',
bonder_smarts=['[$([N]([H])[H])]'],
deleter_smarts=['[$([H][N][H])]']*2
)
stk.fg_types[new_fg_type.name] = new_fg_type
# You can now use the new_fg_type with BuildingBlocks.
bb = stk.BuildingBlock('NCCCN', ['my_fg_type'])
Note that when adding SMARTS, if you want to make a SMARTS that targets an atom in an environment, for example, a bromine connected to a carbon:
[$([Br][C])]
The atom you are targeting needs to be written first. The above SMARTS works but:
[$([C][Br])]
does not.
-
class
FGType(name, func_group_smarts, bonder_smarts, deleter_smarts)¶ Bases:
objectCreates
FunctionalGroupinstances.Methods
get_functional_groups(self, mol)Yield the functional groups in mol.
-
__init__(self, name, func_group_smarts, bonder_smarts, deleter_smarts)¶ Initialize a
FGTypeinstance.- Parameters
name (
str) – A name for theFGType. Helps with identification.func_group_smarts (
str) – A SMARTS string which matches all atoms in a functional group.bonder_smarts (
listofstr) – Alistof SMARTS strings, each of which matches a single atom in a functional group. The matched atom is added toFunctionalGroup.bonders. A SMARTS string needs to be repeated if a single functional group has multiple equivalent atoms, each of which appears in the sameFunctionalGroup.deleter_smarts (
listofstr) – Alistof SMARTS strings, each of which matches a single atom in a functional group. The matched atom is added toFunctionalGroup.deleters. A SMARTS string needs to be repeated if a single functional group has multiple equivalent atoms, each of which appears in the sameFunctionalGroup.
-
get_functional_groups(self, mol)¶ Yield the functional groups in mol.
- Parameters
mol (
Molecule) – The molecule which is to have functional groups identified.- Yields
FunctionalGroup– AFunctionalGroupfor every matched functional group in the mol.
Examples
import stk mol = stk.BuildingBlock('NCCN') amine = stk.FGType( func_group_smarts='[N]([H])[H]', bonder_smarts=['[$([N]([H])[H])]'], deleter_smarts=['[$([H][N][H])]']*2 ) # Make mol use amine functional groups during construction # of ConstructedMolecule. mol.func_groups = tuple(amine.get_functional_groups(mol))
-
-
class
FunctionalGroup(atoms, bonders, deleters, fg_type)¶ Bases:
objectRepresents a functional group in a molecule.
Instances of this class should only be made via
FGType.get_functional_groups().-
bonders¶ The bonder atoms in the functional group. These are atoms which have bonds added during the construction of a
ConstructedMolecule.- Type
tupleofAtom
-
deleters¶ The deleter atoms in the functional group. These are atoms which are deleted during construction of a
ConstructedMolecule.- Type
tupleofAtom
-
fg_type¶ The
FGTypeinstance which created theFunctionalGroup.- Type
Methods
clone(self[, atom_map])Return a clone.
get_atom_ids(self)Yield the ids of
atomsin order.get_bonder_ids(self)Yield the ids of
bondersin order.get_deleter_ids(self)Yield the ids of
deletersin order.-
__init__(self, atoms, bonders, deleters, fg_type)¶ Initialize a
FunctionalGroup.
-
clone(self, atom_map=None)¶ Return a clone.
- Parameters
atom_map (
dict, optional) – If the clone should hold differentAtominstances, then adictshould be provided, which maps atoms in the currentFunctionalGroupto the atoms which should be used in the clone. Only atoms which need to be remapped need to be present in the atom_map.- Returns
A clone.
- Return type
Examples
import stk c0 = stk.C(0) c1 = stk.C(1) bb = stk.BuildingBlock('NCCN', ['amine']) fg = bb.func_groups[0] a0, a1 = fg.atoms[:2] # fg_clone is a clone of fg, except that in all places # fg holds a0 fg_clone holds c0 and in all places where # fg holds a1, fg_clone holds c1. fg_clone = fg.clone({ a0: c0 a1: c1 })
-