| Trees | Indices | Help |
|
|---|
|
|
object --+
|
dict --+
|
odict.odict --+
|
object --+ |
| |
utilities.FileUtils --+
|
NDX
Gromacs index file.
Represented as a ordered dict where the keys are index group names and
values are numpy arrays of atom numbers.
Use the :meth:`NDX.read` and :meth:`NDX.write` methods for
I/O. Access groups by name via the :meth:`NDX.get` and
:meth:`NDX.set` methods.
Alternatively, simply treat the :class:`NDX` instance as a
dictionary. Setting a key automatically transforms the new value
into a integer 1D numpy array (*not* a set, as would be the
:program:`make_ndx` behaviour).
.. Note:: The index entries themselves are ordered and can contain
duplicates so that output from NDX can be easily used for
:program:`g_dih` and friends. If you need set-like behaviour
you will have do use :class:`gromacs.formats.uniqueNDX` or
:class:`gromacs.cbook.IndexBuilder` (which uses
:program:`make_ndx` throughout).
**Example**
Read index file, make new group and write to disk::
ndx = NDX()
ndx.read('system.ndx')
print ndx['Protein']
ndx['my_group'] = [2, 4, 1, 5] # add new group
ndx.write('new.ndx')
Or quicker (replacing the input file ``system.ndx``)::
ndx = NDX('system') # suffix .ndx is automatically added
ndx['chi1'] = [2, 7, 8, 10]
ndx.write()
|
|||
new empty dictionary |
|
||
|
|||
|
|||
| D[k] if k in D, else d |
|
||
|
|||
|
|||
|
|||
|
|||
|
|||
| D.get(k,d), also set D[k]=d if k not in D |
|
||
|
Inherited from Inherited from Inherited from Inherited from Inherited from |
|||
|
|||
|
Inherited from |
|||
|
|||
|
Inherited from |
|||
|
|||
|
groups Return a list of all groups. |
|||
|
sizes Return a dict with group names and number of entries, |
|||
|
ndxlist Return a list of groups in the same format as :func:`gromacs.cbook.get_ndx_groups`. |
|||
|
Inherited from |
|||
|
|||
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
|
|
|
Transform input to the stored representation. Override eg with return set(v) for index lists as sets. |
x[i]=y
|
|
|
|||
groupsReturn a list of all groups.
|
sizesReturn a dict with group names and number of entries,
|
ndxlist
Return a list of groups in the same format as :func:`gromacs.cbook.get_ndx_groups`.
Format:
[ {'name': group_name, 'natoms': number_atoms, 'nr': # group_number}, ....]
|
| Trees | Indices | Help |
|
|---|
| Generated by Epydoc 3.0.1 on Sat Jun 12 15:59:36 2010 | http://epydoc.sourceforge.net |