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: 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', 'chart']

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]

Initialize self. See help(type(self)) for accurate signature.

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.ListParser(aList)[source]

Bases: list

Converts a xml structure into an array See: http://code.activestate.com/recipes/410469-xml-as-dictionary/

__init__(aList)[source]

Initialize self. See help(type(self)) for accurate signature.

class galaxy.visualization.plugins.config_parser.DictParser(parent_element)[source]

Bases: dict

Converts a xml structure into a dictionary See: http://code.activestate.com/recipes/410469-xml-as-dictionary/

__init__(parent_element)[source]

Initialize self. See help(type(self)) for accurate signature.

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]

Parse a visualization parameter from the given xml_tree.

galaxy.visualization.plugins.interactive_environments module

class galaxy.visualization.plugins.interactive_environments.InteractiveEnvironmentRequest(trans, plugin)[source]

Bases: object

__init__(trans, plugin)[source]

Initialize self. See help(type(self)) for accurate signature.

load_allowed_images()[source]
load_deploy_config()[source]
load_container_interface()[source]
get_conf_dict()[source]

Build up a configuration dictionary that is standard for ALL IEs.

TODO: replace hashed password with plaintext.

generate_hex(length)[source]
generate_password(length)[source]

Generate a random alphanumeric password

javascript_boolean(python_boolean)[source]

Convenience function to convert boolean for use in JS

url_template(url_template)[source]

Process a URL template

There are several variables accessible to the user:

  • ${PROXY_URL} will be replaced with the dynamically create proxy’s url

  • ${PROXY_PREFIX} will be replaced with the prefix that may occur

volume(container_path, host_path, **kwds)[source]
base_docker_cmd(subcmd=None)[source]
docker_cmd(image, env_override=None, volumes=None)[source]

Generate and return the docker command to execute

property use_volumes
container_run_args(image, env_override=None, volumes=None)[source]
launch(image=None, additional_ids=None, env_override=None, volumes=None)[source]

Launch a docker image.

Parameters
  • image (str) – Optional image name. If not provided, self.default_image is used, which is the first image listed in the allowed_images.yml{,.sample} file.

  • additional_ids (str) – comma separated list of encoded HDA IDs. These are transformed into Volumes and added to that argument

  • env_override (dict) – dictionary of environment variables to add.

  • volumes (list of py:class:galaxy.containers.docker_model.DockerVolume s) – dictionary of docker volume mounts

inspect_container(container_id)[source]

Runs docker inspect on a container and returns json response as python dictionary inspect_data.

Parameters

container_id (str) – a docker container ID

Returns

inspect_data, a dict of docker inspect output

get_container_host(inspect_data)[source]

Determine the ip address on the container. If inspect_data contains Node.IP return that (e.g. running in Docker Swarm). If the hostname is “localhost”, look for NetworkSettings.Gateway. Otherwise, just return the configured docker_hostname.

Parameters

inspect_data (dict) – output of docker inspect

Returns

IP address or hostname of the node the conatainer is running on.

get_container_port_mapping(inspect_data)[source]
Parameters

inspect_data (dict) – output of docker inspect

Returns

a list of triples containing (internal_port, external_ip, external_port), of which the ports are probably the only useful information.

Someday code that calls this should be refactored whenever we get containers with multiple ports working.

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

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

Bases: 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]

Initialize self. See help(type(self)) for accurate signature.

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.

to_dict()[source]
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.visualization.plugins.interactive_environments.InteractiveEnvironmentRequest

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

Initialize self. See help(type(self)) for accurate signature.

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.ChartVisualizationPlugin(app, path, name, config, context=None, **kwargs)[source]

Bases: galaxy.visualization.plugins.plugin.ScriptVisualizationPlugin

MAKO_TEMPLATE = 'chart_entry_point.mako'
class galaxy.visualization.plugins.plugin.StaticFileVisualizationPlugin(app, path, name, config, context=None, **kwargs)[source]

Bases: galaxy.visualization.plugins.plugin.VisualizationPlugin

A visualization 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, template_cache_dir=None, directories_setting=None, skip_bad_plugins=True, **kwargs)[source]

Bases: object

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

BASE_URL = 'visualizations'

base url to controller endpoint

TEMPLATE_PATHS_CONFIG = 'additional_template_paths.xml'

name of files to search for additional template lookup directories

BUILT_IN_VISUALIZATIONS = ['trackster', 'circster', 'sweepster', 'phyloviz']

built-in visualizations

__init__(app, template_cache_dir=None, directories_setting=None, skip_bad_plugins=True, **kwargs)[source]

Set up the manager and load all visualization plugins.

Parameters
  • app (galaxy.app.UniverseApplication) – the application (and its configuration) using this manager

  • base_url (string) – url to prefix all plugin urls with

  • template_cache_dir (string) – filesytem path to the directory where cached templates are kept

get_plugin(key)[source]

Wrap to throw error if plugin not in registry.

get_plugins(embeddable=None)[source]
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.

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 ResourceParser.<lambda>>, 'float': <class 'float'>, 'int': <class 'int'>, 'json': <function ResourceParser.<lambda>>, 'str': <function ResourceParser.<lambda>>}
__init__(app, *args, **kwargs)[source]

Initialize self. See help(type(self)) for accurate signature.

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