Author: bugman Date: Wed Sep 4 18:07:14 2013 New Revision: 20811 URL: http://svn.gna.org/viewcvs/relax?rev=20811&view=rev Log: Simplification of the data checks in the pipe_control.spectrum module. This is using the new pipe_control.*.check*() functions. Modified: trunk/pipe_control/spectrum.py Modified: trunk/pipe_control/spectrum.py URL: http://svn.gna.org/viewcvs/relax/trunk/pipe_control/spectrum.py?rev=20811&r1=20810&r2=20811&view=diff ============================================================================== --- trunk/pipe_control/spectrum.py (original) +++ trunk/pipe_control/spectrum.py Wed Sep 4 18:07:14 2013 @@ -31,12 +31,12 @@ from warnings import warn # relax module imports. -from lib.errors import RelaxError, RelaxImplementError, RelaxNoSequenceError, RelaxNoSpectraError +from lib.errors import RelaxError, RelaxImplementError, RelaxNoSpectraError from lib.io import write_data from lib.spectrum.peak_list import read_peak_list from lib.warnings import RelaxWarning, RelaxNoSpinWarning from pipe_control import pipes -from pipe_control.mol_res_spin import exists_mol_res_spin_data, generate_spin_id_unique, return_spin, spin_loop +from pipe_control.mol_res_spin import check_mol_res_spin_data, generate_spin_id_unique, return_spin, spin_loop def __errors_height_no_repl(): @@ -264,16 +264,10 @@ @type spin_id: str """ - # Test if the current pipe exists + # Data checks. pipes.test() - - # Test if the sequence data is loaded. - if not exists_mol_res_spin_data(): - raise RelaxNoSequenceError - - # Test the spectrum id string. - if spectrum_id not in cdp.spectrum_ids: - raise RelaxError("The peak intensities corresponding to the spectrum id '%s' do not exist." % spectrum_id) + check_mol_res_spin_data() + check_spectrum_id(spectrum_id) # The scaling by NC_proc. if hasattr(cdp, 'ncproc') and spectrum_id in cdp.ncproc: @@ -319,10 +313,9 @@ @type spectrum_id: str """ - # Tests. + # Data checks. pipes.test() - if not exists_mol_res_spin_data(): - raise RelaxNoSequenceError + check_mol_res_spin_data() check_spectrum_id(spectrum_id) # Remove the ID. @@ -369,12 +362,9 @@ @type subset: list of str """ - # Test if the current pipe exists + # Tests. pipes.test() - - # Test if the sequence data is loaded. - if not exists_mol_res_spin_data(): - raise RelaxNoSequenceError + check_mol_res_spin_data() # Test if spectra have been loaded. if not hasattr(cdp, 'spectrum_ids'): @@ -500,12 +490,9 @@ @type verbose: bool """ - # Test if the current data pipe exists. + # Data checks. pipes.test() - - # Test if sequence data is loaded. - if not exists_mol_res_spin_data(): - raise RelaxNoSequenceError + check_mol_res_spin_data() # Check the file name. if file == None: @@ -624,22 +611,21 @@ @type spectrum_ids: list of str """ - # Test if the current pipe exists + # Test if the current pipe exists. pipes.test() - - # Test if spectra have been loaded. - if not hasattr(cdp, 'spectrum_ids'): - raise RelaxError("No spectra have been loaded therefore replicates cannot be specified.") - - # Test the spectrum id strings. - for spectrum_id in spectrum_ids: - if spectrum_id not in cdp.spectrum_ids: - raise RelaxError("The peak intensities corresponding to the spectrum id '%s' do not exist." % spectrum_id) # Test for None. if spectrum_ids == None: warn(RelaxWarning("The spectrum ID list cannot be None.")) return + + # Test if spectra have been loaded. + if not hasattr(cdp, 'spectrum_ids'): + raise RelaxError("No spectra have been loaded therefore replicates cannot be specified.") + + # Test the spectrum id strings. + for spectrum_id in spectrum_ids: + check_spectrum_id(spectrum_id) # Test for more than one element. if len(spectrum_ids) == 1: