def getFromPathList(self, pathList, use3D=True, coordType="model", setTitle=True): """ Return a list of OE mols constructed from the input pathList of chemical definitions. """ oemList = [] try: for pth in pathList: myReader = PdbxIoAdapter(self.__verbose, self.__lfh) ok = myReader.read(pdbxFilePath=pth) # noqa: F841 pylint: disable=unused-variable for container in myReader.getContainerList(): oem = OeBuildMol(verbose=self.__verbose, log=self.__lfh) oem.setDebug(self.__debug) oem.set(container.getName(), dcChemCompAtom=container.getObj("chem_comp_atom"), dcChemCompBond=container.getObj("chem_comp_bond")) if use3D: oem.build3D(coordType=coordType, setTitle=setTitle) else: oem.build2D(setTitle=setTitle) # oemList.append(oem) # if self.__debug: self.__lfh.write( "+OeChemCompIoUtils.getOeMols() Title = %s\n" % oem.getTitle()) self.__lfh.write( "+OeChemCompIoUtils.getOeMols() SMILES (canonical) = %s\n" % oem.getCanSMILES()) self.__lfh.write( "+OeChemCompIoUtils.getOeMols() SMILES (isomeric) = %s\n" % oem.getIsoSMILES()) except Exception as e: if self.__verbose: self.__lfh.write("+OeChemCompIoUtils.getOeMols() Failed %s\n" % str(e)) traceback.print_exc(file=self.__lfh) return oemList
def testSerialize2D(self): """Test case - build OE molecule using 2D data in the definition source data file then serialize and deserialize this molecule. """ self.__lfh.write("\nStarting OeBuildMolTests testSerialize2D\n") try: oem = OeBuildMol(verbose=self.__verbose, log=self.__lfh) oem.setDebug(True) for pth in self.__pathList: myReader = PdbxIoAdapter(self.__verbose, self.__lfh) ok = myReader.read(pdbxFilePath=pth) myReader.write( pdbxFilePath=os.path.join(self.__testoutput, "TMP.cif")) for container in myReader.getContainerList(): oem.set(container.getName(), dcChemCompAtom=container.getObj("chem_comp_atom"), dcChemCompBond=container.getObj("chem_comp_bond")) oem.build2D() self.__lfh.write("Title = %s\n" % oem.getTitle()) self.__lfh.write("SMILES (canonical) = %s\n" % oem.getCanSMILES()) self.__lfh.write("SMILES (isomeric) = %s\n" % oem.getIsoSMILES()) oeS = oem.serialize() # self.__lfh.write("Serialized string length = %d\n" % len(oeS)) # oemD = OeBuildMol(verbose=self.__verbose, log=self.__lfh) ok = oemD.deserialize(oeS) self.__lfh.write("Deserialized status = %s\n" % ok) self.__lfh.write("Deserialized SMILES (canonical) = %s\n" % oemD.getCanSMILES()) self.__lfh.write("Deserialized SMILES (isomeric) = %s\n" % oemD.getIsoSMILES()) except: # noqa: E722 pylint: disable=bare-except traceback.print_exc(file=self.__lfh) self.fail()