Author: bugman Date: Mon Jul 22 12:01:35 2013 New Revision: 20448 URL: http://svn.gna.org/viewcvs/relax?rev=20448&view=rev Log: Merged revisions 20439-20447 via svnmerge from svn+ssh://bugman@xxxxxxxxxxx/svn/relax/trunk ........ r20439 | bugman | 2013-07-22 08:32:54 +0200 (Mon, 22 Jul 2013) | 6 lines Progress sr #3043: (https://gna.org/support/index.php?3043) - support for NMRPipe seriesTab format *.ser. Completed NMRPipe SeriesTab reader for assignment according to SPARKY format. Changes implemented according to: http://article.gmane.org/gmane.science.nmr.relax.devel/4120. ........ r20440 | bugman | 2013-07-22 08:34:04 +0200 (Mon, 22 Jul 2013) | 5 lines Progress sr #3043: (https://gna.org/support/index.php?3043) - support for NMRPipe seriesTab format *.ser. The Extraction of NMRPipe SeriesTab data is changed in pipe_control/spectrum.py in the read() function. ........ r20441 | bugman | 2013-07-22 08:36:56 +0200 (Mon, 22 Jul 2013) | 8 lines Reverted r20438 and r20439 as the commit messages were incomplete!!! The command used was: svn merge -r20440:20438 . The commit messages need to be complete for the relax release announcements! ........ r20442 | bugman | 2013-07-22 08:37:58 +0200 (Mon, 22 Jul 2013) | 8 lines Completed NMRPipe SeriesTab reader. Progress sr #3043: (https://gna.org/support/index.php?3043) - support for NMRPipe seriesTab format *.ser. Completed NMRPipe SeriesTab reader for assignment according to SPARKY format. Changes implemented according to: http://article.gmane.org/gmane.science.nmr.relax.devel/4120. ........ r20443 | bugman | 2013-07-22 08:45:50 +0200 (Mon, 22 Jul 2013) | 8 lines Reverted the pipe_control/spectrum.py to r20438. The command used was: svn merge -rHEAD:r20439 pipe_control/spectrum.py Somehow the file was in a bad state. ........ r20444 | bugman | 2013-07-22 08:47:33 +0200 (Mon, 22 Jul 2013) | 7 lines Extraction of NMRPipe SeriesTab changed. Progress sr #3043: (https://gna.org/support/index.php?3043) - support for NMRPipe seriesTab format *.ser. The Extraction of NMRPipe SeriesTab data is changed in pipe_control/spectrum.py in the read() function. ........ r20445 | bugman | 2013-07-22 08:48:21 +0200 (Mon, 22 Jul 2013) | 5 lines Added flag for single or multiple extraction of spectrum. Progress sr #3043: (https://gna.org/support/index.php?3043) - support for NMRPipe seriesTab format *.ser. ........ r20446 | bugman | 2013-07-22 08:49:41 +0200 (Mon, 22 Jul 2013) | 5 lines Flag change added to reading of NMRPipe SeriesTab. Progress sr #3043: (https://gna.org/support/index.php?3043) - support for NMRPipe seriesTab format *.ser. ........ r20447 | bugman | 2013-07-22 10:02:30 +0200 (Mon, 22 Jul 2013) | 7 lines Proper bug fix for the spin parameter array always being converted to lowercase (failed at r20421). The commit r20421 was causing failures in certain cases. One system test and one GUI test were failing because of r20421. Now the spin container is checked for the presence 'equation' variable to determine if this is a model free data pipe. ........ Modified: branches/relax_disp/ (props changed) branches/relax_disp/data_store/mol_res_spin.py branches/relax_disp/lib/software/nmrpipe.py branches/relax_disp/pipe_control/spectrum.py Propchange: branches/relax_disp/ ------------------------------------------------------------------------------ --- svnmerge-integrated (original) +++ svnmerge-integrated Mon Jul 22 12:01:35 2013 @@ -1,1 +1,1 @@ -/trunk:1-20421 +/trunk:1-20447 Modified: branches/relax_disp/data_store/mol_res_spin.py URL: http://svn.gna.org/viewcvs/relax/branches/relax_disp/data_store/mol_res_spin.py?rev=20448&r1=20447&r2=20448&view=diff ============================================================================== --- branches/relax_disp/data_store/mol_res_spin.py (original) +++ branches/relax_disp/data_store/mol_res_spin.py Mon Jul 22 12:01:35 2013 @@ -93,7 +93,7 @@ """ # Model-free parameters. - if pipe_control.pipes.get_type() == 'mf': + if hasattr(self, 'equation') and self.equation in ['mf_orig', 'mf_ext', 'mf_ext2']: self._back_compat_hook_mf_data() # Relaxation data. Modified: branches/relax_disp/lib/software/nmrpipe.py URL: http://svn.gna.org/viewcvs/relax/branches/relax_disp/lib/software/nmrpipe.py?rev=20448&r1=20447&r2=20448&view=diff ============================================================================== --- branches/relax_disp/lib/software/nmrpipe.py (original) +++ branches/relax_disp/lib/software/nmrpipe.py Mon Jul 22 12:01:35 2013 @@ -21,3 +21,125 @@ # Module docstring. """Module containing functions for handling NMRPipe SeriesTab files.""" + + +# Python module imports. +import re + +# relax module imports. +from lib.errors import RelaxError +from lib.io import open_write_file, strip + + +def read_list_intensity_seriestab(file_data=None, int_col=None): + """Return the peak intensity information from the NMRPipe SeriesTab peak intensity file. + + The residue number, heteronucleus and proton names, and peak intensity will be returned. + + + @keyword file_data: The data extracted from the file converted into a list of lists. + @type file_data: list of lists of str + @keyword int_col: The column which to multiply the peak intensity data (used by the SeriesTab intensity file format). + @type int_col: int + @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, residue number, the intensity value, and the original line of text. + @rtype: list of lists of str, str, int, float, str + """ + + # Set start variables + modeline = False + mode = False + varsline = False + header = False + + # Loop over lines, to extract variables and find header size + line_nr = 0 + for line in file_data: + if len(line) > 0: + if line[0] == 'REMARK' and line[1] == 'Mode:': + modeline = line[2:] + mode = modeline[0] + elif line[0] == 'VARS': + varsline = line[1:] + elif line[0] == '1': + header = line_nr + break + line_nr += 1 + + # Raise RelaxError, if the MODE is not found + if not (modeline and mode): + raise RelaxError("MODE not detected. Expecting line 2:\nREMARK Mode: Summation") + + # Raise RelaxError, if the VARS line is not found + if not (varsline): + raise RelaxError("VARS not detected. Expecting line 8:\nVARS INDEX X_AXIS Y_AXIS X_PPM Y_PPM VOL ASS Z_A0") + + # Raise RelaxError, if the header size is not found + if not header: + raise RelaxError("'1' not detected in start of line. Cannot determine header size.") + + # Find index of assignment ASS + ass_i = varsline.index('ASS') + + # Make a regular search for Z_A entries + Z_A = re.compile("Z_A*") + spectra = filter(Z_A.search, varsline) + + # Find index of Z_A entries + spectra_i = [[x for x in varsline].index(y) for y in spectra] + + # Remove the header. + file_data = file_data[header:] + + # Define a list, for storing all the data + data_all = [] + + # Define a current counter + i = 0 + + # Loop over the spectra + for spectrum in spectra: + # Define a list, for storing the current spectrum data + data = [] + + # Current intensity index + int_i = spectra_i[i] + + for line in file_data: + # Skip non-assigned peaks. + if line[ass_i] == '?-?': + continue + + # First split by the 2D separator. + x_assign, h_assign = re.split('-', line[ass_i]) + + # The proton info. + h_row = re.split('([A-Z]+)', h_assign) + h_name = h_row[-2] + h_row[-1] + + # The heteronucleus info. + x_row = re.split('([A-Z]+)', x_assign) + x_name = x_row[-2] + x_row[-1] + + # The residue number. + try: + res_num = int(x_row[-3]) + except: + raise RelaxError("Improperly formatted Sparky file.") + + # Intensity. + try: + intensity = float(line[int_i])*float(line[5]) + except ValueError: + raise RelaxError("The peak intensity value %s from the line %s is invalid."%(intensity,line)) + + # Append the data. + data.append([h_name, x_name, res_num, intensity]) + + # Append to all data + data_all.append([data,spectrum]) + + # Add 1 to counter + i += 1 + # Return the data. + return data_all Modified: branches/relax_disp/pipe_control/spectrum.py URL: http://svn.gna.org/viewcvs/relax/branches/relax_disp/pipe_control/spectrum.py?rev=20448&r1=20447&r2=20448&view=diff ============================================================================== --- branches/relax_disp/pipe_control/spectrum.py (original) +++ branches/relax_disp/pipe_control/spectrum.py Mon Jul 22 12:01:35 2013 @@ -623,6 +623,9 @@ # Automatic format detection. format = autodetect_format(file_data) + # Flag for single or multiple spectrum extraction + single_spectrum = True + # Generic. if format == 'generic': # Print out. @@ -663,13 +666,38 @@ # Extract the data. intensity_data = nmrpipe.read_list_intensity_seriestab(file_data=file_data, int_col=int_col) - # Convert the residue number to a spin ID. + # Loop over each spectrum for i in range(len(intensity_data)): - # Generate the spin_id. - spin_id = generate_spin_id_unique(res_num=intensity_data[i][2], spin_name=intensity_data[i][1]) - - # Replace the data. - intensity_data[i][2] = spin_id + spectrum = intensity_data[i][0] + + # Get the spectrum name + spectrum_name = intensity_data[i][1] + + #Loop over each spin in the spectrum information + for j in range(len(spectrum)): + # Extract spin information + spin = spectrum[j] + + # Extract proton info + h_name = spin[0] + + # Extract heteronucleus info + x_name = spin[1] + + # Extract the residue number + res_num = spin[2] + + # Extract the Intensity + intensity = spin[3] + + # Generate the spin_id. + spin_id = generate_spin_id_unique(res_num=res_num, spin_name=x_name) + + # Replace residue number with the spin_id. + intensity_data[i][0][j][2] = spin_id + + # Change Flag for single or multiple spectrum extraction + single_spectrum = False # Sparky. elif format == 'sparky':