Package gromacs :: Module formats :: Class uniqueNDX
[hide private]
[frames] | no frames]

Class uniqueNDX

source code

     object --+            
              |            
           dict --+        
                  |        
        odict.odict --+    
                      |    
         object --+   |    
                  |   |    
utilities.FileUtils --+    
                      |    
                    NDX --+
                          |
                         uniqueNDX

Index that behaves like make_ndx, i.e. entries behaves as sets,
not lists.

The index lists behave like sets:
- adding sets with '+' is equivalent to a logical OR: x + y == "x | y"
- subtraction '-' is AND: x - y == "x & y"
- see :meth:`~gromacs.formats.join` for ORing multiple groups (x+y+z+...)

**Example** ::
   I = uniqueNDX('system.ndx')
   I['SOLVENT'] = I['SOL'] + I['NA+'] + I['CL-']    

Instance Methods [hide private]
 
join(self, *groupnames)
Return an index group that contains atoms from all groupnames.
source code
 
_sum(self, sequence) source code
 
_transform(self, v)
Transform input to the stored representation.
source code
 
_getarray(self, k)
Helper getter that is used in write().
source code

Inherited from NDX: __init__, __setitem__, get, read, set, setdefault, size, write

Inherited from odict.odict: __cmp__, __copy__, __deepcopy__, __delitem__, __eq__, __getstate__, __iter__, __ne__, __repr__, __reversed__, __setstate__, byindex, clear, copy, index, items, iteritems, iterkeys, itervalues, keys, pop, popitem, reverse, sort, update, values

Inherited from dict: __contains__, __ge__, __getattribute__, __getitem__, __gt__, __hash__, __le__, __len__, __lt__, __new__, has_key

Inherited from utilities.FileUtils: check_file_exists, filename, infix_filename

Inherited from utilities.FileUtils (private): _init_filename

Inherited from object: __delattr__, __reduce__, __reduce_ex__, __setattr__, __str__

Class Methods [hide private]

Inherited from odict.odict: fromkeys

Class Variables [hide private]

Inherited from NDX: SECTION, default_extension, format, ncol

Instance Variables [hide private]

Inherited from utilities.FileUtils: real_filename

Properties [hide private]

Inherited from NDX: groups, ndxlist, sizes

Inherited from object: __class__

Method Details [hide private]

join(self, *groupnames)

source code 

Return an index group that contains atoms from all groupnames.

The method will silently ignore any groups that are not in the index.

Example

Always make a solvent group from water and ions, even if not all ions are present in all simulations:

I['SOLVENT'] = I.join('SOL', 'NA+', 'K+', 'CL-')

_transform(self, v)

source code 

Transform input to the stored representation.

Override eg with return set(v) for index lists as sets.

Overrides: NDX._transform
(inherited documentation)

_getarray(self, k)

source code 
Helper getter that is used in write(). Override when using a _transform that stores something that cannot be indexed, e.g. when using set()s.
Overrides: NDX._getarray
(inherited documentation)