mailr27768 - in /branches/frame_order_cleanup: ./ pipe_control/ test_suite/system_tests/ user_functions/


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

Header


Content

Posted by edward on March 03, 2015 - 17:50:
Author: bugman
Date: Tue Mar  3 17:50:29 2015
New Revision: 27768

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

........
  r27763 | bugman | 2015-03-03 17:34:39 +0100 (Tue, 03 Mar 2015) | 5 lines
  
  Created the Rdc.test_corr_plot system test to check the rdc.corr_plot user 
function.
  
  This shows that this poorly tested function works correctly.
........
  r27764 | bugman | 2015-03-03 17:40:22 +0100 (Tue, 03 Mar 2015) | 5 lines
  
  Created the Pcs.test_corr_plot system test to check the pcs.corr_plot user 
function.
  
  This user function is poorly tested, and this test triggers a series of 
bugs.
........
  r27765 | bugman | 2015-03-03 17:42:30 +0100 (Tue, 03 Mar 2015) | 6 lines
  
  Added the 'title' and 'subtitle' arguments to the pcs.corr_plot user 
function.
  
  This problem was detected by the new Pcs.test_corr_plot system test.  The 
pcs.corr_plot user
  function now matches the rdc.corr_plot user function in terms of arguments.
........
  r27766 | bugman | 2015-03-03 17:46:21 +0100 (Tue, 03 Mar 2015) | 3 lines
  
  Fix for the pcs.corr_plot user function when the spin containers have no 
element information.
........
  r27767 | bugman | 2015-03-03 17:50:02 +0100 (Tue, 03 Mar 2015) | 5 lines
  
  Completed the Pcs.test_corr_plot system test.
  
  The file contents are now known and have been carefully checking in Grace.
........

Modified:
    branches/frame_order_cleanup/   (props changed)
    branches/frame_order_cleanup/pipe_control/pcs.py
    branches/frame_order_cleanup/test_suite/system_tests/pcs.py
    branches/frame_order_cleanup/test_suite/system_tests/rdc.py
    branches/frame_order_cleanup/user_functions/pcs.py

Propchange: branches/frame_order_cleanup/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Tue Mar  3 17:50:29 2015
@@ -1 +1 @@
-/trunk:1-27761
+/trunk:1-27767

Modified: branches/frame_order_cleanup/pipe_control/pcs.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/frame_order_cleanup/pipe_control/pcs.py?rev=27768&r1=27767&r2=27768&view=diff
==============================================================================
--- branches/frame_order_cleanup/pipe_control/pcs.py    (original)
+++ branches/frame_order_cleanup/pipe_control/pcs.py    Tue Mar  3 17:50:29 
2015
@@ -428,7 +428,10 @@
     # The spin types.
     types = []
     for spin in spin_loop():
-        if spin.element not in types:
+        if not hasattr(spin, 'element'):
+            if None not in types:
+                types.append(None)
+        elif spin.element not in types:
             types.append(spin.element)
 
     # Loop over the PCS data.
@@ -459,7 +462,7 @@
                     continue
 
                 # Incorrect spin type.
-                if spin.element != types[i]:
+                if hasattr(spin, 'element') and spin.element != types[i]:
                     continue
 
                 # Skip if data is missing.

Modified: branches/frame_order_cleanup/test_suite/system_tests/pcs.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/frame_order_cleanup/test_suite/system_tests/pcs.py?rev=27768&r1=27767&r2=27768&view=diff
==============================================================================
--- branches/frame_order_cleanup/test_suite/system_tests/pcs.py (original)
+++ branches/frame_order_cleanup/test_suite/system_tests/pcs.py Tue Mar  3 
17:50:29 2015
@@ -26,7 +26,7 @@
 # Python module imports.
 from os import sep
 from re import search
-from tempfile import mkdtemp
+from tempfile import mkdtemp, mktemp
 
 # relax module imports.
 from data_store import Relax_data_store; ds = Relax_data_store()
@@ -37,6 +37,128 @@
 
 class Pcs(SystemTestCase):
     """Class for testing PCS operations."""
