mailr19884 - in /branches/relax_disp: ./ pipe_control/spectrum.py


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

Header


Content

Posted by edward on June 06, 2013 - 11:52:
Author: bugman
Date: Thu Jun  6 11:52:17 2013
New Revision: 19884

URL: http://svn.gna.org/viewcvs/relax?rev=19884&view=rev
Log:
Merged revisions 19882 via svnmerge from 
svn+ssh://bugman@xxxxxxxxxxx/svn/relax/trunk

........
  r19882 | bugman | 2013-06-06 11:45:24 +0200 (Thu, 06 Jun 2013) | 8 lines
  
  The spectrum.peak_intensities is now more robust when reading in a generic 
formatted file.
  
  Firstly there is a check that the intensity column number has been 
supplied.  And then there is a
  checks that all relevant data could be extracted from each row of the file. 
 This replaces traceback
  errors with RelaxErrors explaining the problem if the user inputs bad data 
or forgets the intensity
  column argument.
........

Modified:
    branches/relax_disp/   (props changed)
    branches/relax_disp/pipe_control/spectrum.py

Propchange: branches/relax_disp/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Thu Jun  6 11:52:17 2013
@@ -1,1 +1,1 @@
-/trunk:1-19880
+/trunk:1-19883

Modified: branches/relax_disp/pipe_control/spectrum.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/relax_disp/pipe_control/spectrum.py?rev=19884&r1=19883&r2=19884&view=diff
==============================================================================
--- branches/relax_disp/pipe_control/spectrum.py (original)
+++ branches/relax_disp/pipe_control/spectrum.py Thu Jun  6 11:52:17 2013
@@ -487,46 +487,48 @@
 
     @keyword file_data:     The data extracted from the file converted into 
a list of lists.
     @type file_data:        list of lists of str
-    @keyword spin_id_col:   The column containing the spin ID strings (used 
by the generic intensity
-                            file format).  If supplied, the mol_name_col, 
res_name_col, res_num_col,
-                            spin_name_col, and spin_num_col arguments must 
be none.
-    @type spin_id_col:      int or None
-    @keyword mol_name_col:  The column containing the molecule name 
information (used by the generic
-                            intensity file format).  If supplied, 
spin_id_col must be None.
+    @keyword spin_id_col:   The column containing the spin ID strings (used 
by the generic intensity file format).  If supplied, the mol_name_col, 
res_name_col, res_num_col, spin_name_col, and spin_num_col arguments must be 
none. @type spin_id_col:      int or None @keyword mol_name_col:  The column 
containing the molecule name information (used by the generic intensity file 
format).  If supplied, spin_id_col must be None.
     @type mol_name_col:     int or None
-    @keyword res_name_col:  The column containing the residue name 
information (used by the generic
-                            intensity file format).  If supplied, 
spin_id_col must be None.
+    @keyword res_name_col:  The column containing the residue name 
information (used by the generic intensity file format).  If supplied, 
spin_id_col must be None.
     @type res_name_col:     int or None
-    @keyword res_num_col:   The column containing the residue number 
information (used by the
-                            generic intensity file format).  If supplied, 
spin_id_col must be None.
+    @keyword res_num_col:   The column containing the residue number 
information (used by the generic intensity file format).  If supplied, 
spin_id_col must be None.
     @type res_num_col:      int or None
-    @keyword spin_name_col: The column containing the spin name information 
(used by the generic
-                            intensity file format).  If supplied, 
spin_id_col must be None.
+    @keyword spin_name_col: The column containing the spin name information 
(used by the generic intensity file format).  If supplied, spin_id_col must 
be None.
     @type spin_name_col:    int or None
-    @keyword spin_num_col:  The column containing the spin number 
information (used by the generic
-                            intensity file format).  If supplied, 
spin_id_col must be None.
+    @keyword spin_num_col:  The column containing the spin number 
information (used by the generic intensity file format).  If supplied, 
spin_id_col must be None.
     @type spin_num_col:     int or None
     @keyword data_col:      The column containing the peak intensities.
     @type data_col:         int
     @keyword sep:           The column separator which, if None, defaults to 
whitespace.
     @type sep:              str or None
-    @keyword spin_id:       The spin ID string used to restrict data loading 
to a subset of all
-                            spins.
+    @keyword spin_id:       The spin ID string used to restrict data loading 
to a subset of all spins.
     @type spin_id:          None or str
     @raises RelaxError:     When the expected peak intensity is not a float.
-    @return:                The extracted data as a list of lists.  The 
first dimension corresponds
-                            to the spin.  The second dimension consists of 
the proton name,
-                            heteronucleus name, spin ID string, and the 
intensity value.
+    @return:                The extracted data as a list of lists.  The 
first dimension corresponds to the spin.  The second dimension consists of 
the proton name, heteronucleus name, spin ID string, and the intensity value.
     @rtype:                 list of lists of str, str, str, float
     """
+
+    # Check the intensity column argument.
+    if data_col == None:
+        raise RelaxError("The data column argument has not been supplied.")
 
     # Strip the data.
     file_data = strip(file_data)
 
     # Loop over the data.
     data = []
-    for mol_name, res_num, res_name, spin_num, spin_name, value in 
read_spin_data(file_data=file_data, spin_id_col=spin_id_col, 
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, data_col=data_col, sep=sep, spin_id=spin_id):
+    for values in read_spin_data(file_data=file_data, 
spin_id_col=spin_id_col, 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, data_col=data_col, sep=sep, spin_id=spin_id):
+        # Check the values.
+        if len(values) != 6:
+            raise RelaxError("The molecule name, residue number and name, 
spin number and name, and value columns could not be found in the data %s." % 
repr(values))
+
+        # Unpack.
+        mol_name, res_num, res_name, spin_num, spin_name, value = values
+
+        # Create the unique spin ID.
         id = generate_spin_id_unique(mol_name=mol_name, res_num=res_num, 
res_name=res_name, spin_num=spin_num, spin_name=spin_name)
+
+        # Store the necessary data.
         data.append([None, None, id, value, id])
 
     # Return the data.




Related Messages


Powered by MHonArc, Updated Thu Jun 06 12:20:02 2013