Biskit :: Dock :: ComplexList :: ComplexList :: Class ComplexList
[hide private]
[frames] | no frames]

Class ComplexList

source code


List of Complex objects. Special support is given to access and use entries in the Complexes' info dictionaries for filtering and sorting. Some care is taken to avoid the adding of non-Complex objects (but somehow it is, certainly, still possible).

The different rec- and lig_models of all Complexes are centrally kept in a ComplexModelRegistry. Before adding a Complex, we check whether its rec- or lig_model are equivalent (same fileName and unchanged) to one in the registy. If so, they are replaced to avoid that each Complex points to its own copy of essentially the same PDBmodel. This does only work with PDBModels that have been pickled to disc (see PDBModel.saveAs ) and haven't been changed since. It's a very good idea to do this if you want to perform any distributed calculation on the ComplexList. Saved PDBModels cause only little PVM traffic (not much more than the file name is transmitted). By contrast, unsaved ones will severly slow down the job distribution.


To Do: Removing items with pop(), del, remove() etc. will not remove unused PDBModels from rec_models or lig_models.

Instance Methods [hide private]
  __init__(self, lst=[])
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
str version(self)
Version of class.
  __setstate__(self, state)
called for unpickling the object.
  __defaults(self)
  checkType(self, v)
Make sure v is a Complex.
  checkTypes(self, lst)
Make sure lst is a list of Complexes.
  __setitem__(self, i, v)
Set value v of position i.
ComplexList __add__(self, lst)
New ComplexList with the two lists.
ComplexList __iadd__(self, lst)
List appendet to this ComplexList.
[PDBModel] ligModels(self)
Get all shared ligand PDBModels.
[PDBModel] recModels(self)
Get all shared receptor PDBModels.
  __add_once(self, item, lst)
Add eithem to list of it is not already there.
dict strayModels(self)
Look for models that are not in model registry.
  extend(list)
Add all items to (the end of) this instance
  append(Complex)
Append Complex to the end of this list.
ComplexList __getslice__(self, i, j)
Slice list.
[int] argsortRandom(self)
Indices for key in random order:
[int] argsort(self, sortKey)
Indices sort order for values of key:
ComplexList sortBy(self, sortKey)
Sort ComplexList by key:
[any] valuesOf(self, infoKey, default=None, indices=None, unique=0)
Get all values of a certain info record of all or some Complexes.
[int] filterRange(self, infoKey, vLow, vHigh)
Get indices of Complexes where vLow <= c.info[ infoKey ] <= vHigh.
[int] filterEqual(self, infoKey, lst)
Get indices of Complexes where c.info[ infoKey ] in lst.
[int] filterFunct(self, f)
Get indices of Complexes where f( c ) == 1.
ComplexList filter(self, infoKey, cond)
Complexes matching condition.
int argmax(self, infoKey)
Get index of complex c with highest c.infos[infokey] value
Complex max(self, infoKey)
Get higest c.infos[infokey] value.
int argmin(self, infoKey)
Get index of complex c with lowest c.infos[infokey] value
Complex min(self, infoKey)
Get lowest c.infos[infokey] value.
int getIndex(self, infoKey, value)
Get list position of Complex where c.info['infoKey'] == value
Complex getItem(self, infoKey, value)
Get Complex from ComplexList where c.info['infoKey'] == value
ComplexList take(self, indices)
Take the complexes specified by indices.
dict toDict(self, infoKey)
Convert list into dict indexed by a certain info-record value.
[Complex] toList(self)
Convert ComplexList to simple python list of Complexes
ComplexList, ComplexList __maskNone(self, l1, l2)
Take out positions from l1 and l2 that are None in either of them.
biggles.FramedPlot() plot(self, xkey, *ykey, **arg)
Plot pairs of info values.
biggles.FramedArray plotArray(self, xkey, *ykey, **arg)
Plot pairs of info values.:

Inherited from list: __contains__, __delitem__, __delslice__, __eq__, __ge__, __getattribute__, __getitem__, __gt__, __hash__, __imul__, __iter__, __le__, __len__, __lt__, __mul__, __ne__, __new__, __repr__, __reversed__, __rmul__, __setslice__, count, index, insert, pop, remove, reverse, sort

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


