mailr27597 - in /trunk: pipe_control/grace.py pipe_control/plotting.py user_functions/grace.py


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

Header


Content

Posted by edward on February 06, 2015 - 14:58:
Author: bugman
Date: Fri Feb  6 14:58:01 2015
New Revision: 27597

URL: http://svn.gna.org/viewcvs/relax?rev=27597&view=rev
Log:
Shifted the pipe_control.grace.write() function.

This is now the format independent pipe_control.plotting.write_xy() function. 
 The format argument
has been added and this defaults to 'grace'.  The grace.write user function 
has been updated to use
the new backend.


Modified:
    trunk/pipe_control/grace.py
    trunk/pipe_control/plotting.py
    trunk/user_functions/grace.py

Modified: trunk/pipe_control/grace.py
URL: 
http://svn.gna.org/viewcvs/relax/trunk/pipe_control/grace.py?rev=27597&r1=27596&r2=27597&view=diff
==============================================================================
--- trunk/pipe_control/grace.py (original)
+++ trunk/pipe_control/grace.py Fri Feb  6 14:58:01 2015
@@ -34,7 +34,6 @@
 from pipe_control.mol_res_spin import count_molecules, count_residues, 
count_spins, exists_mol_res_spin_data
 from pipe_control import pipes
 from pipe_control.pipes import check_pipe
-from pipe_control.result_files import add_result_file
 from pipe_control.plotting import assemble_data
 from specific_analyses.api import return_api
 from status import Status; status = Status()
@@ -203,81 +202,3 @@
 
     # Run Grace.
     system(grace_exe + " \"" + file_path + "\" &")
