mmtbx.monomer_library.mmCIF
index
/net/chevy/raid1/rwgk/dist/cctbx_project/mmtbx/monomer_library/mmCIF.py

mmCIF file and mmCIF dictionary parser.  Files are parsed
into a set of data structures where they can be further processed.  The
data structures can also be constructed and written back out as mmCIF.
A CIF dictionary parser is also included as a specialized version of the
mmCIF parser.

 
Modules
       
copy
os
re
string
sys

 
Classes
       
__builtin__.dict(__builtin__.object)
mmCIFRow
__builtin__.list(__builtin__.object)
mmCIFData
mmCIFSave
mmCIFFile
mmCIFDictionary
mmCIFTable
__builtin__.object
mmCIFFileBuilder
mmCIFFileParser
mmCIFFileWriter

 
class mmCIFData(__builtin__.list)
    Contains all information found under a data_ block in a mmCIF file.
mmCIF files are represented differently here than their file format
would suggest.  Since a mmCIF file is more-or-less a SQL database dump,
the files are represented here with their sections as "Tables" and
their subsections as "Columns".  The data is stored in "Rows".
 
 
Method resolution order:
mmCIFData
__builtin__.list
__builtin__.object

Methods defined here:
__deepcopy__(self, memo)
__delitem__(self, x)
Remove a mmCIFTable by index or table name.
__eq__(self, other)
__getitem__(self, x)
__init__(self, name)
append(self, table)
Append a mmCIFTable.  This will trigger the removal of any
table with the same name.
debug(self)
get(self, x, default=None)
get_table(self, name)
Looks up and returns a stored mmCIFTable class by it's name.  This
name is the section key in the mmCIF file.
has_key(self, x)
insert(self, i, table)
remove(self, table)

Data descriptors defined here:
file
name

Methods inherited from __builtin__.list:
__add__(...)
x.__add__(y) <==> x+y
__contains__(...)
x.__contains__(y) <==> y in x
__delslice__(...)
x.__delslice__(i, j) <==> del x[i:j]
 
Use of negative indices is not supported.
__ge__(...)
x.__ge__(y) <==> x>=y
__getattribute__(...)
x.__getattribute__('name') <==> x.name
__getslice__(...)
x.__getslice__(i, j) <==> x[i:j]
 
Use of negative indices is not supported.
__gt__(...)
x.__gt__(y) <==> x>y
__iadd__(...)
x.__iadd__(y) <==> x+=y
__imul__(...)
x.__imul__(y) <==> x*=y
__iter__(...)
x.__iter__() <==> iter(x)
__le__(...)
x.__le__(y) <==> x<=y
__len__(...)
x.__len__() <==> len(x)
__lt__(...)
x.__lt__(y) <==> x<y
__mul__(...)
x.__mul__(n) <==> x*n
__ne__(...)
x.__ne__(y) <==> x!=y
__repr__(...)
x.__repr__() <==> repr(x)
__reversed__(...)
L.__reversed__() -- return a reverse iterator over the list
__rmul__(...)
x.__rmul__(n) <==> n*x
__setitem__(...)
x.__setitem__(i, y) <==> x[i]=y
__setslice__(...)
x.__setslice__(i, j, y) <==> x[i:j]=y
 
Use  of negative indices is not supported.
__sizeof__(...)
L.__sizeof__() -- size of L in memory, in bytes
count(...)
L.count(value) -> integer -- return number of occurrences of value
extend(...)
L.extend(iterable) -- extend list by appending elements from the iterable
index(...)
L.index(value, [start, [stop]]) -> integer -- return first index of value
pop(...)
L.pop([index]) -> item -- remove and return item at index (default last)
reverse(...)
L.reverse() -- reverse *IN PLACE*
sort(...)
L.sort(cmp=None, key=None, reverse=False) -- stable sort *IN PLACE*;
cmp(x, y) -> -1, 0, 1

Data and other attributes inherited from __builtin__.list:
__hash__ = None
__new__ = <built-in method __new__ of type object at 0x755d80>
T.__new__(S, ...) -> a new object with type S, a subtype of T

 
class mmCIFDictionary(mmCIFFile)
    Class representing a mmCIF dictionary.  The constructor of this class
