Пример #1
0
def get_fe_atom() -> stk.BuildingBlock:
    return stk.BuildingBlock(
        smiles='[Fe+2]',
        functional_groups=(stk.SingleAtom(stk.Fe(0, charge=2))
                           for i in range(6)),
        position_matrix=([0, 0, 0], ),
    )
Пример #2
0
            carbon=stk.C(0),
            oxygen=stk.O(12),
            sulfur=stk.S(21),
            hydrogen=stk.H(2),
            atom=stk.C(1),
            bonders=(stk.C(0), ),
            deleters=(stk.S(21), stk.H(2)),
        ),
        stk.Thiol(
            sulfur=stk.S(12),
            hydrogen=stk.H(21),
            atom=stk.C(32),
            bonders=(stk.C(32), ),
            deleters=(stk.S(12), stk.H(21)),
        ),
        stk.SingleAtom(atom=stk.Fe(0)),
    ), )
def functional_group1(request):
    """
    A :class:`.GenericFunctionalGroup` instance with 1 bonder atom.

    """

    return request.param


@pytest.fixture
def functional_group1_2(functional_group1):
    """
    A :class:`.GenericFunctionalGroup` instance with 1 bonder atom.
Пример #3
0
            carbon=stk.C(0),
            oxygen=stk.O(1),
            sulfur=stk.S(2),
            hydrogen=stk.H(3),
            atom=stk.C(4),
            bonders=(stk.C(0), ),
            deleters=(stk.S(2), stk.H(3)),
        ),
        lambda: stk.Thiol(
            sulfur=stk.S(0),
            hydrogen=stk.H(1),
            atom=stk.C(2),
            bonders=(stk.C(2), ),
            deleters=(stk.S(0), stk.H(1)),
        ),
        lambda: stk.SingleAtom(atom=stk.Fe(0)),
    ),
)
def functional_group1(request) -> stk.GenericFunctionalGroup:
    """
    A :class:`.GenericFunctionalGroup` with 1 bonder atom.

    """

    return request.param()


@pytest.fixture
def functional_group1_2(functional_group1):
    """
    A :class:`.GenericFunctionalGroup` with 1 bonder atom.
