mailr18908 - in /branches/frame_order_testing: ./ auto_analyses/ generic_fns/ user_functions/


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

Header


Content

Posted by edward on March 20, 2013 - 13:40:
Author: bugman
Date: Wed Mar 20 13:40:11 2013
New Revision: 18908

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

........
  r18903 | bugman | 2013-03-20 10:28:25 +0100 (Wed, 20 Mar 2013) | 8 lines
  
  Fix for a nasty bug introduced at r18901.
  
  The string decode() method was being called for the version.url() and 
version.revision() functions
  to handle Python 3.  However this was causing strings in Python 2 to be 
converted to unicode, which
  then caused the saving of XML state files to fail.  Now the version 
information is explicitly
  converted to a string using the str() builtin function.
........
  r18904 | bugman | 2013-03-20 10:37:53 +0100 (Wed, 20 Mar 2013) | 9 lines
  
  Added the scaling argument to the value.display and value.write user 
functions.
  
  The idea comes from a suggestion by Angelo Figueiredo <am dott figueiredo 
att fct dott unl dott pt>
  and was discussed at 
http://thread.gmane.org/gmane.science.nmr.relax.user/1428/focus=1430.
  
  This allows the user to scale parameters to any value, for example scaling 
the Rex value to the
  field strength dependent value.
........
  r18905 | bugman | 2013-03-20 11:56:23 +0100 (Wed, 20 Mar 2013) | 11 lines
  
  The model-free auto-analysis (the dauvergne_protocol) now generates field 
strength dependent Rex files.
  
  The idea comes from a suggestion by Angelo Figueiredo <am dott figueiredo 
att fct dott unl dott pt>
  and was discussed at 
http://thread.gmane.org/gmane.science.nmr.relax.user/1428/focus=1430.
  
  One file per field strength is generated and named 'rex_600' for 600 MHz, 
for example.  The new
  scaling argument of the value.write user function is being used to scale 
the tiny field strength
  independent value used internally in relax to the Rex value in rad.s^-1 
that you would see in an R2
  data set.
........
  r18906 | bugman | 2013-03-20 13:29:59 +0100 (Wed, 20 Mar 2013) | 5 lines
  
  Added the new 'comment' argument to the value.write user function.
  
  This is used to add user comments to the top of the file.
........
  r18907 | bugman | 2013-03-20 13:32:45 +0100 (Wed, 20 Mar 2013) | 6 lines
  
  The model-free auto-analysis (the dauvergne_protocol module) now adds 
comments to the Rex files.
  
  This is through the new comment argument of the value.write user function.  
These comments explain
  that the Rex values are scaled to the stated field strength.
........

Modified:
    branches/frame_order_testing/   (props changed)
    branches/frame_order_testing/auto_analyses/dauvergne_protocol.py
    branches/frame_order_testing/generic_fns/value.py
    branches/frame_order_testing/user_functions/value.py
    branches/frame_order_testing/version.py

Propchange: branches/frame_order_testing/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Wed Mar 20 13:40:11 2013
@@ -1,1 +1,1 @@
-/trunk:1-18901
+/trunk:1-18907

Modified: branches/frame_order_testing/auto_analyses/dauvergne_protocol.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/frame_order_testing/auto_analyses/dauvergne_protocol.py?rev=18908&r1=18907&r2=18908&view=diff
==============================================================================
--- branches/frame_order_testing/auto_analyses/dauvergne_protocol.py 
(original)
+++ branches/frame_order_testing/auto_analyses/dauvergne_protocol.py Wed Mar 
20 13:40:11 2013
@@ -20,6 +20,7 @@
 
###############################################################################
 
 # Python module imports.
+from math import pi
 from os import F_OK, access, getcwd, listdir, sep
 from re import search
 from time import sleep
@@ -30,7 +31,7 @@
 from generic_fns.interatomic import interatomic_loop
 from generic_fns.mol_res_spin import exists_mol_res_spin_data, 