Properties [hide private]

Inherited from object: __class__


Method Details [hide private]

__init__(self, lst=[])
(Constructor)

source code 

x.__init__(...) initializes x; see x.__class__.__doc__ for signature
Parameters:
  • lst ([Complex]) - list of Complexes
Overrides: list.__init__

version(self)

source code 

Version of class.
Returns: str
class version number

__setstate__(self, state)

source code 

called for unpickling the object.

__defaults(self)

source code 

checkType(self, v)

source code 

Make sure v is a Complex.
Raises:

checkTypes(self, lst)

source code 

Make sure lst is a list of Complexes.
Raises:

__setitem__(self, i, v)
(Index assignment operator)

source code 

Set value v of position i.
>>> lst[i] = v
Parameters:
  • i (int) - list index
  • v (any) - value
Overrides: list.__setitem__

__add__(self, lst)
(Addition operator)

source code 

New ComplexList with the two lists.
Returns: ComplexList
new instance with simply one list appended to the other
Overrides: list.__add__

__iadd__(self, lst)

source code 

List appendet to this ComplexList.
Returns: ComplexList
this instance with lst appended
Overrides: list.__iadd__

ligModels(self)

source code 

Get all shared ligand PDBModels. Stray models (changed or unpickled) are not returned.
Returns: [PDBModel]
list of ligand models

recModels(self)

source code 

Get all shared receptor PDBModels. Stray models (changed or unpickled) are not returned.
Returns: [PDBModel]
list of receptor models

__add_once(self, item, lst)

source code 

Add eithem to list of it is not already there.

strayModels(self)

source code 

Look for models that are not in model registry.
Returns: dict
{ int|str:[ PDBModel ] }

Note: mostly for DEBUGGING

extend(list)

source code 

Add all items to (the end of) this instance
Overrides: list.extend

append(Complex)

source code 

Append Complex to the end of this list.
Overrides: list.append

__getslice__(self, i, j)
(Slicling operator)

source code 

Slice list.
Parameters:
  • i (int) - start index
  • j (int) - end index
Returns: ComplexList
new instance with only the given range of items
Overrides: list.__getslice__

argsortRandom(self)

source code 

Indices for key in random order:
 argsortRandom() -> [ int ], indices in random order.
Returns: [int]
indices in random order

argsort(self, sortKey)

source code 

Indices sort order for values of key:
 argsort( str_sortKey ) -> [ int ], indices after sorting
Parameters:
  • sortKey (str) - key to use for sorting
Returns: [int]
indices after sorting

sortBy(self, sortKey)

source code 

Sort ComplexList by key:
 sortBy( str_sortKey ) -> ComplexList (or sub-class)
                          sorted by info[ str_sortKey ]
Parameters:
  • sortKey (str) - key to use for sorting
Returns: ComplexList
sorted ComplexList

valuesOf(self, infoKey, default=None, indices=None, unique=0)

source code 

Get all values of a certain info record of all or some Complexes.
Parameters:
  • infoKey (str) - key for info dict
  • default (any) - default value if infoKey is not found (None)
  • indices ([int] OR None) - list of int OR None(=all), indices of Complexes (None)
  • unique (1|0) - report each value only once (set union), (default 0)
Returns: [any]
list of values

filterRange(self, infoKey, vLow, vHigh)

source code 

Get indices of Complexes where vLow <= c.info[ infoKey ] <= vHigh.

Use:
  filterRange( str_infoKey, vLow, vHigh )
Parameters:
  • infoKey (str) - key for info dict
  • vLow (float) - upper value limit
  • vHigh (float) - lower value limit
Returns: [int]
array of int

filterEqual(self, infoKey, lst)

source code 

Get indices of Complexes where c.info[ infoKey ] in lst.

Use:
  filterEqual( infoKey, lst )
Parameters:
  • infoKey (str) - key for info dict
  • lst ([any]) - list of values to look for
Returns: [int]
array of int

filterFunct(self, f)