takes two arguments.  The first is the string path for the file, or
alternativly a file object.
 
 
Method resolution order:
mmCIFDictionary
mmCIFFile
__builtin__.list
__builtin__.object

Methods inherited from mmCIFFile:
__deepcopy__(self, memo)
__delitem__(self, x)
Remove a mmCIFData by index or data name.  Raises IndexError
or KeyError if the mmCIFData object is not found, the error raised
depends on the argument type.
__eq__(self, other)
__getitem__(self, x)
Retrieve a mmCIFData object by index or name.
append(self, cdata)
Append a mmCIFData object.  This will trigger the removal of any
mmCIFData object in the file with the same name.
debug(self)
get(self, x, default=None)
get_data(self, name)
has_key(self, x)
insert(self, i, cdata)
load_file(self, fil, update_cb=None, strict=True)
Load and append the mmCIF data from file object fil into self.
save_file(self, fil)

Data descriptors inherited from mmCIFFile:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

Methods inherited from __builtin__.list:
__add__(...)
x.__add__(y) <==> x+y
__contains__(...)
x.__contains__(y) <==> y in x
__delslice__(...)
x.__delslice__(i, j) <==> del x[i:j]
 
Use of negative indices is not supported.
__ge__(...)
x.__ge__(y) <==> x>=y
__getattribute__(...)
x.__getattribute__('name') <==> x.name
__getslice__(...)
x.__getslice__(i, j) <==> x[i:j]
 
Use of negative indices is not supported.
__gt__(...)
x.__gt__(y) <==> x>y
__iadd__(...)
x.__iadd__(y) <==> x+=y
__imul__(...)
x.__imul__(y) <==> x*=y
__init__(...)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
__iter__(...)
x.__iter__() <==> iter(x)
__le__(...)
x.__le__(y) <==> x<=y
__len__(...)
x.__len__() <==> len(x)
__lt__(...)
x.__lt__(y) <==> x<y
__mul__(...)
x.__mul__(n) <==> x*n
__ne__(...)
x.__ne__(y) <==> x!=y
__repr__(...)
x.__repr__() <==> repr(x)
__reversed__(...)
L.__reversed__() -- return a reverse iterator over the list
__rmul__(...)
x.__rmul__(n) <==> n*x
__setitem__(...)
x.__setitem__(i, y) <==> x[i]=y
__setslice__(...)
x.__setslice__(i, j, y) <==> x[i:j]=y
 
Use  of negative indices is not supported.
__sizeof__(...)
L.__sizeof__() -- size of L in memory, in bytes
count(...)
L.count(value) -> integer -- return number of occurrences of value
extend(...)
L.extend(iterable) -- extend list by appending elements from the iterable
index(...)
L.index(value, [start, [stop]]) -> integer -- return first index of value
pop(...)
L.pop([index]) -> item -- remove and return item at index (default last)
remove(...)
L.remove(value) -- remove first occurrence of value
reverse(...)
L.reverse() -- reverse *IN PLACE*
sort(...)
L.sort(cmp=None, key=None, reverse=False) -- stable sort *IN PLACE*;
cmp(x, y) -> -1, 0, 1

Data and other attributes inherited from __builtin__.list:
__hash__ = None
__new__ = <built-in method __new__ of type object at 0x755d80>
T.__new__(S, ...) -> a new object with type S, a subtype of T

 
class mmCIFFile(__builtin__.list)
    Class representing a mmCIF files.
 
 
Method resolution order:
mmCIFFile
__builtin__.list
__builtin__.object

Methods defined here:
__deepcopy__(self, memo)
__delitem__(self, x)
Remove a mmCIFData by index or data name.  Raises IndexError
or KeyError if the mmCIFData object is not found, the error raised
depends on the argument type.
__eq__(self, other)
__getitem__(self, x)
Retrieve a mmCIFData object by index or name.
append(self, cdata)
Append a mmCIFData object.  This will trigger the removal of any
mmCIFData object in the file with the same name.
debug(self)
get(self, x, default=None)
get_data(self, name)
has_key(self, x)
insert(self, i, cdata)
load_file(self, fil, update_cb=None, strict=True)
Load and append the mmCIF data from file object fil into self.
save_file(self, fil)