generate_spin_id, return_spin, spin_index_loop, spin_loop
 from generic_fns.pipes import cdp_name, get_pipe, has_pipe, pipe_names, 
switch
-from generic_fns import selection
+from generic_fns import frq, selection
 from prompt.interpreter import Interpreter
 from relax_errors import RelaxError, RelaxNoSequenceError, RelaxNoValueError
 from relax_io import DummyFileObject
@@ -908,6 +909,10 @@
         self.interpreter.value.write(param='ts',       file='ts.txt',       
dir=dir, force=True)
         self.interpreter.value.write(param='rex',      file='rex.txt',      
dir=dir, force=True)
         self.interpreter.value.write(param='local_tm', file='local_tm.txt', 
dir=dir, force=True)
+        frqs = frq.get_values()
+        for i in range(len(frqs)):
+            comment = "This is the Rex value with units rad.s^-1 scaled to a 
magnetic field strength of %s MHz." % (frqs[i]/1e6)
+            self.interpreter.value.write(param='rex', 
file='rex_%s.txt'%int(frqs[i]/1e6), dir=dir, scaling=(2.0*pi*frqs[i])**2, 
comment=comment, force=True)
 
         # Create the PyMOL macros.
         dir = self.write_results_dir + 'final' + sep + 'pymol'

Modified: branches/frame_order_testing/generic_fns/value.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/frame_order_testing/generic_fns/value.py?rev=18908&r1=18907&r2=18908&view=diff
==============================================================================
--- branches/frame_order_testing/generic_fns/value.py (original)
+++ branches/frame_order_testing/generic_fns/value.py Wed Mar 20 13:40:11 2013
@@ -92,11 +92,13 @@
     minimise.reset_min_stats(pipe_to)
 
 
-def display(param=None):
+def display(param=None, scaling=1.0):
     """Display spin specific data values.
 
-    @param param:       The name of the parameter to display.
+    @keyword param:     The name of the parameter to display.
     @type param:        str
+    @keyword scaling:   The value to scale the parameter by.
+    @type scaling:      float
     """
 
     # Test if the current pipe exists.
@@ -107,7 +109,7 @@
         raise RelaxNoSequenceError
 
     # Print the data.
-    write_data(param, sys.stdout)
+    write_data(param=param, file=sys.stdout, scaling=scaling)
 
 
 def get_parameters():
@@ -426,7 +428,7 @@
         pipes.switch(orig_pipe)
 
 
-def write(param=None, file=None, dir=None, bc=False, force=False, 
return_value=None, return_data_desc=None):
+def write(param=None, file=None, dir=None, scaling=1.0, return_value=None, 
return_data_desc=None, comment=None, bc=False, force=False):
     """Write data to a file.
 
     @keyword param:             The name of the parameter to write to file.
@@ -435,14 +437,18 @@
     @type file:                 str
     @keyword dir:               The name of the directory to place the file 
into (defaults to the current directory).
     @type dir:                  str
+    @keyword scaling:           The value to scale the parameter by.
+    @type scaling:              float
+    @keyword return_value:      An optional function which if supplied will 
override the default value returning function.
+    @type return_value:         None or func
+    @keyword return_data_desc:  An optional function which if supplied will 
override the default parameter description returning function.
+    @type return_data_desc:     None or func
+    @keyword comment:           Text which will be added to the start of the 
file as comments.  All lines will be prefixed by '# '.
+    @type comment:              str
     @keyword bc:                A flag which if True will cause the back 
calculated values to be written.
     @type bc:                   bool
     @keyword force:             A flag which if True will cause any 
pre-existing file to be overwritten.
     @type force:                bool
-    @keyword return_value:      An optional function which if supplied will 
override the default value returning function.
-    @type return_value:         None or func
-    @keyword return_data_desc:  An optional function which if supplied will 
override the default parameter description returning function.
-    @type return_data_desc:     None or func
     """
 
     # Test if the current pipe exists.
