def test_ETKDG_opt(unoptimized_mol):
    optimizer = stko.ETKDG()
    opt_res = optimizer.optimize(unoptimized_mol)
    is_equivalent_molecule(opt_res, unoptimized_mol)
    inequivalent_position_matrices(opt_res, unoptimized_mol)

    optimizer = stko.ETKDG(random_seed=2584)
    opt_res = optimizer.optimize(unoptimized_mol)
    is_equivalent_molecule(opt_res, unoptimized_mol)
    inequivalent_position_matrices(opt_res, unoptimized_mol)
def test_ETKDG_opt(case_etkdg_molecule):
    optimizer = stko.ETKDG()
    opt_res = optimizer.optimize(case_etkdg_molecule)
    is_equivalent_molecule(opt_res, case_etkdg_molecule)
    inequivalent_position_matrices(opt_res, case_etkdg_molecule)

    optimizer = stko.ETKDG(random_seed=2584)
    opt_res = optimizer.optimize(case_etkdg_molecule)
    is_equivalent_molecule(opt_res, case_etkdg_molecule)
    inequivalent_position_matrices(opt_res, case_etkdg_molecule)
Exemple #3
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')
def test_fake_opt(benzene_build):

    # Perform optimisation.
    optimizer = stko.ETKDG()
    opt_benzene = optimizer.optimize(benzene_build)

    compare_benzenes(
        initial_molecule=benzene_build,
        optimized_molecule=opt_benzene,
    )
Exemple #5
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)
def build_guests():

    guest_smiles = {
        'oF': 'C1=CC=C(C(=C1)C=O)F',
        'oB': 'C1=CC=C(C(=C1)C=O)Br',
        'oC': 'C1=CC=C(C(=C1)C=O)Cl',
        'pF': 'C1=CC(=CC=C1C=O)F',
        'pB': 'C1=CC(=CC=C1C=O)Br',
        'pC': 'C1=CC(=CC=C1C=O)Cl',
        'mF': 'C1=CC(=CC(=C1)F)C=O',
        'mB': 'C1=CC(=CC(=C1)Br)C=O',
        'mC': 'C1=CC(=CC(=C1)Cl)C=O',
    }

    guests = {}
    for guest in guest_smiles:
        opt_file = f'{guest}_unopt.mol'

        if exists(opt_file):
            guests[guest] = stk.BuildingBlock.init_from_file(opt_file)
        else:
            print(f'>> optimising {guest}')
            # Build BuildingBlocks.
            molecule = stk.BuildingBlock(guest_smiles[guest])

            # Optimise with ETKDG.
            etkdg = stko.ETKDG()
            molecule = etkdg.optimize(molecule)

            # Save file.
            molecule.write(opt_file)

            # Initialise as building block.
            guests[guest] = stk.BuildingBlock.init_from_molecule(
                molecule=molecule, )

    return guests
Exemple #7
0
def build_linker(lig1_smiles, lig2_smiles, linker_smiles, name):
    """
    Build a linker from 3 components.

    Parameters
    ----------
    lig1_smiles : :class:`str`
        SMILES string representing ligand component.

    lig2_smiles : :class:`str`
        SMILES string representing ligand component.

    linker_smiles : :class:`str`
        SMILES string representing linker component.

    name : :class:`str`
        Identifier for ligand.

    Returns
    -------
    :class:`stk.BuildingBlock`
        Building block constructed from ligand components with
        functional groups assigned.

    """

    opt_file = f'{name}_opt.mol'

    # Build polymer if not already done.
    if exists(opt_file):
        molecule = stk.BuildingBlock.init_from_file(
            path=opt_file,
            functional_groups=[AromaticCNCFactory(),
                               AromaticCNNFactory()],
        )
    else:
        print(f'>> building {name}')
        # Build BuildingBlocks.
        lig1 = stk.BuildingBlock(lig1_smiles, [stk.BromoFactory()])
        lig2 = stk.BuildingBlock(lig2_smiles, [stk.BromoFactory()])
        link = stk.BuildingBlock(linker_smiles, [stk.BromoFactory()])

        # Build polymer.
        molecule = stk.ConstructedMolecule(
            topology_graph=stk.polymer.Linear(building_blocks=(lig1, link,
                                                               lig2),
                                              repeating_unit='ABC',
                                              num_repeating_units=1,
                                              orientations=(0, 0, 0),
                                              num_processes=1))

        # Optimise with ETKDG.
        etkdg = stko.ETKDG()
        molecule = etkdg.optimize(molecule)

        # Initialise as building block.
        molecule = stk.BuildingBlock.init_from_molecule(
            molecule=molecule,
            functional_groups=[
                AromaticCNCFactory(),
                AromaticCNNFactory(),
            ],
        )
        # Save file.
        molecule.write(opt_file)

    return molecule