Пример #1
0
def main():
    bb1 = stk.BuildingBlock('NCCNCCN', [stk.PrimaryAminoFactory()])
    bb2 = stk.BuildingBlock('O=CCCC=O', [stk.AldehydeFactory()])
    polymer = stk.ConstructedMolecule(
        stk.polymer.Linear(building_blocks=(bb1, bb2),
                           repeating_unit="AB",
                           orientations=[0, 0],
                           num_repeating_units=1))

    examples_output = 'output_directory'
    if os.path.exists(examples_output):
        shutil.rmtree(examples_output)

    os.mkdir(examples_output)

    # Run optimisations.
    uff = stko.UFF()
    polymer = uff.optimize(polymer)
    polymer.write(f'{examples_output}/poly_uff.mol')
    mmff = stko.MMFF()
    polymer = mmff.optimize(polymer)
    polymer.write(f'{examples_output}/poly_mmff.mol')
    etkdg = stko.ETKDG()
    polymer = etkdg.optimize(polymer)
    polymer.write(f'{examples_output}/poly_etkdg.mol')
Пример #2
0
def test_UFF_opt(case_uff_molecule):
    energy = (stko.UFFEnergy().get_energy(case_uff_molecule.molecule))
    optimizer = stko.UFF()
    opt_res = optimizer.optimize(case_uff_molecule.molecule)
    is_equivalent_molecule(opt_res, case_uff_molecule.molecule)
    inequivalent_position_matrices(opt_res, case_uff_molecule.molecule)
    opt_energy = (stko.UFFEnergy().get_energy(opt_res))
    assert np.isclose(energy, case_uff_molecule.unoptimised_energy, atol=1E-3)
    assert opt_energy < case_uff_molecule.unoptimised_energy
Пример #3
0
def main():
    if len(sys.argv) > 1:
        orca_path = sys.argv[1]
    else:
        print('usage: orca_example.py orca_path')
        sys.exit()

    bb1 = stk.BuildingBlock('NCCN', [stk.PrimaryAminoFactory()])
    bb2 = stk.BuildingBlock('O=CC=O', [stk.AldehydeFactory()])
    polymer = stk.ConstructedMolecule(
        stk.polymer.Linear(building_blocks=(bb1, bb2),
                           repeating_unit="AB",
                           orientations=(0, 0),
                           num_repeating_units=1))

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

    # Run optimisations.
    etkdg = stko.ETKDG()
    polymer = etkdg.optimize(polymer)

    orca_ey_1 = stko.OrcaEnergy(
        orca_path=orca_path,
        topline='! SP B97-3c',
        basename='example1',
        output_dir=f'{examples_output}/orca_e1_dir',
    )
    print(orca_ey_1.get_energy(polymer))

    uff = stko.UFF()
    polymer = uff.optimize(polymer)
    orca_ey_2 = stko.OrcaEnergy(
        orca_path=orca_path,
        topline='! SP B97-3c',
        basename='example2',
        output_dir=f'{examples_output}/orca_e2_dir',
    )
    print(orca_ey_2.get_energy(polymer))

    orca_ey_3 = stko.OrcaEnergy(
        orca_path=orca_path,
        topline='! SP B97-3c',
        basename='example3',
        output_dir=f'{examples_output}/orca_e3_dir',
        write_input_only=True,
    )
    orca_ey_3.get_results(polymer)
Пример #4
0
def main():
    examples_output = 'aligner_directory'
    if not os.path.exists(examples_output):
        os.mkdir(examples_output)

    bb1 = stk.BuildingBlock('NCCN', [stk.PrimaryAminoFactory()])
    bb2 = stk.BuildingBlock(
        smiles='O=CC(C=O)C=O',
        functional_groups=[stk.AldehydeFactory()],
    )
    cage = stk.ConstructedMolecule(
        topology_graph=stk.cage.FourPlusSix(
            (bb1, bb2), optimizer=stk.MCHammer(num_steps=2000),
        ),
    )

    mol_list = [
        (stk.BuildingBlock('NCCNCCN'), (('N', 'N'), ), True),
        (
            stk.BuildingBlock('CN1C=NC2=C1C(=O)N(C(=O)N2C)C'),
            (('N', 'N'), ('O', 'O'), ),
            True,
        ),
        (stk.BuildingBlock('C1=CN=CN=C1'), (('N', 'N'), ), True),
        (stk.BuildingBlock('c1ccccc1'), (('C', 'C'), ), True),
        (stk.BuildingBlock('C1CCCCC1'), (('C', 'C'), ), True),
        (cage, (('N', 'N'), ), True),
    ]

    _opt = stko.UFF()
    for i, (mol, pairs, uff_opt) in enumerate(mol_list):
        initial = mol.with_rotation_about_axis(
            1.34, np.array((0, 0, 1)), np.array((0, 0, 0)),
        )
        mol.write(os.path.join(examples_output, f'unaligned_{i}.mol'))
        initial.write(os.path.join(examples_output, f'init_{i}.mol'))
        aligner = stko.Aligner(
            initial_molecule=initial,
            matching_pairs=pairs,
        )
        if uff_opt:
            mol = aligner.optimize(_opt.optimize(mol))
        else:
            mol = aligner.optimize(mol)
        mol.write(os.path.join(examples_output, f'aligned_{i}.mol'))
        rmsd_calculator = stko.RmsdMappedCalculator(initial)
        rmsd = rmsd_calculator.get_results(mol).get_rmsd()
        print(f'molecule {i} RMSD: {rmsd}')
Пример #5
0
def test_UFF_opt(unoptimized_mol):
    optimizer = stko.UFF()
    opt_res = optimizer.optimize(unoptimized_mol)
    is_equivalent_molecule(opt_res, unoptimized_mol)
    inequivalent_position_matrices(opt_res, unoptimized_mol)
Пример #6
0
        rmsd:
            The RMSD of the pair of molecules.

    """

    position_matrix: np.ndarray

    def __init__(self, mol1, mol2, rmsd):

        self.mol1 = mol1
        self.mol2 = mol2
        self.rmsd = rmsd


_optimizer = stko.UFF()
_polymer = stk.ConstructedMolecule(topology_graph=stk.polymer.Linear(
    building_blocks=(
        stk.BuildingBlock(
            smiles='BrCCBr',
            functional_groups=[stk.BromoFactory()],
        ),
        stk.BuildingBlock(
            smiles='BrCNCCBr',
            functional_groups=[stk.BromoFactory()],
        ),
    ),
    repeating_unit='AB',
    num_repeating_units=2,
    optimizer=stk.MCHammer(),
), )