@@ -457,7 +463,7 @@
     file = open_write_file(file, dir, force)
 
     # Write the data.
-    write_data(param=param, file=file, bc=bc, return_value=return_value, 
return_data_desc=return_data_desc)
+    write_data(param=param, file=file, scaling=scaling, 
return_value=return_value, return_data_desc=return_data_desc, 
comment=comment, bc=bc)
 
     # Close the file.
     file.close()
@@ -466,19 +472,23 @@
     add_result_file(type='text', label='Text', file=file_path)
 
 
-def write_data(param=None, file=None, bc=False, return_value=None, 
return_data_desc=None):
+def write_data(param=None, file=None, scaling=1.0, bc=False, 
return_value=None, return_data_desc=None, comment=None):
     """The function which actually writes the data.
 
     @keyword param:             The parameter to write.
     @type param:                str
     @keyword file:              The file to write the data to.
     @type file:                 str
+    @keyword scaling:           The value to scale the parameter by.
+    @type scaling:              float
     @keyword bc:                A flag which if True will cause the back 
calculated values to be written.
     @type bc:                   bool
     @keyword return_value:      An optional function which if supplied will 
override the default value returning function.
     @type return_value:         None or func
     @keyword return_data_desc:  An optional function which if supplied will 
override the default parameter description returning function.
     @type return_data_desc:     None or func
+    @keyword comment:           Text which will be added to the start of the 
file as comments.  All lines will be prefixed by '# '.
+    @type comment:              str
     """
 
     # Get the value and error returning function parameter description 
function if required.
@@ -505,17 +515,33 @@
         file.write("# Parameter description:  %s.\n" % desc)
         file.write("#\n")
 
+    # The comments.
+    if comment:
+        # Split up the lines.
+        lines = comment.splitlines()
+
+        # Write out.
+        for line in lines:
+            file.write("# %s\n" % line)
+        file.write("#\n")
+
     # Loop over the sequence.
     for spin, mol_name, res_num, res_name in spin_loop(full_info=True):
         # Get the value and error.
         value, error = return_value(spin, param, bc=bc)
 
-        # Append the data.
+        # Append the spin data (scaled).
         mol_names.append(mol_name)
         res_nums.append(res_num)
         res_names.append(res_name)
         spin_nums.append(spin.num)
         spin_names.append(spin.name)
+
+        # Append the scaled values and errors.
+        if value != None:
+            value *= scaling
+        if error != None:
+            error *= scaling
         values.append(value)
         errors.append(error)
 

Modified: branches/frame_order_testing/user_functions/value.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/frame_order_testing/user_functions/value.py?rev=18908&r1=18907&r2=18908&view=diff
==============================================================================
--- branches/frame_order_testing/user_functions/value.py (original)
+++ branches/frame_order_testing/user_functions/value.py Wed Mar 20 13:40:11 
2013
@@ -1,6 +1,6 @@
 
###############################################################################
 #                                                                            
 #
-# Copyright (C) 2003-2012 Edward d'Auvergne                                  
 #
+# Copyright (C) 2003-2013 Edward d'Auvergne                                  
 #
 #                                                                            
 #
 # This file is part of the program relax (http://www.nmr-relax.com).         
 #
 #                                                                            
 #
@@ -125,6 +125,16 @@
     wiz_combo_iter = value.get_parameters,
     wiz_read_only = True
 )
