Exemplo n.º 1
0
    def mol_to_dict(self, mol):
        """
        Capture all the information from a SureChEMBL molecule into a dictionary

        mol_to_dict( (Surechembl)self, (rdkit.Chem.Mol)mol) -> dict
        """
        props = set(mol.GetPropNames())
        d = {p.lower(): self.cast(mol.GetProp(p)) for p in props}
        d["id"] = "https://www.surechembl.org/chemical/" + mol.GetProp("ID")

        smiles = []
        rdkit_mol = rdkit_standardize(mol)
        rs = rdkit_smiles(rdkit_mol)
        if rs is not None:
            d["rdkit_smiles"] = rs
            smiles.append(rs)

        descs = rdkit_descriptors(rdkit_mol)
        for name in descs:
            d["rdkit_" + name.lower()] = descs[name]

        if smiles:
            d["smiles"] = list(set(smiles))

        return d
Exemplo n.º 2
0
    def mol_to_dict(self, mol):
        """
        Capture all the information from a PubChem molecule into a dictionary

        mol_to_dict( (Pubchem)self, (rdkit.Chem.Mol)mol) -> dict
        """
        props = set(mol.GetPropNames())
        d = {p.lower(): self.cast(mol.GetProp(p)) for p in props}
        d["id"] = "https://pubchem.ncbi.nlm.nih.gov/compound/" + mol.GetProp("PUBCHEM_COMPOUND_CID")

        smiles = [mol.GetProp(p) for p in self.SMILES_PROPS if p in props]
        smiles.append(rdkit_smiles(mol))  # Original SMILES

        if smiles:
            d["smiles"] = list(set(smiles))

        synonyms = [mol.GetProp(p) for p in self.SYNONYM_PROPS if p in props]
        if synonyms:
            d["synonyms"] = list(set(synonyms))

        if "pubchem_compound_canonicalized" in d:
            canon = d["pubchem_compound_canonicalized"]
            if canon == 1:
                d["pubchem_compound_canonicalized"] = True
            elif canon == 0:
                d["pubchem_compound_canonicalized"] = False
            else:
                del d["pubchem_compound_canonicalized"]

        rdkit_mol = rdkit_standardize(mol)
        rs = rdkit_smiles(rdkit_mol)
        if rs is not None:
            d["rdkit_smiles"] = rs
            smiles.append(rs)

        descs = rdkit_descriptors(rdkit_mol)
        for name in descs:
            d["rdkit_" + name.lower()] = descs[name]

        return d