Data descriptors defined here:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

Methods inherited from __builtin__.list:
__add__(...)
x.__add__(y) <==> x+y
__contains__(...)
x.__contains__(y) <==> y in x
__delslice__(...)
x.__delslice__(i, j) <==> del x[i:j]
 
Use of negative indices is not supported.
__ge__(...)
x.__ge__(y) <==> x>=y
__getattribute__(...)
x.__getattribute__('name') <==> x.name
__getslice__(...)
x.__getslice__(i, j) <==> x[i:j]
 
Use of negative indices is not supported.
__gt__(...)
x.__gt__(y) <==> x>y
__iadd__(...)
x.__iadd__(y) <==> x+=y
__imul__(...)
x.__imul__(y) <==> x*=y
__init__(...)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
__iter__(...)
x.__iter__() <==> iter(x)
__le__(...)
x.__le__(y) <==> x<=y
__len__(...)
x.__len__() <==> len(x)
__lt__(...)
x.__lt__(y) <==> x<y
__mul__(...)
x.__mul__(n) <==> x*n
__ne__(...)
x.__ne__(y) <==> x!=y
__repr__(...)
x.__repr__() <==> repr(x)
__reversed__(...)
L.__reversed__() -- return a reverse iterator over the list
__rmul__(...)
x.__rmul__(n) <==> n*x
__setitem__(...)
x.__setitem__(i, y) <==> x[i]=y
__setslice__(...)
x.__setslice__(i, j, y) <==> x[i:j]=y
 
Use  of negative indices is not supported.
__sizeof__(...)
L.__sizeof__() -- size of L in memory, in bytes
count(...)
L.count(value) -> integer -- return number of occurrences of value
extend(...)
L.extend(iterable) -- extend list by appending elements from the iterable
index(...)
L.index(value, [start, [stop]]) -> integer -- return first index of value
pop(...)
L.pop([index]) -> item -- remove and return item at index (default last)
remove(...)
L.remove(value) -- remove first occurrence of value
reverse(...)
L.reverse() -- reverse *IN PLACE*
sort(...)
L.sort(cmp=None, key=None, reverse=False) -- stable sort *IN PLACE*;
cmp(x, y) -> -1, 0, 1

Data and other attributes inherited from __builtin__.list:
__hash__ = None
__new__ = <built-in method __new__ of type object at 0x755d80>
T.__new__(S, ...) -> a new object with type S, a subtype of T

 
class mmCIFFileBuilder(__builtin__.object)
    Builds a mmCIF file from a Structure object.
 
  Methods defined here:
__init__(self, struct, cif_file)
add__atom_site(self)
Adds the _atom_site table.
add__cell(self)
Adds the _cell table.
add__entity(self)
Adds the entity table.  The entity names are faked here, since
it's really not clear to me how the names are chosen by the PDB.
add__entry(self)
Add the _entry table.  If there is not entry ID, it defaults
to XXX.
add__symmetry(self)
Adds the _symmetry table.
get_table(self, name, columns=None)
set_atom_site_row(self, asrow, atm)

Data descriptors defined here:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

Data and other attributes defined here:
cifdb_omit_list = ['entity', 'cell', 'symmetry', 'atom_site', 'atom_site_anisotrop']

 
class mmCIFFileParser(__builtin__.object)
    Stateful parser which uses the mmCIFElementFile tokenizer to read
a mmCIF file and convert it into the mmCIFData/mmCIFTable/mmCIFRow
data hierarchy.
 
  Methods defined here:
__init__(self, strict=True)
gen_token_iter(self, fil)
parse(self, token_iter, cif_file)
parse_file(self, fil, cif_file, update_cb=None)
syntax_error(self, err)

Data descriptors defined here:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

 
class mmCIFFileWriter(__builtin__.object)
    Writes out a mmCIF file using the data in the mmCIFData list.
 
  Methods defined here:
