def AddCategory(self, categoryID, items): """Add Category""" category = DataCategory(categoryID) for item in items: category.appendAttribute(item) # self.__container.append(category)
def test_basic_unicode(self, category_data): dcA = DataCategory('A', category_data['attributeList'], category_data['rowListUnicode']) dcB = DataCategory('A', category_data['attributeList'], category_data['rowListUnicode']) assert dcA == dcA assert dcB == dcB assert dcA == dcB
def test_basic_ascii(self, category_data): dcA = DataCategory('A', category_data['attributeList'], category_data['rowListAsciiA']) dcB = DataCategory('A', category_data['attributeList'], category_data['rowListAsciiA']) assert dcA == dcA assert dcB == dcB assert dcA == dcB
def testGetValues(self): """Test case - value getters""" try: dcU = DataCategory("A", self.__attributeList, self.__rowListUnicode) aL = dcU.getAttributeList() logger.debug("Row length %r", dcU.getRowCount()) for ii, v in enumerate(self.__testRowUnicode): at = aL[ii + 1] for j in range(0, dcU.getRowCount()): logger.debug("ii %d j %d at %s val %r ", ii, j, at, v) self.assertEqual(dcU.getValue(at, j), v) self.assertEqual(dcU.getValueOrDefault(at, j, "mydefault"), v) # # negative indices are interpreted in the python manner self.assertEqual(dcU.getValueOrDefault("colOrd", -1, "default"), 9) self.assertRaises(IndexError, dcU.getValue, "colOrd", dcU.getRowCount() + 1) self.assertRaises(ValueError, dcU.getValue, "badAtt", 0) # except Exception as e: logger.exception("Failing with %s", str(e)) self.fail()
def testBasicAscii(self): """Test case - subcclass instantiation with ascii data""" try: dcA = DataCategory("A", self.__attributeList, self.__rowListAsciiA) dcB = DataCategory("A", self.__attributeList, self.__rowListAsciiA) self.assertEqual(dcA, dcA) self.assertEqual(dcB, dcB) self.assertEqual(dcA, dcB) except Exception as e: logger.exception("Failing with %s", str(e)) self.fail()
def add_category(self, category_id, items): """ This method creates a data category object, adds all items to it and appends it to the container :param category_id: a string; an mmcif category e.g. 'emd_admin' :param items: a list of strings; each element in the list is an item of mmcif category as defined by category_id :return: a list of strings; each element represents a value for the corresponding element in data_items """ category = DataCategory(category_id) for item in items: category.appendAttribute(item) self.__container.append(category)
def test_get_select_values(self, category_data): dcU = DataCategory('A', category_data['attributeListMiss'], category_data['rowListUnicodeMiss']) # assert dcU.getFirstValueOrDefault( ['colNone', 'colM1', 'colM2', 'colC'], rowIndex=0, defaultValue='default' ) == u'abcdĆćĈĉĊċČÄ�ÄŽÄ�Ä�đĒēĔĕĖėĘęĚěĜÄ�ÄžÄŸÄ Ä¡Ä¢Ä£Ä¤Ä¥Ä¦Ä§Ä¨xyz' assert dcU.getFirstValueOrDefault(['colNone', 'colM1', 'colM2'], rowIndex=0, defaultValue='default') == 'default'
def invokeMethods(self, fh=sys.stdout): _ = fh mI = self.__dApi.getMethodIndex() lenD = len(mI) i = 0 for k, mRefL in mI.items(): for mRef in mRefL: i += 1 mId = mRef.getId() mType = mRef.getType() categoryName = mRef.getCategoryName() attributeName = mRef.getAttributeName() # logger.debug("\n") logger.debug("++++++++++++++++++--------------------\n") logger.debug( "Invoking dictionary method on file object: %s (%d/%d)", k, i, lenD) logger.debug(" + Method id: %s", mId) logger.debug(" + Type: %s", mType) logger.debug(" + Category: %s", categoryName) logger.debug(" + Attribute: %s", attributeName) # if mType == "datablock": logger.debug("Invoke datablock method %s", mId) # self.invokeDataBlockMethod(type,self.__dApi.getMethod(id)) # continue # for db in self.__dataContainerList: if mType == "category": if not db.exists(categoryName): dc = DataCategory(categoryName) db.append(dc) dObj = db.getObj(categoryName) dObj.invokeCategoryMethod(mType, self.__dApi.getMethod(mId), db) elif mType == "attribute": if not db.exists(categoryName): dc = DataCategory(categoryName) db.append(dc) dObj = db.getObj(categoryName) # logger.debug("invoke - %r %r %r %r" % (attributeName, type, self.__dApi.getMethod(id), db)) dObj.invokeAttributeMethod(attributeName, mType, self.__dApi.getMethod(mId), db) elif mType == "datablock": logger.debug("Invoke datablock method %s", mId) db.invokeDataBlockMethod(mType, self.__dApi.getMethod(mId), db) else: pass
def testBasicAsciiDiff(self): """Test case - __eq__ and __ne__ methods""" try: dcA = DataCategory("A", self.__attributeList, self.__rowListAsciiA) dcB = DataCategory("A", self.__attributeList, self.__rowListAsciiB) self.assertEqual(dcA, dcA) self.assertIs(dcA, dcA) self.assertEqual(dcB, dcB) self.assertNotEqual(dcA, dcB) self.assertIsNot(dcA, dcB) except Exception as e: logger.exception("Failing with %s", str(e)) self.fail()
def testBasicUnicode(self): """Test case - __eq__ and __ne__ methods w/ unicode""" try: dcA = DataCategory("A", self.__attributeList, self.__rowListUnicode) dcB = DataCategory("A", self.__attributeList, self.__rowListUnicode) self.assertEqual(dcA, dcA) self.assertEqual(dcB, dcB) self.assertEqual(dcA, dcB) except Exception as e: logger.exception("Failing with %s", str(e)) self.fail()
def testEditRowAccessors(self): """Test case - row accessors""" try: # dcA = DataCategory("A", self.__attributeList, self.__rowListAsciiA) self.assertRaises(IndexError, dcA.getRow, dcA.getRowCount() + 1) self.assertRaises(IndexError, dcA.getRowAttributeDict, dcA.getRowCount() + 1) self.assertRaises(IndexError, dcA.getRowItemDict, dcA.getRowCount() + 1) # except Exception as e: logger.exception("Failing with %s", str(e)) self.fail()
def test_set_values(self, category_data): dcU = DataCategory('A', category_data['attributeListMiss'], category_data['rowListUnicodeMiss']) for i in range(0, dcU.getRowCount()): dcU.setValue('newValue', attributeName='colM1', rowIndex=i) assert dcU.setValue('newValue', attributeName='colM1', rowIndex=dcU.getRowCount() + 5) with pytest.raises(ValueError): dcU.setValue('newValue', 'colX', 0)
def testRowDictInitialization(self): """Test case - Row dictionary initialization of a data category and data block """ try: # rLen = 10 fn = self.__pathOutputFile5 attributeNameList = ["a", "b", "c", "d"] rowList = [{"a": 1, "b": 2, "c": 3, "d": 4} for i in range(rLen)] nameCat = "myCategory" # # curContainer = DataContainer("myblock") aCat = DataCategory(nameCat, attributeNameList, rowList) aCat.append({"a": 1, "b": 2, "c": 3, "d": 4}) aCat.append({"a": 1, "b": 2, "c": 3, "d": 4}) aCat.extend(rowList) curContainer.append(aCat) aCat.renameAttributes({"a": "aa", "b": "bb", "c": "cc", "d": "dd"}) aCat.setName("renamedCategory") # # myContainerList = [] myContainerList.append(curContainer) ofh = open(fn, "w") pdbxW = PdbxWriter(ofh) pdbxW.write(myContainerList) ofh.close() myContainerList = [] ifh = open(fn, "r") pRd = PdbxReader(ifh) pRd.read(myContainerList) ifh.close() for container in myContainerList: for objName in container.getObjNameList(): name, aList, rList = container.getObj(objName).get() logger.debug("Recovered data category %s", name) logger.debug("Attribute list %r", repr(aList)) logger.debug("Row list %r", repr(rList)) self.assertEqual(len(myContainerList), 1) self.assertEqual(len(rList), 2 * rLen + 2) except Exception as e: logger.exception("Failing with %s", str(e)) self.fail()
def test_edit_remove_row(self, category_data): dcA = DataCategory('A', category_data['attributeList'], category_data['rowListUnicode'], raiseExceptions=True) for jj in range(0, dcA.getRowCount()): ii = dcA.getRowCount() dcA.removeRow(0) assert ii - 1 == dcA.getRowCount() # assert 0 == dcA.getRowCount()
def testGetSelectValues(self): """Test case - value selectors""" try: dcU = DataCategory("A", self.__attributeListMiss, self.__rowListUnicodeMiss) # self.assertEqual( dcU.getFirstValueOrDefault( ["colNone", "colM1", "colM2", "colC"], rowIndex=0, defaultValue="default"), u"abcdĆćĈĉĊċČčĎďĐđĒēĔĕĖėĘęĚěĜĝĞğĠġĢģĤĥĦħĨxyz") self.assertEqual( dcU.getFirstValueOrDefault(["colNone", "colM1", "colM2"], rowIndex=0, defaultValue="default"), "default") except Exception as e: logger.exception("Failing with %s", str(e)) self.fail()
def test_edit_extend(self, category_data): dcA = DataCategory('A', category_data['attributeList'], category_data['rowListAsciiA']) na = len(dcA.getAttributeList()) assert dcA.appendAttributeExtendRows('colNew') == na + 1 row = dcA.getRow(dcA.getRowCount() - 1) assert row[na] == "?"
def testRowListInitialization(self): """Test case - Row list initialization of a data category and data block""" try: # fn = self.__pathOutputFile4 attributeNameList = [ "aOne", "aTwo", "aThree", "aFour", "aFive", "aSix", "aSeven", "aEight", "aNine", "aTen" ] rowList = [ [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], ] nameCat = "myCategory" # # curContainer = DataContainer("myblock") aCat = DataCategory(nameCat, attributeNameList, rowList) # aCat.printIt() curContainer.append(aCat) # curContainer.printIt() # myContainerList = [] myContainerList.append(curContainer) ofh = open(fn, "w") pdbxW = PdbxWriter(ofh) pdbxW.write(myContainerList) ofh.close() myContainerList = [] ifh = open(fn, "r") pRd = PdbxReader(ifh) pRd.read(myContainerList) ifh.close() for container in myContainerList: for objName in container.getObjNameList(): name, aList, rList = container.getObj(objName).get() logger.debug("Recovered data category %s", name) logger.debug("Attribute list %r", repr(aList)) logger.debug("Row list %r", repr(rList)) self.assertEqual(len(myContainerList), 1) except Exception as e: logger.exception("Failing with %s", str(e)) self.fail()
def __processContent(self, cifFileObj): """Internal method to transfer parsed data from the wrapped input C++ CifFile object into the list of Python DataContainer objects. Args: cifFileObj (wrapped CifFile object): Wrapped input C++ CifFile object Returns: list of DataContainer objects: List of Python DataContainer objects """ containerList = [] containerNameList = [] try: # ----- Repackage the data content ---- # containerList = [] containerNameList = [] containerNameList = list( cifFileObj.GetBlockNames(containerNameList)) for containerName in containerNameList: # aContainer = DataContainer(containerName) # block = cifFileObj.GetBlock(containerName) tableNameList = [] tableNameList = list(block.GetTableNames(tableNameList)) for tableName in tableNameList: table = block.GetTable(tableName) attributeNameList = list(table.GetColumnNames()) numRows = table.GetNumRows() rowList = [] for iRow in range(0, numRows): row = table.GetRow(iRow) # row = table.GetRow(iRow).decode('unicode_escape').encode('utf-8') # row = [p.encode('ascii', 'xmlcharrefreplace') for p in table.GetRow(iRow)] rowList.append(list(row)) aCategory = DataCategory( tableName, attributeNameList, rowList, copyInputData=False, raiseExceptions=self._raiseExceptions) aContainer.append(aCategory) containerList.append(aContainer) except Exception as e: msg = "Failing packaging with %s" % str(e) self._logError(msg) return containerList
def test_row_dict_initialization(self, rw_data): rLen = 10 fn = rw_data['pathOutputFile5'] attributeNameList = ['a', 'b', 'c', 'd'] rowList = [{'a': 1, 'b': 2, 'c': 3, 'd': 4} for i in range(rLen)] nameCat = 'myCategory' # # curContainer = DataContainer("myblock") aCat = DataCategory(nameCat, attributeNameList, rowList) aCat.append({'a': 1, 'b': 2, 'c': 3, 'd': 4}) aCat.append({'a': 1, 'b': 2, 'c': 3, 'd': 4}) aCat.extend(rowList) curContainer.append(aCat) aCat.renameAttributes({'a': 'aa', 'b': 'bb', 'c': 'cc', 'd': 'dd'}) aCat.setName('renamedCategory') # # myContainerList = [] myContainerList.append(curContainer) ofh = open(str(fn), "w") pdbxW = PdbxWriter(ofh) pdbxW.write(myContainerList) ofh.close() myContainerList = [] ifh = open(str(fn), "r") pRd = PdbxReader(ifh) pRd.read(myContainerList) ifh.close() for container in myContainerList: for objName in container.getObjNameList(): name, aList, rList = container.getObj(objName).get() print("Recovered data category %s\n" % name) print("Attribute list %r\n" % repr(aList)) print("Row list %r\n" % repr(rList)) assert len(myContainerList) == 1 assert len(rList) == 2 * rLen + 2
def buildContainerAssemblyIds(self, dataContainer, catName, **kwargs): """Build category rcsb_assembly_container_identifiers. Args: dataContainer (object): mmif.api.DataContainer object instance catName (str): Category name Returns: bool: True for success or False otherwise For example, loop_ _rcsb_assembly_container_identifiers.entry_id _rcsb_assembly_container_identifiers.assembly_id ... """ logger.debug("Starting catName %s kwargs %r", catName, kwargs) try: if not (dataContainer.exists("entry") and dataContainer.exists("pdbx_struct_assembly")): return False if not dataContainer.exists(catName): dataContainer.append( DataCategory( catName, attributeNameList=self.__dApi.getAttributeNameList( catName))) # cObj = dataContainer.getObj(catName) tObj = dataContainer.getObj("entry") entryId = tObj.getValue("id", 0) cObj.setValue(entryId, "entry_id", 0) # tObj = dataContainer.getObj("pdbx_struct_assembly") assemblyIdL = tObj.getAttributeValueList("id") for ii, assemblyId in enumerate(assemblyIdL): cObj.setValue(entryId, "entry_id", ii) cObj.setValue(assemblyId, "assembly_id", ii) cObj.setValue(entryId + "-" + assemblyId, "rcsb_id", ii) # return True except Exception as e: logger.exception("For %s failing with %s", catName, str(e)) return False
def testEditRemoveRow(self): """Test case - remove rows""" try: dcA = DataCategory("A", self.__attributeList, self.__rowListUnicode, raiseExceptions=True) for _ in range(0, dcA.getRowCount()): ii = dcA.getRowCount() dcA.removeRow(0) self.assertEqual(ii - 1, dcA.getRowCount()) # self.assertEqual(0, dcA.getRowCount()) except Exception as e: logger.exception("Failing with %s", str(e)) self.fail()
def __getContainerList(self, locatorObjList): """""" utcnow = datetime.datetime.utcnow() ts = utcnow.strftime("%Y-%m-%d:%H:%M:%S") cL = [] myContainerList = self.__rpP.getContainerList(locatorObjList) for loc in locatorObjList: myContainerList = self.__rpP.getContainerList([loc]) lPathL = self.__rpP.getLocatorPaths([loc]) for cA in myContainerList: dc = DataCategory("rcsb_load_status", ["name", "load_date", "locator"], [[cA.getName(), ts, lPathL[0]]]) logger.debug("data category %r", dc) cA.append(dc) cL.append(cA) return cL
def testEditExtend(self): """Test case - category extension methods""" try: dcA = DataCategory("A", self.__attributeList, self.__rowListAsciiA) na = len(dcA.getAttributeList()) self.assertEqual(dcA.appendAttributeExtendRows("colNew"), na + 1) row = dcA.getRow(dcA.getRowCount() - 1) self.assertEqual(row[na], "?") # except Exception as e: logger.exception("Failing with %s", str(e)) self.fail()
def testSetValues(self): """Test case - value setters""" try: dcU = DataCategory("A", self.__attributeListMiss, self.__rowListUnicodeMiss) for i in range(0, dcU.getRowCount()): dcU.setValue("newValue", attributeName="colM1", rowIndex=i) self.assertTrue( dcU.setValue("newValue", attributeName="colM1", rowIndex=dcU.getRowCount() + 5)) self.assertRaises(ValueError, dcU.setValue, "newValue", "colX", 0) except Exception as e: logger.exception("Failing with %s", str(e)) self.fail()
def test_compare_attributes(self, category_data): dcU = DataCategory('A', category_data['attributeList'], category_data['rowListUnicode']) dcM = DataCategory('A', category_data['attributeListMiss'], category_data['rowListUnicodeMiss']) na = len(dcU.getAttributeList()) t1, t2, t3 = dcU.cmpAttributeNames(dcU) assert len(t1) == 0 assert len(t3) == 0 assert len(t2) == na t1, t2, t3 = dcU.cmpAttributeNames(dcM) assert len(t1) == 0 assert len(t3) == 3 assert len(t2) == na
def test_row_list_initialization(self, rw_data): fn = rw_data['pathOutputFile4'] attributeNameList = ['aOne', 'aTwo', 'aThree', 'aFour', 'aFive', 'aSix', 'aSeven', 'aEight', 'aNine', 'aTen'] rowList = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] ] nameCat = 'myCategory' curContainer = DataContainer("myblock") aCat = DataCategory(nameCat, attributeNameList, rowList) curContainer.append(aCat) myContainerList = [] myContainerList.append(curContainer) ofh = open(str(fn), "w") pdbxW = PdbxWriter(ofh) pdbxW.write(myContainerList) ofh.close() myContainerList = [] ifh = open(str(fn), "r") pRd = PdbxReader(ifh) pRd.read(myContainerList) ifh.close() for container in myContainerList: for objName in container.getObjNameList(): name, aList, rList = container.getObj(objName).get() print("Recovered data category %s\n" % name) print("Attribute list %r\n" % repr(aList)) print("Row list %r\n" % repr(rList)) assert len(myContainerList) == 1
def addOeMol(self, ccId, oeMol, missingModelXyz=True, writeIdealXyz=False, skipAnnotations=False): """Add the input oeMol to the current PDBx data container as a chemical component definition. Args: oeMol (obj): instance of OE molecule ccId (str): chemical component identifer name (str, optional): chemical component name. Defaults to None. missingModelXyz (bool, optional): set the missing model coordinate flag. Defaults to True. writeIdealXyz (bool, optional): write 3D coordinates in using ideal coordinate data items. Defaults to False. Returns: (bool): True for success and False otherwise """ ccIdU = str(ccId).strip().upper() curContainer = DataContainer(ccIdU) # rowD = self.__makeChemCompCategory(ccIdU, oeMol, site="RCSB", missingModelXyz=missingModelXyz, skipAnnotations=skipAnnotations) aCat = DataCategory("chem_comp", list(rowD.keys()), [rowD]) curContainer.append(aCat) # rowDL = self.__makeChemCompAtomCategory(ccIdU, oeMol, writeIdealXyz=writeIdealXyz) aCat = DataCategory("chem_comp_atom", list(rowDL[0].keys()), rowDL) curContainer.append(aCat) # rowDL = self.__makeChemCompBondCategory(ccIdU, oeMol) if rowDL: aCat = DataCategory("chem_comp_bond", list(rowDL[0].keys()), rowDL) curContainer.append(aCat) # if not skipAnnotations: rowDL = self.__makeChemCompDescriptorCategory(ccIdU, oeMol) aCat = DataCategory("pdbx_chem_comp_descriptor", list(rowDL[0].keys()), rowDL) curContainer.append(aCat) # rowDL = self.__makeChemCompIdentifierCategory(ccIdU, oeMol) aCat = DataCategory("pdbx_chem_comp_identifier", list(rowDL[0].keys()), rowDL) curContainer.append(aCat) # rowD = self.__makeChemCompAuditRow(ccIdU) aCat = DataCategory("pdbx_chem_comp_audit", list(rowD.keys()), [rowD]) curContainer.append(aCat) # self.__containerList.append(curContainer) return True
def testCompareAttributes(self): """Test case - compare object attributes -""" try: dcU = DataCategory("A", self.__attributeList, self.__rowListUnicode) dcM = DataCategory("A", self.__attributeListMiss, self.__rowListUnicodeMiss) na = len(dcU.getAttributeList()) t1, t2, t3 = dcU.cmpAttributeNames(dcU) self.assertEqual(len(t1), 0) self.assertEqual(len(t3), 0) self.assertEqual(len(t2), na) t1, t2, t3 = dcU.cmpAttributeNames(dcM) self.assertEqual(len(t1), 0) self.assertEqual(len(t3), 3) self.assertEqual(len(t2), na) except Exception as e: logger.exception("Failing with %s", str(e)) self.fail()
def testSingleRow(self): """Test case - read /write single row and null row in data file""" try: # myDataList = [] # ofh = open(self.__pathOutputFile1, "w") curContainer = DataContainer("myblock") aCat = DataCategory("pdbx_seqtool_mapping_ref") aCat.appendAttribute("ordinal") aCat.appendAttribute("entity_id") aCat.appendAttribute("auth_mon_id") aCat.appendAttribute("auth_mon_num") aCat.appendAttribute("pdb_chain_id") aCat.appendAttribute("ref_mon_id") aCat.appendAttribute("ref_mon_num") aCat.appendAttribute("details") aCat.append([1, 2, 3, 4, 5, 6, 7, "data_my_big_data_file"]) aCat.append([1, 2, 3, 4, 5, 6, 7, "loop_my_big_data_loop"]) aCat.append([1, 2, 3, 4, 5, 6, 7, "save_my_big_data_saveframe"]) aCat.append([1, 2, 3, 4, 5, 6, 7, "_category.item"]) # aCat.dumpIt() curContainer.append(aCat) # bCat = curContainer.getObj("pdbx_seqtool_mapping_ref") logger.debug("----attribute list %r", bCat.getAttributeList()) row = bCat.getRow(0) logger.debug("----ROW %r", row) # with open(self.__pathOutputFile2, "w") as ofh: myDataList.append(curContainer) pdbxW = PdbxWriter(ofh) pdbxW.write(myDataList) self.assertEqual(len(myDataList), 1) except Exception as e: logger.exception("Failing with %s", str(e)) self.fail()
def testUpdateDataFile(self): """Test case - update data file""" try: # Create a initial data file -- # myDataList = [] curContainer = DataContainer("myblock") aCat = DataCategory("pdbx_seqtool_mapping_ref") aCat.appendAttribute("ordinal") aCat.appendAttribute("entity_id") aCat.appendAttribute("auth_mon_id") aCat.appendAttribute("auth_mon_num") aCat.appendAttribute("pdb_chain_id") aCat.appendAttribute("ref_mon_id") aCat.appendAttribute("ref_mon_num") aCat.append([9, 2, 3, 4, 5, 6, 7]) aCat.append([10, 2, 3, 4, 5, 6, 7]) aCat.append([11, 2, 3, 4, 5, 6, 7]) aCat.append([12, 2, 3, 4, 5, 6, 7]) curContainer.append(aCat) myDataList.append(curContainer) ofh = open(self.__pathOutputFile1, "w") pdbxW = PdbxWriter(ofh) pdbxW.write(myDataList) ofh.close() # # # Read and update the data - # myDataList = [] ifh = open(self.__pathOutputFile1, "r") pRd = PdbxReader(ifh) pRd.read(myDataList) ifh.close() # myBlock = myDataList[0] # myBlock.printIt() myCat = myBlock.getObj("pdbx_seqtool_mapping_ref") # myCat.printIt() for iRow in range(0, myCat.getRowCount()): myCat.setValue("some value", "ref_mon_id", iRow) myCat.setValue(100, "ref_mon_num", iRow) with open(self.__pathOutputFile2, "w") as ofh: pdbxW = PdbxWriter(ofh) pdbxW.write(myDataList) # self.assertEqual(len(myDataList), 1) except Exception as e: logger.exception("Failing with %s", str(e)) self.fail()