mailr22246 - in /branches/double_rotor: ./ gui/input_elements/ pipe_control/ test_suite/gui_tests/ test_suite/system_tests/


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

Header


Content

Posted by edward on February 21, 2014 - 20:19:
Author: bugman
Date: Fri Feb 21 20:19:37 2014
New Revision: 22246

URL: http://svn.gna.org/viewcvs/relax?rev=22246&view=rev
Log:
Merged revisions 22240-22241,22243-22245 via svnmerge from 
svn+ssh://bugman@xxxxxxxxxxx/svn/relax/trunk

........
  r22240 | bugman | 2014-02-21 16:51:17 +0100 (Fri, 21 Feb 2014) | 5 lines
  
  Expanded the Peak_lists.test_read_peak_list_sparky_double system test to 
check all intensities.
  
  This now checks all of the peak heights read by the 
spectrum.read_intensities user function.
........
  r22241 | bugman | 2014-02-21 16:59:37 +0100 (Fri, 21 Feb 2014) | 5 lines
  
  Expanded the capabilities of the spectrum.read_intensities user function.
  
  Now multiple files can be loaded simultaneously.
........
  r22243 | bugman | 2014-02-21 17:27:34 +0100 (Fri, 21 Feb 2014) | 7 lines
  
  Fix for the multiple file selection GUI element.
  
  The GUI element now returns single values rather than lists from the 
GetValue() function when only
  a single file is selected.  This allows the spectrum.read_intensities user 
function to operate
  normally again in the GUI.
........
  r22244 | bugman | 2014-02-21 17:29:11 +0100 (Fri, 21 Feb 2014) | 6 lines
  
  Minor fix for the Relax_disp.test_bug_21076_multi_col_peak_list system test.
  
  The spectrum ID argument ['auto'] has been changed to the single value of 
'auto'.  This argument
  should not be a list.
........
  r22245 | bugman | 2014-02-21 17:32:37 +0100 (Fri, 21 Feb 2014) | 5 lines
  
  Fixes for the User_functions.test_structure_pdb_read GUI test.
  
  This test was failing due to the recent changes to the sequence input GUI 
element.
........

Modified:
    branches/double_rotor/   (props changed)
    branches/double_rotor/gui/input_elements/file.py
    branches/double_rotor/pipe_control/spectrum.py
    branches/double_rotor/test_suite/gui_tests/relax_disp.py
    branches/double_rotor/test_suite/gui_tests/test_user_functions.py
    branches/double_rotor/test_suite/system_tests/peak_lists.py

Propchange: branches/double_rotor/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Fri Feb 21 20:19:37 2014
@@ -1,1 +1,1 @@
-/trunk:1-22239
+/trunk:1-22245

Modified: branches/double_rotor/gui/input_elements/file.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/double_rotor/gui/input_elements/file.py?rev=22246&r1=22245&r2=22246&view=diff
==============================================================================
--- branches/double_rotor/gui/input_elements/file.py (original)
+++ branches/double_rotor/gui/input_elements/file.py Fri Feb 21 20:19:37 2014
@@ -495,11 +495,6 @@
         if isinstance(value, list) and len(value) == 1:
             value = value[0]
 
-        # Convert single values to sequences as needed.
-        elif value != None:
-            if not isinstance(value, list):
-                value = [value]
-
         # Handle empty list and tuple values.
         if len(value) == 0:
             return None

Modified: branches/double_rotor/pipe_control/spectrum.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/double_rotor/pipe_control/spectrum.py?rev=22246&r1=22245&r2=22246&view=diff
==============================================================================
--- branches/double_rotor/pipe_control/spectrum.py (original)
+++ branches/double_rotor/pipe_control/spectrum.py Fri Feb 21 20:19:37 2014
@@ -1,6 +1,6 @@
 
###############################################################################
 #                                                                            
 #
-# Copyright (C) 2004-2013 Edward d'Auvergne                                  
 #