data_type(self, x)
Analyze x and return its type: token, qstring, mstring
fix(self, x)
form_mstring(self, mstring)
write(self, x)
write_cif_data(self)
write_file(self, fil, cif_data_list)
write_mstring(self, mstring)
write_multi_row_table(self, cif_table)
write_one_row_table(self, cif_table)
writeln(self, x='')

Data descriptors defined here:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

 
class mmCIFRow(__builtin__.dict)
    Contains one row of data.  In a mmCIF file, this is one complete
set of data found under a section.  The data can be accessed by using
the column names as class attributes.
 
 
Method resolution order:
mmCIFRow
__builtin__.dict
__builtin__.object

Methods defined here:
__deepcopy__(self, memo)
__eq__(self, other)
mget(self, *keys)
Return the fist value found for the given keys in the argument
list.

Data descriptors defined here:
table

Methods inherited from __builtin__.dict:
__cmp__(...)
x.__cmp__(y) <==> cmp(x,y)
__contains__(...)
D.__contains__(k) -> True if D has a key k, else False
__delitem__(...)
x.__delitem__(y) <==> del x[y]
__ge__(...)
x.__ge__(y) <==> x>=y
__getattribute__(...)
x.__getattribute__('name') <==> x.name
__getitem__(...)
x.__getitem__(y) <==> x[y]
__gt__(...)
x.__gt__(y) <==> x>y
__init__(...)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
__iter__(...)
x.__iter__() <==> iter(x)
__le__(...)
x.__le__(y) <==> x<=y
__len__(...)
x.__len__() <==> len(x)
__lt__(...)
x.__lt__(y) <==> x<y
__ne__(...)
x.__ne__(y) <==> x!=y
__repr__(...)
x.__repr__() <==> repr(x)
__setitem__(...)
x.__setitem__(i, y) <==> x[i]=y
__sizeof__(...)
D.__sizeof__() -> size of D in memory, in bytes
clear(...)
D.clear() -> None.  Remove all items from D.
copy(...)
D.copy() -> a shallow copy of D
get(...)
D.get(k[,d]) -> D[k] if k in D, else d.  d defaults to None.
has_key(...)
D.has_key(k) -> True if D has a key k, else False
items(...)
D.items() -> list of D's (key, value) pairs, as 2-tuples
iteritems(...)
D.iteritems() -> an iterator over the (key, value) items of D
iterkeys(...)
D.iterkeys() -> an iterator over the keys of D
itervalues(...)
D.itervalues() -> an iterator over the values of D
keys(...)
D.keys() -> list of D's keys
pop(...)
D.pop(k[,d]) -> v, remove specified key and return the corresponding value
If key is not found, d is returned if given, otherwise KeyError is raised
popitem(...)
D.popitem() -> (k, v), remove and return some (key, value) pair as a
2-tuple; but raise KeyError if D is empty
setdefault(...)
D.setdefault(k[,d]) -> D.get(k,d), also set D[k]=d if k not in D
update(...)
D.update(E, **F) -> None.  Update D from E and F: for k in E: D[k] = E[k]
(if E has keys else: for (k, v) in E: D[k] = v) then: for k in F: D[k] = F[k]
values(...)
D.values() -> list of D's values

Data and other attributes inherited from __builtin__.dict:
__hash__ = None
__new__ = <built-in method __new__ of type object at 0x757720>
T.__new__(S, ...) -> a new object with type S, a subtype of T
fromkeys = <built-in method fromkeys of type object at 0x1cfa870>
dict.fromkeys(S[,v]) -> New dict with keys from S and values equal to v.
v defaults to None.

 
class mmCIFSave(mmCIFData)
    Class to store data from mmCIF dictionary save_ blocks.  I treat
them as non-nested sections along with data_ sections.  This may
not be correct.
 
 
Method resolution order:
mmCIFSave
mmCIFData
__builtin__.list
__builtin__.object

Data descriptors defined here:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

