def template_sdf(smiles, distance_cutoff_1, distance_cutoff_2): """Create a template sdf string and writes it to file. Args(required): smiles (str): one-line representation of the molecule Args(optional): distance_cutoff_1 (float): min distance between non-bonded atoms [A] distance_cutoff_2 (float): max distance between bonded atoms [A] Returns: sdf string """ cnt = 0 sdf_check = True while sdf_check: mol = Chem.MolFromSmiles(smiles) mol = Chem.AddHs(mol) AllChem.EmbedMolecule(mol) AllChem.UFFOptimizeMolecule(mol) Chem.SDWriter('mol.sdf').write(mol) sdf_string = Chem.MolToMolBlock(mol) check = check_geo_sdf(sdf_string, distance_cutoff_1, distance_cutoff_2) if check: sdf_check = False Chem.SDWriter('mol.sdf').write(mol) else: cnt += 1 return sdf_string
def is_geometry_valid(self): """Return True if the geometry is valid.""" check = check_geo_sdf(self.sdf_string, self.mol_info.distance_cutoff_1, self.mol_info.distance_cutoff_2) return check