mailr19353 - in /branches/relax_disp: ./ lib/software/ pipe_control/


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

Header


Content

Posted by edward on April 04, 2013 - 12:44:
Author: bugman
Date: Thu Apr  4 12:44:06 2013
New Revision: 19353

URL: http://svn.gna.org/viewcvs/relax?rev=19353&view=rev
Log:
Merged revisions 19349-19352 via svnmerge from 
svn+ssh://bugman@xxxxxxxxxxx/svn/relax/trunk

........
  r19349 | bugman | 2013-04-04 12:26:09 +0200 (Thu, 04 Apr 2013) | 6 lines
  
  Shifted the Sparky peak intensity reading code to 
lib.software.sparky.read_list_intensity().
  
  This new function comes from the old 
pipe_control.spectrum.intensity_sparky() function, but with the
  spin ID code removed.
........
  r19350 | bugman | 2013-04-04 12:33:19 +0200 (Thu, 04 Apr 2013) | 6 lines
  
  Shifted the XEasy peak intensity reading code to 
lib.software.xeasy.read_list_intensity().
  
  This new function comes from the old 
pipe_control.spectrum.intensity_xeasy() function, but with the
  spin ID code removed.
........
  r19351 | bugman | 2013-04-04 12:39:55 +0200 (Thu, 04 Apr 2013) | 3 lines
  
  Docstring fix for the lib.software.xeasy.read_list_intensity() function.
........
  r19352 | bugman | 2013-04-04 12:41:49 +0200 (Thu, 04 Apr 2013) | 6 lines
  
  Shifted the NMRView peak intensity reading code to 
lib.software.nmrview.read_list_intensity().
  
  This new function comes from the old 
pipe_control.spectrum.intensity_nmrview() function, but with
  the spin ID code removed.
........

Added:
    branches/relax_disp/lib/software/nmrview.py
      - copied unchanged from r19352, trunk/lib/software/nmrview.py
    branches/relax_disp/lib/software/sparky.py
      - copied unchanged from r19352, trunk/lib/software/sparky.py
    branches/relax_disp/lib/software/xeasy.py
      - copied unchanged from r19352, trunk/lib/software/xeasy.py
Modified:
    branches/relax_disp/   (props changed)
    branches/relax_disp/lib/software/__init__.py
    branches/relax_disp/pipe_control/spectrum.py

Propchange: branches/relax_disp/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Thu Apr  4 12:44:06 2013
@@ -1,1 +1,1 @@
-/trunk:1-19333
+/trunk:1-19352

Modified: branches/relax_disp/lib/software/__init__.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/relax_disp/lib/software/__init__.py?rev=19353&r1=19352&r2=19353&view=diff
==============================================================================
--- branches/relax_disp/lib/software/__init__.py (original)
+++ branches/relax_disp/lib/software/__init__.py Thu Apr  4 12:44:06 2013
@@ -25,6 +25,9 @@
 __all__ = [
     'bruker_dc',
     'grace',
+    'nmrview',
     'opendx',
+    'sparky',
+    'xeasy',
     'xplor'
 ]

Modified: branches/relax_disp/pipe_control/spectrum.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/relax_disp/pipe_control/spectrum.py?rev=19353&r1=19352&r2=19353&view=diff
==============================================================================
--- branches/relax_disp/pipe_control/spectrum.py (original)
+++ branches/relax_disp/pipe_control/spectrum.py Thu Apr  4 12:44:06 2013
@@ -35,6 +35,7 @@
 from pipe_control import pipes
 from lib.errors import RelaxError, RelaxImplementError, 
RelaxNoSequenceError, RelaxNoSpectraError
 from lib.io import extract_data, read_spin_data, strip, write_data
+from lib.software import nmrview, sparky, xeasy
 from lib.warnings import RelaxWarning, RelaxNoSpinWarning
 
 
@@ -502,276 +503,6 @@
     for mol_name, res_num, res_name, spin_num, spin_name, value in 
read_spin_data(file_data=file_data, 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, data_col=data_col, sep=sep, spin_id=spin_id):
         id = generate_spin_id_unique(mol_name=mol_name, res_num=res_num, 
res_name=res_name, spin_num=spin_num, spin_name=spin_name)
         data.append([None, None, id, value, id])
