Warning

This document is for an old release of Galaxy. You can alternatively view this page in the latest release if it exists or view the top of the latest release's documentation.

galaxy.visualization.plugins package

Submodules

galaxy.visualization.plugins.config_parser module

exception galaxy.visualization.plugins.config_parser.ParsingException[source]

Bases: exceptions.ValueError

An exception class for errors that occur during parsing of the visualizations framework configuration XML file.

class galaxy.visualization.plugins.config_parser.VisualizationsConfigParser[source]

Bases: object

Class that parses a visualizations configuration XML file.

Each visualization will get the following info:
  • how to load a visualization:

    – how to find the proper template – how to convert query string into DB models

  • when/how to generate a link to the visualization

    – what provides the data – what information needs to be added to the query string

ALLOWED_ENTRY_POINT_TYPES = ['mako', 'html', 'script']

what are the allowed ‘entry_point_type’ for entry_point elements

VALID_RENDER_TARGETS = ['galaxy_main', '_top', '_blank']

what are the allowed href targets when clicking on a visualization anchor

__init__()[source]
parse_file(xml_filepath)[source]

Parse the given XML file for visualizations data. :returns: visualization config dictionary

parse_visualization(xml_tree)[source]

Parse the template, name, and any data_sources and params from the given xml_tree for a visualization.

parse_entry_point(xml_tree)[source]

Parse the config file for an appropriate entry point: a mako template, a script tag, or an html file, returning as dictionary with: type, file, and `attr`ibutes of the element.

class galaxy.visualization.plugins.config_parser.DataSourceParser[source]

Bases: object

Component class of VisualizationsConfigParser that parses data_source elements within visualization elements.

data_sources are (in the extreme) any object that can be used to produce data for the visualization to consume (e.g. HDAs, LDDAs, Jobs, Users, etc.). There can be more than one data_source associated with a visualization.

ALLOWED_MODEL_CLASSES = ['Visualization', 'HistoryDatasetAssociation', 'LibraryDatasetDatasetAssociation']
ATTRIBUTE_SPLIT_CHAR = '.'
ALLOWED_DATA_SOURCE_ATTRIBUTES = ['datatype']
parse(xml_tree)[source]

Return a visualization data_source dictionary parsed from the given XML element.

parse_model_class(xml_tree)[source]

Convert xml model_class element to a galaxy model class (or None if model class is not found).

This element is required and only the first element is used. The model_class string must be in ALLOWED_MODEL_CLASSES.

parse_tests(xml_tree_list)[source]

Returns a list of test dictionaries that the registry can use against a given object to determine if the visualization can be used with the object.

parse_to_params(xml_tree_list)[source]

Given a list of to_param elements, returns a dictionary that allows the registry to convert the data_source into one or more appropriate params for the visualization.

class galaxy.visualization.plugins.config_parser.ParamParser[source]

Bases: object

Component class of VisualizationsConfigParser that parses param elements within visualization elements.

params are parameters that will be parsed (based on their type, etc.) and sent to the visualization template by controllers.visualization.render.

DEFAULT_PARAM_TYPE = 'str'
parse(xml_tree)[source]

Parse a visualization parameter from the given xml_tree.

parse_param_type(xml_tree)[source]

Parse a param type from the given xml_tree.

class galaxy.visualization.plugins.config_parser.ParamModifierParser[source]

Bases: galaxy.visualization.plugins.config_parser.ParamParser

Component class of VisualizationsConfigParser that parses param_modifier elements within visualization elements.

param_modifiers are params from a dictionary (such as a query string) that are not standalone but modify the parsing/conversion of a separate (normal) param (e.g. ‘hda_ldda’ can equal ‘hda’ or ‘ldda’ and control whether a visualizations ‘dataset_id’ param is for an HDA or LDDA).

parse(element)[source]

galaxy.visualization.plugins.plugin module

Visualization plugins: instantiate/deserialize data and models from a query string and render a webpage based on those data.

class galaxy.visualization.plugins.plugin.ServesStaticPluginMixin[source]

Bases: object

An object that serves static files from the server.

class galaxy.visualization.plugins.plugin.ServesTemplatesPluginMixin[source]

Bases: object

An object that renders (mako) template files from the server.

DEFAULT_TEMPLATE_COLLECTION_SIZE = 10

default number of templates to search for plugin template lookup

DEFAULT_TEMPLATE_ENCODING = 'utf-8'

default encoding of plugin templates

class galaxy.visualization.plugins.plugin.VisualizationPlugin(app, path, name, config, context=None, **kwargs)[source]

Bases: galaxy.web.base.pluginframework.Plugin, galaxy.visualization.plugins.plugin.ServesStaticPluginMixin, galaxy.visualization.plugins.plugin.ServesTemplatesPluginMixin

A plugin that instantiates resources, serves static files, and uses mako templates to render web pages.

__init__(app, path, name, config, context=None, **kwargs)[source]
render(trans=None, embedded=None, **kwargs)[source]

Render and return the text of the non-saved plugin webpage/fragment.

render_saved(visualization, trans=None, embedded=None, **kwargs)[source]

Render and return the text of the plugin webpage/fragment using the config/data of a saved visualization.

class galaxy.visualization.plugins.plugin.InteractiveEnvironmentPlugin(app, path, name, config, context=None, **kwargs)[source]

Bases: galaxy.visualization.plugins.plugin.VisualizationPlugin

Serves web-based REPLs such as Jupyter and RStudio.

INTENV_REQUEST_FACTORY

alias of galaxy.web.base.interactive_environments.InteractiveEnvironmentRequest

