def test_parity_method(id_1, id_2, score): c1 = ccd_reader.read_pdb_cif_file(cif_filename(id_1)).component c2 = ccd_reader.read_pdb_cif_file(cif_filename(id_2)).component parity = compare_molecules(c1.mol, c2.mol) assert round(parity.similarity_score, 2) == score
def test_scaffold_absent(ccd_id): component = ccd_reader.read_pdb_cif_file( cif_filename(ccd_id)).component result = component.get_scaffolds() assert result[0].GetNumAtoms() == 0 assert not component.scaffolds
def test_unichem_download(het_code): c = ccd_reader.read_pdb_cif_file(cif_filename(het_code)).component c.fetch_external_mappings() assert len(c.external_mappings) > 0 c.fetch_external_mappings(True) assert len(c.external_mappings) > 0
def test_scaffold_present(ccd_id, smiles): component = ccd_reader.read_pdb_cif_file( cif_filename(ccd_id)).component result = component.get_scaffolds() mol = result[0] assert Chem.MolToSmiles(mol) == smiles assert component.scaffolds assert component.scaffolds[0].smiles == smiles
def test_components_layouts_updated(tmpdir, het_code): dl = PubChemDownloader(tmpdir) to_download = os.path.join(tmpdir, f'{het_code}.sdf') dl.update_ccd_file(cif_filename(het_code)) mol = Chem.MolFromMolFile(to_download) assert os.path.isfile(to_download) assert os.path.getsize(to_download) > 0 assert isinstance(mol, Chem.Mol) assert mol.GetNumAtoms() > 0
def test_components_layouts_downloaded(tmpdir, het_code): dl = PubChemDownloader(tmpdir) to_download = os.path.join(tmpdir, f'{het_code}.sdf') comp = ccd_reader.read_pdb_cif_file(cif_filename(het_code)).component dl.process_template(comp) assert os.path.isfile(to_download) assert os.path.getsize(to_download) > 0 assert comp.mol_no_h.HasSubstructMatch( Chem.MolFromMolFile(to_download, sanitize=True))
def test_valid_properties(key): physchem_props = ccd_reader.read_pdb_cif_file( cif_filename(key)).component.physchem_properties assert test_inputs[key]["logp"] == round( physchem_props["CrippenClogP"], 3) assert test_inputs[key]["heavy_atom_count"] == physchem_props[ "NumHeavyAtoms"] assert test_inputs[key]["numH_acceptors"] == physchem_props["NumHBA"] assert test_inputs[key]["numH_donors"] == physchem_props["NumHBD"] assert (test_inputs[key]["num_rotable_bonds"] == physchem_props["NumRotatableBonds"]) assert test_inputs[key]["rings_count"] == physchem_props["NumRings"] assert test_inputs[key]["TPSA"] == round(physchem_props["tpsa"], 3) assert test_inputs[key]["molwt"] == round(physchem_props["exactmw"], 3)
def component_eoh(): """ loads PDB-CCD for ethanol eoh.cif and returns the component object Returns: pdbeccdutils.core.component.Component: component object for eoh.cif """ cif_file = cif_filename('EOH') reader = ccd_reader.read_pdb_cif_file(cif_file) assert reader.warnings == [] assert reader.errors == [] component = reader.component return component
def test_with_problematic_cif_7om(tmpdir): """ 7OM caused problems because it lacks an inchikey and this used to cause a crash """ cif_file = cif_filename('7OM') test_output_dir = tmpdir.mkdir('test_process_components_cif_70M') parser = create_parser() args = parser.parse_args([cif_file, '-o', str(test_output_dir)]) m = PDBeChemManager() m.run_pipeline(args) assert os.path.isdir( test_output_dir ), f'output directory {str(test_output_dir)} must be created'
def test_invalid_properties(key): physchem_props = ccd_reader.read_pdb_cif_file( cif_filename(key)).component.physchem_properties assert physchem_props == {}
def load_molecule(id_): c = ccd_reader.read_pdb_cif_file(cif_filename(id_)).component c.compute_2d(depictions) return c
def test_scaffolds(scaffold_type): c = ccd_reader.read_pdb_cif_file(cif_filename("NAG")).component c.get_scaffolds(scaffold_type) assert len(c.scaffolds) > 0