mkdir -p source/python/modules mv pdbx source/python/modules PYTHONPATH=$PYTHONPATH:source/python/modules export PYTHONPATH
python PdbxReaderTests.py
and
python PdbxReadWriteTests.py
in /path/to/pdbx/reader, or python PdbxWriterTests.py
in /path/to/pdbx/writer.Reading and writing are handled by the PdbxReader (in pdbx.reader.PdbxReader)
and
PdbxWriter (in pdbx.writer.PdbxWriter)
classes, respectively.
ifh = open("/path/to/file.cif")
pRd = PdbxReader(ifh)
data = []
read(self, containerList)
method with your list pRd.read(data)
block = data[0]
getObj(self, name)
method
struct_conn = block.getObj("struct_conn")
getValue(self, attributeName=None, rowIndex=None)
method
connType = struct_conn.getValue("conn_type_id", 0)
ofh = open("path/to/out.cif", "w")
pWt = PdbxWriter(ofh)
write(self, containerList)
, which takes a list of containers, data and/or definition,
and writeContainer(self, container)
, which takes a single data or definition container.All of the containers are accessible through pdbx.reader.PdbxContainers
. The DataContainer, to which data blocks map,
and DefinitionContainer classes derive from ContainerBase, which maintains an internal dictionary of DataCategory (derived from DataCategoryBase) objects,
to which categories map. The following are some methods of interest for these three major container objects, viz., DefinitionContainer and DataContainer,
derived from ContainerBase, and DataCategory, derived from DataCategoryBase.
exists(self, name)
- returns a bool indicating whether or not the DataCategory object named name exists in this containergetObj(self, name)
- returns the DataCategory object named name, or None if it doesn't existgetObjNameList(self)
- returns the list of category names within this containerprintIt(self, fh=sys.stdout, type="brief")
- prints out the contents of the container
__getitem__(self, x)
- special method, category[x] returns the row specified by the integer x in category
get(self)
- returns 3-tuple consisting of (categoryName, attributeNameList, rowList)getRowList(self)
- returns a list of all the rows in the category tablegetRowCount(self)
- returns the number of rows in the category tablegetRow(self, index)
- attempts to fetch the row at index index and returns an empty list if it failsgetAttributeList(self)
- returns a list of attribute/data item namesgetAttributeCount(self)
- returns the number of attributes/columns in the category tablegetAttributeIndex(self, attributeName)
- returns the index of the attribute specified by attributeName or -1 if not foundhasAttribute(self, attributeName)
- returns a bool indicating whether or not the category has the attribute attributeNamegetIndex(self, attributeName)
- same as getAttributeIndex(self, attributeName)
getValue(self, attributeName=None, rowIndex=None)
- returns the value of the attribute attributeName at row index rowIndex