mailr20118 - in /trunk/specific_analyses/n_state_model: __init__.py data.py


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

Header


Content

Posted by edward on June 14, 2013 - 13:54:
Author: bugman
Date: Fri Jun 14 13:54:21 2013
New Revision: 20118

URL: http://svn.gna.org/viewcvs/relax?rev=20118&view=rev
Log:
Shifted another method from the N_state_model class to the 
specific_analyses.n_state_model.data module.


Modified:
    trunk/specific_analyses/n_state_model/__init__.py
    trunk/specific_analyses/n_state_model/data.py

Modified: trunk/specific_analyses/n_state_model/__init__.py
URL: 
http://svn.gna.org/viewcvs/relax/trunk/specific_analyses/n_state_model/__init__.py?rev=20118&r1=20117&r2=20118&view=diff
==============================================================================
--- trunk/specific_analyses/n_state_model/__init__.py (original)
+++ trunk/specific_analyses/n_state_model/__init__.py Fri Jun 14 13:54:21 2013
@@ -56,7 +56,7 @@
 from pipe_control.structure.mass import centre_of_mass
 from specific_analyses.api_base import API_base
 from specific_analyses.api_common import API_common
-from specific_analyses.n_state_model.data import base_data_types, 
check_rdcs, num_data_points, opt_tensor, opt_uses_align_data, tensor_loop
+from specific_analyses.n_state_model.data import base_data_types, 
calc_ave_dist, check_rdcs, num_data_points, opt_tensor, opt_uses_align_data, 
tensor_loop
 from specific_analyses.n_state_model.parameters import 
assemble_param_vector, assemble_scaling_matrix, disassemble_param_vector, 
linear_constraints, param_model_index, param_num, update_model
 from target_functions.n_state_model import N_state_opt
 from target_functions.potential import quad_pot
@@ -86,54 +86,6 @@
 
         # Add the minimisation data.
         self.PARAMS.add_min_data(min_stats_global=False, min_stats_spin=True)
-
-
-    def _calc_ave_dist(self, atom1, atom2, exp=1):
-        """Calculate the average distances.
-
-        The formula used is::
-
-                      _N_
-                  / 1 \                  \ 1/exp
-            <r> = | -  > |p1i - p2i|^exp |
-                  \ N /__                /
-                       i
-
-        where i are the members of the ensemble, N is the total number of 
structural models, and p1
-        and p2 at the two atom positions.
-
-
-        @param atom1:   The atom identification string of the first atom.
-        @type atom1:    str
-        @param atom2:   The atom identification string of the second atom.
-        @type atom2:    str
-        @keyword exp:   The exponent used for the averaging, e.g. 1 for 
linear averaging and -6 for
-                        r^-6 NOE averaging.
-        @type exp:      int
-        @return:        The average distance between the two atoms.
-        @rtype:         float
-        """
-
-        # Get the spin containers.
-        spin1 = return_spin(atom1)
-        spin2 = return_spin(atom2)
-
-        # Loop over each model.
-        num_models = len(spin1.pos)
-        ave_dist = 0.0
-        for i in range(num_models):
-            # Distance to the minus sixth power.
-            dist = norm(spin1.pos[i] - spin2.pos[i])
-            ave_dist = ave_dist + dist**(exp)
-
-        # Average.
-        ave_dist = ave_dist / num_models
-
-        # The exponent.
-        ave_dist = ave_dist**(1.0/exp)
-
-        # Return the average distance.
-        return ave_dist
 
 
     def _CoM(self, pivot_point=None, centre=None):
@@ -1004,7 +956,7 @@
                 upper[i] = cdp.noe_restraints[i][3]
 
                 # Calculate the average distances, using -6 power averaging.
-                dist[i] = self._calc_ave_dist(cdp.noe_restraints[i][0], 
cdp.noe_restraints[i][1], exp=-6)
+                dist[i] = calc_ave_dist(cdp.noe_restraints[i][0], 
cdp.noe_restraints[i][1], exp=-6)
 
             # Calculate the quadratic potential.
             quad_pot(dist, pot, lower, upper)

Modified: trunk/specific_analyses/n_state_model/data.py
URL: 
http://svn.gna.org/viewcvs/relax/trunk/specific_analyses/n_state_model/data.py?rev=20118&r1=20117&r2=20118&view=diff
==============================================================================
--- trunk/specific_analyses/n_state_model/data.py (original)
+++ trunk/specific_analyses/n_state_model/data.py Fri Jun 14 13:54:21 2013
@@ -23,6 +23,7 @@
 """Module for handling base data of the N-state model or structural ensemble 
analysis."""
 
 # Python module imports.
+from numpy.linalg import norm
 from warnings import warn
 
 # relax module imports.
@@ -30,7 +31,7 @@
 from lib.warnings import RelaxWarning
 from pipe_control import align_tensor
 from pipe_control.interatomic import interatomic_loop
-from pipe_control.mol_res_spin import spin_loop
+from pipe_control.mol_res_spin import return_spin, spin_loop
 
 
 def base_data_types():
@@ -75,6 +76,54 @@
 
     # Return the list.
     return list
+
+
+def calc_ave_dist(atom1, atom2, exp=1):
+    """Calculate the average distances.
+
+    The formula used is::
+
+                  _N_
+              / 1 \                  \ 1/exp
+        <r> = | -  > |p1i - p2i|^exp |
+              \ N /__                /
+                   i
+
+    where i are the members of the ensemble, N is the total number of 
structural models, and p1
+    and p2 at the two atom positions.
+
+
+    @param atom1:   The atom identification string of the first atom.
+    @type atom1:    str
+    @param atom2:   The atom identification string of the second atom.
+    @type atom2:    str
+    @keyword exp:   The exponent used for the averaging, e.g. 1 for linear 
averaging and -6 for
+                    r^-6 NOE averaging.
+    @type exp:      int
+    @return:        The average distance between the two atoms.
+    @rtype:         float
+    """
+
+    # Get the spin containers.
+    spin1 = return_spin(atom1)
+    spin2 = return_spin(atom2)
+
+    # Loop over each model.
+    num_models = len(spin1.pos)
+    ave_dist = 0.0
+    for i in range(num_models):
+        # Distance to the minus sixth power.
+        dist = norm(spin1.pos[i] - spin2.pos[i])
+        ave_dist = ave_dist + dist**(exp)
+
+    # Average.
+    ave_dist = ave_dist / num_models
+
+    # The exponent.
+    ave_dist = ave_dist**(1.0/exp)
+
+    # Return the average distance.
+    return ave_dist
 
 
 def check_rdcs(interatom, spin1, spin2):




Related Messages


Powered by MHonArc, Updated Fri Jun 14 16:20:03 2013