Пример #4
0
def main():
    bb1 = stk.BuildingBlock('NCCN', [stk.PrimaryAminoFactory()])
    bb2 = stk.BuildingBlock('O=CCC=O', [stk.AldehydeFactory()])
    polymer = stk.ConstructedMolecule(
        stk.polymer.Linear(building_blocks=(bb1, bb2),
                           repeating_unit="AB",
                           orientations=(0, 0),
                           num_repeating_units=1))
    bb2 = stk.BuildingBlock('O=CC(C=O)C=O', [stk.AldehydeFactory()])
    cage = stk.ConstructedMolecule(topology_graph=stk.cage.FourPlusSix(
        (bb1, bb2)), )
    cage2 = stk.ConstructedMolecule(topology_graph=stk.cage.FourPlusSix(
        building_blocks=(bb1, bb2),
        optimizer=stk.MCHammer(),
    ), )

    # Produce a Fe+2 atom with 6 functional groups.
    iron_atom = stk.BuildingBlock(
        smiles='[Fe+2]',
        functional_groups=(stk.SingleAtom(stk.Fe(0, charge=2))
                           for i in range(6)),
        position_matrix=[[0, 0, 0]],
    )

    # Define coordinating ligand with dummy bromine groups and
    # metal coordinating functional groups.
    oct_bb = stk.BuildingBlock(
        smiles='C1=NC(C=NBr)=CC=C1',
        functional_groups=[
            stk.SmartsFunctionalGroupFactory(
                smarts='[#6]~[#7X2]~[#35]',
                bonders=(1, ),
                deleters=(),
            ),
            stk.SmartsFunctionalGroupFactory(
                smarts='[#6]~[#7X2]~[#6]',
                bonders=(1, ),
                deleters=(),
            ),
        ],
    )

    # Build iron complex with delta stereochemistry.
    iron_oct_delta = stk.ConstructedMolecule(
        topology_graph=stk.metal_complex.OctahedralDelta(
            metals=iron_atom,
            ligands=oct_bb,
            optimizer=stk.MCHammer(),
        ), )

    # Assign Bromo functional groups to the metal complex.
    iron_oct_delta = stk.BuildingBlock.init_from_molecule(
        molecule=iron_oct_delta,
        functional_groups=[stk.BromoFactory()],
    )

    # Define spacer building block.
    bb3 = stk.BuildingBlock(
        smiles=('C1=CC(C2=CC=C(Br)C=C2)=C'
                'C=C1Br'),
        functional_groups=[stk.BromoFactory()],
    )

    # Build an M4L6 Tetrahedron with a spacer.
    moc = stk.ConstructedMolecule(
        topology_graph=stk.cage.M4L6TetrahedronSpacer(
            building_blocks=(
                iron_oct_delta,
                bb3,
            ),
            optimizer=stk.MCHammer(),
        ), )

    host = stk.ConstructedMolecule(topology_graph=stk.cage.FourPlusSix(
        building_blocks=(
            stk.BuildingBlock(
                smiles='NC1CCCCC1N',
                functional_groups=[
                    stk.PrimaryAminoFactory(),
                ],
            ),
            stk.BuildingBlock(
                smiles='O=Cc1cc(C=O)cc(C=O)c1',
                functional_groups=[stk.AldehydeFactory()],
            ),
        ),
        optimizer=stk.MCHammer(),
    ), )
    guest1 = stk.host_guest.Guest(
        building_block=stk.BuildingBlock('BrBr'),
        displacement=(0., 3., 0.),
    )
    guest2 = stk.host_guest.Guest(
        building_block=stk.BuildingBlock('C1CCCC1'), )

    hg_complex = stk.ConstructedMolecule(topology_graph=stk.host_guest.Complex(
        host=stk.BuildingBlock.init_from_molecule(host),
        guests=(guest1, guest2),
    ), )

    cycle = stk.ConstructedMolecule(topology_graph=stk.macrocycle.Macrocycle(
        building_blocks=(stk.BuildingBlock(
            smiles='[Br]CC[Br]',
            functional_groups=[stk.BromoFactory()],
        ), ),
        repeating_unit='A',
        num_repeating_units=8,
        optimizer=stk.MCHammer(),
    ), )
    axle = stk.ConstructedMolecule(topology_graph=stk.polymer.Linear(
        building_blocks=(
            stk.BuildingBlock('BrCCBr', [stk.BromoFactory()]),
            stk.BuildingBlock('BrCNCBr', [stk.BromoFactory()]),
        ),
        repeating_unit='AB',
        num_repeating_units=3,
        optimizer=stk.MCHammer(),
    ))
    rotaxane = stk.ConstructedMolecule(topology_graph=stk.rotaxane.NRotaxane(
        axle=stk.BuildingBlock.init_from_molecule(axle),
        cycles=(stk.BuildingBlock.init_from_molecule(cycle), ),
        repeating_unit='A',
        num_repeating_units=1,
    ), )

    examples_output = 'output_directory'
    if not os.path.exists(examples_output):
        os.mkdir(examples_output)

    structures = [
        ('bb1', bb1),
        ('bb2', bb2),
        ('bb3', bb3),
        ('polymer', polymer),
        ('cage', cage),
        ('cage2', cage2),
        ('m_iron_oct_delta', iron_oct_delta),
        ('m_moc', moc),
        ('hg_complex', hg_complex),
        ('cycle', cycle),
        ('axle', axle),
        ('rotaxane', rotaxane),
    ]

    # Run optimisations.
    for name, struct in structures:
        if 'm_' in name:
            rdkit_uff_energy = 'NA'
        else:
            rdkit_uff_energy = stko.UFFEnergy(
                ignore_inter_interactions=False).get_energy(struct)
        obabel_uff_energy = (stko.OpenBabelEnergy('uff').get_energy(struct))
        struct.write(os.path.join(examples_output, f'obabel_{name}_unopt.mol'))
        opt = stko.OpenBabel(
            forcefield='uff',
            repeat_steps=10,
            sd_steps=20,
            cg_steps=20,
        )
        opt_struct = opt.optimize(struct)
        opt_struct.write(
            os.path.join(examples_output, f'obabel_{name}_opt.mol'))

        if 'm_' in name:
            new_rdkit_uff_energy = 'NA'
        else:
            new_rdkit_uff_energy = stko.UFFEnergy(
                ignore_inter_interactions=False).get_energy(opt_struct)
        new_obabel_uff_energy = (
            stko.OpenBabelEnergy('uff').get_energy(opt_struct))
        print(f'{name}:\n'
              f'rdkit: {rdkit_uff_energy}, obabel: {obabel_uff_energy}\n'
              f'opt rdkit: {new_rdkit_uff_energy}, '
              f'opt obabel: {new_obabel_uff_energy}\n')
