mailr12659 - in /branches/relax_data: generic_fns/relax_data.py prompt/relax_data.py


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

Header


Content

Posted by edward on March 01, 2011 - 18:09:
Author: bugman
Date: Tue Mar  1 18:09:40 2011
New Revision: 12659

URL: http://svn.gna.org/viewcvs/relax?rev=12659&view=rev
Log:
Converted the back and front ends of the relax_data.copy() user function to 
the new design.


Modified:
    branches/relax_data/generic_fns/relax_data.py
    branches/relax_data/prompt/relax_data.py

Modified: branches/relax_data/generic_fns/relax_data.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/relax_data/generic_fns/relax_data.py?rev=12659&r1=12658&r2=12659&view=diff
==============================================================================
--- branches/relax_data/generic_fns/relax_data.py (original)
+++ branches/relax_data/generic_fns/relax_data.py Tue Mar  1 18:09:40 2011
@@ -338,19 +338,15 @@
     star.experiment.add(name=exp_label, spectrometer_ids=spectro_ids, 
spectrometer_labels=spectro_labels)
 
 
-def copy(pipe_from=None, pipe_to=None, ri_label=None, frq_label=None):
+def copy(pipe_from=None, pipe_to=None, ri_id=None):
     """Copy the relaxation data from one data pipe to another.
 
-    @keyword pipe_from: The data pipe to copy the relaxation data from.  
This defaults to the
-                        current data pipe.
+    @keyword pipe_from: The data pipe to copy the relaxation data from.  
This defaults to the current data pipe.
     @type pipe_from:    str
-    @keyword pipe_to:   The data pipe to copy the relaxation data to.  This 
defaults to the current
-                        data pipe.
+    @keyword pipe_to:   The data pipe to copy the relaxation data to.  This 
defaults to the current data pipe.
     @type pipe_to:      str
-    @param ri_label:    The relaxation data type, ie 'R1', 'R2', or 'NOE'.
+    @param ri_id:       The relaxation data ID string.
     @type ri_label:     str
-    @param frq_label:   The field strength label.
-    @type frq_label:    str
     """
 
     # Defaults.
@@ -378,7 +374,7 @@
         raise RelaxNoSequenceError
 
     # Copy all data.
-    if ri_label == None and frq_label == None:
+    if ri_id == None:
         # Get all data structure names.
         names = get_data_names()
 
@@ -399,13 +395,13 @@
 
     # Copy a specific data set.
     else:
-        # Test if relaxation data corresponding to 'ri_label' and 
'frq_label' exists for pipe_from.
-        if not test_labels(ri_label, frq_label, pipe=pipe_from):
-            raise RelaxNoRiError(ri_label, frq_label)
-
-        # Test if relaxation data corresponding to 'ri_label' and 
'frq_label' exists for pipe_to.
-        if not test_labels(ri_label, frq_label, pipe=pipe_to):
-            raise RelaxRiError(ri_label, frq_label)
+        # Test if relaxation data ID string exists for pipe_from.
+        if not hasattr(dp_from, 'ri_ids') or ri_id not in dp_from.ri_ids:
+            raise RelaxNoRiError(ri_id)
+
+        # Test if relaxation data ID string exists for pipe_to.
+        if not hasattr(dp_to, 'ri_ids') or ri_id not in dp_to.ri_ids:
+            raise RelaxNoRiError(ri_id)
 
         # Spin loop.
         for mol_index, res_index, spin_index in spin_index_loop():
@@ -413,19 +409,15 @@
             spin_from = 
dp_from.mol[mol_index].res[res_index].spin[spin_index]
             spin_to = dp_to.mol[mol_index].res[res_index].spin[spin_index]
 
-            # Find the index corresponding to 'ri_label' and 'frq_label'.
-            index = find_ri_index(spin_from, ri_label, frq_label)
-
-            # Catch any problems.
-            if index == None:
-                continue
-
-            # Get the value and error from pipe_from.
-            value = spin_from.relax_data[index]
-            error = spin_from.relax_error[index]
-
-            # Update all data structures for pipe_to.
-            update_data_structures_spin(spin_to, ri_label, frq_label, frq, 
value, error)
+            # Initialise the spin data if necessary.
+            if not hasattr(spin_to, 'ri_data'):
+                spin_to.ri_data = {}
+            if not hasattr(spin_to, 'ri_data_err'):
+                spin_to.ri_data_err = {}
+
+            # Copy the value and error from pipe_from.
+            spin_to.ri_data[ri_id] = spin_from.ri_data[ri_id]
+            spin_to.ri_data_err[ri_id] = spin_from.ri_data_err[ri_id]
 
 
 def get_data_names(global_flag=False, sim_names=False):
@@ -715,9 +707,9 @@
             raise RelaxNoSpinError(spin_ids[i])
 
         # Initialise the spin data if necessary.