+# Copyright (C) 2004-2014 Edward d'Auvergne                                  
 #
 # Copyright (C) 2008 Sebastien Morin                                         
 #
 # Copyright (C) 2013 Troels E. Linnet                                        
 #
 #                                                                            
 #
@@ -465,8 +465,8 @@
 def read(file=None, dir=None, spectrum_id=None, dim=1, int_col=None, 
int_method=None, spin_id_col=None, mol_name_col=None, res_num_col=None, 
res_name_col=None, spin_num_col=None, spin_name_col=None, sep=None, 
spin_id=None, ncproc=None, verbose=True):
     """Read the peak intensity data.
 
-    @keyword file:          The name of the file containing the peak 
intensities.
-    @type file:             str
+    @keyword file:          The name of the file(s) containing the peak 
intensities.
+    @type file:             str or list of str
     @keyword dir:           The directory where the file is located.
     @type dir:              str
     @keyword spectrum_id:   The spectrum identification string.
@@ -511,13 +511,48 @@
     if hasattr(cdp, 'int_method') and cdp.int_method != int_method:
         raise RelaxError("The '%s' measure of peak intensities does not 
match '%s' of the previously loaded spectra." % (int_method, cdp.int_method))
 
+    # Multiple ID flags.
+    flag_multi = False
+    flag_multi_file = False
+    flag_multi_col = False
+    if isinstance(spectrum_id, list) or spectrum_id == 'auto':
+        flag_multi = True
+    if isinstance(file, list):
+        flag_multi_file = True
+    if isinstance(int_col, list) or spectrum_id == 'auto':
+        flag_multi_col = True
+
+    # List argument checks.
+    if flag_multi:
+        # Too many lists.
+        if flag_multi_file and flag_multi_col:
+            raise RelaxError("If a list of spectrum IDs is supplied, the 
file names and intensity column arguments cannot both be lists.")
+
+        # Not enough lists.
+        if not flag_multi_file and not flag_multi_col:
+            raise RelaxError("If a list of spectrum IDs is supplied, either 
the file name or intensity column arguments must be a list of equal length.")
+
+        # List lengths for multiple files.
+        if flag_multi_file and len(spectrum_id) != len(file):
+                raise RelaxError("The file list %s and spectrum ID list %s 
do not have the same number of elements." % (file, spectrum_id))
+
+        # List lengths for multiple intensity columns.
+        if flag_multi_col and spectrum_id != 'auto' and len(spectrum_id) != 
len(int_col):
+            raise RelaxError("The spectrum ID list %s and intensity column 
list %s do not have the same number of elements." % (spectrum_id, int_col))
+
+    # More list argument checks (when only one spectrum ID is supplied).
+    else:
+        # Multiple files.
+        if flag_multi_file:
+            raise RelaxError("If multiple files are supplied, then multiple 
spectrum IDs must also be supplied.")
+
+        # Multiple intensity columns.
+        if flag_multi_col:
+            raise RelaxError("If multiple intensity columns are supplied, 
then multiple spectrum IDs must also be supplied.")
+
     # Intensity column checks.
-    if isinstance(spectrum_id, list) and not isinstance(int_col, list):
-        raise RelaxError("If a list of spectrum IDs is supplied, the 
intensity column argument must also be a list of equal length.")
-    if spectrum_id != 'auto' and not isinstance(spectrum_id, list) and 
isinstance(int_col, list):
+    if spectrum_id != 'auto' and not flag_multi and flag_multi_col:
         raise RelaxError("If a list of intensity columns is supplied, the 
spectrum ID argument must also be a list of equal length.")
-    if isinstance(spectrum_id, list) and len(spectrum_id) != len(int_col):
-        raise RelaxError("The spectrum ID list %s has a different number of 
elements to the intensity column list %s." % (spectrum_id, int_col))
 
     # Check the intensity measure.
     if not int_method in ['height', 'point sum', 'other']:
@@ -526,87 +561,94 @@
     # Set the peak intensity measure.
     cdp.int_method = int_method
 
-    # Read the peak list data.
-    peak_list = read_peak_list(file=file, dir=dir, int_col=int_col, 
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, sep=sep, spin_id=spin_id)
-
-    # Automatic spectrum IDs.
-    if spectrum_id == 'auto':
-        spectrum_id = peak_list[0].intensity_name
-
-    # Loop over the assignments.
-    data = []
-    data_flag = False
-    for assign in peak_list:
-        # Generate the spin_id.
-        spin_id = generate_spin_id_unique(res_num=assign.res_nums[dim-1], 
spin_name=assign.spin_names[dim-1])
-
-        # Convert the intensity data and spectrum IDs to lists if needed.
-        intensity = assign.intensity
-        if not isinstance(intensity, list):
-            intensity = [intensity]
-        if not isinstance(spectrum_id, list):
-            spectrum_id = [spectrum_id]
-
-        # Checks for matching length of spectrum IDs and intensities columns.
-        if len(spectrum_id) != len(intensity):
-            raise RelaxError("The spectrum ID list %s has a different number 
of elements to the intensity column list %s." % (spectrum_id, len(intensity)))
-
-        # Loop over the intensity data.
-        for i in range(len(intensity)):
-            # Sanity check.
-            if intensity[i] == 0.0:
-                warn(RelaxWarning("A peak intensity of zero has been 
encountered for the spin '%s' - this could be fatal later on." % spin_id))
-
-            # Get the spin container.
-            spin = return_spin(spin_id)
-            if not spin:
-                warn(RelaxNoSpinWarning(spin_id))
-                continue
-
-            # Skip deselected spins.
-            if not spin.select:
-                continue
-
-            # Initialise.
-            if not hasattr(spin, 'intensities'):
-                spin.intensities = {}
-
-            # Intensity scaling.
+    # Convert the file argument to a list if necessary.
+    if not isinstance(file, list):
+        file = [file]
+
+    # Loop over all files.
+    for file_index in range(len(file)):
+        # Read the peak list data.
+        peak_list = read_peak_list(file=file[file_index], dir=dir, 
int_col=int_col, 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, sep=sep, 
spin_id=spin_id)
+
+        # Automatic spectrum IDs.
+        if spectrum_id == 'auto':
+            spectrum_id = peak_list[0].intensity_name
+
+        # Loop over the assignments.
+        data = []
+        data_flag = False
+        for assign in peak_list:
+            # Generate the spin_id.
+            spin_id = 
generate_spin_id_unique(res_num=assign.res_nums[dim-1], 
spin_name=assign.spin_names[dim-1])
+
+            # Convert the intensity data to a list if needed.
+            intensity = assign.intensity
+            if not isinstance(intensity, list):
+                intensity = [intensity]
+
+            # Loop over the intensity data.
+            for int_index in range(len(intensity)):
+                # Sanity check.
+                if intensity[int_index] == 0.0:
+                    warn(RelaxWarning("A peak intensity of zero has been 
encountered for the spin '%s' - this could be fatal later on." % spin_id))
+
+                # Get the spin container.
+                spin = return_spin(spin_id)
+                if not spin:
+                    warn(RelaxNoSpinWarning(spin_id))
+                    continue
+
+                # Skip deselected spins.
+                if not spin.select:
+                    continue
+
+                # Initialise.
+                if not hasattr(spin, 'intensities'):
+                    spin.intensities = {}
+
+                # Intensity scaling.
+                if ncproc != None:
+                    intensity[int_index] = intensity[int_index] / 
float(2**ncproc)
+
+                # Add the data.
+                if flag_multi_file:
+                    id = spectrum_id[file_index]
+                elif flag_multi_col:
+                    id = spectrum_id[int_index]
+                else:
+                    id = spectrum_id
+                spin.intensities[id] = intensity[int_index]
+
+                # Switch the flag.
+                data_flag = True
+
+                # Append the data for printing out.
+                data.append([spin_id, repr(intensity[int_index])])
+
+        # Add the spectrum id (and ncproc) to the relax data store.
+        spectrum_ids = spectrum_id
+        if isinstance(spectrum_id, str):
+            spectrum_ids = [spectrum_id]
+        if ncproc != None and not hasattr(cdp, 'ncproc'):
+            cdp.ncproc = {}
+        for i in range(len(spectrum_ids)):
+            add_spectrum_id(spectrum_ids[i])
             if ncproc != None:
-                intensity[i] = intensity[i] / float(2**ncproc)
-
-            # Add the data.
-            spin.intensities[spectrum_id[i]] = intensity[i]
-
-            # Switch the flag.
-            data_flag = True
-
-            # Append the data for printing out.
-            data.append([spin_id, repr(intensity[i])])
-
-    # Add the spectrum id (and ncproc) to the relax data store.
-    spectrum_ids = spectrum_id
-    if isinstance(spectrum_id, str):
-        spectrum_ids = [spectrum_id]
-    if ncproc != None and not hasattr(cdp, 'ncproc'):
-        cdp.ncproc = {}
-    for i in range(len(spectrum_ids)):
-        add_spectrum_id(spectrum_ids[i])
-        if ncproc != None:
-            cdp.ncproc[spectrum_ids[i]] = ncproc
-
-    # No data.
-    if not data_flag:
-        # Delete all the data.
-        delete(spectrum_id)
-
-        # Raise the error.
-        raise RelaxError("No data could be loaded from the peak list")
-
-    # Print out.
-    if verbose:
-        print("\nThe following intensities have been loaded into the relax 
data store:\n")
-        write_data(out=sys.stdout, headings=["Spin_ID", "Intensity"], 
data=data)
+                cdp.ncproc[spectrum_ids[i]] = ncproc
+
+        # No data.
+        if not data_flag:
+            # Delete all the data.
+            delete(spectrum_id)
+
+            # Raise the error.
+            raise RelaxError("No data could be loaded from the peak list")
+
+        # Printout.
+        if verbose:
+            print("\nThe following intensities have been loaded into the 
relax data store:\n")
+            write_data(out=sys.stdout, headings=["Spin_ID", "Intensity"], 
data=data)
+        print('')
 
 
 def read_spins(file=None, dir=None, dim=1, spin_id_col=None, 
mol_name_col=None, res_num_col=None, res_name_col=None, spin_num_col=None, 
spin_name_col=None, sep=None, spin_id=None, verbose=True):

Modified: branches/double_rotor/test_suite/gui_tests/relax_disp.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/double_rotor/test_suite/gui_tests/relax_disp.py?rev=22246&r1=22245&r2=22246&view=diff
==============================================================================
--- branches/double_rotor/test_suite/gui_tests/relax_disp.py (original)
+++ branches/double_rotor/test_suite/gui_tests/relax_disp.py Fri Feb 21 
20:19:37 2014
@@ -182,7 +182,7 @@
         # The spectrum, where the use of Keyword auto will auto-assign 
spectra Z_A{i}.
         page = wizard.get_page(wizard.page_indices['read'])
         
page.uf_args['file'].SetValue(str_to_gui("%sfolded_sparky_corr_final_max_standard_trunc.ser"
 % data_path))
-        page.uf_args['spectrum_id'].SetValue(['auto'])
+        page.uf_args['spectrum_id'].SetValue('auto')
         wizard._go_next(None)
 
         # The error type window.

Modified: branches/double_rotor/test_suite/gui_tests/test_user_functions.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/double_rotor/test_suite/gui_tests/test_user_functions.py?rev=22246&r1=22245&r2=22246&view=diff
==============================================================================
--- branches/double_rotor/test_suite/gui_tests/test_user_functions.py 
(original)
+++ branches/double_rotor/test_suite/gui_tests/test_user_functions.py Fri Feb 
21 20:19:37 2014
@@ -60,17 +60,16 @@
         # Set the models to read.
         uf.page.SetValue('read_model', str_to_gui('6'))
         uf.page.uf_args['read_model'].selection_win_show()
-        uf.page.uf_args['read_model'].sel_win.append_row(None)
-        
uf.page.uf_args['read_model'].sel_win.sequence.SetStringItem(index=0, col=0, 
label=int_to_gui(2))
-        
uf.page.uf_args['read_model'].sel_win.sequence.SetStringItem(index=1, col=0, 
label=int_to_gui(4))
+        uf.page.uf_args['read_model'].sel_win.add_element(None)
+        
uf.page.uf_args['read_model'].sel_win.sequence.SetStringItem(index=0, col=1, 
label=int_to_gui(2))
+        
uf.page.uf_args['read_model'].sel_win.sequence.SetStringItem(index=1, col=1, 
label=int_to_gui(4))
         uf.page.uf_args['read_model'].selection_win_data()
 
         # Renumber the models.
         uf.page.uf_args['set_model_num'].selection_win_show()
-        uf.page.uf_args['set_model_num'].sel_win.append_row(None)
-        uf.page.uf_args['set_model_num'].sel_win.append_row(None)
-        
uf.page.uf_args['set_model_num'].sel_win.sequence.SetStringItem(index=0, 
col=0, label=int_to_gui(1))
-        
uf.page.uf_args['set_model_num'].sel_win.sequence.SetStringItem(index=1, 
col=0, label=int_to_gui(3))
+        uf.page.uf_args['set_model_num'].sel_win.add_element(None)
+        
uf.page.uf_args['set_model_num'].sel_win.sequence.SetStringItem(index=0, 
col=1, label=int_to_gui(1))
+        
uf.page.uf_args['set_model_num'].sel_win.sequence.SetStringItem(index=1, 
col=1, label=int_to_gui(3))
         uf.page.uf_args['set_model_num'].selection_win_data()
 
         # GUI data checks.

Modified: branches/double_rotor/test_suite/system_tests/peak_lists.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/double_rotor/test_suite/system_tests/peak_lists.py?rev=22246&r1=22245&r2=22246&view=diff
==============================================================================
--- branches/double_rotor/test_suite/system_tests/peak_lists.py (original)
+++ branches/double_rotor/test_suite/system_tests/peak_lists.py Fri Feb 21 
20:19:37 2014
@@ -818,10 +818,14 @@
         self.interpreter.spectrum.read_intensities(file=["ref_ave.list", 
"sat_ave.list"], dir=status.install_path + 
sep+'test_suite'+sep+'shared_data'+sep+'peak_lists', spectrum_id=['ref', 
'sat'], int_method='height')
 
         # Test the data.
-        
self.assertEqual(list(cdp.mol[0].res[0].spin[0].intensities.values())[0], 
6262)
-        
self.assertEqual(list(cdp.mol[0].res[1].spin[0].intensities.values())[0], 
148614)
-        
self.assertEqual(list(cdp.mol[0].res[2].spin[0].intensities.values())[0], 
166842)
-        
self.assertEqual(list(cdp.mol[0].res[3].spin[0].intensities.values())[0], 
128690)
+        self.assertEqual(cdp.mol[0].res[0].spin[0].intensities['ref'], 6262)
+        self.assertEqual(cdp.mol[0].res[0].spin[0].intensities['sat'], 
2535.0)
+        self.assertEqual(cdp.mol[0].res[1].spin[0].intensities['ref'], 
148614)
+        self.assertEqual(cdp.mol[0].res[1].spin[0].intensities['sat'], 
5050.0)
+        self.assertEqual(cdp.mol[0].res[2].spin[0].intensities['ref'], 
166842)
+        self.assertEqual(cdp.mol[0].res[2].spin[0].intensities['sat'], 
51643.0)
+        self.assertEqual(cdp.mol[0].res[3].spin[0].intensities['ref'], 
128690)
+        self.assertEqual(cdp.mol[0].res[3].spin[0].intensities['sat'], 
53663.0)
 
 
     def test_read_peak_list_xeasy(self):




Related Messages


Powered by MHonArc, Updated Fri Feb 21 20:40:03 2014