mailr19355 - in /branches/relax_disp: ./ lib/software/sparky.py test_suite/unit_tests/_lib/_software/test_sparky.py


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

Header


Content

Posted by edward on April 04, 2013 - 15:15:
Author: bugman
Date: Thu Apr  4 15:15:18 2013
New Revision: 19355

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

........
  r19354 | bugman | 2013-04-04 15:14:11 +0200 (Thu, 04 Apr 2013) | 5 lines
  
  Created the lib.software.sparky.write_list() function and associated unit 
test.
  
  This will be used to create simple Sparky .list files.
........

Added:
    branches/relax_disp/test_suite/unit_tests/_lib/_software/test_sparky.py
      - copied unchanged from r19354, 
trunk/test_suite/unit_tests/_lib/_software/test_sparky.py
Modified:
    branches/relax_disp/   (props changed)
    branches/relax_disp/lib/software/sparky.py

Propchange: branches/relax_disp/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Thu Apr  4 15:15:18 2013
@@ -1,1 +1,1 @@
-/trunk:1-19352
+/trunk:1-19354

Modified: branches/relax_disp/lib/software/sparky.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/relax_disp/lib/software/sparky.py?rev=19355&r1=19354&r2=19355&view=diff
==============================================================================
--- branches/relax_disp/lib/software/sparky.py (original)
+++ branches/relax_disp/lib/software/sparky.py Thu Apr  4 15:15:18 2013
@@ -107,3 +107,72 @@
 
     # Return the data.
     return data
+
+
+def write_list(file_prefix=None, dir=None, res_names=None, res_nums=None, 
atom1_names=None, atom2_names=None, w1=None, w2=None, data_height=None, 
force=True):
+    """Create a Sparky .list file.
+
+    @keyword file_prefix:   The base part of the file name without the .list 
extension.
+    @type file_prefix:      str
+    @keyword dir:           The directory to place the file in.
+    @type dir:              str or None
+    @keyword res_names:     The residue name list for each peak entry.
+    @type res_names:        list of str
+    @keyword res_nums:      The residue number list for each peak entry.
+    @type res_nums:         list of int
+    @keyword atom1_names:   The atom name list for w1 for each peak entry.
+    @type atom1_names:      list of str
+    @keyword atom2_names:   The atom name list for w2 for each peak entry.
+    @type atom2_names:      list of str
+    @keyword w1:            The w1 chemical shift list in ppm for each peak 
entry.
+    @type w1:               list of float
+    @keyword w2:            The w2 chemical shift list in ppm for each peak 
entry.
+    @type w2:               list of float
+    @keyword data_height:   The optional data height list for each peak 
entry.
+    @type data_height:      None or list of float
+    @keyword force:         A flag which if True will cause any pre-existing 
files to be overwritten.
+    @type force:            bool
+    """
+
+    # Checks.
+    N = len(w1)
+    if len(res_names) != N:
+        raise RelaxError("The %s residue names does not match the %s number 
of entries." % (len(res_names), N))
+    if len(res_nums) != N:
+        raise RelaxError("The %s residue numbers does not match the %s 
number of entries." % (len(res_nums), N))
+    if len(atom1_names) != N:
+        raise RelaxError("The %s w1 atom names does not match the %s number 
of entries." % (len(atom1_names), N))
+    if len(atom2_names) != N:
+        raise RelaxError("The %s w2 atom names does not match the %s number 
of entries." % (len(atom2_names), N))
+    if len(w1) != N:
+        raise RelaxError("The %s w1 chemical shifts does not match the %s 
number of entries." % (len(w1), N))
+    if len(w2) != N:
+        raise RelaxError("The %s w2 chemical shifts does not match the %s 
number of entries." % (len(w2), N))
+    if data_height and len(data_height) != N:
+        raise RelaxError("The %s data heights does not match the %s number 
of entries." % (len(data_height), N))
+
+    # Printout.
+    print("Creating the Sparky list file.")
+
+    # Open the file.
+    if isinstance(file_prefix, str):
+        file = open_write_file(file_name=file_prefix+".list", dir=dir, 
force=force)
+    else:
+        file = file_prefix
+
+    # The header.
+    file.write("%17s %10s %10s" % ("Assignment ", "w1 ", "w2 "))
+    if data_height != None:
+        file.write(" %12s" % "Data Height")
+    file.write("\n\n")
+
+    # The data.
+    for i in range(N):
+        # Generate the assignment.
+        assign = "%s%i%s-%s" % (res_names[i], res_nums[i], atom1_names[i], 
atom2_names[i])
+
+        # Write out the line.
+        file.write("%17s %10.3f %10.3f" % (assign, w1[i], w2[i]))
+        if data_height != None:
+            file.write(" %12i" % data_height[i])
+        file.write("\n")




Related Messages


Powered by MHonArc, Updated Thu Apr 04 15:40:01 2013