mailr2796 - in /branches/tensor_pdb: data.py data/diff_tensor.py data/diff_tensor_auto_objects.py


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by edward . dauvergne on November 10, 2006 - 06:40:
Author: bugman
Date: Fri Nov 10 06:39:55 2006
New Revision: 2796

URL: http://svn.gna.org/viewcvs/relax?rev=2796&view=rev
Log:
Complete redesign of 'self.relax.data.diff': auto-calculated objects updated 
when params are set.

The previous commits redesigned the 'self.relax.data.diff' code so that when 
a diffusion tensor
object (e.g. Diso, tensor, rotation, etc.) which is not one of the standard 
internal parameters is
accessed, they would be calculated on the fly.  Therefore if you asked for
'self.relax.data.diff[run].tensor', it would first be calculated and then 
returned.  Most of these
automatically created objects were setup when the program was initialised, 
although a few were
returned by the 'self.__getattr__()' function.

However this approach is incredibly slow.  This is especially apparent when 
each vector of the
spherical vector distribution for creating the geometric representation of 
the Brownian rotational
diffusion tensor is rotated and then extended to the correct length.  The 
chain of auto-object
creation by other auto-objects dependant on them together with the large 
number of accesses to
'self.relax.data.diff' caused the implementation to take minutes to create 
the vector distribution.

Therefore I have completely redesigned the code.  Rather than being 
calculated on the fly, the
objects are created when parameters are set.  This uses the 
'self.__setattr__()' function.  All the
auto-object functions of the file 'data/diff_tensor_auto_objects.py' have 
been shifted back into the
diffusion tensor class DiffTensorElement.  They have been renamed to 
'self._calc_'+obj where obj is
the calculated object name.  The underscored first character is used by the 
'Element' base class
method 'self.__repr__()' to hide the object when printing the contents of 
'self.relax.data.diff'.

The 'self.__setattr__()' function consists of two parts.  Firstly the 
'self.relax.data.diff' object
attribute is set and then the data structures are updated.  Before the 
attribute is set, it is
checked to see if it belongs to a list of modifiable attributes.  If it 
doesn't, a RelaxError is
thrown saying that the object is not modifiable.  If it is modifiable, it is 
set using the
statement:
    self.__dict__[name] = value

The objects which are currently updated include:
    Diso (the isotropic diffusion rate),
    Dpar (the diffusion rate parallel to the unique axis, spheroid only),
    Dper (the diffusion rate perpendicular to the unique axis, spheroid only),
    Dx (the diffusion rate parallel to the x-axis, ellipsoid only),
    Dy (the diffusion rate parallel to the y-axis, ellipsoid only),
    Dz (the diffusion rate parallel to the z-axis, ellipsoid only),
    Dratio (the ratio of Dpar and Dper, spheroid only),
    Dpar_unit (the unit vector parallel to the unique axis, spheroid only),
    Dx_unit (the unit vector parallel to the x-axis, ellipsoid only),
    Dy_unit (the unit vector parallel to the y-axis, ellipsoid only),
    Dz_unit (the unit vector parallel to the z-axis, ellipsoid only),
    tensor_diag (the diagonalised diffusion tensor),
    rotation (the rotation matrix),
    tensor (the diffusion tensor in the PDB frame).

These are all updated using the function 'self._update_object()'.  Dependant 
on the category (val,
err, sim) of the object being set by 'self.__setattr__()', this function 
updates solely the
value, error, or Monte Carlo simulation objects affected by it.  For 
efficiency it returns without
doing anything if the object being set is not within the 'update_if_set' 
list.  This is a list of
parameter names that, if modified, the 'target' object would then change.  The
'self._update_object()' function automatically determines which 
'self._calc_xxx()' function to use.
Then to update the 'target', the objects corresponding to the names in the 
'depends' list are sent
to the 'self._calc_xxx()' function which then returns the calculated object.  
If the object being
set belongs to the Monte Carlo simulation category, then the 
'self._update_object()' will create an
array by looping over each simulation calling 'self._calc_xxx()' for each 
sim.  The updated object
is then set using the statement:

    self.__dict__[target] = value

In the case of MC simulations, 'value' is replaced with 'sim_values'.


Removed:
    branches/tensor_pdb/data.py
    branches/tensor_pdb/data/diff_tensor_auto_objects.py
Modified:
    branches/tensor_pdb/data/diff_tensor.py

[This mail would be too long, it was shortened to contain the URLs only.]

Modified: branches/tensor_pdb/data/diff_tensor.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/tensor_pdb/data/diff_tensor.py?rev=2796&r1=2795&r2=2796&view=diff




Related Messages


Powered by MHonArc, Updated Fri Nov 10 07:40:05 2006