mailr7565 - in /1.3: prompt/noe.py specific_fns/noe.py


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

Header


Content

Posted by edward on October 07, 2008 - 23:04:
Author: bugman
Date: Tue Oct  7 23:04:49 2008
New Revision: 7565

URL: http://svn.gna.org/viewcvs/relax?rev=7565&view=rev
Log:
Converted the noe.error() user function front and back-end to the new design.


Modified:
    1.3/prompt/noe.py
    1.3/specific_fns/noe.py

Modified: 1.3/prompt/noe.py
URL: 
http://svn.gna.org/viewcvs/relax/1.3/prompt/noe.py?rev=7565&r1=7564&r2=7565&view=diff
==============================================================================
--- 1.3/prompt/noe.py (original)
+++ 1.3/prompt/noe.py Tue Oct  7 23:04:49 2008
@@ -42,7 +42,7 @@
         self.__relax__ = relax
 
 
-    def error(self, error=0.0, spectrum_type=None, res_num=None, 
res_name=None):
+    def error(self, error=0.0, spectrum_type=None, spin_id=None):
         """Function for setting the errors in the reference or saturated NOE 
spectra.
 
         Keyword Arguments
@@ -52,9 +52,7 @@
 
         spectrum_type:  The type of spectrum.
 
-        res_num:  The residue number.
-
-        res_name:  The residue name.
+        spin_id:  The spin identification string.
 
 
         Description
@@ -76,8 +74,7 @@
             text = sys.ps3 + "noe.error("
             text = text + "error=" + `error`
             text = text + ", spectrum_type=" + `spectrum_type`
-            text = text + ", res_num=" + `res_num`
-            text = text + ", res_name=" + `res_name` + ")"
+            text = text + ", spin_id=" + `spin_id` + ")"
             print text
 
         # The error.
@@ -88,16 +85,12 @@
         if type(spectrum_type) != str:
             raise RelaxStrError, ('spectrum type', spectrum_type)
 
-        # Residue number.
-        if res_num != None and type(res_num) != int and type(res_num) != str:
-            raise RelaxNoneIntStrError, ('residue number', res_num)
-
-        # Residue name.
-        if res_name != None and type(res_name) != str:
-            raise RelaxNoneStrError, ('residue name', res_name)
+        # Spin identification string.
+        if spin_id != None and type(spin_id) != str:
+            raise RelaxNoneStrError, ('spin identification string', spin_id)
 
         # Execute the functional code.
-        noe_obj.set_error(error=error, spectrum_type=spectrum_type, 
res_num=res_num, res_name=res_name)
+        noe_obj.set_error(error=error, spectrum_type=spectrum_type, 
spin_id=spin_id)
 
 
     def read(self, file=None, dir=None, spectrum_type=None, format='sparky', 
heteronuc='N', proton='HN', int_col=None):

Modified: 1.3/specific_fns/noe.py
URL: 
http://svn.gna.org/viewcvs/relax/1.3/specific_fns/noe.py?rev=7565&r1=7564&r2=7565&view=diff
==============================================================================
--- 1.3/specific_fns/noe.py (original)
+++ 1.3/specific_fns/noe.py Tue Oct  7 23:04:49 2008
@@ -27,7 +27,7 @@
 # relax module imports.
 from data import Relax_data_store; ds = Relax_data_store()
 from generic_fns import intensity, pipes
-from generic_fns.mol_res_spin import exists_mol_res_spin_data
+from generic_fns.mol_res_spin import exists_mol_res_spin_data, spin_loop
 from relax_errors import RelaxArgNotInListError, RelaxError, 
RelaxInvalidDataError, RelaxNoSequenceError, RelaxRegExpError
 from relax_io import open_write_file
 
@@ -349,14 +349,17 @@
         return value, error
 
 
-    def set_error(self, run=None, error=0.0, spectrum_type=None, 
res_num=None, res_name=None):
-        """Function for setting the errors."""
-
-        # Arguments.
-        self.run = run
-        self.spectrum_type = spectrum_type
-        self.res_num = res_num
-        self.res_name = res_name
+    def set_error(self, error=0.0, spectrum_type=None, spin_id=None):
+        """Set the peak intensity errors.
+
+        @param error:           The peak intensity error value defined as 
the RMSD of the base plane
+                                noise.
+        @type error:            float
+        @keyword spectrum_type: The type of spectrum, one of 'ref' or 'sat'.
+        @type spectrum_type:    str
+        @param spin_id:         The spin identification string.
+        @type spin_id:          str
+        """
 
         # Test if the current pipe exists
         pipes.test()
@@ -365,44 +368,17 @@
         if not exists_mol_res_spin_data():
             raise RelaxNoSequenceError
 
-        # Test if the residue number is a valid regular expression.
-        if type(res_num) == str:
-            try:
-                compile(res_num)
-            except:
-                raise RelaxRegExpError, ('residue number', res_num)
-
-        # Test if the residue name is a valid regular expression.
-        if res_name:
-            try:
-                compile(res_name)
-            except:
-                raise RelaxRegExpError, ('residue name', res_name)
-
-        # Loop over the sequence.
-        for i in xrange(len(ds.res[run])):
-            # Remap the data structure 'ds.res[self.run][i]'.
-            data = ds.res[self.run][i]
-
-            # Skip deselected residues.
-            if not data.select:
+        # Loop over the spins.
+        for spin in spin_loop(spin_id):
+            # Skip deselected spins.
+            if not spin.select:
                 continue
 
-            # If 'res_num' is not None, skip the residue if there is no 
match.
-            if type(res_num) == int and not data.num == res_num:
-                continue
-            elif type(res_num) == str and not match(res_num, `data.num`):
-                continue
-
-            # If 'res_name' is not None, skip the residue if there is no 
match.
-            if res_name != None and not match(res_name, data.name):
-                continue
-
             # Set the error.
-            if self.spectrum_type == 'ref':
-                data.ref_err = float(error)
-            elif self.spectrum_type == 'sat':
-                data.sat_err = float(error)
+            if spectrum_type == 'ref':
+                spin.ref_err = float(error)
+            elif spectrum_type == 'sat':
+                spin.sat_err = float(error)
 
 
     def write(self, run=None, file=None, dir=None, force=False):




Related Messages


Powered by MHonArc, Updated Tue Oct 07 23:20:03 2008