-
-    # Return the data.
-    return data
-
-
-def intensity_nmrview(file_data=None, int_col=None):
-    """Return the process data from the NMRView 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 containing the peak intensity data. The 
default is 16 for intensities. Setting the int_col argument to 15 will use 
the volumes (or evolumes). For a non-standard formatted file, use a different 
value.
-    @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, spin ID string, the intensity value, and the 
original line of text
-    @rtype:             list of lists of str, str, str, float, str
-    """
-
-    # Assume the NMRView file has six header lines!
-    num = 6
-    print("Number of header lines: " + repr(num))
-
-    # Remove the header.
-    file_data = file_data[num:]
-
-    # Strip the data.
-    file_data = strip(file_data)
-
-    # The peak intensity column.
-    if int_col == None:
-        int_col = 16
-    if int_col == 16:
-        print('Using peak heights.')
-    if int_col == 15:
-        print('Using peak volumes (or evolumes).')
-
-    # Loop over the file data.
-    data = []
-    for line in file_data:
-        # Unknown assignment.
-        if line[1] == '{}':
-            warn(RelaxWarning("The assignment '%s' is unknown, skipping this 
peak." % line[1]))
-            continue
-
-        # The residue number
-        res_num = ''
-        try:
-            res_num = line[1].strip('{')
-            res_num = res_num.strip('}')
-            res_num = res_num.split('.')
-            res_num = res_num[0]
-        except ValueError:
-            raise RelaxError("The peak list is invalid.")
-
-        # Nuclei names.
-        x_name = ''
-        if line[8]!='{}':
-            x_name = line[8].strip('{')
-            x_name = x_name.strip('}')
-            x_name = x_name.split('.')
-            x_name = x_name[1]
-        h_name = ''
-        if line[1]!='{}':
-            h_name = line[1].strip('{')
-            h_name = h_name.strip('}')
-            h_name = h_name.split('.')
-            h_name = h_name[1]
-
-        # Intensity.
-        try:
-            intensity = float(line[int_col])
-        except ValueError:
-            raise RelaxError("The peak intensity value " + repr(intensity) + 
" from the line " + repr(line) + " is invalid.")
-
-        # Generate the spin_id.
-        spin_id = generate_spin_id_unique(res_num=res_num, spin_name=x_name)
-
-        # Append the data.
-        data.append([h_name, x_name, spin_id, intensity, line])
-
-    # Return the data.
-    return data
-
-
-def intensity_sparky(file_data=None, int_col=None):
-    """Return the process data from the Sparky 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 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.
-    @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, spin ID string, the intensity value, and the 
original line of text.
-    @rtype:             list of lists of str, str, str, float, str
-    """
-
-    # The number of header lines.
-    num = 0
-    if file_data[0][0] == 'Assignment':
-        num = num + 1
-    if file_data[1] == '':
-        num = num + 1
-    print("Number of header lines found: %s" % num)
-
-    # Remove the header.
-    file_data = file_data[num:]
-
-    # Strip the data.
-    file_data = strip(file_data)
-
-    # Loop over the file data.
-    data = []
-    for line in file_data:
-        # The Sparky assignment.
-        assignment = ''
-        res_num = ''
-        h_name = ''
-        x_name = ''
-        intensity = ''
-
-        # Skip non-assigned peaks.
-        if line[0] == '?-?':
-            continue
-
-        # First split by the 2D separator.
-        x_assign, h_assign = split('-', line[0])
-
-        # The proton info.
-        h_row = split('([A-Z]+)', h_assign)
-        h_name = h_row[-2] + h_row[-1]
-
-        # The heteronucleus info.
-        x_row = 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.")
-
-        # 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 " + repr(intensity) + 
" from the line " + repr(line) + " is invalid.")
-
-        # Generate the spin_id.
-        spin_id = generate_spin_id_unique(res_num=res_num, spin_name=x_name)
-
-        # Append the data.
-        data.append([h_name, x_name, spin_id, intensity, line])
-
-    # Return the data.
-    return data
-
-
-def intensity_xeasy(file_data=None, heteronuc=None, proton=None, 
int_col=None):
-    """Return the process data from the XEasy 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 heteronuc: The name of the heteronucleus as specified in the 
peak intensity file.
-    @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).
-    @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, spin ID string, the intensity value, and the 
original line of text.
-    @rtype:             list of lists of str, str, str, float, str
-    """
-
-    # The columns.
-    w1_col = 4
-    w2_col = 7
-    if int_col == None:
-        int_col = 10
-
-    # Set the default proton dimension.
-    H_dim = 'w1'
-
-    # Determine the number of header lines.
-    num = 0
-    for line in file_data:
-        # Try to see if the intensity can be extracted.
-        try:
-            intensity = float(line[int_col])
-        except ValueError:
-            num = num + 1
-        except IndexError:
-            num = num + 1
-        else:
-            break
-    print("Number of header lines found: " + repr(num))
-
-    # Remove the header.
-    file_data = file_data[num:]
-
-    # Strip the data.
-    file_data = strip(file_data)
-
-    # Determine the proton and heteronucleus dimensions.
-    for line in file_data:
-        # Proton in w1, heteronucleus in w2.
-        if line[w1_col] == proton and line[w2_col] == heteronuc:
-            # Set the proton dimension.
-            H_dim = 'w1'
-
-            # Print out.
-            print("The proton dimension is w1")
-
-            # Don't continue (waste of time).
-            break
-
-        # Heteronucleus in w1, proton in w2.
-        if line[w1_col] == heteronuc and line[w2_col] == proton:
-            # Set the proton dimension.
-            H_dim = 'w2'
-
-            # Print out.
-            print("The proton dimension is w2")
-
-            # Don't continue (waste of time).
-            break
-
-    # Loop over the file data.
-    data = []
-    for line in file_data:
-        # Test for invalid assignment lines which have the column numbers 
changed and return empty data.
-        if line[w1_col] == 'inv.':
-            continue
-
-        # 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[w1_col]
-            x_name = line[w2_col]
-        else:
-            x_name = line[w1_col]
-            h_name = line[w2_col]
-
-        # Intensity.
-        try:
-            intensity = float(line[int_col])
-        except ValueError:
-            raise RelaxError("The peak intensity value " + repr(intensity) + 
" from the line " + repr(line) + " is invalid.")
-
-        # Generate the spin_id.
-        spin_id = generate_spin_id_unique(res_num=res_num, spin_name=x_name)
-
-        # Append the data.
-        data.append([h_name, x_name, spin_id, intensity, line])
 
     # Return the data.
     return data
@@ -858,7 +589,15 @@
         print("NMRView formatted data file.\n")
 
         # Extract the data.
-        intensity_data = intensity_nmrview(file_data=file_data)
+        intensity_data = nmrview.read_list_intensity(file_data=file_data)
+
+        # Convert the residue number to a spin ID.
+        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
 
     # Sparky.
     elif format == 'sparky':
@@ -866,7 +605,15 @@
         print("Sparky formatted data file.\n")
 
         # Extract the data.
-        intensity_data = intensity_sparky(file_data=file_data, 
int_col=int_col)
+        intensity_data = sparky.read_list_intensity(file_data=file_data, 
int_col=int_col)
+
+        # Convert the residue number to a spin ID.
+        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
 
     # XEasy.
     elif format == 'xeasy':
@@ -874,7 +621,15 @@
         print("XEasy formatted data file.\n")
 
         # Extract the data.
-        intensity_data = intensity_xeasy(file_data=file_data, proton=proton, 
heteronuc=heteronuc, int_col=int_col)
+        intensity_data = xeasy.read_list_intensity(file_data=file_data, 
proton=proton, heteronuc=heteronuc, int_col=int_col)
+
+        # Convert the residue number to a spin ID.
+        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
 
     # Add the spectrum id (and ncproc) to the relax data store.
     if not hasattr(cdp, 'spectrum_ids'):




Related Messages


Powered by MHonArc, Updated Thu Apr 04 15:20:02 2013