コード例 #1
0
    for x in df.itertuples():
        name = str(x.reac.label.split('_r')[0])
        mol = x.prod.get_rdkit_mol()

        xcontrol_name = name + "_xcontrol"
        create_xcontrol(mol, xcontrol_name)

        n = name + "_ts"

        ts_scan(x.prod, n, charge, mult, xcontrol_name)

        with open(n + "_xtbscan.log", 'r') as out:
            output = out.read()

        print(output)
        ts_qmmol = QMMol()

        xyz_file = ts_scan_xtb.read_ts_guess_structure2(output)
        ts_qmmol.add_conformer(input_mol=xyz_file,
                               fmt='xyz',
                               label=n,
                               charge=charge,
                               multiplicity=mult,
                               read_freq=False,
                               charged_fragments=True)
        ts_conf = ts_qmmol.conformers[0]

        ts_conf.results['energy'] = ts_scan_xtb.read_ts_guess_energy(output)[0]

        #print(ts_conf.results['energy'])
        reac_qmconf = x.reac
コード例 #2
0
def gs_conformer_search(name, rdkit_conf, chrg, mult, cpus):
    """ ground state conformer search """
    
    charged = True # hard coded for mogens
    
    # create conformers
    qmmol = QMMol()
    qmmol.add_conformer(rdkit_conf, fmt='rdkit', label=name,
                       charged_fragments=charged, set_initial=True)

    # find #-- rot bond.
    mol = qmmol.get_rdkit_mol()
    triple_smart = '[c]:[c]-[CH0]#[CH0]'
    extra_rot_bond = int(len(mol.GetSubstructMatches(Chem.MolFromSmarts(triple_smart))) / 2)

    # print compute number of conformers to find
    rot_bonds = len(RotatableBonds(qmmol.initial_conformer.get_rdkit_mol())) + extra_rot_bond
    num_confs = 5 + 5*rot_bonds
    qmmol.create_random_conformers(threads=cpus, num_confs=num_confs)

    xtb_params = {'method': 'gfn2',
                  'opt': 'opt',
                  'cpus': 1}

    qmmol.calc = xTB(parameters=xtb_params)
    qmmol.optimize(num_procs=cpus, keep_files=False)

    # Get most stable conformer. If most stable conformer
    # not identical to initial conf try second lowest.
    initial_smi = Chem.MolToSmiles(Chem.RemoveHs(qmmol.initial_conformer.get_rdkit_mol()))
    low_energy_conf = qmmol.nlowest(1)[0]
    conf_smi = Chem.MolToSmiles(Chem.RemoveHs(low_energy_conf.get_rdkit_mol()))

    i = 1
    while initial_smi != conf_smi:
        low_energy_conf = qmmol.nlowest(i+1)[-1]
        conf_smi = Chem.MolToSmiles(Chem.RemoveHs(low_energy_conf.get_rdkit_mol()))
        i += 1
        
        if len(qmmol.conformers) < i:
            sys.exit('no conformers match the initial input')

    return low_energy_conf