Author: bugman
Date: Thu Jan  3 15:52:24 2008
New Revision: 4272

URL: http://svn.gna.org/viewcvs/relax?rev=4272&view=rev
Log:
Finished converting generic_fns.value.set() to the new relax design.

The function is now considerably simpler.


Modified:
    1.3/generic_fns/value.py

Modified: 1.3/generic_fns/value.py
URL: 
http://svn.gna.org/viewcvs/relax/1.3/generic_fns/value.py?rev=4272&r1=4271&r2=4272&view=diff
==============================================================================
--- 1.3/generic_fns/value.py (original)
+++ 1.3/generic_fns/value.py Thu Jan  3 15:52:24 2008
@@ -29,6 +29,7 @@
 from data import Data as relax_data_store
 from generic_fns import diffusion_tensor
 from generic_fns.minimise import reset_min_stats
+from generic_fns.selection import exists_mol_res_spin_data, spin_loop
 from relax_errors import RelaxError, RelaxFileEmptyError, RelaxNoResError, 
RelaxNoPipeError, RelaxNoSequenceError, RelaxRegExpError, 
RelaxUnknownParamError, RelaxValueError
 from specific_fns import get_specific_fn
 
@@ -222,71 +223,35 @@
 
     if spin_params:
         # Test if the sequence data is loaded.
-        if not relax_data_store.res.has_key(run):
-            raise RelaxNoSequenceError, run
-
-        # Test if the residue number is a valid regular expression.
-        if type(spin_num) == str:
-            try:
-                compile(spin_num)
-            except:
-                raise RelaxRegExpError, ('residue number', spin_num)
-
-        # Test if the residue name is a valid regular expression.
-        if spin_name:
-            try:
-                compile(spin_name)
-            except:
-                raise RelaxRegExpError, ('residue name', spin_name)
-
-        # Test if parameter value already exists.
+        if not exists_mol_res_spin_data():
+            raise RelaxNoSequenceError
+
+        # First test if parameter value already exists, prior to setting any 
params.
         if not force:
-            # Loop over the residues.
-            for i in xrange(len(relax_data_store.res[run])):
-                # Skip unselected residues.
-                if not relax_data_store.res[run][i].select:
-                    continue
-
-                # If 'spin_num' is not None, skip the residue if there is no 
match.
-                if type(spin_num) == int and not 
relax_data_store.res[run][i].num == spin_num:
-                    continue
-                elif type(spin_num) == str and not match(spin_num, 
`relax_data_store.res[run][i].num`):
-                    continue
-
-                # If 'spin_name' is not None, skip the residue if there is no 
match.
-                if spin_name != None and not match(spin_name, 
relax_data_store.res[run][i].name):
+            # Loop over the spins.
+            for spin in spin_loop(spin_id):
+                # Skip unselected spins.
+                if not spin.select:
                     continue
 
                 # Loop over the parameters.
                 for param in spin_params:
-                    if param:
-                        # Get the value and error.
-                        temp_value, temp_error = return_value(run, i, param)
-
-                        # Data exists.
-                        if temp_value != None or temp_error != None:
-                            raise RelaxValueError, (param, run)
-
-        # Loop over the sequence.
-        for i in xrange(len(relax_data_store.res[run])):
+                    # Get the value and error.
+                    temp_value, temp_error = return_value(spin, param)
+
+                    # Data exists.
+                    if temp_value != None or temp_error != None:
+                        raise RelaxValueError, (param)
+
+        # Loop over the spins.
+        for spin in spin_loop(spin_id):
             # Skip unselected residues.
-            if not relax_data_store.res[run][i].select:
-                continue
-
-            # If 'spin_num' is not None, skip the residue if there is no match.
-            if type(spin_num) == int and not relax_data_store.res[run][i].num 
== spin_num:
-                continue
-            elif type(spin_num) == str and not match(spin_num, 
`relax_data_store.res[run][i].num`):
-                continue
-
-            # If 'spin_name' is not None, skip the residue if there is no 
match.
-            if spin_name != None and not match(spin_name, 
relax_data_store.res[run][i].name):
+            if not spin.select:
                 continue
 
             # Go to the specific code.
             for j in xrange(len(spin_params)):
-                set(run=run, value=spin_values[j], error=None, 
param=spin_params[j], index=i)
-
+                set(value=spin_values[j], error=None, spin=spin, 
param=spin_params[j])
 
     # Reset all minimisation statistics.
     reset_min_stats()


_______________________________________________
relax (http://nmr-relax.com)

This is the relax-commits mailing list
relax-commits@gna.org

To unsubscribe from this list, get a password
reminder, or change your subscription options,
visit the list information page at
https://mail.gna.org/listinfo/relax-commits

Reply via email to