mailr8928 - in /branches/bmrb: ./ generic_fns/mol_res_spin.py generic_fns/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 08, 2009 - 22:15:
Author: bugman
Date: Sun Mar  8 22:15:18 2009
New Revision: 8928

URL: http://svn.gna.org/viewcvs/relax?rev=8928&view=rev
Log:
Merged revisions 8920-8927 via svnmerge from 
svn+ssh://bugman@xxxxxxxxxxx/svn/relax/1.3

........
  r8925 | bugman | 2009-03-06 19:21:27 +0100 (Fri, 06 Mar 2009) | 5 lines
  
  The read() function has been split into to for code recycling in the bmrb 
branch.
  
  The new pack_data() function has been spun off to fill the data pipe and 
spin containers.
........
  r8926 | bugman | 2009-03-06 19:25:21 +0100 (Fri, 06 Mar 2009) | 5 lines
  
  Bug fix for the read() function.
  
  The construction of the data for sending to pack_data() was failing.
........
  r8927 | bugman | 2009-03-06 19:25:49 +0100 (Fri, 06 Mar 2009) | 3 lines
  
  Spacing fix.
........

Modified:
    branches/bmrb/   (props changed)
    branches/bmrb/generic_fns/mol_res_spin.py
    branches/bmrb/generic_fns/relax_data.py

Propchange: branches/bmrb/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Sun Mar  8 22:15:18 2009
@@ -1,1 +1,1 @@
-/1.3:1-8919
+/1.3:1-8927

Modified: branches/bmrb/generic_fns/mol_res_spin.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/bmrb/generic_fns/mol_res_spin.py?rev=8928&r1=8927&r2=8928&view=diff
==============================================================================
--- branches/bmrb/generic_fns/mol_res_spin.py (original)
+++ branches/bmrb/generic_fns/mol_res_spin.py Sun Mar  8 22:15:18 2009
@@ -841,7 +841,6 @@
     for i in xrange(len(cdp.mol)):
         if cdp.mol[i].name == mol_name:
             raise RelaxError, "The molecule '" + `mol_name` + "' already 
exists in the relax data store."
-
 
     # Append the molecule.
     cdp.mol.add_item(mol_name=mol_name)

Modified: branches/bmrb/generic_fns/relax_data.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/bmrb/generic_fns/relax_data.py?rev=8928&r1=8927&r2=8928&view=diff
==============================================================================
--- branches/bmrb/generic_fns/relax_data.py (original)
+++ branches/bmrb/generic_fns/relax_data.py Sun Mar  8 22:15:18 2009
@@ -29,7 +29,7 @@
 
 # relax module imports.
 from data import Relax_data_store; ds = Relax_data_store()
-from generic_fns.mol_res_spin import exists_mol_res_spin_data, 
generate_spin_id_data_array, return_spin, spin_index_loop, spin_loop
+from generic_fns.mol_res_spin import create_molecule, create_residue, 
create_spin, exists_mol_res_spin_data, generate_spin_id, return_spin, 
spin_index_loop, spin_loop
 from generic_fns import pipes
 from generic_fns import value
 from relax_errors import RelaxError, RelaxNoRiError, RelaxNoSequenceError, 
RelaxNoSpinError, RelaxRiError
@@ -596,6 +596,65 @@
 
     # Return the index.
     return index