Methods inherited from mmCIFData:
__deepcopy__(self, memo)
__delitem__(self, x)
Remove a mmCIFTable by index or table name.
__eq__(self, other)
__getitem__(self, x)
__init__(self, name)
append(self, table)
Append a mmCIFTable.  This will trigger the removal of any
table with the same name.
debug(self)
get(self, x, default=None)
get_table(self, name)
Looks up and returns a stored mmCIFTable class by it's name.  This
name is the section key in the mmCIF file.
has_key(self, x)
insert(self, i, table)
remove(self, table)

Data descriptors inherited from mmCIFData:
file
name

Methods inherited from __builtin__.list:
__add__(...)
x.__add__(y) <==> x+y
__contains__(...)
x.__contains__(y) <==> y in x
__delslice__(...)
x.__delslice__(i, j) <==> del x[i:j]
 
Use of negative indices is not supported.
__ge__(...)
x.__ge__(y) <==> x>=y
__getattribute__(...)
x.__getattribute__('name') <==> x.name
__getslice__(...)
x.__getslice__(i, j) <==> x[i:j]
 
Use of negative indices is not supported.
__gt__(...)
x.__gt__(y) <==> x>y
__iadd__(...)
x.__iadd__(y) <==> x+=y
__imul__(...)
x.__imul__(y) <==> x*=y
__iter__(...)
x.__iter__() <==> iter(x)
__le__(...)
x.__le__(y) <==> x<=y
__len__(...)
x.__len__() <==> len(x)
__lt__(...)
x.__lt__(y) <==> x<y
__mul__(...)
x.__mul__(n) <==> x*n
__ne__(...)
x.__ne__(y) <==> x!=y
__repr__(...)
x.__repr__() <==> repr(x)
__reversed__(...)
L.__reversed__() -- return a reverse iterator over the list
__rmul__(...)
x.__rmul__(n) <==> n*x
__setitem__(...)
x.__setitem__(i, y) <==> x[i]=y
__setslice__(...)
x.__setslice__(i, j, y) <==> x[i:j]=y
 
Use  of negative indices is not supported.
__sizeof__(...)
L.__sizeof__() -- size of L in memory, in bytes
count(...)
L.count(value) -> integer -- return number of occurrences of value
extend(...)
L.extend(iterable) -- extend list by appending elements from the iterable
index(...)
L.index(value, [start, [stop]]) -> integer -- return first index of value
pop(...)
L.pop([index]) -> item -- remove and return item at index (default last)
reverse(...)
L.reverse() -- reverse *IN PLACE*
sort(...)
L.sort(cmp=None, key=None, reverse=False) -- stable sort *IN PLACE*;
cmp(x, y) -> -1, 0, 1

Data and other attributes inherited from __builtin__.list:
__hash__ = None
__new__ = <built-in method __new__ of type object at 0x755d80>
T.__new__(S, ...) -> a new object with type S, a subtype of T

 
class mmCIFTable(__builtin__.list)
    Contains columns and rows of data for a mmCIF section.  Rows of data
are stored as mmCIFRow classes.
 
 
Method resolution order:
mmCIFTable
__builtin__.list
__builtin__.object

Methods defined here:
__deepcopy__(self, memo)
__delitem__(self, i)
__eq__(self, other)
__getitem__(self, x)
Retrieves mmCIFRow at index x from the table if the argument is
a integer.  If the argument is a string, then the data from the
first row is returned.
__init__(self, name, columns=None)
__setitem__(self, i, row)
append(self, row)
autoset_columns(self)
Iterates through all rows in self, and forms a list of all
unique column names, then sets the self.columns to that list.
debug(self)
get_row(self, *args)
Preforms a SQL-like 'AND' select aginst all the rows in the table,
and returns the first matching row found.  The arguments are a
variable list of tuples of the form:
  (<column-name>, <column-value>)
For example:
  ger_row(('atom_id','CA'),('entity_id', '1'))
returns the first matching row with atom_id==1 and entity_id==1.
insert(self, i, row)
iter_rows(self, *args)
This is the same as get_row, but it iterates over all matching
rows in the table.
remove(self, row)
row_index_dict(self, key)
Return a dictionary mapping the value of the row's value in
column 'key' to the row itself.  If there are multiple rows with
the same key value, they will be overwritten with the last found
row.