-
-
-def write(x_data_type='res_num', y_data_type=None, spin_id=None, 
plot_data='value', norm_type='first', file=None, dir=None, force=False, 
norm=True):
-    """Writing data to a file.
-
-    @keyword x_data_type:   The category of the X-axis data.
-    @type x_data_type:      str
-    @keyword y_data_type:   The category of the Y-axis data.
-    @type y_data_type:      str
-    @keyword spin_id:       The spin identification string.
-    @type spin_id:          str
-    @keyword plot_data:     The type of the plotted data, one of 'value', 
'error', or 'sim'.
-    @type plot_data:        str
-    @keyword norm_type:     The point to normalise to 1.  This can be 
'first' or 'last'.
-    @type norm_type:        str
-    @keyword file:          The name of the Grace file to create.
-    @type file:             str
-    @keyword dir:           The optional directory to place the file into.
-    @type dir:              str
-    @param force:           Boolean argument which if True causes the file 
to be overwritten if it already exists.
-    @type force:            bool
-    @keyword norm:          The normalisation flag which if set to True will 
cause all graphs to be normalised to a starting value of 1.
-    @type norm:             bool
-    """
-
-    # Test if the current pipe exists.
-    check_pipe()
-
-    # Test if the sequence data is loaded.
-    if not exists_mol_res_spin_data():
-        raise RelaxNoSequenceError
-
-    # Test if the plot_data argument is one of 'value', 'error', or 'sim'.
-    if plot_data not in ['value', 'error', 'sim']:
-        raise RelaxError("The plot data argument " + repr(plot_data) + " 
must be set to either 'value', 'error', 'sim'.")
-
-    # Test if the simulations exist.
-    if plot_data == 'sim' and not hasattr(cdp, 'sim_number'):
-        raise RelaxNoSimError
-
-    # Open the file for writing.
-    file_path = get_file_path(file, dir)
-    file = open_write_file(file, dir, force)
-
-    # Get the data.
-    data, set_names, graph_type = assemble_data(spin_id, 
x_data_name=x_data_type, y_data_name=y_data_type, plot_data=plot_data)
-
-    # Convert the graph type.
-    if graph_type == 'X,Y':
-        graph_type = 'xy'
-    elif graph_type == 'X,Y,dX':
-        graph_type = 'xydx'
-    elif graph_type == 'X,Y,dY':
-        graph_type = 'xydy'
-    elif graph_type == 'X,Y,dX,dY':
-        graph_type = 'xydxdy'
-
-    # No data, so close the empty file and exit.
-    if not len(data) or not len(data[0]) or not len(data[0][0]):
-        warn(RelaxWarning("No data could be found, creating an empty file."))
-        file.close()
-        return
-
-    # Get the axis information.
-    data_type = [x_data_type, y_data_type]
-    seq_type, axis_labels = axis_setup(data_type=data_type, norm=norm)
-
-    # Write the header.
-    write_xy_header(format='grace', file=file, data_type=data_type, 
seq_type=seq_type, sets=[len(data[0])], set_names=[set_names], 
axis_labels=[axis_labels], norm=[norm])
-
-    # Write the data.
-    write_xy_data(format='grace', data=data, file=file, 
graph_type=graph_type, norm_type=norm_type, norm=[norm])
-
-    # Close the file.
-    file.close()
-
-    # Add the file to the results file list.
-    add_result_file(type='grace', label='Grace', file=file_path)

Modified: trunk/pipe_control/plotting.py
URL: 
http://svn.gna.org/viewcvs/relax/trunk/pipe_control/plotting.py?rev=27597&r1=27596&r2=27597&view=diff
==============================================================================
--- trunk/pipe_control/plotting.py      (original)
+++ trunk/pipe_control/plotting.py      Fri Feb  6 14:58:01 2015
@@ -1,6 +1,6 @@
 
###############################################################################
 #                                                                            
 #
-# Copyright (C) 2013-2014 Edward d'Auvergne                                  
 #
+# Copyright (C) 2013-2015 Edward d'Auvergne                                  
 #
 #                                                                            
 #
 # This file is part of the program relax (http://www.nmr-relax.com).         
 #
 #                                                                            
 #
@@ -29,6 +29,7 @@
 # relax module imports.
 from lib.errors import RelaxError
 from pipe_control.mol_res_spin import spin_loop
+from pipe_control.result_files import add_result_file
 from specific_analyses.api import return_api
 
 
@@ -635,3 +636,86 @@
     # Analysis specific value returning functions.
     api = return_api()
     return api.data_type(data_name)
+
+
+def write_xy(format='grace', x_data_type='res_num', y_data_type=None, 
spin_id=None, plot_data='value', norm_type='first', file=None, dir=None, 
force=False, norm=True):
+    """Writing data to a file.
+
+    @keyword format:        The specific backend to use.  The currently 
support backends are 'grace'.
+    @type format:           str
+    @keyword x_data_type:   The category of the X-axis data.
+    @type x_data_type:      str
+    @keyword y_data_type:   The category of the Y-axis data.
+    @type y_data_type:      str
+    @keyword spin_id:       The spin identification string.
+    @type spin_id:          str
+    @keyword plot_data:     The type of the plotted data, one of 'value', 
'error', or 'sim'.
+    @type plot_data:        str
+    @keyword norm_type:     The point to normalise to 1.  This can be 
'first' or 'last'.
+    @type norm_type:        str
+    @keyword file:          The name of the Grace file to create.
+    @type file:             str
+    @keyword dir:           The optional directory to place the file into.
+    @type dir:              str
+    @param force:           Boolean argument which if True causes the file 
to be overwritten if it already exists.
+    @type force:            bool
+    @keyword norm:          The normalisation flag which if set to True will 
cause all graphs to be normalised to a starting value of 1.
+    @type norm:             bool
+    """
+
+    # Test if the current pipe exists.
+    check_pipe()
+
+    # Test if the sequence data is loaded.
+    if not exists_mol_res_spin_data():
+        raise RelaxNoSequenceError
+
+    # Test if the plot_data argument is one of 'value', 'error', or 'sim'.
+    if plot_data not in ['value', 'error', 'sim']:
+        raise RelaxError("The plot data argument " + repr(plot_data) + " 
must be set to either 'value', 'error', 'sim'.")
+
+    # Test if the simulations exist.
+    if plot_data == 'sim' and not hasattr(cdp, 'sim_number'):
+        raise RelaxNoSimError
+
+    # Open the file for writing.
+    file_path = get_file_path(file, dir)
+    file = open_write_file(file, dir, force)
+
+    # Get the data.
+    data, set_names, graph_type = assemble_data(spin_id, 
x_data_name=x_data_type, y_data_name=y_data_type, plot_data=plot_data)
+
+    # Convert the graph type.
+    if graph_type == 'X,Y':
+        graph_type = 'xy'
+    elif graph_type == 'X,Y,dX':
+        graph_type = 'xydx'
+    elif graph_type == 'X,Y,dY':
+        graph_type = 'xydy'
+    elif graph_type == 'X,Y,dX,dY':
+        graph_type = 'xydxdy'
+
+    # No data, so close the empty file and exit.
+    if not len(data) or not len(data[0]) or not len(data[0][0]):
+        warn(RelaxWarning("No data could be found, creating an empty file."))
+        file.close()
+        return
+
+    # Get the axis information.
+    data_type = [x_data_type, y_data_type]
+    seq_type, axis_labels = axis_setup(data_type=data_type, norm=norm)
+
+    # Write the header.
+    write_xy_header(format=format, file=file, data_type=data_type, 
seq_type=seq_type, sets=[len(data[0])], set_names=[set_names], 
axis_labels=[axis_labels], norm=[norm])
+
+    # Write the data.
+    write_xy_data(format=format, data=data, file=file, 
graph_type=graph_type, norm_type=norm_type, norm=[norm])
+
+    # Close the file.
+    file.close()
+
+    # Add the file to the results file list.
+    label = None
+    if format == 'grace':
+        label = 'Grace'
+    add_result_file(type=format, label='Grace', file=file_path)

Modified: trunk/user_functions/grace.py
URL: 
http://svn.gna.org/viewcvs/relax/trunk/user_functions/grace.py?rev=27597&r1=27596&r2=27597&view=diff
==============================================================================
--- trunk/user_functions/grace.py       (original)
+++ trunk/user_functions/grace.py       Fri Feb  6 14:58:01 2015
@@ -1,6 +1,6 @@
 
###############################################################################
 #                                                                            
 #
-# Copyright (C) 2004-2014 Edward d'Auvergne                                  
 #
+# Copyright (C) 2004-2015 Edward d'Auvergne                                  
 #
 #                                                                            
 #
 # This file is part of the program relax (http://www.nmr-relax.com).         
 #
 #                                                                            
 #
@@ -33,6 +33,7 @@
 # relax module imports.
 from graphics import WIZARD_IMAGE_PATH
 from pipe_control import grace
+from pipe_control.plotting import write_xy
 from specific_analyses.consistency_tests.parameter_object import 
Consistency_tests_params; consistency_test_params = Consistency_tests_params()
 from specific_analyses.jw_mapping.parameter_object import Jw_mapping_params; 
jw_mapping_params = Jw_mapping_params()
 from specific_analyses.model_free.parameter_object import Model_free_params; 
model_free_params = Model_free_params()
@@ -229,7 +230,7 @@
 uf.desc[-1].add_prompt("relax> grace.write(x_data_type='rex', 
y_data_type='te', spin_id=':123', plot_data='sims', file='s2_te.agr')")
 uf.desc[-1].add_paragraph("By plotting the peak intensities, the integrity 
of exponential relaxation curves can be checked and anomalies searched for 
prior to model-free analysis or reduced spectral density mapping.  For 
example the normalised average peak intensities can be plotted verses the 
relaxation time periods for the relaxation curves of all residues of a 
protein.  The normalisation, whereby the initial peak intensity of each 
residue I(0) is set to 1, emphasises any problems.  To produce this Grace 
file, type:")
 uf.desc[-1].add_prompt("relax> grace.write(x_data_type='relax_times', 
y_data_type='ave_int', file='intensities_norm.agr', force=True, norm=True)")
-uf.backend = grace.write
+uf.backend = write_xy
 uf.menu_text = "&write"
 uf.gui_icon = "oxygen.actions.document-save"
 uf.wizard_size = (1000, 700)




Related Messages


Powered by MHonArc, Updated Fri Feb 06 15:20:03 2015