+
+    def test_corr_plot(self):
+        """Test the operation of the pcs.corr_plot user function."""
+
+        # Create a data pipe.
+        self.interpreter.pipe.create('orig', 'N-state')
+
+        # Data directory.
+        dir = status.install_path + 
sep+'test_suite'+sep+'shared_data'+sep+'align_data'+sep
+
+        # Load the spins.
+        self.interpreter.sequence.read(file='pcs.txt', dir=dir, 
spin_name_col=1)
+        self.interpreter.sequence.display()
+
+        # Load the PCSs.
+        self.interpreter.pcs.read(align_id='tb', file='pcs.txt', dir=dir, 
spin_name_col=1, data_col=2)
+        self.interpreter.sequence.display()
+
+        # Create back-calculated PCS values from the real values.
+        for spin in spin_loop():
+            if hasattr(spin, 'pcs'):
+                if not hasattr(spin, 'pcs_bc'):
+                    spin.pcs_bc = {}
+                spin.pcs_bc['tb'] = spin.pcs['tb']
+                if spin.pcs_bc['tb'] != None:
+                    spin.pcs_bc['tb'] += 1.0
+
+        # Correlation plot.
+        ds.tmpfile = mktemp()
+        self.interpreter.pcs.corr_plot(format='grace', title='Test', 
subtitle='Test2', file=ds.tmpfile, dir=None, force=True)
+
+        # The expected file contents.
+        real_contents = [
+            "@version 50121",
+            "@page size 842, 595",
+            "@with g0",
+            "@    world 0.0, 0.0, 2.0, 2.0",
+            "@    view 0.15, 0.15, 1.28, 0.85",
+            "@    title \"Test\"",
+            "@    subtitle \"Test2\"",
+            "@    xaxis  label \"Back-calculated PCS (ppm)\"",
+            "@    xaxis  label char size 1.00",
+            "@    xaxis  tick major 1",
+            "@    xaxis  tick major size 0.50",
+            "@    xaxis  tick major linewidth 0.5",
+            "@    xaxis  tick minor ticks 9",
+            "@    xaxis  tick minor linewidth 0.5",
+            "@    xaxis  tick minor size 0.25",
+            "@    xaxis  ticklabel char size 0.70",
+            "@    yaxis  label \"Measured PCS (ppm)\"",
+            "@    yaxis  label char size 1.00",
+            "@    yaxis  tick major 1",
+            "@    yaxis  tick major size 0.50",
+            "@    yaxis  tick major linewidth 0.5",
+            "@    yaxis  tick minor ticks 9",
+            "@    yaxis  tick minor linewidth 0.5",
+            "@    yaxis  tick minor size 0.25",
+            "@    yaxis  ticklabel char size 0.70",
+            "@    legend on",
+            "@    legend 1, 0.5",
+            "@    legend box fill pattern 1",
+            "@    legend char size 1.0",
+            "@    frame linewidth 0.5",
+            "@    s0 symbol 1",
+            "@    s0 symbol size 0.45",
+            "@    s0 symbol linewidth 0.5",
+            "@    s0 errorbar size 0.5",
+            "@    s0 errorbar linewidth 0.5",
+            "@    s0 errorbar riser linewidth 0.5",
+            "@    s0 line linestyle 2",
+            "@    s1 symbol 2",
+            "@    s1 symbol size 0.45",
+            "@    s1 symbol linewidth 0.5",
+            "@    s1 errorbar size 0.5",
+            "@    s1 errorbar linewidth 0.5",
+            "@    s1 errorbar riser linewidth 0.5",
+            "@    s1 line linestyle 0",
+            "@    s1 legend \"tb (None)\"",
+            "@target G0.S0",
+            "@type xy",
+            "-100                           -100.000000000000000             
                            \"# 0\"",
+            "100                            100.000000000000000              
                            \"# 0\"",
+            "&",
+            "@target G0.S1",
+            "@type xy",
+            "1.004                          0.004000000000000                
                            \"# @C1\"",
+            "1.008                          0.008000000000000                
                            \"# @C2\"",
+            "1.021                          0.021000000000000                
                            \"# @C3\"",
+            "1.029                          0.029000000000000                
                            \"# @C4\"",
+            "1.016                          0.016000000000000                
                            \"# @C5\"",
+            "1.01                           0.010000000000000                
                            \"# @C6\"",
+            "1.008                          0.008000000000000                
                            \"# @H1\"",
+            "1.003                          0.003000000000000                
                            \"# @H2\"",
+            "1.006                          0.006000000000000                
                            \"# @H3\"",
+            "1.003                          0.003000000000000                
                            \"# @H4\"",
+            "1.007                          0.007000000000000                
                            \"# @H5\"",
+            "1.005                          0.005000000000000                
                            \"# @H6\"",
+            "1.001                          0.001000000000000                
                            \"# @H7\"",
+            "1.07                           0.070000000000000                
                            \"# @C7\"",
+            "1.025                          0.025000000000000                
                            \"# @C9\"",
+            "1.098                          0.098000000000000                
                            \"# @C10\"",
+            "1.054                          0.054000000000000                
                            \"# @C11\"",
+            "1.075                          0.075000000000000                
                            \"# @C12\"",
+            "1.065                          0.065000000000000                
                            \"# @H12\"",
+            "1.07                           0.070000000000000                
                            \"# @H14\"",
+            "1.015                          0.015000000000000                
                            \"# @H15\"",
+            "1.098                          0.098000000000000                
                            \"# @H16\"",
+            "1.06                           0.060000000000000                
                            \"# @H17\"",
+            "1.12                           0.120000000000000                
                            \"# @H18\"",
+            "&"
+        ]
+
+        # Check the data.
+        print("\nChecking the Grace file contents.")
+        file = open(ds.tmpfile)
+        lines = file.readlines()
+        file.close()
+        self.assertEqual(len(real_contents), len(lines))
+        for i in range(len(lines)):
+            print(lines[i][:-1])
+            self.assertEqual(real_contents[i], lines[i][:-1])
+
 
     def test_grace_plot(self):
         """Test the creation of Grace plots of PCS data."""

