mailr25823 - /branches/frame_order_cleanup/specific_analyses/frame_order/checks.py


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

Header


Content

Posted by edward on September 14, 2014 - 13:13:
Author: bugman
Date: Sun Sep 14 13:13:40 2014
New Revision: 25823

URL: http://svn.gna.org/viewcvs/relax?rev=25823&view=rev
Log:
Created the check_parameters() function for the frame order analysis.

This is in the specific_analyses.frame_order.checks module.  The function 
checks that the frame
order parameters have been set up and have values.


Modified:
    branches/frame_order_cleanup/specific_analyses/frame_order/checks.py

Modified: branches/frame_order_cleanup/specific_analyses/frame_order/checks.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/frame_order_cleanup/specific_analyses/frame_order/checks.py?rev=25823&r1=25822&r2=25823&view=diff
==============================================================================
--- branches/frame_order_cleanup/specific_analyses/frame_order/checks.py      
  (original)
+++ branches/frame_order_cleanup/specific_analyses/frame_order/checks.py      
  Sun Sep 14 13:13:40 2014
@@ -94,6 +94,55 @@
     return flag
 
 
+def check_parameters(escalate=0):
+    """Check if the frame order parameters exist.
+
+    @keyword escalate:      The feedback to give if the check fails.  This 
can be 0 for no printouts, 1 to throw a RelaxWarning, or 2 to raise a 
RelaxError.
+    @type escalate:         int
+    @raises RelaxError:     If escalate is set to 2 and the check fails.
+    @return:                True if the check passes, False otherwise.
+    @rtype:                 bool
+    """
+
+    # Init.
+    flag = True
+    msg = ''
+    missing = []
+
+    # The model has not been set up.
+    if not hasattr(cdp, 'params'):
+        flag = False
+        msg = "The frame order model has not been set up, no parameters have 
been defined."
+
+    # The model has been set up.
+    else:
+        # Loop over all parameters.
+        for param in cdp.params:
+            # Check that the parameters exists.
+            if not hasattr(cdp, param):
+                missing.append(param)
+
+            # Check that it has a value.
+            else:
+                obj = getattr(cdp, param)
+                if obj == None:
+                    missing.append(param)
+
+        # Failure.
+        if len(missing):
+            flag = False
+            msg = "The frame order parameters %s have not been set up." % 
missing
+
+    # Warnings and errors.
+    if not flag and escalate == 1:
+        warn(RelaxWarning(msg))
+    elif not flag and escalate == 2:
+        raise RelaxError(msg)
+
+    # Return the answer.
+    return flag
+
+
 def check_pivot(pipe_name=None):
     """Check that the pivot point has been set.
 




Related Messages


Powered by MHonArc, Updated Sun Sep 14 13:20:02 2014