source code 

Get indices of Complexes where f( c ) == 1.

Use:
  filterFunct( f )
Parameters:
  • f (function) - filterFunct
Returns: [int]
array of int

filter(self, infoKey, cond)

source code 

Complexes matching condition.
Parameters:
  • infoKey (str) - key of Complex.info dict (not used if cond is function )
  • cond (any) - filter condition:
           - (vLow, vHigh) -> vLow <= c.info[ infoKey ] <= vHigh
           - list          -> c.info[ infoKey ] in cond
           - function      -> cond( c ) == 1
    
Returns: ComplexList
ComplexList (or sub-class)
Raises:

argmax(self, infoKey)

source code 

Get index of complex c with highest c.infos[infokey] value
Parameters:
  • infoKey (str) - key for info dict
Returns: int
index of complex c with highest c.infos[infokey] value

max(self, infoKey)

source code 

Get higest c.infos[infokey] value.
Parameters:
  • infoKey (str) - key for info dict
Returns: Complex
with highest c.info['infoKey'] value

argmin(self, infoKey)

source code 

Get index of complex c with lowest c.infos[infokey] value
Parameters:
  • infoKey (str) - key for info dict
Returns: int
index of complex c with lowest c.infos[infokey] value

min(self, infoKey)

source code 

Get lowest c.infos[infokey] value.
Parameters:
  • infoKey (str) - key for info dict
Returns: Complex
with lowest c.info['infoKey'] value

getIndex(self, infoKey, value)

source code 

Get list position of Complex where c.info['infoKey'] == value
Parameters:
  • value (any) - vaue to look for
  • infoKey (str) - key for info dict
Returns: int
position in ComplexList where c.info['infoKey'] == value
Raises:
  • AmbiguousMatch - ComplexNotFound, if there are more or less than 1 matches

getItem(self, infoKey, value)

source code 

Get Complex from ComplexList where c.info['infoKey'] == value
Parameters:
  • value (any) - vaue to look for
  • infoKey (str) - key for info dict
Returns: Complex
Complex where c.info['infoKey'] == value
Raises:
  • AmbiguousMatch - ComplexNotFound, if there are more or less than 1 matches

take(self, indices)

source code 

Take the complexes specified by indices.
Parameters:
  • indices ([int]) - array/list of int, list positions
Returns: ComplexList
ComplexList with all items specified.

toDict(self, infoKey)

source code 

Convert list into dict indexed by a certain info-record value. If several Complexes have the same value, the result will have a list registered for this key.

EXAMPLE:
>>> clst.toDict('soln') -> {1:Complex, 3:Complex, solnN:Complex}
Parameters:
  • infoKey (str) - key of info dict in Complexes
Returns: dict
{ info1:Complex, info2:Complex, info3:[Complex, Complex].. }

toList(self)

source code 

Convert ComplexList to simple python list of Complexes
Returns: [Complex]
simple python list of Complexes

__maskNone(self, l1, l2)

source code 

Take out positions from l1 and l2 that are None in either of them.
Parameters:
  • l1 (ComplexList) - first ComplexList
  • l2 (ComplexList) - second ComplexList
Returns: ComplexList, ComplexList
(l1, l2) modified lists

plot(self, xkey, *ykey, **arg)

source code 

Plot pairs of info values. The additional arg arguments are handed over to biggles.Points().:
 plot( xkey, [ykey1, ykey2..],[arg1=x, arg2=y]) -> biggles.FramedPlot
Parameters:
  • xkey (str) - key specifying x-values
  • ykey (str OR [str]) - key specifying y-values
  • arg (key=value) - additional biggles arguments
Returns: biggles.FramedPlot()
biggles plot object

plotArray(self, xkey, *ykey, **arg)

source code 

Plot pairs of info values.:
 plot( xkey, [ykey1, ykey2..],[arg1=x, arg2=y]) -> biggles.FramedArray
Parameters:
  • xkey (str) - key specifying x-values
  • ykey (str OR [str]) - key specifying y-values
  • arg (key=value) - additional biggles arguments
Returns: biggles.FramedArray
biggles plot object