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.tools.data package

Manage tool data tables, which store (at the application level) data that is used by tools, for example in the generation of dynamic options. Tables are loaded and stored by names which tools use to refer to them. This allows users to configure data tables for a local Galaxy instance without needing to modify the tool configurations.

class galaxy.tools.data.ToolDataPathFiles(tool_data_path)[source]

Bases: object

__init__(tool_data_path)[source]
property tool_data_path_files
update_files()[source]
exists(path)[source]
class galaxy.tools.data.ToolDataTableManager(tool_data_path, config_filename=None, tool_data_table_config_path_set=None, other_config_dict=None)[source]

Bases: galaxy.util.dictifiable.Dictifiable

Manages a collection of tool data tables

__init__(tool_data_path, config_filename=None, tool_data_table_config_path_set=None, other_config_dict=None)[source]
get(name, default=None)[source]
set(name, value)[source]
get_tables()[source]
to_dict()[source]

Return item dictionary.

to_json(path)[source]
classmethod from_dict(d)[source]
load_from_config_file(config_filename, tool_data_path, from_shed_config=False)[source]

This method is called under 3 conditions:

  1. When the ToolDataTableManager is initialized (see __init__ above).

  2. Just after the ToolDataTableManager is initialized and the additional entries defined by shed_tool_data_table_conf.xml are being loaded into the ToolDataTableManager.data_tables.

  3. When a tool shed repository that includes a tool_data_table_conf.xml.sample file is being installed into a local Galaxy instance. In this case, we have 2 entry types to handle, files whose root tag is <tables>, for example:

add_new_entries_from_config_file(config_filename, tool_data_path, shed_tool_data_table_config, persist=False)[source]

This method is called when a tool shed repository that includes a tool_data_table_conf.xml.sample file is being installed into a local galaxy instance. We have 2 cases to handle, files whose root tag is <tables>, for example:

<tables>
    <!-- Location of Tmap files -->
    <table name="tmap_indexes" comment_char="#">
        <columns>value, dbkey, name, path</columns>
        <file path="tool-data/tmap_index.loc" />
    </table>
</tables>

and files whose root tag is <table>, for example:

<!-- Location of Tmap files -->
<table name="tmap_indexes" comment_char="#">
    <columns>value, dbkey, name, path</columns>
    <file path="tool-data/tmap_index.loc" />
</table>
to_xml_file(shed_tool_data_table_config, new_elems=None, remove_elems=None)[source]

Write the current in-memory version of the shed_tool_data_table_conf.xml file to disk. remove_elems are removed before new_elems are added.

reload_tables(table_names=None, path=None)[source]

Reload tool data tables. If neither table_names nor path is given, reloads all tool data tables.

get_table_names_by_path(path)[source]

Returns a list of table names given a path

class galaxy.tools.data.ToolDataTable(config_element, tool_data_path, from_shed_config=False, filename=None, tool_data_path_files=None, other_config_dict=None)[source]

Bases: object

type_key: str
classmethod from_elem(table_elem, tool_data_path, from_shed_config, filename, tool_data_path_files, other_config_dict=None)[source]
classmethod from_dict(d)[source]
__init__(config_element, tool_data_path, from_shed_config=False, filename=None, tool_data_path_files=None, other_config_dict=None)[source]
get_empty_field_by_name(name)[source]
add_entry(entry, allow_duplicates=True, persist=False, entry_source=None, **kwd)[source]
add_entries(entries, allow_duplicates=True, persist=False, entry_source=None, **kwd)[source]
remove_entry(values)[source]
is_current_version(other_version)[source]
merge_tool_data_table(other_table, allow_duplicates=True, persist=False, entry_source=None, **kwd)[source]
reload_from_files()[source]
class galaxy.tools.data.TabularToolDataTable(config_element, tool_data_path, from_shed_config=False, filename=None, tool_data_path_files=None, other_config_dict=None)[source]

Bases: galaxy.tools.data.ToolDataTable, galaxy.util.dictifiable.Dictifiable

