def _generate_conformers(self, n_confs=None): """Generate conformers at the TS """ from autode.conformers.conformer import Conformer from autode.conformers.conf_gen import get_simanl_atoms from autode.conformers.conformers import conf_is_unique_rmsd n_confs = Config.num_conformers if n_confs is None else n_confs self.conformers = [] distance_consts = get_distance_constraints(self) with Pool(processes=Config.n_cores) as pool: results = [ pool.apply_async(get_simanl_atoms, (self, distance_consts, i)) for i in range(n_confs) ] conf_atoms_list = [res.get(timeout=None) for res in results] for i, atoms in enumerate(conf_atoms_list): conf = Conformer(name=f'{self.name}_conf{i}', charge=self.charge, mult=self.mult, atoms=atoms, dist_consts=distance_consts) # If the conformer is unique on an RMSD threshold if conf_is_unique_rmsd(conf, self.conformers): conf.solvent = self.solvent conf.graph = deepcopy(self.graph) self.conformers.append(conf) logger.info(f'Generated {len(self.conformers)} conformer(s)') return None
def test_rmsd_confs(): methane1 = Conformer(name='methane1', charge=0, mult=1, atoms=[ Atom('C', -1.38718, 0.38899, 0.00000), Atom('H', -0.27778, 0.38899, -0.00000), Atom('H', -1.75698, 1.06232, 0.80041), Atom('H', -1.75698, -0.64084, 0.18291), Atom('H', -1.75698, 0.74551, -0.98332) ]) methane2 = Conformer(name='methane2', charge=0, mult=1, atoms=[ Atom('C', -1.38718, 0.38899, 0.00000), Atom('H', -0.43400, 0.50158, -0.55637), Atom('H', -2.23299, 0.69379, -0.64998), Atom('H', -1.36561, 1.03128, 0.90431), Atom('H', -1.51612, -0.67068, 0.30205) ]) # Methane but rotated should have an RMSD ~ 0 Angstroms assert not conf_is_unique_rmsd( conf=methane2, conf_list=[methane1], rmsd_tol=0.1)
def _generate_conformers(self, n_confs=None): """ Use a simulated annealing approach to generate conformers for this molecule. Keyword Arguments: n_confs (int): Number of conformers requested if None default to autode.Config.num_conformers """ n_confs = n_confs if n_confs is not None else Config.num_conformers self.conformers = [] if self.smiles is not None and self.rdkit_conf_gen_is_fine: logger.info(f'Using RDKit to gen conformers. {n_confs} requested') method = AllChem.ETKDGv2() method.pruneRmsThresh = Config.rmsd_threshold method.numThreads = Config.n_cores logger.info( 'Running conformation generation with RDKit... running') conf_ids = list( AllChem.EmbedMultipleConfs(self.rdkit_mol_obj, numConfs=n_confs, params=method)) logger.info(' ... done') conf_atoms_list = [ atoms_from_rdkit_mol(self.rdkit_mol_obj, conf_id) for conf_id in conf_ids ] methods.add('ETKDGv2 algorithm (10.1021/acs.jcim.5b00654) ' f'implemented in RDKit v. {rdkit.__version__}') else: logger.info('Using repulsion+relaxed (RR) to generate conformers') with Pool(processes=Config.n_cores) as pool: results = [ pool.apply_async(get_simanl_atoms, (self, None, i)) for i in range(n_confs) ] conf_atoms_list = [res.get(timeout=None) for res in results] methods.add('RR algorithm (???) implemented in autodE') # Add the unique conformers for i, atoms in enumerate(conf_atoms_list): conf = get_conformer(name=f'{self.name}_conf{i}', species=self) conf.set_atoms(atoms) # If the conformer is unique on an RMSD threshold if conf_is_unique_rmsd(conf, self.conformers): self.conformers.append(conf) logger.info(f'Generated {len(self.conformers)} unique conformer(s)') return None
def _generate_conformers(self, n_confs=None): """ Use a simulated annealing approach to generate conformers for this molecule. Keyword Arguments: n_confs (int): Number of conformers requested if None default to autode.Config.num_conformers """ n_confs = n_confs if n_confs is not None else Config.num_conformers self.conformers = [] if self.smiles is not None and self.rdkit_conf_gen_is_fine: logger.info(f'Using RDKit to gen conformers. {n_confs} requested') method = AllChem.ETKDGv2() method.pruneRmsThresh = Config.rmsd_threshold method.numThreads = Config.n_cores logger.info( 'Running conformation generation with RDKit... running') conf_ids = list( AllChem.EmbedMultipleConfs(self.rdkit_mol_obj, numConfs=n_confs, params=method)) logger.info(' ... done') conf_atoms_list = [ get_atoms_from_rdkit_mol_object(self.rdkit_mol_obj, conf_id) for conf_id in conf_ids ] else: logger.info('Using simulated annealing to generate conformers') with Pool(processes=Config.n_cores) as pool: results = [ pool.apply_async(get_simanl_atoms, (self, None, i)) for i in range(n_confs) ] conf_atoms_list = [res.get(timeout=None) for res in results] for i, atoms in enumerate(conf_atoms_list): conf = Conformer(name=f'{self.name}_conf{i}', charge=self.charge, mult=self.mult, atoms=atoms) # If the conformer is unique on an RMSD threshold if conf_is_unique_rmsd(conf, self.conformers): conf.solvent = self.solvent self.conformers.append(conf) logger.info(f'Generated {len(self.conformers)} unique conformer(s)') return None