Beispiel #1
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
Beispiel #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)
    
    rot_bonds = len(RotatableBonds(qmmol.initial_conformer.get_rdkit_mol()))
    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()))
    
    try:
        low_energy_conf = qmmol.nlowest(1)[0]
        conf_smi = Chem.MolToSmiles(Chem.RemoveHs(low_energy_conf.get_rdkit_mol()))
    except:
        conf_smi = 'wrong'

    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