Data descriptors defined here:
columns
data
name

Methods inherited from __builtin__.list:
__add__(...)
x.__add__(y) <==> x+y
__contains__(...)
x.__contains__(y) <==> y in x
__delslice__(...)
x.__delslice__(i, j) <==> del x[i:j]
 
Use of negative indices is not supported.
__ge__(...)
x.__ge__(y) <==> x>=y
__getattribute__(...)
x.__getattribute__('name') <==> x.name
__getslice__(...)
x.__getslice__(i, j) <==> x[i:j]
 
Use of negative indices is not supported.
__gt__(...)
x.__gt__(y) <==> x>y
__iadd__(...)
x.__iadd__(y) <==> x+=y
__imul__(...)
x.__imul__(y) <==> x*=y
__iter__(...)
x.__iter__() <==> iter(x)
__le__(...)
x.__le__(y) <==> x<=y
__len__(...)
x.__len__() <==> len(x)
__lt__(...)
x.__lt__(y) <==> x<y
__mul__(...)
x.__mul__(n) <==> x*n
__ne__(...)
x.__ne__(y) <==> x!=y
__repr__(...)
x.__repr__() <==> repr(x)
__reversed__(...)
L.__reversed__() -- return a reverse iterator over the list
__rmul__(...)
x.__rmul__(n) <==> n*x
__setslice__(...)
x.__setslice__(i, j, y) <==> x[i:j]=y
 
Use  of negative indices is not supported.
__sizeof__(...)
L.__sizeof__() -- size of L in memory, in bytes
count(...)
L.count(value) -> integer -- return number of occurrences of value
extend(...)
L.extend(iterable) -- extend list by appending elements from the iterable
index(...)
L.index(value, [start, [stop]]) -> integer -- return first index of value
pop(...)
L.pop([index]) -> item -- remove and return item at index (default last)
reverse(...)
L.reverse() -- reverse *IN PLACE*
sort(...)
L.sort(cmp=None, key=None, reverse=False) -- stable sort *IN PLACE*;
cmp(x, y) -> -1, 0, 1

Data and other attributes inherited from __builtin__.list:
__hash__ = None
__new__ = <built-in method __new__ of type object at 0x755d80>
T.__new__(S, ...) -> a new object with type S, a subtype of T

 
Functions
       
OpenFile(path, mode)
Right now this only supports opening GZip'ed files, in the future
it might be extended for URLs.

 
Data
        MAX_LINE = 80
generators = _Feature((2, 2, 0, 'alpha', 1), (2, 3, 0, 'final', 0), 0)
mmCIFError = 'mmCIFError'
mmCIFStandardColumnsMap = {'atom_site': ['group_PDB', 'id', 'type_symbol', 'label_entity_id', 'Cartn_x', 'Cartn_y', 'Cartn_z', 'occupancy', 'B_iso_or_equiv', 'Cartn_x_esd', 'Cartn_y_esd', 'Cartn_z_esd', 'occupancy_esd', 'B_iso_or_equiv_esd', 'auth_asym_id', 'auth_seq_id', 'auth_comp_id', 'auth_alt_id', 'auth_atom_id'], 'atom_site_anisotrop': ['id', 'type_symbol', 'label_entity_id', 'U[1][1]', 'U[1][2]', 'U[1][3]', 'U[2][2]', 'U[2][3]', 'U[3][3]', 'U[1][1]_esd', 'U[1][2]_esd', 'U[1][3]_esd', 'U[2][2]_esd', 'U[2][3]_esd', 'U[3][3]_esd', 'pdbx_auth_seq_id', 'pdbx_auth_comp_id', 'pdbx_auth_asym_id', 'pdbx_auth_atom_id'], 'audit_author': ['name'], 'cell': ['entry_id', 'length_a', 'length_b', 'length_c', 'angle_alpha', 'angle_beta', 'angle_gamma', 'PDB_Z'], 'entity': ['id', 'type', 'details'], 'entry': ['id'], 'symmetry': ['entry_id', 'space_group_name_H-M', 'cell_setting', 'Int_Tables_number']}