mailr6903 - /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 July 09, 2008 - 18:20:
Author: bugman
Date: Wed Jul  9 18:09:14 2008
New Revision: 6903

URL: http://svn.gna.org/viewcvs/relax?rev=6903&view=rev
Log:
Spun out some of the minimise() code to create the __determine_data_type() 
method.


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=6903&r1=6902&r2=6903&view=diff
==============================================================================
--- branches/rdc_analysis/specific_fns/n_state_model.py (original)
+++ branches/rdc_analysis/specific_fns/n_state_model.py Wed Jul  9 18:09:14 
2008
@@ -92,6 +92,37 @@
                 cdp.beta = [None] * cdp.N
             if not hasattr(cdp, 'gamma'):
                 cdp.gamma = [None] * cdp.N
+
+
+    def __determine_data_type(self):
+        """Determine if the data type is alignment tensors or RDCs.
+
+        @return:    The data type being one of 'tensor' or 'rdc'.
+        @rtype:     str
+        """
+
+
+        # Alignment tensor search.
+        tensor_flag = False
+        if hasattr(cdp, 'align_tensors'):
+            tensor_flag = True
+
+        # RDC search.
+        rdc_flag = False
+        for spin in spin_loop():
+            if hasattr(spin, 'rdc'):
+                rdc_flag = True
+                break
+
+        # Ok, have no idea what to do, so complain.
+        if tensor_flag and rdc_flag:
+            raise RelaxError, "Both RDCs and alignment tensors are present.  
Cannot determine the data type to be used for the analysis." 
+
+        # Return the data type.
+        if tensor_flag:
+            return 'tensor'
+        else:
+            return 'rdc'
 
 
     def assemble_param_vector(self, sim_index=None):
@@ -610,25 +641,14 @@
             A, b = self.linear_constraints()
 
         # Determine if alignment tensors or RDCs are to be used.
-        tensor_flag = False
-        rdc_flag = False
-        if hasattr(cdp, 'align_tensors'):
-            tensor_flag = True
-        for spin in spin_loop():
-            if hasattr(spin, 'rdc'):
-                rdc_flag = True
-                break
-
-        # Ok, have no idea what to do, so complain.
-        if tensor_flag and rdc_flag:
-            raise RelaxError, "Both RDCs and alignment tensors are present.  
Cannot determine which will be used for optimisation." 
+        data_type = self.__determine_data_type()
 
         # Set up minimisation using alignment tensors.
-        if tensor_flag:
+        if data_type == 'tensor':
             model = self.minimise_setup_tensors(param_vector=param_vector)
 
         # Set up minimisation using RDCs.
-        elif rdc_flag:
+        elif data_type == 'rdc':
             model = self.minimise_setup_rdcs(param_vector=param_vector)
 
         # Minimisation.




Related Messages


Powered by MHonArc, Updated Wed Jul 09 18:40:13 2008