+uf.add_keyarg(
+    name = "scaling",
+    default = 1.0,
+    py_type = "float",
+    desc_short = "scaling",
+    desc = "The factor to scale parameters by."
+)
+# Description.
+uf.desc.append(Desc_container())
+uf.desc[-1].add_paragraph("The values corresponding to the given parameter 
will be displayed.  The scaling argument can be used to scale the parameter 
values.  This can be useful for example in the case of the model-free Rex 
parameter to obtain the spectrometer dependent value from the omega_ex field 
strength independent internal value.  Or to scale correlation times from 
seconds down to nanosecond or picosecond timescales.")
 uf.desc.append(regexp_doc)
 uf.desc.append(Model_free.return_data_name_doc)
 uf.desc.append(Model_free.write_doc)
@@ -137,6 +147,9 @@
 uf.desc.append(Desc_container("Prompt examples"))
 uf.desc[-1].add_paragraph("To show all CSA values, type:")
 uf.desc[-1].add_prompt("relax> value.display('csa')")
+uf.desc[-1].add_paragraph("To display the model-free Rex values scaled to 
600 MHz, type one of:")
+uf.desc[-1].add_prompt("relax> value.display('rex', 
scaling=(2.0*pi*600e6)**2)")
+uf.desc[-1].add_prompt("relax> value.display(param='rex', 
scaling=(2.0*pi*600e6)**2)")
 uf.backend = value.display
 uf.menu_text = "&display"
 uf.gui_icon = "oxygen.actions.document-preview"
@@ -417,6 +430,20 @@
     can_be_none = True
 )
 uf.add_keyarg(
+    name = "scaling",
+    default = 1.0,
+    py_type = "float",
+    desc_short = "scaling",
+    desc = "The factor to scale parameters by."
+)
+uf.add_keyarg(
+    name = "comment",
+    py_type = "str",
+    desc_short = "comment",
+    desc = "Text which will be added to the start of the file as comments.  
All lines will be prefixed by '# '.",
+    can_be_none = True
+)
+uf.add_keyarg(
     name = "bc",
     default = False,
     py_type = "bool",
@@ -432,7 +459,7 @@
 )
 # Description.
 uf.desc.append(Desc_container())
-uf.desc[-1].add_paragraph("The values corresponding to the given parameter 
will be written to file.")
+uf.desc[-1].add_paragraph("The values corresponding to the given parameter 
will be written to file.  The scaling argument can be used to scale the 
parameter values.  This can be useful for example in the case of the 
model-free Rex parameter to obtain the spectrometer dependent value from the 
omega_ex field strength independent internal value.  Or to scale correlation 
times from seconds down to nanosecond or picosecond timescales.")
 uf.desc.append(regexp_doc)
 uf.desc.append(Model_free.return_data_name_doc)
 uf.desc.append(Model_free.write_doc)
@@ -451,6 +478,9 @@
 uf.desc[-1].add_prompt("relax> value.write(param='noe', file='noe.out')")
 uf.desc[-1].add_prompt("relax> value.write(param='noe', file='noe.out')")
 uf.desc[-1].add_prompt("relax> value.write(param='noe', file='noe.out', 
force=True)")
+uf.desc[-1].add_paragraph("To write the model-free Rex values scaled to 600 
MHz to the file 'rex_600', type one of:")
+uf.desc[-1].add_prompt("relax> value.write('rex', 'rex_600', 
scaling=(2.0*pi*600e6)**2)")
+uf.desc[-1].add_prompt("relax> value.write(param='rex', file='rex_600', 
scaling=(2.0*pi*600e6)**2)")
 uf.backend = value.write
 uf.menu_text = "&write"
 uf.gui_icon = "oxygen.actions.document-save"

Modified: branches/frame_order_testing/version.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/frame_order_testing/version.py?rev=18908&r1=18907&r2=18908&view=diff
==============================================================================
--- branches/frame_order_testing/version.py (original)
+++ branches/frame_order_testing/version.py Wed Mar 20 13:40:11 2013
@@ -71,7 +71,7 @@
 
         # The revision.
         if len(row) and row[0] == 'Revision:':
-            return row[1]
+            return str(row[1])
 
 
 def url():
@@ -107,7 +107,7 @@
 
         # The revision.
         if len(row) and row[0] == 'URL:':
-            return row[1]
+            return str(row[1])
 
 
 def version_full():




Related Messages


Powered by MHonArc, Updated Wed Mar 20 14:00:03 2013