mailr20037 - in /trunk: auto_analyses/ 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 June 11, 2013 - 16:36:
Author: bugman
Date: Tue Jun 11 16:36:31 2013
New Revision: 20037

URL: http://svn.gna.org/viewcvs/relax?rev=20037&view=rev
Log:
Fix for bug #20888 (https://gna.org/bugs/?20888), the autoscaling of Grace 
graphs.

This solution was mentioned in the post at
http://thread.gmane.org/gmane.science.nmr.relax.devel/3920/focus=3930.

Instead of using minimum and maximum values for the axes in the Grace graphs 
produced by the
lib.software.grace module, which was the old solution for having the graphs 
scaled to reasonable
values, instead the '@autoscale' command is appended to the end of all 
graphs.  This is performed by
the write_xy_data() function.


Modified:
    trunk/auto_analyses/stereochem_analysis.py
    trunk/lib/software/grace.py
    trunk/pipe_control/grace.py
    trunk/pipe_control/pcs.py
    trunk/pipe_control/rdc.py

Modified: trunk/auto_analyses/stereochem_analysis.py
URL: 
http://svn.gna.org/viewcvs/relax/trunk/auto_analyses/stereochem_analysis.py?rev=20037&r1=20036&r2=20037&view=diff
==============================================================================
--- trunk/auto_analyses/stereochem_analysis.py (original)
+++ trunk/auto_analyses/stereochem_analysis.py Tue Jun 11 16:36:31 2013
@@ -418,8 +418,8 @@
                 dist.append(self.generate_distribution(noe_viols, 
inc=self.bucket_num, upper=self.upper_lim_noe, lower=self.lower_lim_noe))
 
             # Headers.
