mailr7227 - /branches/rdc_analysis/specific_fns/n_state_model.py


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

Header


Content

Posted by edward on August 23, 2008 - 03:48:
Author: bugman
Date: Sat Aug 23 03:31:59 2008
New Revision: 7227

URL: http://svn.gna.org/viewcvs/relax?rev=7227&view=rev
Log:
Wrote a function to calculate the RDC Q-factor.


Modified:
    branches/rdc_analysis/specific_fns/n_state_model.py

Modified: branches/rdc_analysis/specific_fns/n_state_model.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/rdc_analysis/specific_fns/n_state_model.py?rev=7227&r1=7226&r2=7227&view=diff
==============================================================================
--- branches/rdc_analysis/specific_fns/n_state_model.py (original)
+++ branches/rdc_analysis/specific_fns/n_state_model.py Sat Aug 23 03:31:59 
2008
@@ -24,7 +24,7 @@
 """Module for the specific analysis of the N-state dynamic model."""
 
 # Python module imports.
-from math import acos, cos, pi
+from math import acos, cos, pi, sqrt
 from minfx.generic import generic_minimise
 from numpy import array, dot, float64, identity, ones, zeros
 from numpy.linalg import inv, norm
@@ -703,6 +703,42 @@
 
         # Return the data structures.
         return full_tensors, red_tensor_elem, red_tensor_err, 
full_in_ref_frame
+
+
+    def __q_factors_rdc(self):
+        """Calculate the Q-factors for the RDC data."""
+
+        # Alias the current data pipe.
+        cdp = ds[ds.current_pipe]
+
+        # Q-factor list.
+        cdp.q_factors = []
+
+        # Loop over the alignments.
+        for i in xrange(len(ds[ds.current_pipe].align_tensors)):
+            # Init.
+            D2_sum = 0.0
+            sse = 0.0
+
+            # Spin loop.
+            for spin in spin_loop():
+                # Skip deselected spins.
+                if not spin.select:
+                    continue
+
+                # Skip spins without RDC data.
+                if not hasattr(spin, 'rdc') or not hasattr(spin, 'rdc_bc') 
or spin.rdc[i] == None:
+                    continue
+
+                # Sum of squares.
+                sse = sse + (spin.rdc[i] - spin.rdc_bc[i])**2
+
+                # Sum the RDCs squared (for normalisation).
+                D2_sum = D2_sum + spin.rdc[i]**2
+
+            # The Q-factor for the alignment.
+            Q = sqrt(sse / D2_sum)
+            cdp.q_factors.append(Q)
 
 
     def __update_model(self):
@@ -1229,6 +1265,9 @@
             # Get the final back calculated data (for the Q-factor and
             self.__minimise_bc_data(model)
 
+            # Calculate the RDC Q-factors.
+            self.__q_factors_rdc()
+
 
     def model_statistics(self, instance=None, spin_id=None, 
global_stats=None):
         """Return the k, n, and chi2 model statistics.




Related Messages


Powered by MHonArc, Updated Sat Aug 23 04:20:06 2008