Пример #5
0
import pytest
import stk

from ....case_data import CaseData


metal_atom = stk.BuildingBlock(
    smiles='[Fe+2]',
    functional_groups=(
        stk.SingleAtom(stk.Fe(0, charge=2))
        for i in range(6)
    ),
    position_matrix=([0, 0, 0], ),
)
ditopic_linker = stk.BuildingBlock(
    smiles=(
        '[H]C1=C([H])C(C2=C([H])C([H])=C(Br)C([H])=C2[H])=C([H])C([H])'
        '=C1Br'
    ),
    functional_groups=[stk.BromoFactory()]
)
complex_ligand = stk.BuildingBlock(
    smiles='[H]C1=NC(C([H])=NBr)=C([H])C([H])=C1[H]',
    functional_groups=[
        stk.SmartsFunctionalGroupFactory(
            smarts='[#6]~[#7X2]~[#35]',
            bonders=(1, ),
            deleters=(),
        ),
        stk.SmartsFunctionalGroupFactory(
            smarts='[#6]~[#7X2]~[#6]',
Пример #6
0
import pytest
import stk

from ....case_data import CaseData

metal_atom = stk.BuildingBlock(
    smiles='[Fe+2]',
    functional_groups=(stk.SingleAtom(stk.Fe(0, charge=2)) for i in range(6)),
    position_matrix=([0, 0, 0], ),
)

tritopic_linker = stk.BuildingBlock(
    smiles=('[H]C1=C([H])C(N(C2=C([H])C([H])=C(Br)C([H])=C2[H])C2=C([H])C('
            '[H])=C(Br)C([H])=C2[H])=C([H])C([H])=C1Br'),
    functional_groups=[stk.BromoFactory()])
tetratopic_linker = stk.BuildingBlock(
    smiles=('[H]C1=C([H])C(C(C2=C([H])C([H])=C(Br)C([H])=C2[H])C(C2=C([H])'
            'C([H])=C(Br)C([H])=C2[H])C2=C([H])C([H])=C(Br)C([H])=C2[H])=C'
            '([H])C([H])=C1Br'),
    functional_groups=[stk.BromoFactory()])
complex_ligand = stk.BuildingBlock(
    smiles='[H]C1=NC(C([H])=NBr)=C([H])C([H])=C1[H]',
    functional_groups=[
        stk.SmartsFunctionalGroupFactory(
            smarts='[#6]~[#7X2]~[#35]',
            bonders=(1, ),
            deleters=(),
        ),
        stk.SmartsFunctionalGroupFactory(
            smarts='[#6]~[#7X2]~[#6]',
            bonders=(1, ),
Пример #7
0
            functional_groups=[stk.BromoFactory()],
        ),
        stk.BuildingBlock(
            smiles='BrCNCCBr',
            functional_groups=[stk.BromoFactory()],
        ),
    ),
    repeating_unit='AB',
    num_repeating_units=2,
), )

_square_planar = stk.ConstructedMolecule(
    topology_graph=stk.metal_complex.SquarePlanar(
        metals=stk.BuildingBlock(
            smiles='[Pd+2]',
            functional_groups=(stk.SingleAtom(stk.Fe(0, charge=2))
                               for i in range(4)),
            position_matrix=[[0, 0, 0]],
        ),
        ligands=stk.BuildingBlock(
            smiles='NBr',
            functional_groups=(stk.PrimaryAminoFactory(), ),
        ),
        optimizer=stk.MCHammer(),
    ))
uff = stko.OpenBabel('uff')
_square_planar_uff = uff.optimize(_square_planar)
_octahedral = stk.ConstructedMolecule(
    topology_graph=stk.metal_complex.Octahedral(
        metals=stk.BuildingBlock(
            smiles='[Fe+2]',