Author: bugman Date: Tue Oct 6 13:20:57 2009 New Revision: 9580 URL: http://svn.gna.org/viewcvs/relax?rev=9580&view=rev Log: Converted spectrum.read_intensities() to use the new relax_io.read_spin_data_file() function. This is only for the generic formatted file. Modified: 1.3/generic_fns/spectrum.py 1.3/prompt/spectrum.py Modified: 1.3/generic_fns/spectrum.py URL: http://svn.gna.org/viewcvs/relax/1.3/generic_fns/spectrum.py?rev=9580&r1=9579&r2=9580&view=diff ============================================================================== --- 1.3/generic_fns/spectrum.py (original) +++ 1.3/generic_fns/spectrum.py Tue Oct 6 13:20:57 2009 @@ -698,7 +698,7 @@ return header_lines -def read(file=None, dir=None, spectrum_id=None, heteronuc=None, proton=None, int_col=None, int_method=None, mol_name_col=None, res_num_col=None, res_name_col=None, spin_num_col=None, spin_name_col=None, sep=None, ncproc=None): +def read(file=None, dir=None, spectrum_id=None, heteronuc=None, proton=None, 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): """Read the peak intensity data. @keyword file: The name of the file containing the peak intensities. @@ -712,23 +712,35 @@ @type heteronuc: str @keyword proton: The name of the proton as specified in the peak intensity file. @type proton: str - @keyword int_col: The column containing the peak intensity data (for a non-standard - formatted file). + @keyword int_col: The column containing the peak intensity data (used by the generic + intensity file format). @type int_col: int @keyword int_method: The integration method, one of 'height', 'point sum' or 'other'. @type int_method: str - @keyword mol_name_col: The column containing the molecule name information. + @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. + @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. + @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. + @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. + @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 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. + @type spin_id: None or str @keyword ncproc: The Bruker ncproc binary intensity scaling factor. @type ncproc: int or None """ @@ -761,10 +773,6 @@ if format == 'generic': # Print out. print("Generic formatted data file.\n") - - # Test that column numbers have been given. - if max(mol_name_col, res_num_col, res_name_col, spin_num_col, spin_name_col) == None: - raise RelaxError("No column numbers have been supplied.") # Set the intensity reading function. intensity_fn = intensity_generic Modified: 1.3/prompt/spectrum.py URL: http://svn.gna.org/viewcvs/relax/1.3/prompt/spectrum.py?rev=9580&r1=9579&r2=9580&view=diff ============================================================================== --- 1.3/prompt/spectrum.py (original) +++ 1.3/prompt/spectrum.py Tue Oct 6 13:20:57 2009 @@ -266,7 +266,7 @@ spectrum.integration_points(N=N, spectrum_id=spectrum_id, spin_id=spin_id) - def read_intensities(self, file=None, dir=None, spectrum_id=None, heteronuc='N', proton='HN', int_col=None, int_method='height', mol_name_col=None, res_num_col=None, res_name_col=None, spin_num_col=None, spin_name_col=None, sep=None, ncproc=None): + def read_intensities(self, file=None, dir=None, spectrum_id=None, heteronuc='N', proton='HN', int_col=None, int_method='height', 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): """Function for reading peak intensities from a file for NOE calculations. Keyword Arguments @@ -282,21 +282,34 @@ proton: The name of the proton as specified in the peak intensity file. - int_col: The column(s) containing the peak intensity data (for a non-standard format). + int_col: The column containing the peak intensity data (used by the generic intensity file + format). int_method: The integration method. - mol_name_col: The molecule name column used by the generic intensity file format. - - res_num_col: The residue number column used by the generic intensity file format. - - res_name_col: The residue name column used by the generic intensity file format. - - spin_num_col: The spin number column used by the generic intensity file format. - - spin_name_col: The spin name column used by the generic intensity file format. - - sep: The column separator used by the generic intensity format (defaults to white space). + spin_id_col: The spin ID string column used by the generic intensity file format (an + alternative to the mol, res, and spin name and number columns). + + mol_name_col: The molecule name column used by the generic intensity file format + (alternative to the spid_id_col). + + res_num_col: The residue number column used by the generic intensity file format + (alternative to the spid_id_col). + + res_name_col: The residue name column used by the generic intensity file format + (alternative to the spid_id_col). + + spin_num_col: The spin number column used by the generic intensity file format + (alternative to the spid_id_col). + + spin_name_col: The spin name column used by the generic intensity file format + (alternative to the spid_id_col). + + sep: The column separator used by the generic intensity format (the default is white + space). + + spin_id: The spin ID string used by the generic intensity file format to restrict the + loading of data to certain spin subsets. ncproc: The Bruker specific FID intensity scaling factor. @@ -358,12 +371,14 @@ support non-supported peak lists. It should contain in the first few columns enough information to identify the spin. This can include columns for the molecule name, residue number, residue name, spin number, and spin name, with each optional type positioned with - the *name_col and *num_col arguments. The peak intensities can be placed in another column - specified by the int_col argument. Intensities from multiple spectra can be placed into - different columns, and these can then be specified simultaneously by setting the int_col - argument to a list of columns. This list must be matched by setting the spectrum_id - argument to list of the same length. If columns are delimited by a character other than - whitespace, this can be specified with the sep argument. + the *name_col and *num_col arguments. Alternatively a spin ID string column can be used. + The peak intensities can be placed in another column specified by the int_col argument. + Intensities from multiple spectra can be placed into different columns, and these can then + be specified simultaneously by setting the int_col argument to a list of columns. This list + must be matched by setting the spectrum_id argument to list of the same length. If columns + are delimited by a character other than whitespace, this can be specified with the sep + argument. The spin_id argument can be used to restrict the loading to specific spin + subsets. Examples @@ -392,12 +407,15 @@ text = text + ", proton=" + repr(proton) text = text + ", int_col=" + repr(int_col) text = text + ", int_method=" + repr(int_method) + text = text + ", spin_id_col=" + repr(spin_id_col) text = text + ", mol_name_col=" + repr(mol_name_col) text = text + ", res_num_col=" + repr(res_num_col) text = text + ", res_name_col=" + repr(res_name_col) text = text + ", spin_num_col=" + repr(spin_num_col) text = text + ", spin_name_col=" + repr(spin_name_col) - text = text + ", sep=" + repr(sep) + ")" + text = text + ", sep=" + repr(sep) + text = text + ", spin_id=" + repr(spin_id) + text = text + ", ncproc=" + repr(ncproc) + ")" print(text) # The argument checks. @@ -408,16 +426,18 @@ check.is_str(proton, 'proton name') check.is_int_or_int_list(int_col, 'intensity column', can_be_none=True) check.is_str(int_method, 'integration method') + check.is_int(spin_id_col, 'spin ID string column', can_be_none=True) check.is_int(mol_name_col, 'molecule name column', can_be_none=True) check.is_int(res_num_col, 'residue number column', can_be_none=True) check.is_int(res_name_col, 'residue name column', can_be_none=True) check.is_int(spin_num_col, 'spin number column', can_be_none=True) check.is_int(spin_name_col, 'spin name column', can_be_none=True) check.is_str(sep, 'column separator', can_be_none=True) + check.is_str(spin_id, 'spin ID string', can_be_none=True) check.is_int(ncproc, 'Bruker ncproc parameter', can_be_none=True) # Execute the functional code. - spectrum.read(file=file, dir=dir, spectrum_id=spectrum_id, heteronuc=heteronuc, proton=proton, int_col=int_col, int_method=int_method, 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, ncproc=ncproc) + spectrum.read(file=file, dir=dir, spectrum_id=spectrum_id, heteronuc=heteronuc, proton=proton, int_col=int_col, int_method=int_method, 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, ncproc=ncproc) def replicated(self, spectrum_ids=None):