__init__(app, path, name, config, context=None, **kwargs)[source]
class galaxy.visualization.plugins.plugin.ScriptVisualizationPlugin(app, path, name, config, context=None, **kwargs)[source]

Bases: galaxy.visualization.plugins.plugin.VisualizationPlugin

A visualization plugin that starts by loading a single (js) script.

The script is loaded into a pre-defined mako template:
config/plugins/visualizations/common/templates/script_entry_point.mako
MAKO_TEMPLATE = 'script_entry_point.mako'
class galaxy.visualization.plugins.plugin.StaticFileVisualizationPlugin(app, path, name, config, context=None, **kwargs)[source]

Bases: galaxy.visualization.plugins.plugin.VisualizationPlugin

A visualiztion plugin that starts by loading a static html file defined in the visualization’s config file.

galaxy.visualization.plugins.registry module

Lower level of visualization framework which does three main things:
  • associate visualizations with objects
  • create urls to visualizations based on some target object(s)
  • unpack a query string into the desired objects needed for rendering
class galaxy.visualization.plugins.registry.VisualizationsRegistry(app, skip_bad_plugins=True, **kwargs)[source]

Bases: galaxy.web.base.pluginframework.PageServingPluginManager

Main responsibilities are:
  • discovering visualization plugins in the filesystem

  • testing if an object has a visualization that can be applied to it

  • generating a link to controllers.visualization.render with

    the appropriate params

  • validating and parsing params into resources (based on a context)

    used in the visualization template

NAMED_ROUTE = 'visualization_plugin'
DEFAULT_BASE_URL = 'visualizations'
BUILT_IN_VISUALIZATIONS = ['trackster', 'circster', 'sweepster', 'phyloviz']

any built in visualizations that have their own render method in ctrls/visualization

__init__(app, skip_bad_plugins=True, **kwargs)[source]
is_plugin(plugin_path)[source]

Determines whether the given filesystem path contains a plugin.

In this base class, all sub-directories are considered plugins.

Parameters:plugin_path (string) – relative or absolute filesystem path to the potential plugin
Return type:bool
Returns:True if the path contains a plugin
load_plugin(plugin_path)[source]

Create the visualization plugin object, parse its configuration file, and return it.

Parameters:plugin_path (string) – relative or absolute filesystem path to the plugin
Return type:VisualizationPlugin
Returns:the loaded plugin
get_plugin(key)[source]

Wrap to throw error if plugin not in registry.

get_visualizations(trans, target_object)[source]

Get the names of visualizations usable on the target_object and the urls to call in order to render the visualizations.

get_visualization(trans, visualization_name, target_object)[source]

Return data to build a url to the visualization with the given visualization_name if it’s applicable to target_object or None if it’s not.

is_object_applicable(trans, target_object, data_source_tests)[source]

Run a visualization’s data_source tests to find out if it can be applied to the target_object.

get_visualization_url(trans, target_object, visualization, param_data)[source]

Generates a url for the visualization with visualization for use with the given target_object with a query string built from the configuration data in param_data.

get_url_params(trans, target_object, param_data)[source]

Convert the applicable objects and assoc. data into a param dict for a url query string to add to the url that loads the visualization.

galaxy.visualization.plugins.resource_parser module

Deserialize Galaxy resources (hdas, ldas, datasets, genomes, etc.) from a dictionary of string data/ids (often from a query string).

class galaxy.visualization.plugins.resource_parser.ResourceParser(app, *args, **kwargs)[source]

Bases: object

Given a parameter dictionary (often a converted query string) and a configuration dictionary (curr. only VisualizationsRegistry uses this), convert the entries in the parameter dictionary into resources (Galaxy models, primitive types, lists of either, etc.) and return in a new dictionary.

The keys used to store the new values can optionally be re-mapped to new keys (e.g. dataset_id=”NNN” -> hda=<HistoryDatasetAssociation>).

primitive_parsers = {'bool': <function <lambda> at 0x7faf34647c80>, 'float': <type 'float'>, 'int': <type 'int'>, 'json': <function <lambda> at 0x7faf34647cf8>, 'str': <function <lambda> at 0x7faf34647c08>}
__init__(app, *args, **kwargs)[source]
parse_parameter_dictionary(trans, param_config_dict, query_params, param_modifiers=None)[source]

Parse all expected params from the query dictionary query_params.

If param is required and not present, raises a KeyError.

parse_config(trans, param_config_dict, query_params)[source]

Return query_params dict parsing only JSON serializable params. Complex params such as models, etc. are left as the original query value. Keys in query_params not found in the param_config_dict will not be returned.

parse_parameter_modifiers(trans, param_modifiers, query_params)[source]

Parse and return parameters that are meant to modify other parameters, be grouped with them, or are needed to successfully parse other parameters.

parse_parameter_default(trans, param_config)[source]

Parse any default values for the given param, defaulting the default to None.

parse_parameter(trans, expected_param_data, query_param, recurse=True, param_modifiers=None)[source]

Use data in expected_param_data to parse query_param from a string into a resource usable directly by a template.

galaxy.visualization.plugins.utils module

Utilities for visualization plugins.

class galaxy.visualization.plugins.utils.OpenObject[source]

Bases: dict

A dict that allows assignment and attribute retrieval using the dot operator.

If an attribute isn’t contained in the dict None is returned (no KeyError). JSON-serializable.

galaxy.visualization.plugins.utils.getattr_recursive(item, attr_key, *args)[source]

Allows dot member notation in attribute name when getting an item’s attribute.

NOTE: also searches dictionaries

galaxy.visualization.plugins.utils.hasattr_recursive(item, attr_key)[source]

Allows dot member notation in attribute name when getting an item’s attribute.

NOTE: also searches dictionaries