Data stored in a tabular / separated value format on disk, allows multiple files to be merged but all must have the same column definitions:

<table type="tabular" name="test">
    <column name='...' index = '...' />
    <file path="..." />
    <file path="..." />
</table>
dict_collection_visible_keys = ['name']
dict_element_visible_keys = ['name', 'fields']
dict_export_visible_keys = ['name', 'data', 'largest_index', 'columns', 'missing_index_file']
type_key: str = 'tabular'
__init__(config_element, tool_data_path, from_shed_config=False, filename=None, tool_data_path_files=None, other_config_dict=None)[source]
configure_and_load(config_element, tool_data_path, from_shed_config=False, url_timeout=10)[source]

Configure and load table from an XML element.

merge_tool_data_table(other_table, allow_duplicates=True, persist=False, entry_source=None, **kwd)[source]
handle_found_index_file(filename)[source]
get_fields()[source]
get_field(value)[source]
get_named_fields_list()[source]
get_version_fields()[source]
parse_column_spec(config_element)[source]

Parse column definitions, which can either be a set of ‘column’ elements with a name and index (as in dynamic options config), or a shorthand comma separated list of names in order as the text of a ‘column_names’ element.

A column named ‘value’ is required.

extend_data_with(filename, errors=None)[source]
parse_file_fields(filename, errors=None, here='__HERE__')[source]

Parse separated lines from file and return a list of tuples.

TODO: Allow named access to fields using the column names.

get_column_name_list()[source]
get_entry(query_attr, query_val, return_attr, default=None)[source]

Returns table entry associated with a col/val pair.

get_entries(query_attr, query_val, return_attr, default=None, limit=None)[source]

Returns table entry associated with a col/val pair.

get_filename_for_source(source, default=None)[source]
filter_file_fields(loc_file, values)[source]

Reads separated lines from file and print back only the lines that pass a filter.

property xml_string
to_dict(view='collection')[source]

Return item dictionary.

class galaxy.tools.data.TabularToolDataField(data)[source]

Bases: galaxy.util.dictifiable.Dictifiable

dict_collection_visible_keys: List[str] = []
__init__(data)[source]
get_base_path()[source]
get_base_dir()[source]
clean_base_dir(path)[source]
get_files()[source]
get_filesize_map(rm_base_dir=False)[source]
get_fingerprint()[source]
to_dict()[source]

Return item dictionary.

class galaxy.tools.data.RefgenieToolDataTable(config_element, tool_data_path, from_shed_config=False, filename=None, tool_data_path_files=None, other_config_dict=None)[source]

Bases: galaxy.tools.data.TabularToolDataTable

Data stored in refgenie

<table name="all_fasta" type="refgenie" asset="fasta" >
    <file path="refgenie.yml" />
    <field name="value" template="true">${__REFGENIE_UUID__}</field>
    <field name="dbkey" template="true">${__REFGENIE_GENOME__}</field>
    <field name="name" template="true">${__REFGENIE_DISPLAY_NAME__}</field>
    <field name="path" template="true">${__REFGENIE_ASSET__}</field>
</table>
dict_collection_visible_keys = ['name']
dict_element_visible_keys = ['name', 'fields']
dict_export_visible_keys = ['name', 'data', 'rg_asset', 'largest_index', 'columns', 'missing_index_file']
type_key: str = 'refgenie'
__init__(config_element, tool_data_path, from_shed_config=False, filename=None, tool_data_path_files=None, other_config_dict=None)[source]
configure_and_load(config_element, tool_data_path, from_shed_config=False, url_timeout=10)[source]

Configure and load table from an XML element.

parse_column_spec(config_element)[source]

Parse column definitions, which can either be a set of ‘column’ elements with a name and index (as in dynamic options config), or a shorthand comma separated list of names in order as the text of a ‘column_names’ element.

A column named ‘value’ is required.

parse_file_fields(filename, errors=None, here='__HERE__')[source]

Parse separated lines from file and return a list of tuples.

TODO: Allow named access to fields using the column names.

galaxy.tools.data.expand_here_template(content, here=None)[source]