Package generic_fns :: Module grace
[hide private]
[frames] | no frames]

Module grace

source code

Module for interfacing with Grace (also known as Xmgrace, Xmgr, and ace).

Functions [hide private]
str
determine_seq_type(spin_id=None)
Determine the spin sequence data type.
source code
list of lists of lists of float, str, and list of str
get_data(spin_id=None, x_data_type=None, y_data_type=None, plot_data=None)
Return all the xy data, along with the graph type and names for the graph sets.
source code
 
view(file=None, dir=None, grace_exe='xmgrace')
Execute Grace.
source code
 
write(x_data_type='spin', y_data_type=None, spin_id=None, plot_data='value', file=None, dir=None, force=False, norm=True)
Writing data to a file.
source code
 
write_xy_data(data, file=None, graph_type=None, norm=False)
Write the data into the Grace xy-scatter plot.
source code
 
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)
Write the grace header for xy-scatter plots.
source code
Variables [hide private]
  status = Status()
  __package__ = 'generic_fns'

Imports: array, ndarray, system, warn, generic_fns, count_molecules, count_residues, count_spins, exists_mol_res_spin_data, generate_spin_id, spin_loop, pipes, RelaxError, RelaxNoSequenceError, RelaxNoSimError, get_file_path, open_write_file, test_binary, RelaxWarning, specific_fns, Status


Function Details [hide private]

determine_seq_type(spin_id=None)

source code 

Determine the spin sequence data type.

The purpose is to identify systems whereby only spins or only residues exist.

Parameters:
  • spin_id (str) - The spin identification string.
Returns: str
The spin sequence data type. This can be one of 'spin', 'res,' or 'mixed'.

get_data(spin_id=None, x_data_type=None, y_data_type=None, plot_data=None)

source code 

Return all the xy data, along with the graph type and names for the graph sets.

Parameters:
  • spin_id (str) - The spin identification string.
  • x_data_type (str) - The category of the X-axis data.
  • y_data_type (str) - The category of the Y-axis data.
  • plot_data (str) - The type of the plotted data, one of 'value', 'error', or 'sim'.
Returns: list of lists of lists of float, str, and list of str
The 4D graph numerical data structure, the graph type (i.e. on of 'xy', 'xydy', or 'xydxdy'), and the labels for the graph sets.

view(file=None, dir=None, grace_exe='xmgrace')

source code 

Execute Grace.

Parameters:
  • file (str) - The name of the file to open in Grace.
  • dir (str) - The optional directory containing the file.
  • grace_exe (str) - The name of the Grace executable file. This should be located within the system path.

write(x_data_type='spin', y_data_type=None, spin_id=None, plot_data='value', file=None, dir=None, force=False, norm=True)

source code 

Writing data to a file.

Parameters:
  • x_data_type (str) - The category of the X-axis data.
  • y_data_type (str) - The category of the Y-axis data.
  • spin_id (str) - The spin identification string.
  • plot_data (str) - The type of the plotted data, one of 'value', 'error', or 'sim'.
  • file (str) - The name of the Grace file to create.
  • dir (str) - The optional directory to place the file into.
  • force (bool) - Boolean argument which if True causes the file to be overwritten if it already exists.
  • norm (bool) - The normalisation flag which if set to True will cause all graphs to be normalised to a starting value of 1.

write_xy_data(data, file=None, graph_type=None, norm=False)

source code 

Write the data into the Grace xy-scatter plot.

The numerical data should be supplied as a 4 dimensional list or array object. The first dimension corresponds to the graphs, Gx. The second corresponds the sets of each graph, Sx. The third corresponds to the data series (i.e. each data point). The forth is a list of the information about each point, it is a list where the first element is the x value, the second is the y value, the third is the optional dx or dy error (either dx or dy dependent upon the graph_type arg), and the forth is the optional dy error when graph_type is xydxdy (the third position is then dx).

Parameters:
  • data (list of lists of lists of float) - The 4D structure of numerical data to graph (see docstring).
  • file (file object) - The file object to write the data to.
  • graph_type (str) - The graph type which can be one of xy, xydy, xydx, or xydxdy.
  • norm (bool) - The normalisation flag which if set to True will cause all graphs to be normalised to 1.

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)

source code 

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).

Parameters:
  • file (file object) - The file object to write the data to.
  • paper_size (str) - The paper size, i.e. 'A4'. If set to None, this will default to letter size.
  • title (None or str) - The title of the graph.
  • subtitle (None or str) - The sub-title of the graph.
  • view (None or list of float) - List of 4 coordinates defining the graph view port.
  • sets (int) - The number of data sets in the graph G0.
  • set_names (None or list of str) - The names associated with each graph data set G0.Sx. For example this can be a list of spin identification strings.
  • set_colours (None or list of int) - The colours for each graph data set G0.Sx.
  • symbols (None or list of int) - The symbol style for each graph data set G0.Sx.
  • symbol_sizes (None or list of int) - The symbol size for each graph data set G0.Sx.
  • symbol_fill (None or list of int) - The symbol file style for each graph data set G0.Sx.
  • linestyle (None or list of int) - The line style for each graph data set G0.Sx.
  • linetype (None or list of int) - The line type for each graph data set G0.Sx.
  • linewidth (None or float) - The line width for all elements of each graph data set G0.Sx.
  • data_type (None or list of str) - The axis data category (in the [X, Y] list format).
  • seq_type (None or list of str) - The sequence data type (in the [X, Y] list format). This is for molecular sequence specific data and can be one of 'res', 'spin', or 'mixed'.
  • axis_labels (None or list of str) - The labels for the axes (in the [X, Y] list format).
  • axis_min (None or list of str) - The minimum values for specifying the graph ranges (in the [X, Y] list format).
  • axis_max (None or list of str) - The maximum values for specifying the graph ranges (in the [X, Y] list format).
  • legend_pos (None or list of float) - The position of the legend, e.g. [0.3, 0.8].
  • legend (bool) - If True, the legend will be visible.
  • norm (bool) - The normalisation flag which if set to True will cause all graphs to be normalised to 1.