mailr14874 - in /1.3/generic_fns: pcs.py rdc.py


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

Header


Content

Posted by edward on October 17, 2011 - 14:09:
Author: bugman
Date: Mon Oct 17 14:09:51 2011
New Revision: 14874

URL: http://svn.gna.org/viewcvs/relax?rev=14874&view=rev
Log:
Updated the RDC and PCS display and write user function backends for the new 
bc flag.

This allows access to the back-calculated rather than measured data.


Modified:
    1.3/generic_fns/pcs.py
    1.3/generic_fns/rdc.py

Modified: 1.3/generic_fns/pcs.py
URL: 
http://svn.gna.org/viewcvs/relax/1.3/generic_fns/pcs.py?rev=14874&r1=14873&r2=14874&view=diff
==============================================================================
--- 1.3/generic_fns/pcs.py (original)
+++ 1.3/generic_fns/pcs.py Mon Oct 17 14:09:51 2011
@@ -315,15 +315,17 @@
         grace.write_xy_data(data=data, file=file, graph_type=graph_type)
 
 
-def display(align_id=None):
+def display(align_id=None, bc=False):
     """Display the PCS data corresponding to the alignment ID.
 
     @keyword align_id:  The alignment tensor ID string.
     @type align_id:     str
+    @keyword bc:        The back-calculation flag which if True will cause 
the back-calculated rather than measured data to be displayed.
+    @type bc:           bool
     """
 
     # Call the write method with sys.stdout as the file.
-    write(align_id=align_id, file=sys.stdout)
+    write(align_id=align_id, file=sys.stdout, bc=bc)
 
 
 def q_factors(spin_id=None):
@@ -548,7 +550,7 @@
         spin.pcs_weight[align_id] = weight
 
 
-def write(align_id=None, file=None, dir=None, force=False):
+def write(align_id=None, file=None, dir=None, bc=False, force=False):
     """Display the PCS data corresponding to the alignment ID.
 
     @keyword align_id:  The alignment tensor ID string.
@@ -557,6 +559,8 @@
     @type file:         str or file object
     @keyword dir:       The name of the directory to place the file into 
(defaults to the current directory).
     @type dir:          str
+    @keyword bc:        The back-calculation flag which if True will cause 
the back-calculated rather than measured data to be written.
+    @type bc:           bool
     @keyword force:     A flag which if True will cause any pre-existing 
file to be overwritten.
     @type force:        bool
     """
@@ -581,12 +585,21 @@
     errors = []
     for spin, spin_id in spin_loop(return_id=True):
         # Skip spins with no PCSs.
-        if not hasattr(spin, 'pcs') or not align_id in spin.pcs.keys():
+        if not bc and (not hasattr(spin, 'pcs') or not align_id in 
spin.pcs.keys()):
             continue
-
-        # Store the data.
+        elif bc and (not hasattr(spin, 'pcs_bc') or align_id not in 
spin.pcs_bc.keys()):
+            continue
+
+        # Store the spin ID.
         spin_ids.append(spin_id)
-        values.append(spin.pcs[align_id])
+
+        # The value.
+        if bc:
+            values.append(spin.pcs_bc[align_id])
+        else:
+            values.append(spin.pcs[align_id])
+
+        # The error.
         if hasattr(spin, 'pcs_err') and align_id in spin.pcs_err.keys():
             errors.append(spin.pcs_err[align_id])
         else:

Modified: 1.3/generic_fns/rdc.py
URL: 
http://svn.gna.org/viewcvs/relax/1.3/generic_fns/rdc.py?rev=14874&r1=14873&r2=14874&view=diff
==============================================================================
--- 1.3/generic_fns/rdc.py (original)
+++ 1.3/generic_fns/rdc.py Mon Oct 17 14:09:51 2011
@@ -242,15 +242,17 @@
         grace.write_xy_data(data=data, file=file, graph_type=graph_type)
 
 
-def display(align_id=None):
+def display(align_id=None, bc=False):
     """Display the RDC data corresponding to the alignment ID.
 
     @keyword align_id:  The alignment tensor ID string.
     @type align_id:     str
+    @keyword bc:        The back-calculation flag which if True will cause 
the back-calculated rather than measured data to be displayed.
+    @type bc:           bool
     """
 
     # Call the write method with sys.stdout as the file.
-    write(align_id=align_id, file=sys.stdout)
+    write(align_id=align_id, file=sys.stdout, bc=bc)
 
 
 def q_factors(spin_id=None):
@@ -525,7 +527,7 @@
         spin.rdc_weight[align_id] = weight
 
 
-def write(align_id=None, file=None, dir=None, force=False):
+def write(align_id=None, file=None, dir=None, bc=False, force=False):
     """Display the RDC data corresponding to the alignment ID.
 
     @keyword align_id:  The alignment tensor ID string.
@@ -534,6 +536,8 @@
     @type file:         str or file object
     @keyword dir:       The name of the directory to place the file into 
(defaults to the current directory).
     @type dir:          str
+    @keyword bc:        The back-calculation flag which if True will cause 
the back-calculated rather than measured data to be written.
+    @type bc:           bool
     @keyword force:     A flag which if True will cause any pre-existing 
file to be overwritten.
     @type force:        bool
     """
@@ -561,14 +565,19 @@
     errors = []
     for spin, spin_id in spin_loop(return_id=True):
         # Skip spins with no RDCs.
-        if not hasattr(spin, 'rdc') or align_id not in spin.rdc.keys():
+        if not bc and (not hasattr(spin, 'rdc') or align_id not in 
spin.rdc.keys()):
+            continue
+        elif bc and (not hasattr(spin, 'rdc_bc') or align_id not in 
spin.rdc_bc.keys()):
             continue
 
         # Store the spin ID.
         spin_ids.append(spin_id)
 
         # The value.
-        values.append(convert(spin.rdc[align_id], align_id))
+        if bc:
+            values.append(convert(spin.rdc_bc[align_id], align_id))
+        else:
+            values.append(convert(spin.rdc[align_id], align_id))
 
         # The error.
         if hasattr(spin, 'rdc_err') and align_id in spin.rdc_err.keys():




Related Messages


Powered by MHonArc, Updated Mon Oct 17 18:40:02 2011