Modified: branches/frame_order_cleanup/test_suite/system_tests/rdc.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/frame_order_cleanup/test_suite/system_tests/rdc.py?rev=27768&r1=27767&r2=27768&view=diff
==============================================================================
--- branches/frame_order_cleanup/test_suite/system_tests/rdc.py (original)
+++ branches/frame_order_cleanup/test_suite/system_tests/rdc.py Tue Mar  3 
17:50:29 2015
@@ -25,6 +25,7 @@
 
 # Python module imports.
 from os import sep
+from tempfile import mktemp
 
 # relax module imports.
 from data_store import Relax_data_store; ds = Relax_data_store()
@@ -64,6 +65,111 @@
 
         # Q factors.
         self.interpreter.rdc.calc_q_factors()
+
+
+    def test_corr_plot(self):
+        """Test the operation of the rdc.corr_plot user function."""
+
+        # Create a data pipe.
+        self.interpreter.pipe.create('orig', 'N-state')
+
+        # Data directory.
+        dir = status.install_path + 
sep+'test_suite'+sep+'shared_data'+sep+'align_data'+sep
+
+        # Load the spins.
+        self.interpreter.sequence.read(file='tb.txt', dir=dir, spin_id_col=1)
+        self.interpreter.sequence.attach_protons()
+        self.interpreter.sequence.display()
+
+        # Load the RDCs.
+        self.interpreter.rdc.read(align_id='tb', file='tb.txt', dir=dir, 
spin_id1_col=1, spin_id2_col=2, data_col=3, error_col=4)
+        self.interpreter.sequence.display()
+
+        # Create back-calculated RDC values from the real values.
+        for interatom in interatomic_loop():
+            if hasattr(interatom, 'rdc'):
+                if not hasattr(interatom, 'rdc_bc'):
+                    interatom.rdc_bc = {}
+                interatom.rdc_bc['tb'] = interatom.rdc['tb'] + 1.0
+
+        # Correlation plot.
+        ds.tmpfile = mktemp()
+        self.interpreter.rdc.corr_plot(format='grace', title='Test', 
subtitle='Test2', file=ds.tmpfile, dir=None, force=True)
+
+        # The expected file contents.
+        real_contents = [
+            "@version 50121",
+            "@page size 842, 595",
+            "@with g0",
+            "@    world -27.0, -27.0, 16.0, 16.0",
+            "@    view 0.15, 0.15, 1.28, 0.85",
+            "@    title \"Test\"",
+            "@    subtitle \"Test2\"",
+            "@    xaxis  label \"Back-calculated RDC (Hz)\"",
+            "@    xaxis  label char size 1.00",
+            "@    xaxis  tick major 10",
+            "@    xaxis  tick major size 0.50",
+            "@    xaxis  tick major linewidth 0.5",
+            "@    xaxis  tick minor ticks 9",
+            "@    xaxis  tick minor linewidth 0.5",
+            "@    xaxis  tick minor size 0.25",
+            "@    xaxis  ticklabel char size 0.70",
+            "@    yaxis  label \"Measured RDC (Hz)\"",
+            "@    yaxis  label char size 1.00",
+            "@    yaxis  tick major 10",
+            "@    yaxis  tick major size 0.50",
+            "@    yaxis  tick major linewidth 0.5",
+            "@    yaxis  tick minor ticks 9",
+            "@    yaxis  tick minor linewidth 0.5",
+            "@    yaxis  tick minor size 0.25",
+            "@    yaxis  ticklabel char size 0.70",
+            "@    legend on",
+            "@    legend 1, 0.5",
+            "@    legend box fill pattern 1",
+            "@    legend char size 1.0",
+            "@    frame linewidth 0.5",
+            "@    s0 symbol 1",
+            "@    s0 symbol size 0.45",
+            "@    s0 symbol linewidth 0.5",
+            "@    s0 errorbar size 0.5",
+            "@    s0 errorbar linewidth 0.5",
+            "@    s0 errorbar riser linewidth 0.5",
+            "@    s0 line linestyle 2",
+            "@    s1 symbol 2",
+            "@    s1 symbol size 0.45",
+            "@    s1 symbol linewidth 0.5",
+            "@    s1 errorbar size 0.5",
+            "@    s1 errorbar linewidth 0.5",
+            "@    s1 errorbar riser linewidth 0.5",
+            "@    s1 line linestyle 0",
+            "@    s1 legend \"tb\"",
+            "@target G0.S0",
+            "@type xydy",
+            "-100                           -100.000000000000000           
0.000000000000000             ",
+            "100                            100.000000000000000            
0.000000000000000             ",
+            "&",
+            "@target G0.S1",
+            "@type xydy",
+            "-25.2501958629                 -26.250195862900000            
1.000000000000000                                            \"# 
#CaM:5@N-#CaM:5@H\"",
+            "10.9308176694                  9.930817669420000              
1.000000000000000                                            \"# 
#CaM:6@N-#CaM:6@H\"",
+            "8.26317614156                  7.263176141560000              
1.000000000000000                                            \"# 
#CaM:7@N-#CaM:7@H\"",
+            "-0.24840526981                 -1.248405269810000             
0.000000000000000                                            \"# 
#CaM:8@N-#CaM:8@H\"",
+            "6.31803314334                  5.318033143340000              
1.000000000000000                                            \"# 
#CaM:9@N-#CaM:9@H\"",
+            "15.0362909456                  14.036290945599999             
1.000000000000000                                            \"# 
#CaM:10@N-#CaM:10@H\"",
+            "2.33652530397                  1.336525303970000              
0.000000000000000                                            \"# 
#CaM:11@N-#CaM:11@H\"",
+            "-0.6021670281                  -1.602167028100000             
0.000000000000000                                            \"# 
#CaM:12@N-#CaM:12@H\"",
+            "&",
+        ]
+
+        # Check the data.
+        print("\nChecking the Grace file contents.")
+        file = open(ds.tmpfile)
+        lines = file.readlines()
+        file.close()
+        self.assertEqual(len(real_contents), len(lines))
+        for i in range(len(lines)):
+            print(lines[i][:-1])
+            self.assertEqual(real_contents[i], lines[i][:-1])
 
 
     def test_rdc_copy(self):

Modified: branches/frame_order_cleanup/user_functions/pcs.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/frame_order_cleanup/user_functions/pcs.py?rev=27768&r1=27767&r2=27768&view=diff
==============================================================================
--- branches/frame_order_cleanup/user_functions/pcs.py  (original)
+++ branches/frame_order_cleanup/user_functions/pcs.py  Tue Mar  3 17:50:29 
2015
@@ -179,6 +179,20 @@
     can_be_none = True
 )
 uf.add_keyarg(
+    name = "title",
+    py_type = "str",
+    desc_short = "alternative plot title",
+    desc = "The title for the plot, overriding the default.",
+    can_be_none = True
+)
+uf.add_keyarg(
+    name = "subtitle",
+    py_type = "str",
+    desc_short = "alternative plot subtitle",
+    desc = "The subtitle for the plot, overriding the default.",
+    can_be_none = True
+)
+uf.add_keyarg(
     name = "file",
     default = "pcs_corr_plot.agr",
     py_type = "str",




Related Messages


Powered by MHonArc, Updated Wed Mar 04 13:40:02 2015