def test_overlay_molecules(reference_smiles, fit_smiles, comparator): """Compare results to have a TanimotoCombo score bigger or smaller than 1.""" reference_molecule = read_smiles(reference_smiles) reference_molecule = generate_conformations(reference_molecule, max_conformations=1) fit_molecule = read_smiles(fit_smiles) fit_molecule = generate_conformations(fit_molecule, max_conformations=10) score, overlay = overlay_molecules(reference_molecule, fit_molecule) if comparator == ">": assert score > 1 elif comparator == "<": assert score < 1 else: raise ValueError( "Wrong comparator provided. Only '<' and '>' are allowed.")
def test_generate_reasonable_conformations(smiles, n_conformations_list): """Compare results to expected number of isomers and conformations.""" molecule = read_smiles(smiles) conformations_ensemble = generate_reasonable_conformations( molecule, max_conformations=5) assert len(conformations_ensemble) == len(n_conformations_list) for conformations, n_conformations in zip(conformations_ensemble, n_conformations_list): assert conformations.NumConfs() == n_conformations
def test_read_smiles(smiles, add_hydrogens, expectation, n_atoms): """Compare results to expected number of atoms.""" with expectation: molecule = read_smiles(smiles, add_hydrogens) assert molecule.NumAtoms() == n_atoms
def test_are_identical_molecules(smiles1, smiles2, identical_molecules): """Compare results to expected molecular identity.""" molecule1 = read_smiles(smiles1) molecule2 = read_smiles(smiles2) assert are_identical_molecules(molecule1, molecule2) == identical_molecules
def test_enumerate_isomeric_smiles(smiles, n_smiles): """Compare results to expected number of generated isomeric SMILES strings.""" molecule = read_smiles(smiles) isomeric_smiles_representations = enumerate_isomeric_smiles(molecule) assert len(isomeric_smiles_representations) == n_smiles
def test_generate_conformations(smiles, n_conformations): """Compare results to expected number of conformations.""" molecule = read_smiles(smiles) conformations = generate_conformations(molecule, max_conformations=5) assert conformations.NumConfs() == n_conformations
def test_generate_enantiomers(smiles, n_enantiomers): """Compare results to expected number of enantiomers.""" molecule = read_smiles(smiles) enantiomers = generate_enantiomers(molecule) assert len(enantiomers) == n_enantiomers
def test_generate_tautomers(smiles, n_tautomers): """Compare results to expected number of tautomers.""" molecule = read_smiles(smiles) tautomers = generate_tautomers(molecule) assert len(tautomers) == n_tautomers
0, ), ], ) def test_read_electron_density(package, resource, expectation, n_grid_points): """Compare results to expected number of grip points in the interpreted electron density.""" with resources.path(package, resource) as path: with expectation: electron_density = read_electron_density(path) assert electron_density.GetSize() == n_grid_points @pytest.mark.parametrize( "molecules, suffix, n_atoms_list", [ ([read_smiles("CCC")], ".sdf", [11]), ([read_smiles("CCC")], ".pdb", [11]), ([read_smiles("COCC"), read_smiles("cccccc")], ".sdf", [12, 14]), ([read_smiles("CCC"), read_smiles("cccccc")], ".pdb", [11, 14]), ], ) def test_write_molecules(molecules, suffix, n_atoms_list): """Compare results to expected number of molecules and atoms in the written file.""" import tempfile def _count_molecules(path): with open(path) as rf: if path.split(".")[-1] == "sdf": return rf.read().count("\n$$$$\n") elif path.split(".")[-1] == "pdb": return rf.read().count("\nEND\n")