Пример #1
0
 def toMolFile(self,
               identifier,
               identifierType,
               molfilePath=None,
               fmt="mol",
               **kwargs):
     """Create molfile (fmt) from InChI, SMILES descriptors or PDB identifier."""
     try:
         molfilePath = molfilePath if molfilePath else self.__makeMolfilePath(
             fmt=fmt)
         oeio = OeIoUtils()
         if identifierType.lower() in ["smiles"]:
             oeMol = oeio.smilesToMol(identifier)
             oeMol.SetTitle("From SMILES")
         elif identifierType.lower() in ["inchi"]:
             oeMol = oeio.inchiToMol(identifier)
             oeMol.SetTitle("From InChI")
         elif identifierType.lower() in ["identifierpdb"]:
             ccsw = ChemCompSearchWrapper()
             oesmP = ccsw.getSearchMoleculeProvider()
             oeMol = oesmP.getMol(identifier)
         #
         ok = self.__toMolFile(oeMol, molfilePath, **kwargs)
         return molfilePath if ok else None
     except Exception as e:
         logger.exception("Failing with %s", str(e))
     return None
Пример #2
0
    def alignMoleculePair(self,
                          refIdentifier,
                          refIdentifierType,
                          fitIdentifier,
                          fitIdentifierType,
                          imagePath=None,
                          **kwargs):
        """Create aligned depiction for a target molecule InChI, SMILES descriptors or PDB identifier."""
        try:
            imagePath = imagePath if imagePath else self.__makeImagePath()
            oeio = OeIoUtils()
            ccsw = ChemCompSearchWrapper()
            oesmP = ccsw.getSearchMoleculeProvider()
            # ---
            if refIdentifierType.lower() in ["smiles"]:
                oeMolRef = oeio.smilesToMol(refIdentifier)
            elif refIdentifierType.lower() in ["inchi"]:
                oeMolRef = oeio.inchiToMol(refIdentifier)
            elif refIdentifierType.lower() in ["identifierpdb"]:
                oeMolRef = oesmP.getMol(refIdentifier)
            #
            if fitIdentifierType.lower() in ["smiles"]:
                oeMolFit = oeio.smilesToMol(fitIdentifier)
            elif fitIdentifierType.lower() in ["inchi"]:
                oeMolFit = oeio.inchiToMol(fitIdentifier)
            elif fitIdentifierType.lower() in ["identifierpdb"]:
                oeMolFit = oesmP.getMol(fitIdentifier)
            # ---
            logger.info("oeMolRef atoms %r", oeMolRef.NumAtoms())
            logger.info("oeMolFit atoms %r", oeMolFit.NumAtoms())

            displayIdRef = "Ref"
            displayIdFit = "Fit"
            ok = self.__depictAlignedPair(oeMolRef, displayIdRef, oeMolFit,
                                          displayIdFit, imagePath, **kwargs)
            return imagePath if ok else None
        except Exception as e:
            logger.exception("Failing with %s", str(e))
        return None
Пример #3
0
 def depictMolecule(self,
                    identifier,
                    identifierType,
                    imagePath=None,
                    **kwargs):
     """Create depiction from InChI, SMILES descriptors or PDB identifier."""
     try:
         imagePath = imagePath if imagePath else self.__makeImagePath()
         oeio = OeIoUtils()
         if identifierType.lower() in ["smiles"]:
             oeMol = oeio.smilesToMol(identifier)
         elif identifierType.lower() in ["inchi"]:
             oeMol = oeio.inchiToMol(identifier)
         elif identifierType.lower() in ["identifierpdb"]:
             ccsw = ChemCompSearchWrapper()
             oesmP = ccsw.getSearchMoleculeProvider()
             oeMol = oesmP.getMol(identifier)
         #
         ok = self.__depictOne(oeMol, imagePath, **kwargs)
         return imagePath if ok else None
     except Exception as e:
         logger.exception("Failing with %s", str(e))
     return None