-            write_xy_header(file=grace_curve, title='NOE violation 
comparison', subtitle=subtitle, sets=n, set_names=self.configs, 
set_colours=colours, symbols=[0]*n, axis_labels=['Ensemble (sorted)', 'NOE 
violation (Angstrom\\S2\\N)'], axis_min=[0, 0], axis_max=[self.num_ens, 200], 
legend_pos=[0.3, 0.8])
-            write_xy_header(file=grace_dist, title='NOE violation 
comparison', subtitle=subtitle, sets=n, set_names=self.configs, 
set_colours=colours, symbols=[1]*n, symbol_sizes=[0.5]*n, linestyle=[3]*n, 
axis_labels=['NOE violation (Angstrom\\S2\\N)', 'Frequency'], axis_min=[0, 
0], axis_max=[200, 0.2], legend_pos=[1.1, 0.8])
+            write_xy_header(file=grace_curve, title='NOE violation 
comparison', subtitle=subtitle, sets=n, set_names=self.configs, 
set_colours=colours, symbols=[0]*n, axis_labels=['Ensemble (sorted)', 'NOE 
violation (Angstrom\\S2\\N)'], legend_pos=[0.3, 0.8])
+            write_xy_header(file=grace_dist, title='NOE violation 
comparison', subtitle=subtitle, sets=n, set_names=self.configs, 
set_colours=colours, symbols=[1]*n, symbol_sizes=[0.5]*n, linestyle=[3]*n, 
axis_labels=['NOE violation (Angstrom\\S2\\N)', 'Frequency'], 
legend_pos=[1.1, 0.8])
 
             # Write the data.
             write_xy_data([data], file=grace_curve, graph_type='xy')
@@ -464,8 +464,8 @@
                 dist.append(self.generate_distribution(values, 
inc=self.bucket_num, upper=self.upper_lim_rdc, lower=self.lower_lim_rdc))
 
             # Headers.
-            write_xy_header(file=grace_curve, title='%s RDC Q-factor 
comparison' % self.rdc_name, subtitle=subtitle, sets=n, 
set_names=self.configs, set_colours=colours, symbols=[0]*n, 
axis_labels=['Ensemble (sorted)', '%s RDC Q-factor (pales format)' % 
self.rdc_name], axis_min=[0, 0], axis_max=[self.num_ens, 2], legend_pos=[0.3, 
0.8])
-            write_xy_header(file=grace_dist, title='%s RDC Q-factor 
comparison' % self.rdc_name, subtitle=subtitle, sets=n, 
set_names=self.configs, set_colours=colours, symbols=[1]*n, 
symbol_sizes=[0.5]*n, linestyle=[3]*n, axis_labels=['%s RDC Q-factor (pales 
format)' % self.rdc_name, 'Frequency'], axis_min=[0, 0], axis_max=[2, 0.2], 
legend_pos=[1.1, 0.8])
+            write_xy_header(file=grace_curve, title='%s RDC Q-factor 
comparison' % self.rdc_name, subtitle=subtitle, sets=n, 
set_names=self.configs, set_colours=colours, symbols=[0]*n, 
axis_labels=['Ensemble (sorted)', '%s RDC Q-factor (pales format)' % 
self.rdc_name], legend_pos=[0.3, 0.8])
+            write_xy_header(file=grace_dist, title='%s RDC Q-factor 
comparison' % self.rdc_name, subtitle=subtitle, sets=n, 
set_names=self.configs, set_colours=colours, symbols=[1]*n, 
symbol_sizes=[0.5]*n, linestyle=[3]*n, axis_labels=['%s RDC Q-factor (pales 
format)' % self.rdc_name, 'Frequency'], legend_pos=[1.1, 0.8])
 
             # Write the data.
             write_xy_data([data], file=grace_curve, graph_type='xy')
@@ -513,8 +513,8 @@
                     data_scaled[i].append([sqrt(noe_viol/self.noe_norm), 
q_factor])
 
             # Write the data.
-            write_xy_header(file=grace_file, title='Correlation plot - %s 
RDC vs. NOE' % self.rdc_name, subtitle=subtitle, sets=n, 
set_names=self.configs, set_colours=colours, symbols=[9]*n, 
symbol_sizes=[0.24]*n, linetype=[0]*n, axis_labels=['NOE violation 
(Angstrom\\S2\\N)', '%s RDC Q-factor (pales format)' % self.rdc_name], 
axis_min=[0, 0], axis_max=[noe_viols[-1]+10, values[-1]+0.1], 
legend_pos=[1.1, 0.8])
-            write_xy_header(file=grace_file_scaled, title='Correlation plot 
- %s RDC vs. NOE Q-factor' % self.rdc_name, subtitle=subtitle, sets=n, 
set_names=self.configs, set_colours=colours, symbols=[9]*n, 
symbol_sizes=[0.24]*n, linetype=[0]*n, axis_labels=['Normalised NOE violation 
(Q = sqrt(U / \\xS\\f{}NOE\\si\\N\\S2\\N))', '%s RDC Q-factor (pales format)' 
% self.rdc_name], axis_min=[0, 0], axis_max=[1, 1], legend_pos=[1.1, 0.8])
+            write_xy_header(file=grace_file, title='Correlation plot - %s 
RDC vs. NOE' % self.rdc_name, subtitle=subtitle, sets=n, 
set_names=self.configs, set_colours=colours, symbols=[9]*n, 
symbol_sizes=[0.24]*n, linetype=[0]*n, axis_labels=['NOE violation 
(Angstrom\\S2\\N)', '%s RDC Q-factor (pales format)' % self.rdc_name], 
legend_pos=[1.1, 0.8])
+            write_xy_header(file=grace_file_scaled, title='Correlation plot 
- %s RDC vs. NOE Q-factor' % self.rdc_name, subtitle=subtitle, sets=n, 
set_names=self.configs, set_colours=colours, symbols=[9]*n, 
symbol_sizes=[0.24]*n, linetype=[0]*n, axis_labels=['Normalised NOE violation 
(Q = sqrt(U / \\xS\\f{}NOE\\si\\N\\S2\\N))', '%s RDC Q-factor (pales format)' 
% self.rdc_name], legend_pos=[1.1, 0.8])
             write_xy_data([data], file=grace_file, graph_type='xy')
             write_xy_data([data_scaled], file=grace_file_scaled, 
graph_type='xy')
 

Modified: trunk/lib/software/grace.py
URL: 
http://svn.gna.org/viewcvs/relax/trunk/lib/software/grace.py?rev=20037&r1=20036&r2=20037&view=diff
==============================================================================
--- trunk/lib/software/grace.py (original)
+++ trunk/lib/software/grace.py Tue Jun 11 16:36:31 2013
@@ -116,8 +116,11 @@
             # End of the data set i.
             file.write("&\n")
 
-
-def write_xy_header(file=None, paper_size='A4', title=None, subtitle=None, 
view=None, sets=1, set_names=None, set_colours=None, symbols=None, 
symbol_sizes=None, symbol_fill=None, linestyle=None, linetype=None, 
linewidth=0.5, data_type=None, seq_type=None, axis_labels=None, 
axis_min=None, axis_max=None, legend_pos=None, legend=False, norm=False):
+    # Autoscaling of all graphs to avoid user confusion.
+    file.write("@autoscale\n")
+
+
+def write_xy_header(file=None, paper_size='A4', title=None, subtitle=None, 
view=None, sets=1, set_names=None, set_colours=None, symbols=None, 
symbol_sizes=None, symbol_fill=None, linestyle=None, linetype=None, 
linewidth=0.5, data_type=None, seq_type=None, axis_labels=None, 
legend_pos=None, legend=False, norm=False):
     """Write the grace header for xy-scatter plots.
 
     Many of these keyword arguments should be supplied in a [X, Y] list 
format, where the first element corresponds to the X data, and the second the 
Y data.  Defaults will be used for any non-supplied args (or lists with 
elements set to None).
@@ -157,10 +160,6 @@
     @type seq_type:                 None or list of str
     @keyword axis_labels:           The labels for the axes (in the [X, Y] 
list format).
     @type axis_labels:              None or list of str
-    @keyword axis_min:              The minimum values for specifying the 
graph ranges (in the [X, Y] list format).
-    @type axis_min:                 None or list of str
-    @keyword axis_max:              The maximum values for specifying the 
graph ranges (in the [X, Y] list format).
-    @type axis_max:                 None or list of str
     @keyword legend_pos:            The position of the legend, e.g. [0.3, 
0.8].
     @type legend_pos:               None or list of float
     @keyword legend:                If True, the legend will be visible.
@@ -176,10 +175,6 @@
         seq_type = [None, None]
     if not axis_labels:
         axis_labels = [None, None]
-    if not axis_min:
-        axis_min = [None, None]
-    if not axis_max:
-        axis_max = [None, None]
 
     # Set the Grace version number of the header's formatting for 
compatibility.
     file.write("@version 50121\n")
@@ -224,24 +219,12 @@
         if data_type[i] == 'spin':
             # Residue only data.
             if seq_type[i] == 'res':
-                # Axis limits.
-                if not axis_min[i]:
-                    axis_min[i] = repr(cdp.mol[0].res[0].num - 1)
-                if not axis_max[i]:
-                    axis_max[i] = repr(cdp.mol[0].res[-1].num + 1)
-
                 # X-axis label.
                 if not axis_labels[i]:
                     axis_labels[i] = "Residue number"
 
             # Spin only data.
             if seq_type[i] == 'spin':
-                # Axis limits.
-                if not axis_min[i]:
-                    axis_min[i] = repr(cdp.mol[0].res[0].spin[0].num - 1)
-                if not axis_max[i]:
-                    axis_max[i] = repr(cdp.mol[0].res[0].spin[-1].num + 1)
-
                 # X-axis label.
                 if not axis_labels[i]:
                     axis_labels[i] = "Spin number"
@@ -271,10 +254,6 @@
                     axis_labels[i] = axis_labels[i] + " 
\\N\\q(normalised)\\Q"
 
         # Write out the data.
-        if axis_min[i] != None:
-            file.write("@    world %smin %s\n" % (axes[i], axis_min[i]))
-        if axis_max[i] != None:
-            file.write("@    world %smax %s\n" % (axes[i], axis_max[i]))
         if axis_labels[i]:
             file.write("@    %saxis  label \"%s\"\n" % (axes[i], 
axis_labels[i]))
         file.write("@    %saxis  label char size 1.48\n" % axes[i])

Modified: trunk/pipe_control/grace.py
URL: 
http://svn.gna.org/viewcvs/relax/trunk/pipe_control/grace.py?rev=20037&r1=20036&r2=20037&view=diff
==============================================================================
--- trunk/pipe_control/grace.py (original)
+++ trunk/pipe_control/grace.py Tue Jun 11 16:36:31 2013
@@ -54,8 +54,6 @@
 
     # Axis specific settings.
     axes = ['x', 'y']
-    axis_min = [None, None]
-    axis_max = [None, None]
     seq_type = [None, None]
     axis_labels = [None, None]
     for i in range(2):
@@ -82,24 +80,12 @@
         if data_type[i] == 'res_num':
             # Residue only data.
             if seq_type[i] == 'res':
-                # Axis limits.
-                if not axis_min[i]:
-                    axis_min[i] = repr(cdp.mol[0].res[0].num - 1)
-                if not axis_max[i]:
-                    axis_max[i] = repr(cdp.mol[0].res[-1].num + 1)
-
                 # X-axis label.
                 if not axis_labels[i]:
                     axis_labels[i] = "Residue number"
 
             # Spin only data.
             if seq_type[i] == 'spin':
-                # Axis limits.
-                if not axis_min[i]:
-                    axis_min[i] = repr(cdp.mol[0].res[0].spin[0].num - 1)
-                if not axis_max[i]:
-                    axis_max[i] = repr(cdp.mol[0].res[0].spin[-1].num + 1)
-
                 # X-axis label.
                 if not axis_labels[i]:
                     axis_labels[i] = "Spin number"
@@ -129,7 +115,7 @@
                     axis_labels[i] = axis_labels[i] + " 
\\N\\q(normalised)\\Q"
 
     # Return the data.
-    return seq_type, axis_min, axis_max, axis_labels
+    return seq_type, axis_labels
 
 
 def determine_seq_type(spin_id=None):
@@ -287,10 +273,10 @@
 
     # Get the axis information.
     data_type = [x_data_type, y_data_type]
-    seq_type, axis_min, axis_max, axis_labels = 
axis_setup(data_type=data_type, norm=norm)
+    seq_type, axis_labels = axis_setup(data_type=data_type, norm=norm)
 
     # Write the header.
-    write_xy_header(sets=len(data[0]), file=file, data_type=data_type, 
seq_type=seq_type, set_names=set_names, axis_labels=axis_labels, 
axis_min=axis_min, axis_max=axis_max, norm=norm)
+    write_xy_header(sets=len(data[0]), file=file, data_type=data_type, 
seq_type=seq_type, set_names=set_names, axis_labels=axis_labels, norm=norm)
 
     # Write the data.
     write_xy_data(data, file=file, graph_type=graph_type, norm=norm)

Modified: trunk/pipe_control/pcs.py
URL: 
http://svn.gna.org/viewcvs/relax/trunk/pipe_control/pcs.py?rev=20037&r1=20036&r2=20037&view=diff
==============================================================================
--- trunk/pipe_control/pcs.py (original)
+++ trunk/pipe_control/pcs.py Tue Jun 11 16:36:31 2013
@@ -442,7 +442,7 @@
                 set_names.append("%s (%s)" % (cdp.pcs_ids[i], types[j]))
 
         # The header.
-        grace.write_xy_header(file=file, title="PCS correlation plot", 
sets=size, set_names=set_names, linestyle=[2]+[0]*size, data_type=['pcs_bc', 
'pcs'], axis_min=[-0.5, -0.5], axis_max=[0.5, 0.5], legend_pos=[1, 0.5])
+        grace.write_xy_header(file=file, title="PCS correlation plot", 
sets=size, set_names=set_names, linestyle=[2]+[0]*size, data_type=['pcs_bc', 
'pcs'], legend_pos=[1, 0.5])
 
         # The main data.
         grace.write_xy_data(data=data, file=file, graph_type=graph_type)

Modified: trunk/pipe_control/rdc.py
URL: 
http://svn.gna.org/viewcvs/relax/trunk/pipe_control/rdc.py?rev=20037&r1=20036&r2=20037&view=diff
==============================================================================
--- trunk/pipe_control/rdc.py (original)
+++ trunk/pipe_control/rdc.py Tue Jun 11 16:36:31 2013
@@ -365,7 +365,7 @@
     # Grace file.
     if format == 'grace':
         # The header.
-        grace.write_xy_header(file=file, title="RDC correlation plot", 
sets=size, set_names=[None]+cdp.rdc_ids, linestyle=[2]+[0]*size, 
data_type=['rdc_bc', 'rdc'], axis_min=[-10, -10], axis_max=[10, 10], 
legend_pos=[1, 0.5])
+        grace.write_xy_header(file=file, title="RDC correlation plot", 
sets=size, set_names=[None]+cdp.rdc_ids, linestyle=[2]+[0]*size, 
data_type=['rdc_bc', 'rdc'], legend_pos=[1, 0.5])
 
         # The main data.
         grace.write_xy_data(data=data, file=file, graph_type=graph_type)




Related Messages


Powered by MHonArc, Updated Tue Jun 11 16:40:02 2013