+
+
+def pack_data(ri_label, frq_label, frq, values, errors, mol_names=None, 
res_nums=None, res_names=None, spin_nums=None, spin_names=None, 
gen_seq=False):
+    """Pack the relaxation data into the data pipe and spin containers.
+
+    The values, errors, mol_names, res_nums, res_names, spin_nums, and 
spin_names arguments must be
+    lists of equal length or None.  Each element i corresponds to a unique 
spin.
+
+    @param ri_label:        The relaxation data type, ie 'R1', 'R2', or 
'NOE'.
+    @type ri_label:         str
+    @param frq_label:       The field strength label.
+    @type frq_label:        str
+    @param frq:             The spectrometer proton frequency in Hz.
+    @type frq:              float
+    @keyword mol_names:     The list of molecule names for each spin.
+    @type mol_names:        None or list of str
+    @keyword res_nums:      The list of residue numbers for each spin.
+    @type res_nums:         None or list of str
+    @keyword res_names:     The list of residue names for each spin.
+    @type res_names:        None or list of str
+    @keyword spin_nums:     The list of spin numbers.
+    @type spin_nums:        None or list of str
+    @keyword spin_names:    The list of spin names.
+    @type spin_names:       None or list of str
+    @keyword gen_seq:       A flag which if True will cause the molecule, 
residue, and spin sequence
+                            data to be generated.
+    @type gen_seq:          bool
+    """
+
+    # Get the current data pipe.
+    cdp = pipes.get_pipe()
+
+    # Initialise the global data for the current pipe if necessary.
+    data_init(cdp, global_flag=True)
+
+    # Update the global data.
+    update_data_structures_pipe(ri_label, frq_label, frq)
+
+    # Loop over the spin data.
+    for value, error, mol_name, res_num, res_name, spin_num, spin_name in 
zip(values, errors, mol_names, res_nums, res_names, spin_nums, spin_names):
+        # Generate the spin identification string.
+        id = generate_spin_id(mol_name=mol_name, res_num=res_num, 
res_name=res_name, spin_num=spin_num, spin_name=spin_name)
+
+        # Skip all rows where the value or error is None.
+        if value == None or error == None:
+            continue
+
+        # Get the corresponding spin container.
+        spin = return_spin(id)
+        if spin == None:
+            if not gen_seq:
+                raise RelaxNoSpinError, id
+            else:
+                create_molecule(mol_name)
+                create_residue(res_num, res_name, 
mol_id=generate_spin_id(mol_name=mol_name))
+                create_spin(spin_num, spin_name, 
res_id=generate_spin_id(mol_name=mol_name, res_num=res_num, 
res_name=res_name))
+
+        # Update all data structures.
+        update_data_structures_spin(spin, ri_label, frq_label, frq, value, 
error)
 
 
 def read(ri_label=None, frq_label=None, frq=None, file=None, dir=None, 
file_data=None, mol_name_col=None, res_num_col=0, res_name_col=1, 
spin_num_col=None, spin_name_col=None, data_col=2, error_col=3, sep=None):
@@ -633,9 +692,6 @@
     # Test if the current data pipe exists.
     pipes.test()
 
-    # Get the current data pipe.
-    cdp = pipes.get_pipe()
-
     # Test if sequence data exists.
     if not exists_mol_res_spin_data():
         raise RelaxNoSequenceError
@@ -688,44 +744,47 @@
             except ValueError:
                 raise RelaxError, "The relaxation data in the line " + 
`file_data[i]` + " is invalid."
 
-
-    # Global (non-residue specific) data.
-    #####################################
-
-    # Initialise the global data for the current pipe if necessary.
-    data_init(cdp, global_flag=True)
-
-    # Update the global data.
-    update_data_structures_pipe(ri_label, frq_label, frq)
-
-
-    # Residue specific data.
-    ########################
-
-    # Loop over the relaxation data.
+    # Loop over the file data to create the data structures for packing.
+    values = []
+    errors = []
+    mol_names = []
+    res_nums = []
+    res_names = []
+    spin_nums = []
+    spin_names = []
     for i in xrange(len(file_data)):
         # Skip missing data.
         if len(file_data[i]) <= min_col_num:
             continue
 
-        # Generate the spin identification string.
-        id = generate_spin_id_data_array(data=file_data[i], 
mol_name_col=mol_name_col, res_num_col=res_num_col, 
res_name_col=res_name_col, spin_num_col=spin_num_col, 
spin_name_col=spin_name_col)
+        # Pack the spin ID info.
+        if mol_name_col != None:
+            mol_names.append(file_data[i][mol_name_col])
+        else:
+            mol_names.append(None)
+        if res_num_col != None:
+            res_nums.append(file_data[i][res_num_col])
+        else:
+            res_nums.append(None)
+        if res_name_col != None:
+            res_names.append(file_data[i][res_name_col])
+        else:
+            res_names.append(None)
+        if spin_num_col != None:
+            spin_nums.append(file_data[i][spin_num_col])
+        else:
+            spin_nums.append(None)
+        if spin_name_col != None:
+            spin_names.append(file_data[i][spin_name_col])
+        else:
+            spin_names.append(None)
 
         # Convert the data.
-        value = eval(file_data[i][data_col])
-        error = eval(file_data[i][error_col])
-
-        # Skip all rows where the value or error is None.
-        if value == None or error == None:
-            continue
-
-        # Get the corresponding spin container.
-        spin = return_spin(id)
-        if spin == None:
-            raise RelaxNoSpinError, id
-
-        # Update all data structures.
-        update_data_structures_spin(spin, ri_label, frq_label, frq, value, 
error)
+        values.append(eval(file_data[i][data_col]))
+        errors.append(eval(file_data[i][error_col]))
+
+    # Pack the data.
+    pack_data(ri_label, frq_label, frq, values, errors, mol_names, res_nums, 
res_names, spin_nums, spin_names)
 
 
 def return_data_desc(name):




Related Messages


Powered by MHonArc, Updated Sun Mar 08 22:40:06 2009