-        if not hasattr(cdp, 'ri_data'):
+        if not hasattr(spin, 'ri_data'):
             spin.ri_data = {}
-        if not hasattr(cdp, 'ri_data_err'):
+        if not hasattr(spin, 'ri_data_err'):
             spin.ri_data_err = {}
 
         # Update all data structures.

Modified: branches/relax_data/prompt/relax_data.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/relax_data/prompt/relax_data.py?rev=12659&r1=12658&r2=12659&view=diff
==============================================================================
--- branches/relax_data/prompt/relax_data.py (original)
+++ branches/relax_data/prompt/relax_data.py Tue Mar  1 18:09:40 2011
@@ -65,8 +65,8 @@
         relax_data.back_calc(ri_label=ri_label, frq_label=frq_label, frq=frq)
 
 
-    def copy(self, pipe_from=None, pipe_to=None, ri_label=None, 
frq_label=None):
-        """Function for copying relaxation data from pipe_from to pipe_to.
+    def copy(self, pipe_from=None, pipe_to=None, ri_id=None):
+        """Copy relaxation data from one pipe to another.
 
         Keyword Arguments
         ~~~~~~~~~~~~~~~~~
@@ -75,17 +75,15 @@
 
         pipe_to:  The name of the pipe to copy the relaxation data to.
 
-        ri_label:  The relaxation data type, ie 'R1', 'R2', or 'NOE'.
-
-        frq_label:  The field strength label.
-
-
-        Description
-        ~~~~~~~~~~~
-
-        This function will copy relaxation data from 'pipe_from' to 
'pipe_to'.  If ri_label and frq_label
-        are not given then all relaxation data will be copied, otherwise 
only a specific data set
-        will be copied.
+        ri_id:  The relaxation data ID string.
+
+
+        Description
+        ~~~~~~~~~~~
+
+        This function will copy relaxation data from 'pipe_from' to 
'pipe_to'.  If ri_id is not
+        given then all relaxation data will be copied, otherwise only a 
specific data set will be
+        copied.
 
 
         Examples
@@ -95,14 +93,14 @@
 
         relax> relax_data.copy('m1', 'm9')
         relax> relax_data.copy(pipe_from='m1', pipe_to='m9')
-        relax> relax_data.copy('m1', 'm9', None, None)
-        relax> relax_data.copy(pipe_from='m1', pipe_to='m9', ri_label=None, 
frq_label=None)
-
-        To copy only the NOE relaxation data with the frq_label of '800' 
from 'm3' to 'm6', type one
-        of:
-
-        relax> relax_data.copy('m3', 'm6', 'NOE', '800')
-        relax> relax_data.copy(pipe_from='m3', pipe_to='m6', ri_label='NOE', 
frq_label='800')
+        relax> relax_data.copy('m1', 'm9', None)
+        relax> relax_data.copy(pipe_from='m1', pipe_to='m9', ri_id=None)
+
+        To copy only the NOE relaxation data with the ID string of 'NOE_800' 
from 'm3' to 'm6', type
+        one of:
+
+        relax> relax_data.copy('m3', 'm6', 'NOE_800')
+        relax> relax_data.copy(pipe_from='m3', pipe_to='m6', ri_id='NOE_800')
         """
 
         # Function intro text.
@@ -110,22 +108,20 @@
             text = self._exec_info.ps3 + "relax_data.copy("
             text = text + "pipe_from=" + repr(pipe_from)
             text = text + ", pipe_to=" + repr(pipe_to)
-            text = text + ", ri_label=" + repr(ri_label)
-            text = text + ", frq_label=" + repr(frq_label) + ")"
+            text = text + ", ri_id=" + repr(ri_id) + ")"
             print(text)
 
         # The argument checks.
         arg_check.is_str(pipe_from, 'pipe from', can_be_none=True)
         arg_check.is_str(pipe_to, 'pipe to', can_be_none=True)
-        arg_check.is_str(ri_label, 'relaxation label', can_be_none=True)
-        arg_check.is_str(frq_label, 'frequency label', can_be_none=True)
+        arg_check.is_str(ri_id, 'relaxation data ID string', 
can_be_none=True)
 
         # Both pipe arguments cannot be None.
         if pipe_from == None and pipe_to == None:
             raise RelaxError("The pipe_from and pipe_to arguments cannot 
both be set to None.")
 
         # Execute the functional code.
-        relax_data.copy(pipe_from=pipe_from, pipe_to=pipe_to, 
ri_label=ri_label, frq_label=frq_label)
+        relax_data.copy(pipe_from=pipe_from, pipe_to=pipe_to, ri_id=ri_id)
 
 
     def delete(self, ri_label=None, frq_label=None):




Related Messages


Powered by MHonArc, Updated Tue Mar 01 18:20:01 2011