def initialize_system(dt=0.001, temperature=100, forcefield_file='forcefield/smirnoff99Frosst.offxml', smiles="C1CCCCC1"): mol = OEMol() # OEParseSmiles(mol, 'CCOCCSCC') # OEParseSmiles(mol, 'c1ccccc1') OEParseSmiles(mol, smiles) # OEParseSmiles(mol, 'C([C@@H]1[C@H]([C@@H]([C@H](C(O1)O)O)O)O)O') OEAddExplicitHydrogens(mol) masses = get_masses(mol) num_atoms = mol.NumAtoms() topology = generateTopologyFromOEMol(mol) ff = ForceField(get_data_filename(forcefield_file)) nrgs, total_params, offsets = system_builder.construct_energies( ff, mol, False) # dt = 0.0025 # friction = 10.0 # temperature = 300 # gradient descent dt = dt friction = 10.0 temperature = temperature a, b, c = get_abc_coefficents(masses, dt, friction, temperature) buf_size = estimate_buffer_size(1e-10, a) print("BUFFER SIZE", buf_size) omegaOpts = oeomega.OEOmegaOptions() omegaOpts.SetMaxConfs(1) omega = oeomega.OEOmega(omegaOpts) omega.SetStrictStereo(False) if not omega(mol): assert 0 x0 = mol_coords_to_numpy_array(mol) / 10 intg = custom_ops.Integrator_double(dt, buf_size, num_atoms, total_params, a, b, c) context = custom_ops.Context_double(nrgs, intg) x0 = minimizer.minimize_newton_cg(nrgs, x0, total_params) return nrgs, offsets, intg, context, x0, total_params
def size_and_wbo_fingerprint(mol: oechem.OEMol): """Fingerprint with number of atoms in the mol and WBO between central atoms in the t142 param. (WBO is Wiberg Bond Order.) Note: The indices are the same in OpenEye and OFF molecules, so the parameter indices are correct, even though they were calculated for the OFF mol. """ oechem.OEAddExplicitHydrogens(mol) params = smirnoff_param_utils.read_params_from_mol(mol) return ( mol.NumAtoms(), smirnoff_param_utils.calculate_t142_central_wbo(mol, params), )
def initialize(input_smiles, gp): train_reference_args = [] train_args = [] train_offset_idxs = [] train_charge_idxs = [] for smi_idx, smiles in enumerate(input_smiles): print("processing", smiles, smi_idx, "/", len(input_smiles)) mol = OEMol() OEParseSmiles(mol, smiles) OEAddExplicitHydrogens(mol) masses = get_masses(mol) num_atoms = mol.NumAtoms() omegaOpts = oeomega.OEOmegaOptions() omegaOpts.SetMaxConfs(1) omega = oeomega.OEOmega(omegaOpts) omega.SetStrictStereo(False) if not omega(mol): assert 0 topology = generateTopologyFromOEMol(mol) reference_forcefield_file = 'forcefield/smirnoff99Frosst_perturbed.offxml' ff = ForceField(get_data_filename(reference_forcefield_file)) params = system_builder.construct_energies(ff, mol, True) train_reference_args.append((params[0], params[1], masses, mol)) params = system_builder.construct_energies(ff, mol, False) # global_params = args[0] # nrg_params = args[1] # total_params = args[2] # masses = args[3] # mol = args[4] # charge_idxs = args[5] train_args.append((gp, params[0], params[1], masses, mol, params[3])) train_offset_idxs.append(params[2]) train_charge_idxs.append(params[3]) label_confs = [generate_conformations(a) for a in train_reference_args] return train_args, train_offset_idxs, train_charge_idxs, label_confs
def __init__(self, mol: oechem.OEMol): """ mol (oechem.OEMol): OEMol object """ self.num_atoms = mol.NumAtoms() self.adj_mat = self._get_adjacency_matrix(mol)