Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update generic structures for topology graphs using single atom representations. #495

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 27 additions & 53 deletions src/stk/_internal/topology_graphs/cage/four_plus_six.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,64 +16,36 @@ class FourPlusSix(Cage):
"""
Represents a cage topology graph.

Unoptimized construction
Vertex connectivities:

.. moldoc::

import moldoc.molecule as molecule
import stk

bb1 = stk.BuildingBlock(
smiles='NC1CCCCC1N',
functional_groups=[stk.PrimaryAminoFactory()],
)
bb2 = stk.BuildingBlock(
smiles='O=Cc1cc(C=O)cc(C=O)c1',
functional_groups=[stk.AldehydeFactory()],
)
cage = stk.ConstructedMolecule(
topology_graph=stk.cage.FourPlusSix((bb1, bb2)),
three_c_bb = stk.BuildingBlock(
smiles="[Br][C]([Br])[Br]",
position_matrix=[
[-2, 0, -1],
[0, 0, 1],
[0, -2, -1],
[2, 0, 1],
],
functional_groups=(stk.BromoFactory(placers=(0, 1)),),
)

moldoc_display_molecule = molecule.Molecule(
atoms=(
molecule.Atom(
atomic_number=atom.get_atomic_number(),
position=position,
) for atom, position in zip(
cage.get_atoms(),
cage.get_position_matrix(),
)
),
bonds=(
molecule.Bond(
atom1_id=bond.get_atom1().get_id(),
atom2_id=bond.get_atom2().get_id(),
order=bond.get_order(),
) for bond in cage.get_bonds()
),
two_c_bb = stk.BuildingBlock(
smiles="[Br][N][Br]",
position_matrix=[
[-2, 0, -1],
[0, 0, 1],
[0, -2, -1],
],
functional_groups=(stk.BromoFactory(placers=(0, 1)),),
)

:class:`.MCHammer` optimized construction

.. moldoc::

import moldoc.molecule as molecule
import stk

bb1 = stk.BuildingBlock(
smiles='NC1CCCCC1N',
functional_groups=[stk.PrimaryAminoFactory()],
)
bb2 = stk.BuildingBlock(
smiles='O=Cc1cc(C=O)cc(C=O)c1',
functional_groups=[stk.AldehydeFactory()],
)
cage = stk.ConstructedMolecule(
topology_graph=stk.cage.FourPlusSix(
building_blocks=(bb1, bb2),
optimizer=stk.MCHammer(),
),
topology_graph=stk.cage.FourPlusSix((three_c_bb, two_c_bb)),
)

moldoc_display_molecule = molecule.Molecule(
Expand All @@ -95,20 +67,22 @@ class FourPlusSix(Cage):
),
)

Nonlinear building blocks with three functional groups are
required for this topology.
Nonlinear building blocks (COLOUR1) with three functional groups
are required for this topology.

Linear building blocks (COLOUR2) with two functional groups
are required for this topology.

Linear building blocks with two functional groups are required for
this topology.
:class:`.MCHammer` optimization is recommended for construction.

When using a :class:`dict` for the `building_blocks` parameter,
as in :ref:`cage-topology-graph-examples`:
*Multi-Building Block Cage Construction*, a
:class:`.BuildingBlock`, with the following number of functional
groups, needs to be assigned to each of the following vertex ids:

| 3-functional groups: 0 to 3
| 2-functional groups: 4 to 9
| 3-functional groups (COLOUR1): 0 to 3
| 2-functional groups (COLOUR2): 4 to 9

See :class:`.Cage` for more details and examples.

Expand Down
73 changes: 47 additions & 26 deletions src/stk/_internal/topology_graphs/cage/m24l48.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,43 +19,62 @@ class M24L48(Cage):
import moldoc.molecule as molecule
import stk

bb1 = stk.BuildingBlock(
smiles='[Pd+2]',
functional_groups=(
stk.SingleAtom(stk.Pd(0, charge=2))
for i in range(4)
),
position_matrix=[[0, 0, 0]],
four_c_bb = stk.BuildingBlock(
smiles="[Br][C]([Br])([Br])[Br]",
position_matrix=[
[-2, 0, -1],
[0, 0, 1],
[0, -2, -1],
[2, 0, 1],
[0, 2, 1],
],
functional_groups=(stk.BromoFactory(placers=(0, 1)),),
)

bb2 = stk.BuildingBlock(
smiles=(
'C1=NC=CC(C2=CC=CC(C3=C'
'C=NC=C3)=C2)=C1'
),
functional_groups=[
stk.SmartsFunctionalGroupFactory(
smarts='[#6]~[#7X2]~[#6]',
bonders=(1, ),
deleters=(),
),
two_c_bb = stk.BuildingBlock(
smiles="[Br][N][Br]",
position_matrix=[
[-2, 0, -1],
[0, 0, 1],
[0, -2, -1],
],
functional_groups=(stk.BromoFactory(placers=(0, 1)),),
)

cage = stk.ConstructedMolecule(
topology_graph=stk.cage.M24L48(
building_blocks=(bb1, bb2),
building_blocks=(four_c_bb, two_c_bb),
),
)
rgb1 = [192, 87, 161]
rgb2 = [97, 201, 217]
points = cage.get_num_atoms()
colour_list = [
[
int(rgb1[0] + ((rgb2[0]-rgb1[0])/points)*i),
int(rgb1[1] + ((rgb2[1]-rgb1[1])/points)*i),
int(rgb1[2] + ((rgb2[2]-rgb1[2])/points)*i),
]
for i in range(points)
]

moldoc_display_molecule = molecule.Molecule(
atoms=(
molecule.Atom(
atomic_number=atom.get_atomic_number(),
position=position,
) for atom, position in zip(
config=molecule.AtomConfig(
color=molecule.Color(
red=col[0],
green=col[1],
blue=col[2],
),
size=2.0,
)
) for atom, position, col in zip(
cage.get_atoms(),
cage.get_position_matrix(),
colour_list,
)
),
bonds=(
Expand All @@ -71,20 +90,22 @@ class M24L48(Cage):
),
)

Metal building blocks with four functional groups are
required for this topology.
Metal building blocks (COLOUR1) with four functional groups
are required for this topology.

Ligand building blocks (COLOUR2) with two functional groups
are required for this topology.

Ligand building blocks with two functional groups are required for
this topology.
:class:`.MCHammer` optimization is recommended for construction.

When using a :class:`dict` for the `building_blocks` parameter,
as in :ref:`cage-topology-graph-examples`:
*Multi-Building Block Cage Construction*, a
:class:`.BuildingBlock`, with the following number of functional
groups, needs to be assigned to each of the following vertex ids:

| 4-functional groups: 0 to 23
| 2-functional groups: 24 to 71
| 4-functional groups (\u25FC, COLOUR1): 0 to 23
| 2-functional groups (u'\u25FC', COLOUR2): 24 to 71

See :class:`.Cage` for more details and examples.

Expand Down
74 changes: 47 additions & 27 deletions src/stk/_internal/topology_graphs/cage/m2l4_lantern.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,44 +80,62 @@ class M2L4Lantern(Cage):
import moldoc.molecule as molecule
import stk

bb1 = stk.BuildingBlock(
smiles='[Pd+2]',
functional_groups=(
stk.SingleAtom(stk.Pd(0, charge=2))
for i in range(4)
),
position_matrix=[[0, 0, 0]],
four_c_bb = stk.BuildingBlock(
smiles="[Br][C]([Br])([Br])[Br]",
position_matrix=[
[-2, 0, -1],
[0, 0, 1],
[0, -2, -1],
[2, 0, 1],
[0, 2, 1],
],
functional_groups=(stk.BromoFactory(placers=(0, 1)),),
)

bb2 = stk.BuildingBlock(
smiles=(
'C1=NC=CC(C2=CC=CC(C3=C'
'C=NC=C3)=C2)=C1'
),
functional_groups=[
stk.SmartsFunctionalGroupFactory(
smarts='[#6]~[#7X2]~[#6]',
bonders=(1, ),
deleters=(),
),
two_c_bb = stk.BuildingBlock(
smiles="[Br][N][Br]",
position_matrix=[
[-2, 0, -1],
[0, 0, 1],
[0, -2, -1],
],
functional_groups=(stk.BromoFactory(placers=(0, 1)),),
)

cage = stk.ConstructedMolecule(
topology_graph=stk.cage.M2L4Lantern(
building_blocks=(bb1, bb2),
optimizer=stk.MCHammer(),
building_blocks=(four_c_bb, two_c_bb),
),
)
rgb1 = [192, 87, 161]
rgb2 = [97, 201, 217]
points = cage.get_num_atoms()
colour_list = [
[
int(rgb1[0] + ((rgb2[0]-rgb1[0])/points)*i),
int(rgb1[1] + ((rgb2[1]-rgb1[1])/points)*i),
int(rgb1[2] + ((rgb2[2]-rgb1[2])/points)*i),
]
for i in range(points)
]

moldoc_display_molecule = molecule.Molecule(
atoms=(
molecule.Atom(
atomic_number=atom.get_atomic_number(),
position=position,
) for atom, position in zip(
config=molecule.AtomConfig(
color=molecule.Color(
red=col[0],
green=col[1],
blue=col[2],
),
size=2.0,
)
) for atom, position, col in zip(
cage.get_atoms(),
cage.get_position_matrix(),
colour_list,
)
),
bonds=(
Expand All @@ -133,20 +151,22 @@ class M2L4Lantern(Cage):
),
)

Metal building blocks with four functional groups are
required for this topology.
Metal building blocks (COLOUR1) with four functional groups
are required for this topology.

Ligand building blocks (COLOUR2) with two functional groups
are required for this topology.

Ligand building blocks with two functional groups are required for
this topology.
:class:`.MCHammer` optimization is recommended for construction.

When using a :class:`dict` for the `building_blocks` parameter,
as in :ref:`cage-topology-graph-examples`:
*Multi-Building Block Cage Construction*, a
:class:`.BuildingBlock`, with the following number of functional
groups, needs to be assigned to each of the following vertex ids:

| 4-functional groups: 0 to 1
| 2-functional groups: 2 to 5
| 4-functional groups (COLOUR1): 0 to 1
| 2-functional groups (COLOUR2): 2 to 5

See :class:`.Cage` for more details and examples.

Expand Down