Author: semor Date: Fri Oct 17 21:34:13 2008 New Revision: 7802 URL: http://svn.gna.org/viewcvs/relax?rev=7802&view=rev Log: Ordered functions alphabetically. Modified: 1.3/generic_fns/intensity.py Modified: 1.3/generic_fns/intensity.py URL: http://svn.gna.org/viewcvs/relax/1.3/generic_fns/intensity.py?rev=7802&r1=7801&r2=7802&view=diff ============================================================================== --- 1.3/generic_fns/intensity.py (original) +++ 1.3/generic_fns/intensity.py Fri Oct 17 21:34:13 2008 @@ -89,101 +89,6 @@ # Not implemented yet... - - -def intensity_sparky(line, int_col): - """Function for returning relevant data from the Sparky peak intensity line. - - The residue number, heteronucleus and proton names, and peak intensity will be returned. - - - @param line: The single line of information from the intensity file. - @type line: list of str - @keyword int_col: The column containing the peak intensity data (for a non-standard formatted - file). - @type int_col: int - @raises RelaxError: When the expected peak intensity is not a float. - """ - - - # The Sparky assignment. - assignment = '' - res_num = '' - h_name = '' - x_name = '' - intensity = '' - if line[0]!='?-?': - assignment = split('([A-Z]+)', line[0]) - assignment = assignment[1:-1] - - # The residue number. - try: - res_num = int(assignment[1]) - except: - raise RelaxError, "Improperly formatted Sparky file." - - # Nuclei names. - x_name = assignment[2] - h_name = assignment[4] - - # The peak intensity column. - if int_col == None: - int_col = 3 - - # Intensity. - try: - intensity = float(line[int_col]) - except ValueError: - raise RelaxError, "The peak intensity value " + `intensity` + " from the line " + `line` + " is invalid." - - # Return the data. - return res_num, h_name, x_name, intensity - - -def intensity_xeasy(line, int_col, H_dim='w1'): - """Function for returning relevant data from the XEasy peak intensity line. - - The residue number, heteronucleus and proton names, and peak intensity will be returned. - - - @param line: The single line of information from the intensity file. - @type line: list of str - @keyword int_col: The column containing the peak intensity data (for a non-standard formatted - file). - @type int_col: int - @raises RelaxError: When the expected peak intensity is not a float. - """ - - # Test for invalid assignment lines which have the column numbers changed and return empty data. - if line[4] == 'inv.': - return None, None, None, 0.0 - - # The residue number. - try: - res_num = int(line[5]) - except: - raise RelaxError, "Improperly formatted XEasy file." - - # Nuclei names. - if H_dim == 'w1': - h_name = line[4] - x_name = line[7] - else: - x_name = line[4] - h_name = line[7] - - # The peak intensity column. - if int_col == None: - int_col = 10 - - # Intensity. - try: - intensity = float(line[int_col]) - except ValueError: - raise RelaxError, "The peak intensity value " + `intensity` + " from the line " + `line` + " is invalid." - - # Return the data. - return res_num, h_name, x_name, intensity def intensity_nmrview(line, int_col): @@ -232,6 +137,101 @@ print 'Using peak heights.' if int_col == 15: print 'Using peak volumes (or evolumes).' + + # Intensity. + try: + intensity = float(line[int_col]) + except ValueError: + raise RelaxError, "The peak intensity value " + `intensity` + " from the line " + `line` + " is invalid." + + # Return the data. + return res_num, h_name, x_name, intensity + + +def intensity_sparky(line, int_col): + """Function for returning relevant data from the Sparky peak intensity line. + + The residue number, heteronucleus and proton names, and peak intensity will be returned. + + + @param line: The single line of information from the intensity file. + @type line: list of str + @keyword int_col: The column containing the peak intensity data (for a non-standard formatted + file). + @type int_col: int + @raises RelaxError: When the expected peak intensity is not a float. + """ + + + # The Sparky assignment. + assignment = '' + res_num = '' + h_name = '' + x_name = '' + intensity = '' + if line[0]!='?-?': + assignment = split('([A-Z]+)', line[0]) + assignment = assignment[1:-1] + + # The residue number. + try: + res_num = int(assignment[1]) + except: + raise RelaxError, "Improperly formatted Sparky file." + + # Nuclei names. + x_name = assignment[2] + h_name = assignment[4] + + # The peak intensity column. + if int_col == None: + int_col = 3 + + # Intensity. + try: + intensity = float(line[int_col]) + except ValueError: + raise RelaxError, "The peak intensity value " + `intensity` + " from the line " + `line` + " is invalid." + + # Return the data. + return res_num, h_name, x_name, intensity + + +def intensity_xeasy(line, int_col, H_dim='w1'): + """Function for returning relevant data from the XEasy peak intensity line. + + The residue number, heteronucleus and proton names, and peak intensity will be returned. + + + @param line: The single line of information from the intensity file. + @type line: list of str + @keyword int_col: The column containing the peak intensity data (for a non-standard formatted + file). + @type int_col: int + @raises RelaxError: When the expected peak intensity is not a float. + """ + + # Test for invalid assignment lines which have the column numbers changed and return empty data. + if line[4] == 'inv.': + return None, None, None, 0.0 + + # The residue number. + try: + res_num = int(line[5]) + except: + raise RelaxError, "Improperly formatted XEasy file." + + # Nuclei names. + if H_dim == 'w1': + h_name = line[4] + x_name = line[7] + else: + x_name = line[4] + h_name = line[7] + + # The peak intensity column. + if int_col == None: + int_col = 10 # Intensity. try: