API documentation for interacting with Galaxy

GalaxyInstance

class bioblend.galaxy.GalaxyInstance(url, key=None, email=None, password=None, verify=True)[source]

A base representation of a connection to a Galaxy instance, identified by the server URL and user credentials.

After you have created a GalaxyInstance object, access various modules via the class fields. For example, to work with histories and get a list of all the user’s histories, the following should be done:

from bioblend import galaxy

gi = galaxy.GalaxyInstance(url='http://127.0.0.1:8000', key='your_api_key')

hl = gi.histories.get_histories()
Parameters
  • url (str) – A FQDN or IP for a given instance of Galaxy. For example: http://127.0.0.1:8080 . If a Galaxy instance is served under a prefix (e.g., http://127.0.0.1:8080/galaxy/), supply the entire URL including the prefix (note that the prefix must end with a slash).

  • key (str) – User’s API key for the given instance of Galaxy, obtained from the user preferences. If a key is not supplied, an email address and password must be and the key will automatically be created for the user.

  • email (str) – Galaxy e-mail address corresponding to the user. Ignored if key is supplied directly.

  • password (str) – Password of Galaxy account corresponding to the above e-mail address. Ignored if key is supplied directly.

  • verify (bool) – Whether to verify the server’s TLS certificate

__init__(url, key=None, email=None, password=None, verify=True)[source]

A base representation of a connection to a Galaxy instance, identified by the server URL and user credentials.

After you have created a GalaxyInstance object, access various modules via the class fields. For example, to work with histories and get a list of all the user’s histories, the following should be done:

from bioblend import galaxy

gi = galaxy.GalaxyInstance(url='http://127.0.0.1:8000', key='your_api_key')

hl = gi.histories.get_histories()
Parameters
  • url (str) – A FQDN or IP for a given instance of Galaxy. For example: http://127.0.0.1:8080 . If a Galaxy instance is served under a prefix (e.g., http://127.0.0.1:8080/galaxy/), supply the entire URL including the prefix (note that the prefix must end with a slash).

  • key (str) – User’s API key for the given instance of Galaxy, obtained from the user preferences. If a key is not supplied, an email address and password must be and the key will automatically be created for the user.

  • email (str) – Galaxy e-mail address corresponding to the user. Ignored if key is supplied directly.

  • password (str) – Password of Galaxy account corresponding to the above e-mail address. Ignored if key is supplied directly.

  • verify (bool) – Whether to verify the server’s TLS certificate

property get_retry_delay
property max_get_attempts

Config

Contains possible interaction dealing with Galaxy configuration.

class bioblend.galaxy.config.ConfigClient(galaxy_instance)[source]

A generic Client interface defining the common fields.

All clients must define the following field (which will be used as part of the URL composition (e.g., http://<galaxy_instance>/api/libraries): self.module = 'workflows' | 'libraries' | 'histories' | ...

get_config()[source]

Get a list of attributes about the Galaxy instance. More attributes will be present if the user is an admin.

Return type

list

Returns

A list of attributes. For example:

{'allow_library_path_paste': False,
 'allow_user_creation': True,
 'allow_user_dataset_purge': True,
 'allow_user_deletion': False,
 'enable_unique_workflow_defaults': False,
 'ftp_upload_dir': '/SOMEWHERE/galaxy/ftp_dir',
 'ftp_upload_site': 'galaxy.com',
 'library_import_dir': 'None',
 'logo_url': None,
 'support_url': 'https://galaxyproject.org/support',
 'terms_url': None,
 'user_library_import_dir': None,
 'wiki_url': 'https://galaxyproject.org/'}

get_version()[source]

Get the current version of the Galaxy instance.

Return type

dict

Returns

Version of the Galaxy instance For example:

{'extra': {}, 'version_major': '17.01'}


Datasets

Contains possible interactions with the Galaxy Datasets

class bioblend.galaxy.datasets.DatasetClient(galaxy_instance)[source]

A generic Client interface defining the common fields.

All clients must define the following field (which will be used as part of the URL composition (e.g., http://<galaxy_instance>/api/libraries): self.module = 'workflows' | 'libraries' | 'histories' | ...

download_dataset(dataset_id, file_path=None, use_default_filename=True, maxwait=12000)[source]

Download a dataset to file or in memory. If the dataset state is not ‘ok’, a DatasetStateException will be thrown.

Parameters
  • dataset_id (str) – Encoded dataset ID

  • file_path (str) – If this argument is provided, the dataset will be streamed to disk at that path (should be a directory if use_default_filename=True). If the file_path argument is not provided, the dataset content is loaded into memory and returned by the method (Memory consumption may be heavy as the entire file will be in memory).

  • use_default_filename (bool) – If True, the exported file will be saved as file_path/%s, where %s is the dataset name. If False, file_path is assumed to contain the full file path including the filename.

  • maxwait (float) – Total time (in seconds) to wait for the dataset state to become terminal. If the dataset state is not terminal within this time, a DatasetTimeoutException will be thrown.

Return type

dict

Returns

If a file_path argument is not provided, returns a dict containing the file content. Otherwise returns nothing.

get_datasets(limit=500, offset=0)[source]

Provide a list of all datasets. Since this may be very large, limit and offset parameters should be used to speficy the desired range.

Parameters
  • limit (int) – Maximum number of datasets to return.

  • offset (int) – Return datasets starting from this specified position. For example, if limit is set to 100 and offset to 200, datasets 200-299 will be returned.

Return type

list

Returns

Return a list of dataset dicts.

show_dataset(dataset_id, deleted=False, hda_ldda='hda')[source]

Get details about a given dataset. This can be a history or a library dataset.

Parameters
  • dataset_id (str) – Encoded dataset ID

  • deleted (bool) – Whether to return results for a deleted dataset

  • hda_ldda (str) – Whether to show a history dataset (‘hda’ - the default) or library dataset (‘ldda’).

Return type

dict

Returns

Information about the HDA or LDDA

exception bioblend.galaxy.datasets.DatasetStateException[source]
exception bioblend.galaxy.datasets.DatasetTimeoutException[source]

Datatypes

Contains possible interactions with the Galaxy Datatype

class bioblend.galaxy.datatypes.DatatypesClient(galaxy_instance)[source]

A generic Client interface defining the common fields.

All clients must define the following field (which will be used as part of the URL composition (e.g., http://<galaxy_instance>/api/libraries): self.module = 'workflows' | 'libraries' | 'histories' | ...

get_datatypes(extension_only=False, upload_only=False)[source]

Get the list of all installed datatypes.

Parameters
  • extension_only (bool) – Return only the extension rather than the datatype name

  • upload_only (bool) – Whether to return only datatypes which can be uploaded

Return type

list

Returns

A list of datatype names. For example:

['snpmatrix',
 'snptest',
 'tabular',
 'taxonomy',
 'twobit',
 'txt',
 'vcf',
 'wig',
 'xgmml',
 'xml']

get_sniffers()[source]

Get the list of all installed sniffers.

Return type

list

Returns

A list of sniffer names. For example:

['galaxy.datatypes.tabular:Vcf',
 'galaxy.datatypes.binary:TwoBit',
 'galaxy.datatypes.binary:Bam',
 'galaxy.datatypes.binary:Sff',
 'galaxy.datatypes.xml:Phyloxml',
 'galaxy.datatypes.xml:GenericXml',
 'galaxy.datatypes.sequence:Maf',
 'galaxy.datatypes.sequence:Lav',
 'galaxy.datatypes.sequence:csFasta']


Folders

Contains possible interactions with the Galaxy library folders

class bioblend.galaxy.folders.FoldersClient(galaxy_instance)[source]

A generic Client interface defining the common fields.

All clients must define the following field (which will be used as part of the URL composition (e.g., http://<galaxy_instance>/api/libraries): self.module = 'workflows' | 'libraries' | 'histories' | ...

create_folder(parent_folder_id, name, description=None)[source]

Create a folder.

Parameters
  • parent_folder_id (str) – Folder’s description

  • name (str) – name of the new folder

  • description (str) – folder’s description

Return type

dict

Returns

details of the updated folder

delete_folder(folder_id, undelete=False)[source]

Marks the folder with the given id as deleted (or removes the deleted mark if the undelete param is True).

Parameters
  • folder_id (str) – the folder’s encoded id, prefixed by ‘F’

  • undelete (bool) – If set to True, the folder will be undeleted (i.e. the deleted mark will be removed)

Returns

detailed folder information

Return type

dict

get_permissions(folder_id, scope)[source]

Get the permissions of a folder.

Parameters
  • folder_id (str) – the folder’s encoded id, prefixed by ‘F’

  • scope (str) – scope of permissions, either ‘current’ or ‘available’

Return type

dict

Returns

dictionary including details of the folder

set_permissions(folder_id, action='set_permissions', add_ids=None, manage_ids=None, modify_ids=None)[source]

Set the permissions of a folder.

Parameters
  • folder_id (str) – the folder’s encoded id, prefixed by ‘F’

  • action (str) – action to execute, only “set_permissions” is supported.

  • add_ids (list of str) – list of role IDs which can add datasets to the folder

  • manage_ids (list of str) – list of role IDs which can manage datasets in the folder

  • modify_ids (list of str) – list of role IDs which can modify datasets in the folder

Return type

dict

Returns

dictionary including details of the folder

show_folder(folder_id, contents=False)[source]

Display information about a folder.

Parameters
  • folder_id (str) – the folder’s encoded id, prefixed by ‘F’

  • contents (bool) – True to get the contents of the folder, rather than just the folder details.

Return type

dict

Returns

dictionary including details of the folder

update_folder(folder_id, name, description=None)[source]

Update folder information.

Parameters
  • folder_id (str) – the folder’s encoded id, prefixed by ‘F’

  • name (str) – name of the new folder

  • description (str) – folder’s description

Return type

dict

Returns

details of the updated folder


Forms

Contains possible interactions with the Galaxy Forms

class bioblend.galaxy.forms.FormsClient(galaxy_instance)[source]

A generic Client interface defining the common fields.

All clients must define the following field (which will be used as part of the URL composition (e.g., http://<galaxy_instance>/api/libraries): self.module = 'workflows' | 'libraries' | 'histories' | ...

create_form(form_xml_text)[source]

Create a new form.

Parameters

form_xml_text (str) – Form xml to create a form on galaxy instance

Return type

str

Returns

Unique URL of newly created form with encoded id

get_forms()[source]

Get the list of all forms.

Return type

list

Returns

Displays a collection (list) of forms. For example:

[{'id': 'f2db41e1fa331b3e',
  'model_class': 'FormDefinition',
  'name': 'First form',
  'url': '/api/forms/f2db41e1fa331b3e'},
 {'id': 'ebfb8f50c6abde6d',
  'model_class': 'FormDefinition',
  'name': 'second form',
  'url': '/api/forms/ebfb8f50c6abde6d'}]

show_form(form_id)[source]

Get details of a given form.

Parameters

form_id (str) – Encoded form ID

Return type

dict

Returns

A description of the given form. For example:

{'desc': 'here it is ',
 'fields': [],
 'form_definition_current_id': 'f2db41e1fa331b3e',
 'id': 'f2db41e1fa331b3e',
 'layout': [],
 'model_class': 'FormDefinition',
 'name': 'First form',
 'url': '/api/forms/f2db41e1fa331b3e'}


FTP files

Contains possible interactions with the Galaxy FTP Files

class bioblend.galaxy.ftpfiles.FTPFilesClient(galaxy_instance)[source]

A generic Client interface defining the common fields.

All clients must define the following field (which will be used as part of the URL composition (e.g., http://<galaxy_instance>/api/libraries): self.module = 'workflows' | 'libraries' | 'histories' | ...

get_ftp_files(deleted=False)[source]

Get a list of local files.

Parameters

deleted (bool) – Whether to include deleted files

Return type

list

Returns

A list of dicts with details on individual files on FTP


Genomes

Contains possible interactions with the Galaxy Histories

class bioblend.galaxy.genomes.GenomeClient(galaxy_instance)[source]

A generic Client interface defining the common fields.

All clients must define the following field (which will be used as part of the URL composition (e.g., http://<galaxy_instance>/api/libraries): self.module = 'workflows' | 'libraries' | 'histories' | ...

get_genomes()[source]

Returns a list of installed genomes

Return type

list

Returns

List of installed genomes

install_genome(func='download', source=None, dbkey=None, ncbi_name=None, ensembl_dbkey=None, url_dbkey=None, indexers=None)[source]

Download and/or index a genome.

Parameters
  • dbkey (str) – DB key of the build to download, ignored unless ‘UCSC’ is specified as the source

  • ncbi_name (str) – NCBI’s genome identifier, ignored unless NCBI is specified as the source

  • ensembl_dbkey (str) – Ensembl’s genome identifier, ignored unless Ensembl is specified as the source

  • url_dbkey (str) – DB key to use for this build, ignored unless URL is specified as the source

  • source (str) – Data source for this build. Can be: UCSC, Ensembl, NCBI, URL

  • indexers (list) – POST array of indexers to run after downloading (indexers[] = first, indexers[] = second, …)

  • func (str) – Allowed values: ‘download’, Download and index; ‘index’, Index only

Return type

dict

Returns

dict( status: ‘ok’, job: <job ID> ) If error: dict( status: ‘error’, error: <error message> )

show_genome(id, num=None, chrom=None, low=None, high=None)[source]

Returns information about build <id>

Parameters
  • id (str) – Genome build ID to use

  • num (str) – num

  • chrom (str) – chrom

  • low (str) – low

  • high (str) – high

Return type

dict

Returns

Information about the genome build

Groups

Contains possible interactions with the Galaxy Groups

class bioblend.galaxy.groups.GroupsClient(galaxy_instance)[source]

A generic Client interface defining the common fields.

All clients must define the following field (which will be used as part of the URL composition (e.g., http://<galaxy_instance>/api/libraries): self.module = 'workflows' | 'libraries' | 'histories' | ...

add_group_role(group_id, role_id)[source]

Add a role to the given group.

Parameters
  • group_id (str) – Encoded group ID

  • role_id (str) – Encoded role ID to add to the group

Return type

dict

Returns

Added group role’s info

add_group_user(group_id, user_id)[source]

Add a user to the given group.

Parameters
  • group_id (str) – Encoded group ID

  • user_id (str) – Encoded user ID to add to the group

Return type

dict

Returns

Added group user’s info

create_group(group_name, user_ids=[], role_ids=[])[source]

Create a new group.

Parameters
  • group_name (str) – A name for the new group

  • user_ids (list) – A list of encoded user IDs to add to the new group

  • role_ids (list) – A list of encoded role IDs to add to the new group

Return type

list

Returns

A (size 1) list with newly created group details, like:

[{'id': '7c9636938c3e83bf',
  'model_class': 'Group',
  'name': 'My Group Name',
  'url': '/api/groups/7c9636938c3e83bf'}]

delete_group_role(group_id, role_id)[source]

Remove a role from the given group.

Parameters
  • group_id (str) – Encoded group ID

  • role_id (str) – Encoded role ID to remove from the group

Return type

dict

Returns

The role which was removed

delete_group_user(group_id, user_id)[source]

Remove a user from the given group.

Parameters
  • group_id (str) – Encoded group ID

  • user_id (str) – Encoded user ID to remove from the group

Return type

dict

Returns

The user which was removed

get_group_roles(group_id)[source]

Get the list of roles associated to the given group.

Parameters

group_id (str) – Encoded group ID

Return type

list of dicts

Returns

List of group roles’ info

get_group_users(group_id)[source]

Get the list of users associated to the given group.

Parameters

group_id (str) – Encoded group ID

Return type

list of dicts

Returns

List of group users’ info

get_groups()[source]

Get all (not deleted) groups.

Return type

list

Returns

A list of dicts with details on individual groups. For example:

[{'id': '33abac023ff186c2',
  'model_class': 'Group',
  'name': 'Listeria',
  'url': '/api/groups/33abac023ff186c2'},
 {'id': '73187219cd372cf8',
  'model_class': 'Group',
  'name': 'LPN',
  'url': '/api/groups/73187219cd372cf8'}]

show_group(group_id)[source]

Get details of a given group.

Parameters

group_id (str) – Encoded group ID

Return type

dict

Returns

A description of group For example:

{'id': '33abac023ff186c2',
 'model_class': 'Group',
 'name': 'Listeria',
 'roles_url': '/api/groups/33abac023ff186c2/roles',
 'url': '/api/groups/33abac023ff186c2',
 'users_url': '/api/groups/33abac023ff186c2/users'}

update_group(group_id, group_name=None, user_ids=[], role_ids=[])[source]

Update a group.

Parameters
  • group_id (str) – Encoded group ID

  • group_name (str) – A new name for the group. If None, the group name is not changed.

  • user_ids (list) – New list of encoded user IDs for the group. It will substitute the previous list of users (with [] if not specified)

  • role_ids (list) – New list of encoded role IDs for the group. It will substitute the previous list of roles (with [] if not specified)

Return type

None

Returns

None


Histories

Contains possible interactions with the Galaxy Histories

class bioblend.galaxy.histories.HistoryClient(galaxy_instance)[source]

A generic Client interface defining the common fields.

All clients must define the following field (which will be used as part of the URL composition (e.g., http://<galaxy_instance>/api/libraries): self.module = 'workflows' | 'libraries' | 'histories' | ...

copy_dataset(history_id, dataset_id, source='hda')[source]

Copy a dataset to a history.

Parameters
  • history_id (str) – history ID to which the dataset should be copied

  • dataset_id (str) – dataset ID

  • source (str) – Source of the dataset to be copied: ‘hda’ (the default), ‘library’ or ‘library_folder’

Return type

dict

Returns

Information about the copied dataset

create_dataset_collection(history_id, collection_description)[source]

Create a new dataset collection

Parameters
  • history_id (str) – Encoded history ID

  • collection_description (bioblend.galaxy.dataset_collections.CollectionDescription) –

    a description of the dataset collection For example:

    {'collection_type': 'list',
     'element_identifiers': [{'id': 'f792763bee8d277a',
                              'name': 'element 1',
                              'src': 'hda'},
                             {'id': 'f792763bee8d277a',
                              'name': 'element 2',
                              'src': 'hda'}],
     'name': 'My collection list'}
    

Return type

dict

Returns

Information about the new HDCA

create_history(name=None)[source]

Create a new history, optionally setting the name.

Parameters

name (str) – Optional name for new history

Return type

dict

Returns

Dictionary containing information about newly created history

create_history_tag(history_id, tag)[source]

Create history tag

Parameters
  • history_id (str) – Encoded history ID

  • tag (str) – Add tag to history

Return type

dict

Returns

A dictionary with information regarding the tag. For example:

{'id': 'f792763bee8d277a',
 'model_class': 'HistoryTagAssociation',
 'user_tname': 'NGS_PE_RUN',
 'user_value': None}

delete_dataset(history_id, dataset_id, purge=False)[source]

Mark corresponding dataset as deleted.

Parameters
  • history_id (str) – Encoded history ID

  • dataset_id (str) – Encoded dataset ID

  • purge (bool) – if True, also purge (permanently delete) the dataset

Return type

None

Returns

None

Note

For the purge option to work, the Galaxy instance must have the allow_user_dataset_purge option set to true in the config/galaxy.yml configuration file.

delete_dataset_collection(history_id, dataset_collection_id)[source]

Mark corresponding dataset collection as deleted.

Parameters
  • history_id (str) – Encoded history ID

  • dataset_collection_id (str) – Encoded dataset collection ID

Return type

None

Returns

None

delete_history(history_id, purge=False)[source]

Delete a history.

Parameters
  • history_id (str) – Encoded history ID

  • purge (bool) – if True, also purge (permanently delete) the history

Return type

dict

Returns

An error object if an error occurred or a dictionary containing: id (the encoded id of the history), deleted (if the history was marked as deleted), purged (if the history was purged).

Note

For the purge option to work, the Galaxy instance must have the allow_user_dataset_purge option set to true in the config/galaxy.yml configuration file.

download_dataset(history_id, dataset_id, file_path, use_default_filename=True)[source]

Deprecated since version 0.8.0: Use download_dataset() instead.

download_history(history_id, jeha_id, outf, chunk_size=4096)[source]

Download a history export archive. Use export_history() to create an export.

Parameters
  • history_id (str) – history ID

  • jeha_id (str) – jeha ID (this should be obtained via export_history())

  • outf (file) – output file object, open for writing in binary mode

  • chunk_size (int) – how many bytes at a time should be read into memory

Return type

None

Returns

None

export_history(history_id, gzip=True, include_hidden=False, include_deleted=False, wait=False, maxwait=None)[source]

Start a job to create an export archive for the given history.

Parameters
  • history_id (str) – history ID

  • gzip (bool) – create .tar.gz archive if True, else .tar

  • include_hidden (bool) – whether to include hidden datasets in the export

  • include_deleted (bool) – whether to include deleted datasets in the export

  • wait (bool) – if True, block until the export is ready; else, return immediately

  • maxwait (float) – Total time (in seconds) to wait for the export to become ready. When set, implies that wait is True.

Return type

str

Returns

jeha_id of the export, or empty if wait is False and the export is not ready.

get_current_history()[source]

Deprecated since version 0.5.2: Use get_most_recently_used_history() instead.

get_histories(history_id=None, name=None, deleted=False)[source]

Get all histories or filter the specific one(s) via the provided name or history_id. Provide only one argument, name or history_id, but not both.

If deleted is set to True, return histories that have been deleted.

Parameters
  • history_id (str) – Encoded history ID to filter on

  • name (str) – Name of history to filter on

  • deleted (bool) – whether to filter for the deleted histories (True) or for the non-deleted ones (False)

Return type

list

Returns

Return a list of history element dicts. If more than one history matches the given name, return the list of all the histories with the given name

get_most_recently_used_history()[source]

Returns the current user’s most recently used history (not deleted).

Return type

dict

Returns

History representation

get_status(history_id)[source]

Returns the state of this history

Parameters

history_id (str) – Encoded history ID

Return type

dict

Returns

A dict documenting the current state of the history. Has the following keys: ‘state’ = This is the current state of the history, such as ok, error, new etc. ‘state_details’ = Contains individual statistics for various dataset states. ‘percent_complete’ = The overall number of datasets processed to completion.

import_history(file_path=None, url=None)[source]

Import a history from an archive on disk or a URL. :type file_path: str :param file_path: Path to exported history archive on disk. :type url: str :param url: URL for an exported history archive

show_dataset(history_id, dataset_id)[source]

Get details about a given history dataset.

Parameters
  • history_id (str) – Encoded history ID

  • dataset_id (str) – Encoded dataset ID

Return type

dict

Returns

Information about the dataset

show_dataset_collection(history_id, dataset_collection_id)[source]

Get details about a given history dataset collection.

Parameters
  • history_id (str) – Encoded history ID

  • dataset_collection_id (str) – Encoded dataset collection ID

Return type

dict

Returns

Information about the dataset collection

show_dataset_provenance(history_id, dataset_id, follow=False)[source]

Get details related to how dataset was created (id, job_id, tool_id, stdout, stderr, parameters, inputs, etc…).

Parameters
  • history_id (str) – Encoded history ID

  • dataset_id (str) – Encoded dataset ID

  • follow (bool) – If True, recursively fetch dataset provenance information for all inputs and their inputs, etc.

Return type

dict

Returns

Dataset provenance information For example:

{'id': '6fbd9b2274c62ebe',
 'job_id': '5471ba76f274f929',
 'parameters': {'chromInfo': '"/usr/local/galaxy/galaxy-dist/tool-data/shared/ucsc/chrom/mm9.len"',
                'dbkey': '"mm9"',
                'experiment_name': '"H3K4me3_TAC_MACS2"',
                'input_chipseq_file1': {'id': '6f0a311a444290f2',
                                        'uuid': 'null'},
                'input_control_file1': {'id': 'c21816a91f5dc24e',
                                        'uuid': '16f8ee5e-228f-41e2-921e-a07866edce06'},
                'major_command': '{"gsize": "2716965481.0", "bdg": "False", "__current_case__": 0, "advanced_options": {"advanced_options_selector": "off", "__current_case__": 1}, "input_chipseq_file1": 104715, "xls_to_interval": "False", "major_command_selector": "callpeak", "input_control_file1": 104721, "pq_options": {"pq_options_selector": "qvalue", "qvalue": "0.05", "__current_case__": 1}, "bw": "300", "nomodel_type": {"nomodel_type_selector": "create_model", "__current_case__": 1}}'},
 'stderr': '',
 'stdout': '',
 'tool_id': 'toolshed.g2.bx.psu.edu/repos/ziru-zhou/macs2/modencode_peakcalling_macs2/2.0.10.2',
 'uuid': '5c0c43f5-8d93-44bd-939d-305e82f213c6'}

show_history(history_id, contents=False, deleted=None, visible=None, details=None, types=None)[source]

Get details of a given history. By default, just get the history meta information.

Parameters
  • history_id (str) – Encoded history ID to filter on

  • contents (bool) – When True, instead of the history details, return a list with info for all datasets in the given history. Note that inside each dataset info dict, the id which should be used for further requests about this history dataset is given by the value of the id (not dataset_id) key.

  • deleted (bool or None) – When contents=True, whether to filter for the deleted datasets (True) or for the non-deleted ones (False). If not set, no filtering is applied.

  • visible (bool or None) – When contents=True, whether to filter for the visible datasets (True) or for the hidden ones (False). If not set, no filtering is applied.

  • details (str) – When contents=True, include dataset details. Set to ‘all’ for the most information.

  • types (list) – When contents=True, filter for history content types. If set to ['dataset'], return only datasets. If set to ['dataset_collection'], return only dataset collections. If not set, no filtering is applied.

Return type

dict or list of dicts

Returns

details of the given history or list of dataset info

show_matching_datasets(history_id, name_filter=None)[source]

Get dataset details for matching datasets within a history.

Parameters
  • history_id (str) – Encoded history ID

  • name_filter (str) – Only datasets whose name matches the name_filter regular expression will be returned; use plain strings for exact matches and None to match all datasets in the history

Return type

list

Returns

List of dictionaries

undelete_history(history_id)[source]

Undelete a history

Parameters

history_id (str) – Encoded history ID

Return type

str

Returns

‘OK’ if it was deleted

update_dataset(history_id, dataset_id, **kwds)[source]

Update history dataset metadata. Some of the attributes that can be modified are documented below.

Parameters
  • history_id (str) – Encoded history ID

  • dataset_id (str) – Id of the dataset

  • name (str) – Replace history dataset name with the given string

  • genome_build (str) – Replace history dataset genome build (dbkey)

  • annotation (str) – Replace history dataset annotation with given string

  • deleted (bool) – Mark or unmark history dataset as deleted

  • visible (bool) – Mark or unmark history dataset as visible

Return type

dict

Returns

details of the updated dataset

Warning

The return value was changed in BioBlend v0.8.0, previously it was the status code (type int).

update_dataset_collection(history_id, dataset_collection_id, **kwds)[source]

Update history dataset collection metadata. Some of the attributes that can be modified are documented below.

Parameters
  • history_id (str) – Encoded history ID

  • dataset_collection_id (str) – Encoded dataset_collection ID

  • name (str) – Replace history dataset collection name with the given string

  • deleted (bool) – Mark or unmark history dataset collection as deleted

  • visible (bool) – Mark or unmark history dataset collection as visible

Return type

dict

Returns

the updated dataset collection attributes

Warning

The return value was changed in BioBlend v0.8.0, previously it was the status code (type int).

update_history(history_id, **kwds)[source]

Update history metadata information. Some of the attributes that can be modified are documented below.

Parameters
  • history_id (str) – Encoded history ID

  • name (str) – Replace history name with the given string

  • annotation (str) – Replace history annotation with given string

  • deleted (bool) – Mark or unmark history as deleted

  • purged (bool) – If True, mark history as purged (permanently deleted).

  • published (bool) – Mark or unmark history as published

  • importable (bool) – Mark or unmark history as importable

  • tags (list) – Replace history tags with the given list

Return type

dict

Returns

details of the updated history

Warning

The return value was changed in BioBlend v0.8.0, previously it was the status code (type int).

upload_dataset_from_library(history_id, lib_dataset_id)[source]

Upload a dataset into the history from a library. Requires the library dataset ID, which can be obtained from the library contents.

Parameters
  • history_id (str) – Encoded history ID

  • lib_dataset_id (str) – Encoded library dataset ID

Return type

dict

Returns

Information about the newly created HDA


Jobs

Contains possible interactions with the Galaxy Jobs

class bioblend.galaxy.jobs.JobsClient(galaxy_instance)[source]

A generic Client interface defining the common fields.

All clients must define the following field (which will be used as part of the URL composition (e.g., http://<galaxy_instance>/api/libraries): self.module = 'workflows' | 'libraries' | 'histories' | ...

get_jobs()[source]

Get the list of jobs of the current user.

Return type

list

Returns

list of dictionaries containing summary job information. For example:

[{'create_time': '2014-03-01T16:16:48.640550',
  'exit_code': 0,
  'id': 'ebfb8f50c6abde6d',
  'model_class': 'Job',
  'state': 'ok',
  'tool_id': 'fasta2tab',
  'update_time': '2014-03-01T16:16:50.657399'},
 {'create_time': '2014-03-01T16:05:34.851246',
  'exit_code': 0,
  'id': '1cd8e2f6b131e891',
  'model_class': 'Job',
  'state': 'ok',
  'tool_id': 'upload1',
  'update_time': '2014-03-01T16:05:39.558458'}]

get_metrics(job_id)[source]

Return job metrics for a given job.

Parameters

job_id (str) – job ID

Return type

list

Returns

list containing job metrics

Note

Calling show_job() with full_details=True also returns the metrics for a job if the user is an admin. This method allows to fetch metrics even as a normal user as long as the Galaxy instance has the expose_potentially_sensitive_job_metrics option set to true in the config/galaxy.yml configuration file.

get_state(job_id)[source]

Display the current state for a given job of the current user.

Parameters

job_id (str) – job ID

Return type

str

Returns

state of the given job among the following values: new, queued, running, waiting, ok. If the state cannot be retrieved, an empty string is returned.

New in version 0.5.3.

search_jobs(job_info)[source]

Return jobs for the current user based payload content.

Parameters

job_info (dict) – dictionary containing description of the requested job. This is in the same format as a request to POST /api/tools would take to initiate a job

Return type

list

Returns

list of dictionaries containing summary job information of the jobs that match the requested job run

This method is designed to scan the list of previously run jobs and find records of jobs that had the exact some input parameters and datasets. This can be used to minimize the amount of repeated work, and simply recycle the old results.

show_job(job_id, full_details=False)[source]

Get details of a given job of the current user.

Parameters
  • job_id (str) – job ID

  • full_details (bool) – when True, the complete list of details for the given job.

Return type

dict

Returns

A description of the given job. For example:

{'create_time': '2014-03-01T16:17:29.828624',
 'exit_code': 0,
 'id': 'a799d38679e985db',
 'inputs': {'input': {'id': 'ebfb8f50c6abde6d', 'src': 'hda'}},
 'model_class': 'Job',
 'outputs': {'output': {'id': 'a799d38679e985db', 'src': 'hda'}},
 'params': {'chromInfo': '"/opt/galaxy-central/tool-data/shared/ucsc/chrom/?.len"',
            'dbkey': '"?"',
            'seq_col': '"2"',
            'title_col': '["1"]'},
 'state': 'ok',
 'tool_id': 'tab2fasta',
 'update_time': '2014-03-01T16:17:31.930728'}


Libraries

Contains possible interactions with the Galaxy Data Libraries

class bioblend.galaxy.libraries.LibraryClient(galaxy_instance)[source]

A generic Client interface defining the common fields.

All clients must define the following field (which will be used as part of the URL composition (e.g., http://<galaxy_instance>/api/libraries): self.module = 'workflows' | 'libraries' | 'histories' | ...

copy_from_dataset(library_id, dataset_id, folder_id=None, message='')[source]

Copy a Galaxy dataset into a library.

Parameters
  • library_id (str) – id of the library where to place the uploaded file

  • dataset_id (str) – id of the dataset to copy from

  • folder_id (str) – id of the folder where to place the uploaded files. If not provided, the root folder will be used

  • message (str) – message for copying action

Return type

dict

Returns

LDDA information

create_folder(library_id, folder_name, description=None, base_folder_id=None)[source]

Create a folder in a library.

Parameters
  • library_id (str) – library id to use

  • folder_name (str) – name of the new folder in the data library

  • description (str) – description of the new folder in the data library

  • base_folder_id (str) – id of the folder where to create the new folder. If not provided, the root folder will be used

Return type

list

Returns

List with a single dictionary containing information about the new folder

create_library(name, description=None, synopsis=None)[source]

Create a data library with the properties defined in the arguments.

Parameters
  • name (str) – Name of the new data library

  • description (str) – Optional data library description

  • synopsis (str) – Optional data library synopsis

Return type

dict

Returns

Details of the created library. For example:

{'id': 'f740ab636b360a70',
 'name': 'Library from bioblend',
 'url': '/api/libraries/f740ab636b360a70'}

delete_library(library_id)[source]

Delete a data library.

Parameters

library_id (str) – Encoded data library ID identifying the library to be deleted

Return type

dict

Returns

Information about the deleted library

Warning

Deleting a data library is irreversible - all of the data from the library will be permanently deleted.

delete_library_dataset(library_id, dataset_id, purged=False)[source]

Delete a library dataset in a data library.

Parameters
  • library_id (str) – library id where dataset is found in

  • dataset_id (str) – id of the dataset to be deleted

  • purged (bool) – Indicate that the dataset should be purged (permanently deleted)

Return type

dict

Returns

A dictionary containing the dataset id and whether the dataset has been deleted. For example:

{'deleted': True,
 'id': '60e680a037f41974'}

get_dataset_permissions(dataset_id)[source]

Get the permissions for a dataset.

Parameters

dataset_id (str) – id of the dataset

Return type

dict

Returns

dictionary with all applicable permissions’ values

get_folders(library_id, folder_id=None, name=None)[source]

Get all the folders or filter specific one(s) via the provided name or folder_id in data library with id library_id. Provide only one argument: name or folder_id, but not both.

Parameters
  • library_id (str) – library id to use

  • folder_id (str) – filter for folder by folder id

  • name (str) – filter for folder by name. For name specify the full path of the folder starting from the library’s root folder, e.g. /subfolder/subsubfolder.

Return type

list

Returns

list of dicts each containing basic information about a folder

get_libraries(library_id=None, name=None, deleted=False)[source]

Get all the libraries or filter for specific one(s) via the provided name or ID. Provide only one argument: name or library_id, but not both.

Parameters
  • library_id (str) – filter for library by library id

  • name (str) – If name is set and multiple names match the given name, all the libraries matching the argument will be returned

  • deleted (bool) – If False (the default), return only non-deleted libraries. If True, return only deleted libraries. If None, return both deleted and non-deleted libraries.

Return type

list

Returns

list of dicts each containing basic information about a library

get_library_permissions(library_id)[source]

Get the permissions for a library.

Parameters

library_id (str) – id of the library

Return type

dict

Returns

dictionary with all applicable permissions’ values

set_dataset_permissions(dataset_id, access_in=None, modify_in=None, manage_in=None)[source]

Set the permissions for a dataset. Note: it will override all security for this dataset even if you leave out a permission type.

Parameters
  • dataset_id (str) – id of the dataset

  • access_in (list) – list of role ids

  • modify_in (list) – list of role ids

  • manage_in (list) – list of role ids

Return type

dict

Returns

dictionary with all applicable permissions’ values

set_library_permissions(library_id, access_in=None, modify_in=None, add_in=None, manage_in=None)[source]

Set the permissions for a library. Note: it will override all security for this library even if you leave out a permission type.

Parameters
  • library_id (str) – id of the library

  • access_in (list) – list of role ids

  • modify_in (list) – list of role ids

  • add_in (list) – list of role ids

  • manage_in (list) – list of role ids

Return type

dict

Returns

General information about the library

show_dataset(library_id, dataset_id)[source]

Get details about a given library dataset. The required library_id can be obtained from the datasets’s library content details.

Parameters
  • library_id (str) – library id where dataset is found in

  • dataset_id (str) – id of the dataset to be inspected

Return type

dict

Returns

A dictionary containing information about the dataset in the library

show_folder(library_id, folder_id)[source]

Get details about a given folder. The required folder_id can be obtained from the folder’s library content details.

Parameters
  • library_id (str) – library id to inspect folders in

  • folder_id (str) – id of the folder to be inspected

Return type

dict

Returns

Information about the folder

show_library(library_id, contents=False)[source]

Get information about a library.

Parameters
  • library_id (str) – filter for library by library id

  • contents (bool) – whether to get contents of the library (rather than just the library details)

Return type

dict

Returns

details of the given library

update_library_dataset(dataset_id, **kwds)[source]

Update library dataset metadata. Some of the attributes that can be modified are documented below.

Parameters
  • dataset_id (str) – id of the dataset to be deleted

  • name (str) – Replace library dataset name with the given string

  • misc_info (str) – Replace library dataset misc_info with given string

  • file_ext (str) – Replace library dataset extension (must exist in the Galaxy registry)

  • genome_build (str) – Replace library dataset genome build (dbkey)

  • tags (list) – Replace library dataset tags with the given list

Return type

dict

Returns

details of the updated dataset

upload_file_contents(library_id, pasted_content, folder_id=None, file_type='auto', dbkey='?', tags=None)[source]

Upload pasted_content to a data library as a new file.

Parameters
  • library_id (str) – id of the library where to place the uploaded file

  • pasted_content (str) – Content to upload into the library

  • folder_id (str) – id of the folder where to place the uploaded file. If not provided, the root folder will be used

  • file_type (str) – Galaxy file format name

  • dbkey (str) – Dbkey

  • tags (list) – A list of tags to add to the datasets

Return type

list

Returns

List with a single dictionary containing information about the LDDA

upload_file_from_local_path(library_id, file_local_path, folder_id=None, file_type='auto', dbkey='?', tags=None)[source]

Read local file contents from file_local_path and upload data to a library.

Parameters
  • library_id (str) – id of the library where to place the uploaded file

  • file_local_path (str) – path of local file to upload

  • folder_id (str) – id of the folder where to place the uploaded file. If not provided, the root folder will be used

  • file_type (str) – Galaxy file format name

  • dbkey (str) – Dbkey

  • tags (list) – A list of tags to add to the datasets

Return type

list

Returns

List with a single dictionary containing information about the LDDA

upload_file_from_server(library_id, server_dir, folder_id=None, file_type='auto', dbkey='?', link_data_only=None, roles='', preserve_dirs=False, tag_using_filenames=False, tags=None)[source]

Upload all files in the specified subdirectory of the Galaxy library import directory to a library.

Note

For this method to work, the Galaxy instance must have the library_import_dir option configured in the config/galaxy.yml configuration file.

Parameters
  • library_id (str) – id of the library where to place the uploaded file

  • server_dir (str) – relative path of the subdirectory of library_import_dir to upload. All and only the files (i.e. no subdirectories) contained in the specified directory will be uploaded

  • folder_id (str) – id of the folder where to place the uploaded files. If not provided, the root folder will be used

  • file_type (str) – Galaxy file format name

  • dbkey (str) – Dbkey

  • link_data_only (str) – either ‘copy_files’ (default) or ‘link_to_files’. Setting to ‘link_to_files’ symlinks instead of copying the files

  • roles (str) –

    ???

  • preserve_dirs (bool) – Indicate whether to preserve the directory structure when importing dir

  • tag_using_filenames (bool) –

    Indicate whether to generate dataset tags from filenames.

    Warning

    The default was changed from True to False in BioBlend v0.14.0.

  • tags (list) – A list of tags to add to the datasets

Return type

list

Returns

List with a single dictionary containing information about the LDDA

upload_file_from_url(library_id, file_url, folder_id=None, file_type='auto', dbkey='?', tags=None)[source]

Upload a file to a library from a URL.

Parameters
  • library_id (str) – id of the library where to place the uploaded file

  • file_url (str) – URL of the file to upload

  • folder_id (str) – id of the folder where to place the uploaded file. If not provided, the root folder will be used

  • file_type (str) – Galaxy file format name

  • dbkey (str) – Dbkey

  • tags (list) – A list of tags to add to the datasets

Return type

list

Returns

List with a single dictionary containing information about the LDDA

upload_from_galaxy_filesystem(library_id, filesystem_paths, folder_id=None, file_type='auto', dbkey='?', link_data_only=None, roles='', preserve_dirs=False, tag_using_filenames=False, tags=None)[source]

Upload a set of files already present on the filesystem of the Galaxy server to a library.

Note

For this method to work, the Galaxy instance must have the allow_path_paste option set to true in the config/galaxy.yml configuration file.

Parameters
  • library_id (str) – id of the library where to place the uploaded file

  • filesystem_paths (str) – file paths on the Galaxy server to upload to the library, one file per line

  • folder_id (str) – id of the folder where to place the uploaded files. If not provided, the root folder will be used

  • file_type (str) – Galaxy file format name

  • dbkey (str) – Dbkey

  • link_data_only (str) – either ‘copy_files’ (default) or ‘link_to_files’. Setting to ‘link_to_files’ symlinks instead of copying the files

  • roles (str) –

    ???

  • preserve_dirs (bool) – Indicate whether to preserve the directory structure when importing dir

  • tag_using_filenames (bool) –

    Indicate whether to generate dataset tags from filenames.

    Warning

    The default was changed from True to False in BioBlend v0.14.0.

  • tags (list) – A list of tags to add to the datasets

Return type

list

Returns

List with a single dictionary containing information about the LDDA

wait_for_dataset(library_id, dataset_id, maxwait=12000, interval=3)[source]

Wait until the library dataset state is terminal (‘ok’, ‘empty’, ‘error’, ‘discarded’ or ‘failed_metadata’).

Parameters
  • library_id (str) – library id where dataset is found in

  • dataset_id (str) – id of the dataset to wait for

  • maxwait (float) – Total time (in seconds) to wait for the dataset state to become terminal. If the dataset state is not terminal within this time, a DatasetTimeoutException will be thrown.

  • interval (float) – Time (in seconds) to wait between 2 consecutive checks.

Return type

dict

Returns

A dictionary containing information about the dataset in the library


Quotas

Contains possible interactions with the Galaxy Quota

class bioblend.galaxy.quotas.QuotaClient(galaxy_instance)[source]

A generic Client interface defining the common fields.

All clients must define the following field (which will be used as part of the URL composition (e.g., http://<galaxy_instance>/api/libraries): self.module = 'workflows' | 'libraries' | 'histories' | ...

create_quota(name, description, amount, operation, default='no', in_users=[], in_groups=[])[source]

Create a new quota

Parameters
  • name (str) – Name for the new quota. This must be unique within a Galaxy instance.

  • description (str) – Quota description

  • amount (str) – Quota size (E.g. 10000MB, 99 gb, 0.2T, unlimited)

  • operation (str) – One of (+, -, =)

  • default (str) – Whether or not this is a default quota. Valid values are no, unregistered, registered. None is equivalent to no.

  • in_users (list of str) – A list of user IDs or user emails.

  • in_groups (list of str) – A list of group IDs or names.

Return type

dict

Returns

A description of quota. For example:

{'url': '/galaxy/api/quotas/386f14984287a0f7',
 'model_class': 'Quota',
 'message': "Quota 'Testing' has been created with 1 associated users and 0 associated groups.",
 'id': '386f14984287a0f7',
 'name': 'Testing'}

delete_quota(quota_id)[source]

Delete a quota

Before a quota can be deleted, the quota must not be a default quota.

Parameters

quota_id (str) – Encoded quota ID.

Return type

str

Returns

A description of the changes, mentioning the deleted quota. For example:

"Deleted 1 quotas: Testing-B"

get_quotas(deleted=False)[source]

Get a list of quotas

Parameters

deleted (bool) – Only return quota(s) that have been deleted

Return type

list

Returns

A list of dicts with details on individual quotas. For example:

[{'id': '0604c8a56abe9a50',
  'model_class': 'Quota',
  'name': 'test ',
  'url': '/api/quotas/0604c8a56abe9a50'},
 {'id': '1ee267091d0190af',
  'model_class': 'Quota',
  'name': 'workshop',
  'url': '/api/quotas/1ee267091d0190af'}]

show_quota(quota_id, deleted=False)[source]

Display information on a quota

Parameters
  • quota_id (str) – Encoded quota ID

  • deleted (bool) – Search for quota in list of ones already marked as deleted

Return type

dict

Returns

A description of quota. For example:

{'bytes': 107374182400,
 'default': [],
 'description': 'just testing',
 'display_amount': '100.0 GB',
 'groups': [],
 'id': '0604c8a56abe9a50',
 'model_class': 'Quota',
 'name': 'test ',
 'operation': '=',
 'users': []}

undelete_quota(quota_id)[source]

Undelete a quota

Parameters

quota_id (str) – Encoded quota ID.

Return type

str

Returns

A description of the changes, mentioning the undeleted quota. For example:

"Undeleted 1 quotas: Testing-B"

update_quota(quota_id, name=None, description=None, amount=None, operation=None, default='no', in_users=[], in_groups=[])[source]

Update an existing quota

Parameters
  • quota_id (str) – Encoded quota ID

  • name (str) – Name for the new quota. This must be unique within a Galaxy instance.

  • description (str) – Quota description. If you supply this parameter, but not the name, an error will be thrown.

  • amount (str) – Quota size (E.g. 10000MB, 99 gb, 0.2T, unlimited)

  • operation (str) – One of (+, -, =). If you wish to change this value, you must also provide the amount, otherwise it will not take effect.

  • default (str) – Whether or not this is a default quota. Valid values are no, unregistered, registered. Calling this method with default="no" on a non-default quota will throw an error. Not passing this parameter is equivalent to passing no.

  • in_users (list of str) – A list of user IDs or user emails.

  • in_groups (list of str) – A list of group IDs or names.

Return type

str

Returns

A semicolon separated list of changes to the quota. For example:

"Quota 'Testing-A' has been renamed to 'Testing-B'; Quota 'Testing-e' is now '-100.0 GB'; Quota 'Testing-B' is now the default for unregistered users"


Roles

Contains possible interactions with the Galaxy Roles

class bioblend.galaxy.roles.RolesClient(galaxy_instance)[source]

A generic Client interface defining the common fields.

All clients must define the following field (which will be used as part of the URL composition (e.g., http://<galaxy_instance>/api/libraries): self.module = 'workflows' | 'libraries' | 'histories' | ...

create_role(role_name, description, user_ids=[], group_ids=[])[source]

Create a new role.

Parameters
  • role_name (str) – A name for the new role

  • description (str) – Description for the new role

  • user_ids (list) – A list of encoded user IDs to add to the new role

  • group_ids (list) – A list of encoded group IDs to add to the new role

Return type

list

Returns

A (size 1) list with newly created role details, like:

[{'description': 'desc',
  'url': '/api/roles/ebfb8f50c6abde6d',
  'model_class': 'Role',
  'type': 'admin',
  'id': 'ebfb8f50c6abde6d',
  'name': 'Foo'}]

get_roles()[source]

Displays a collection (list) of roles.

Return type

list

Returns

A list of dicts with details on individual roles. For example:

[{"id": "f2db41e1fa331b3e",
  "model_class": "Role",
  "name": "Foo",
  "url": "/api/roles/f2db41e1fa331b3e"},
 {"id": "f597429621d6eb2b",
  "model_class": "Role",
  "name": "Bar",
  "url": "/api/roles/f597429621d6eb2b"}]

show_role(role_id)[source]

Display information on a single role

Parameters

role_id (str) – Encoded role ID

Return type

dict

Returns

A description of role For example:

{"description": "Private Role for Foo",
 "id": "f2db41e1fa331b3e",
 "model_class": "Role",
 "name": "Foo",
 "type": "private",
 "url": "/api/roles/f2db41e1fa331b3e"}


Tools

Contains possible interaction dealing with Galaxy tools.

class bioblend.galaxy.tools.ToolClient(galaxy_instance)[source]

A generic Client interface defining the common fields.

All clients must define the following field (which will be used as part of the URL composition (e.g., http://<galaxy_instance>/api/libraries): self.module = 'workflows' | 'libraries' | 'histories' | ...

get_tool_panel()[source]

Get a list of available tool elements in Galaxy’s configured toolbox.

Return type

list

Returns

List containing tools (if not in sections) or tool sections with nested tool descriptions.

See also

bioblend.galaxy.toolshed.get_repositories()

get_tools(tool_id=None, name=None, trackster=None)[source]

Get all tools or filter the specific one(s) via the provided name or tool_id. Provide only one argument, name or tool_id, but not both.

If name is set and multiple names match the given name, all the tools matching the argument will be returned.

Parameters
  • tool_id (str) – id of the requested tool

  • name (str) – name of the requested tool(s)

  • trackster (bool) – whether to return only tools that are compatible with Trackster

Return type

list

Returns

List of tool descriptions.

See also

bioblend.galaxy.toolshed.get_repositories()

install_dependencies(tool_id)[source]

Install dependencies for a given tool via a resolver. This works only for Conda currently. This functionality is available only to Galaxy admins.

Parameters

tool_id (str) – id of the requested tool

Return type

dict

Returns

Tool requirement status

paste_content(content, history_id, **kwds)[source]

Upload a string to a new dataset in the history specified by history_id.

Parameters
  • content (str) – content of the new dataset to upload or a list of URLs (one per line) to upload

  • history_id (str) – id of the history where to upload the content

Return type

dict

Returns

Information about the created upload job

See upload_file() for the optional parameters.

put_url(content, history_id, **kwds)

Upload a string to a new dataset in the history specified by history_id.

Parameters
  • content (str) – content of the new dataset to upload or a list of URLs (one per line) to upload

  • history_id (str) – id of the history where to upload the content

Return type

dict

Returns

Information about the created upload job

See upload_file() for the optional parameters.

run_tool(history_id, tool_id, tool_inputs)[source]

Runs tool specified by tool_id in history indicated by history_id with inputs from dict tool_inputs.

Parameters
  • history_id (str) – encoded ID of the history in which to run the tool

  • tool_id (str) – ID of the tool to be run

  • tool_inputs (dict) – dictionary of input datasets and parameters for the tool (see below)

Return type

dict

Returns

Information about outputs and job For example:

{'implicit_collections': [],
 'jobs': [{'create_time': '2019-05-08T12:26:16.067372',
           'exit_code': None,
           'id': '7dd125b61b35d782',
           'model_class': 'Job',
           'state': 'new',
           'tool_id': 'cut1',
           'update_time': '2019-05-08T12:26:16.067389'}],
 'output_collections': [],
 'outputs': [{'create_time': '2019-05-08T12:26:15.997739',
              'data_type': 'galaxy.datatypes.tabular.Tabular',
              'deleted': False,
              'file_ext': 'tabular',
              'file_size': 0,
              'genome_build': '?',
              'hda_ldda': 'hda',
              'hid': 42,
              'history_content_type': 'dataset',
              'history_id': 'df8fe5ddadbf3ab1',
              'id': 'aeb65580396167f3',
              'metadata_column_names': None,
              'metadata_column_types': None,
              'metadata_columns': None,
              'metadata_comment_lines': None,
              'metadata_data_lines': None,
              'metadata_dbkey': '?',
              'metadata_delimiter': '       ',
              'misc_blurb': 'queued',
              'misc_info': None,
              'model_class': 'HistoryDatasetAssociation',
              'name': 'Cut on data 1',
              'output_name': 'out_file1',
              'peek': None,
              'purged': False,
              'state': 'new',
              'tags': [],
              'update_time': '2019-05-08T12:26:16.069798',
              'uuid': 'd91d10af-7546-45be-baa9-902010661466',
              'visible': True}]}

The tool_inputs dict should contain input datasets and parameters in the (largely undocumented) format used by the Galaxy API. Some examples can be found in Galaxy’s API test suite.

show_tool(tool_id, io_details=False, link_details=False)[source]

Get details of a given tool.

Parameters
  • tool_id (str) – id of the requested tool

  • io_details (bool) – whether to get also input and output details

  • link_details (bool) – whether to get also link details

Return type

dict

Returns

Information about the tool’s interface

upload_file(path, history_id, **keywords)[source]

Upload the file specified by path to the history specified by history_id.

Parameters
  • path (str) – path of the file to upload

  • history_id (str) – id of the history where to upload the file

  • file_name (str) – (optional) name of the new history dataset

  • file_type (str) – (optional) Galaxy datatype for the new dataset, default is auto

  • dbkey (str) – (optional) genome dbkey

  • to_posix_lines (bool) – if True (the default), convert universal line endings to POSIX line endings. Set to False when uploading a gzip, bz2 or zip archive containing a binary file

  • space_to_tab (bool) – whether to convert spaces to tabs. Default is False. Applicable only if to_posix_lines is True

Return type

dict

Returns

Information about the created upload job

upload_from_ftp(path, history_id, **keywords)[source]

Upload the file specified by path from the user’s FTP directory to the history specified by history_id.

Parameters
  • path (str) – path of the file in the user’s FTP directory

  • history_id (str) – id of the history where to upload the file

See upload_file() for the optional parameters.

Return type

dict

Returns

Information about the created upload job


Tool data tables

Contains possible interactions with the Galaxy Tool data tables

class bioblend.galaxy.tool_data.ToolDataClient(galaxy_instance)[source]

A generic Client interface defining the common fields.

All clients must define the following field (which will be used as part of the URL composition (e.g., http://<galaxy_instance>/api/libraries): self.module = 'workflows' | 'libraries' | 'histories' | ...

delete_data_table(data_table_id, values)[source]

Delete an item from a data table.

Parameters
  • data_table_id (str) – ID of the data table

  • values (str) – a “|” separated list of column contents, there must be a value for all the columns of the data table

Return type

dict

Returns

Remaining contents of the given data table

get_data_tables()[source]

Get the list of all data tables.

Return type

list

Returns

A list of dicts with details on individual data tables. For example:

[{"model_class": "TabularToolDataTable", "name": "fasta_indexes"},
 {"model_class": "TabularToolDataTable", "name": "bwa_indexes"}]

reload_data_table(data_table_id)[source]

Reload a data table.

Parameters

data_table_id (str) – ID of the data table

Return type

dict

Returns

A description of the given data table and its content. For example:

{'columns': ['value', 'dbkey', 'name', 'path'],
 'fields': [['test id',
             'test',
             'test name',
             '/opt/galaxy-dist/tool-data/test/seq/test id.fa']],
 'model_class': 'TabularToolDataTable',
 'name': 'all_fasta'}

show_data_table(data_table_id)[source]

Get details of a given data table.

Parameters

data_table_id (str) – ID of the data table

Return type

dict

Returns

A description of the given data table and its content. For example:

{'columns': ['value', 'dbkey', 'name', 'path'],
 'fields': [['test id',
             'test',
             'test name',
             '/opt/galaxy-dist/tool-data/test/seq/test id.fa']],
 'model_class': 'TabularToolDataTable',
 'name': 'all_fasta'}


ToolShed

Interaction with a Galaxy Tool Shed.

class bioblend.galaxy.toolshed.ToolShedClient(galaxy_instance)[source]

A generic Client interface defining the common fields.

All clients must define the following field (which will be used as part of the URL composition (e.g., http://<galaxy_instance>/api/libraries): self.module = 'workflows' | 'libraries' | 'histories' | ...

get_repositories()[source]

Get the list of all installed Tool Shed repositories on this Galaxy instance.

Return type

list

Returns

a list of dictionaries containing information about repositories present in the Tool Shed. For example:

[{'changeset_revision': '4afe13ac23b6',
  'deleted': False,
  'dist_to_shed': False,
  'error_message': '',
  'name': 'velvet_toolsuite',
  'owner': 'edward-kirton',
  'status': 'Installed'}]

Changed in version 0.4.1: Changed method name from get_tools to get_repositories to better align with the Tool Shed concepts

See also

bioblend.galaxy.tools.get_tool_panel()

install_repository_revision(tool_shed_url, name, owner, changeset_revision, install_tool_dependencies=False, install_repository_dependencies=False, install_resolver_dependencies=False, tool_panel_section_id=None, new_tool_panel_section_label=None)[source]

Install a specified repository revision from a specified Tool Shed into this Galaxy instance. This example demonstrates installation of a repository that contains valid tools, loading them into a section of the Galaxy tool panel or creating a new tool panel section. You can choose if tool dependencies or repository dependencies should be installed through the Tool Shed, (use install_tool_dependencies or install_repository_dependencies) or through a resolver that supports installing dependencies (use install_resolver_dependencies). Note that any combination of the three dependency resolving variables is valid.

Installing the repository into an existing tool panel section requires the tool panel config file (e.g., tool_conf.xml, shed_tool_conf.xml, etc) to contain the given tool panel section:

<section id=”from_test_tool_shed” name=”From Test Tool Shed” version=”“> </section>

Parameters
  • tool_shed_url (str) – URL of the Tool Shed from which the repository should be installed from (e.g., https://testtoolshed.g2.bx.psu.edu)

  • name (str) – The name of the repository that should be installed

  • owner (str) – The name of the repository owner

  • changeset_revision (str) – The revision of the repository to be installed

  • install_tool_dependencies (bool) – Whether or not to automatically handle tool dependencies (see https://galaxyproject.org/toolshed/tool-dependency-recipes/ for more details)

  • install_repository_dependencies (bool) – Whether or not to automatically handle repository dependencies (see https://galaxyproject.org/toolshed/defining-repository-dependencies/ for more details)

  • install_resolver_dependencies (bool) – Whether or not to automatically install resolver dependencies (e.g. conda).

  • tool_panel_section_id (str) – The ID of the Galaxy tool panel section where the tool should be insterted under. Note that you should specify either this parameter or the new_tool_panel_section_label. If both are specified, this one will take precedence.

  • new_tool_panel_section_label (str) – The name of a Galaxy tool panel section that should be created and the repository installed into.

show_repository(toolShed_id)[source]

Get details of a given Tool Shed repository as it is installed on this Galaxy instance.

Parameters

toolShed_id (str) – Encoded toolShed ID

Return type

dict

Returns

Information about the tool For example:

{'changeset_revision': 'b17455fb6222',
 'ctx_rev': '8',
 'owner': 'aaron',
 'status': 'Installed',
 'url': '/api/tool_shed_repositories/82de4a4c7135b20a'}

Changed in version 0.4.1: Changed method name from show_tool to show_repository to better align with the Tool Shed concepts

uninstall_repository_revision(name, owner, changeset_revision, tool_shed_url, remove_from_disk=True)[source]

Uninstalls a specified repository revision from this Galaxy instance.

Parameters
  • name (str) – The name of the repository

  • owner (str) – The owner of the repository

  • changeset_revision (str) – The revision of the repository to uninstall

  • tool_shed_url (str) – URL of the Tool Shed from which the repository was installed from (e.g., https://testtoolshed.g2.bx.psu.edu)

  • remove_from_disk (bool) – whether to also remove the repository from disk (the default) or only deactivate it

Return type

dict

Returns

If successful, a dictionary with a message noting the removal


Users

Contains possible interaction dealing with Galaxy users.

Most of these methods must be executed by a registered Galaxy admin user.

class bioblend.galaxy.users.UserClient(galaxy_instance)[source]

A generic Client interface defining the common fields.

All clients must define the following field (which will be used as part of the URL composition (e.g., http://<galaxy_instance>/api/libraries): self.module = 'workflows' | 'libraries' | 'histories' | ...

create_local_user(username, user_email, password)[source]

Create a new Galaxy local user.

Note

For this method to work, the Galaxy instance must have the allow_user_creation option set to true and use_remote_user option set to false in the config/galaxy.yml configuration file.

Parameters
  • username (str) – username of the user to be created

  • user_email (str) – email of the user to be created

  • password (str) – password of the user to be created

Return type

dict

Returns

a dictionary containing information about the created user

create_remote_user(user_email)[source]

Create a new Galaxy remote user.

Note

For this method to work, the Galaxy instance must have the allow_user_creation and use_remote_user options set to true in the config/galaxy.yml configuration file. Also note that setting use_remote_user will require an upstream authentication proxy server; however, if you do not have one, access to Galaxy via a browser will not be possible.

Parameters

user_email (str) – email of the user to be created

Return type

dict

Returns

a dictionary containing information about the created user

create_user_apikey(user_id)[source]

Create a new API key for a given user.

Parameters

user_id (str) – encoded user ID

Return type

str

Returns

the API key for the user

delete_user(user_id, purge=False)[source]

Delete a user.

Note

For this method to work, the Galaxy instance must have the allow_user_deletion option set to true in the config/galaxy.yml configuration file.

Parameters
  • user_id (str) – encoded user ID

  • purge (bool) – if True, also purge (permanently delete) the history

Return type

dict

Returns

a dictionary containing information about the deleted user

get_current_user()[source]

Display information about the user associated with this Galaxy connection.

Return type

dict

Returns

a dictionary containing information about the current user

get_user_apikey(user_id)[source]

Get the current API key for a given user.

Parameters

user_id (str) – encoded user ID

Return type

str

Returns

the API key for the user

get_users(deleted=False, f_email=None, f_name=None, f_any=None)[source]

Get a list of all registered users. If deleted is set to True, get a list of deleted users.

Parameters
  • deleted (bool) – Whether to include deleted users

  • f_email (str) – filter for user emails. The filter will be active for non-admin users only if the Galaxy instance has the expose_user_email option set to true in the config/galaxy.yml configuration file.

  • f_name (str) – filter for user names. The filter will be active for non-admin users only if the Galaxy instance has the expose_user_name option set to true in the config/galaxy.yml configuration file.

  • f_any (str) – filter for user email or name. Each filter will be active for non-admin users only if the Galaxy instance has the corresponding expose_user_* option set to true in the config/galaxy.yml configuration file.

Return type

list

Returns

a list of dicts with user details. For example:

[{'email': 'a_user@example.com',
  'id': 'dda47097d9189f15',
  'url': '/api/users/dda47097d9189f15'}]

show_user(user_id, deleted=False)[source]

Display information about a user.

Parameters
  • user_id (str) – encoded user ID

  • deleted (bool) – whether to return results for a deleted user

Return type

dict

Returns

a dictionary containing information about the user

update_user(user_id, **kwds)[source]

Update user information. Some of the attributes that can be modified are documented below.

Parameters
  • user_id (str) – encoded user ID

  • username (str) – Replace user name with the given string

  • email (str) – Replace user email with the given string

Return type

dict

Returns

details of the updated user


Visual

Contains possible interactions with the Galaxy visualization

class bioblend.galaxy.visual.VisualClient(galaxy_instance)[source]

A generic Client interface defining the common fields.

All clients must define the following field (which will be used as part of the URL composition (e.g., http://<galaxy_instance>/api/libraries): self.module = 'workflows' | 'libraries' | 'histories' | ...

get_visualizations()[source]

Get the list of all visualizations.

Return type

list

Returns

A list of dicts with details on individual visualizations. For example:

[{'dbkey': 'eschColi_K12',
  'id': 'df1c7c96fc427c2d',
  'title': 'AVTest1',
  'type': 'trackster',
  'url': '/api/visualizations/df1c7c96fc427c2d'},
 {'dbkey': 'mm9',
  'id': 'a669f50f8bf55b02',
  'title': 'Bam to Bigwig',
  'type': 'trackster',
  'url': '/api/visualizations/a669f50f8bf55b02'}]

show_visualization(visual_id)[source]

Get details of a given visualization.

Parameters

visual_id (str) – Encoded visualization ID

Return type

dict

Returns

A description of the given visualization. For example:

{'annotation': None,
 'dbkey': 'mm9',
 'id': '18df9134ea75e49c',
 'latest_revision': {  ... },
 'model_class': 'Visualization',
 'revisions': ['aa90649bb3ec7dcb', '20622bc6249c0c71'],
 'slug': 'visualization-for-grant-1',
 'title': 'Visualization For Grant',
 'type': 'trackster',
 'url': '/u/azaron/v/visualization-for-grant-1',
 'user_id': '21e4aed91386ca8b'}


Workflows

Contains possible interactions with the Galaxy Workflows

class bioblend.galaxy.workflows.WorkflowClient(galaxy_instance)[source]

A generic Client interface defining the common fields.

All clients must define the following field (which will be used as part of the URL composition (e.g., http://<galaxy_instance>/api/libraries): self.module = 'workflows' | 'libraries' | 'histories' | ...

cancel_invocation(workflow_id, invocation_id)[source]

Cancel the scheduling of a workflow.

Parameters
  • workflow_id (str) – Encoded workflow ID

  • invocation_id (str) – Encoded workflow invocation ID

Return type

dict

Returns

The workflow invocation being cancelled

delete_workflow(workflow_id)[source]

Delete a workflow identified by workflow_id.

Parameters

workflow_id (str) – Encoded workflow ID

Return type

str

Returns

A message about the deletion

Warning

Deleting a workflow is irreversible - all workflow data will be permanently deleted.

export_workflow_dict(workflow_id, version=None)[source]

Exports a workflow.

Parameters
  • workflow_id (str) – Encoded workflow ID

  • version (int) – Workflow version to export

Return type

dict

Returns

Dictionary representing the requested workflow

export_workflow_json(workflow_id)[source]

Deprecated since version 0.9.0: Use export_workflow_dict() instead.

export_workflow_to_local_path(workflow_id, file_local_path, use_default_filename=True)[source]

Exports a workflow in JSON format to a given local path.

Parameters
  • workflow_id (str) – Encoded workflow ID

  • file_local_path (str) – Local path to which the exported file will be saved. (Should not contain filename if use_default_name=True)

  • use_default_filename (bool) – If the use_default_name parameter is True, the exported file will be saved as file_local_path/Galaxy-Workflow-%s.ga, where %s is the workflow name. If use_default_name is False, file_local_path is assumed to contain the full file path including filename.

Return type

None

Returns

None

get_invocations(workflow_id)[source]

Get a list containing all the workflow invocations corresponding to the specified workflow.

Parameters

workflow_id (str) – Encoded workflow ID

Return type

list

Returns

A list of workflow invocations. For example:

[{'history_id': '2f94e8ae9edff68a',
  'id': 'df7a1f0c02a5b08e',
  'model_class': 'WorkflowInvocation',
  'state': 'new',
  'update_time': '2015-10-31T22:00:22',
  'uuid': 'c8aa2b1c-801a-11e5-a9e5-8ca98228593c',
  'workflow_id': '03501d7626bd192f'}]

get_workflow_inputs(workflow_id, label)[source]

Get a list of workflow input IDs that match the given label. If no input matches the given label, an empty list is returned.

Parameters
  • workflow_id (str) – Encoded workflow ID

  • label (str) – label to filter workflow inputs on

Return type

list

Returns

list of workflow inputs matching the label query

get_workflows(workflow_id=None, name=None, published=False)[source]

Get all workflows or filter the specific one(s) via the provided name or workflow_id. Provide only one argument, name or workflow_id, but not both.

Parameters
  • workflow_id (str) – Encoded workflow ID (incompatible with name)

  • name (str) – Filter by name of workflow (incompatible with workflow_id). If multiple names match the given name, all the workflows matching the argument will be returned.

  • published (bool) – if True, return also published workflows

Return type

list

Returns

A list of workflow dicts. For example:

[{'id': '92c56938c2f9b315',
  'name': 'Simple',
  'url': '/api/workflows/92c56938c2f9b315'}]

import_shared_workflow(workflow_id)[source]

Imports a new workflow from the shared published workflows.

Parameters

workflow_id (str) – Encoded workflow ID

Return type

dict

Returns

A description of the workflow. For example:

{'id': 'ee0e2b4b696d9092',
 'model_class': 'StoredWorkflow',
 'name': 'Super workflow that solves everything!',
 'published': False,
 'tags': [],
 'url': '/api/workflows/ee0e2b4b696d9092'}

import_workflow_dict(workflow_dict, publish=False)[source]

Imports a new workflow given a dictionary representing a previously exported workflow.

Parameters
  • workflow_dict (dict) – dictionary representing the workflow to be imported

  • publish (bool) – if True the uploaded workflow will be published; otherwise it will be visible only by the user which uploads it (default)

Return type

dict

Returns

Information about the imported workflow. For example:

{'name': 'Training: 16S rRNA sequencing with mothur: main tutorial',
 'tags': [],
 'deleted': false,
 'latest_workflow_uuid': '368c6165-ccbe-4945-8a3c-d27982206d66',
 'url': '/api/workflows/94bac0a90086bdcf',
 'number_of_steps': 44,
 'published': false,
 'owner': 'jane-doe',
 'model_class': 'StoredWorkflow',
 'id': '94bac0a90086bdcf'}

import_workflow_from_local_path(file_local_path, publish=False)[source]

Imports a new workflow given the path to a file containing a previously exported workflow.

Parameters
  • file_local_path (str) – File to upload to the server for new workflow

  • publish (bool) – if True the uploaded workflow will be published; otherwise it will be visible only by the user which uploads it (default)

Return type

dict

Returns

Information about the imported workflow. For example:

{'name': 'Training: 16S rRNA sequencing with mothur: main tutorial',
 'tags': [],
 'deleted': false,
 'latest_workflow_uuid': '368c6165-ccbe-4945-8a3c-d27982206d66',
 'url': '/api/workflows/94bac0a90086bdcf',
 'number_of_steps': 44,
 'published': false,
 'owner': 'jane-doe',
 'model_class': 'StoredWorkflow',
 'id': '94bac0a90086bdcf'}

import_workflow_json(workflow_json)[source]

Deprecated since version 0.9.0: Use import_workflow_dict() instead.

Parameters

workflow_json (dict) – dictionary representing the workflow to be imported

invoke_workflow(workflow_id, inputs=None, params=None, history_id=None, history_name=None, import_inputs_to_history=False, replacement_params=None, allow_tool_state_corrections=None, inputs_by=None)[source]

Invoke the workflow identified by workflow_id. This will cause a workflow to be scheduled and return an object describing the workflow invocation.

Parameters
  • workflow_id (str) – Encoded workflow ID

  • inputs (dict) –

    A mapping of workflow inputs to datasets and dataset collections. The datasets source can be a LibraryDatasetDatasetAssociation (ldda), LibraryDataset (ld), HistoryDatasetAssociation (hda), or HistoryDatasetCollectionAssociation (hdca).

    The map must be in the following format: {'<input_index>': {'id': <encoded dataset ID>, 'src': '[ldda, ld, hda, hdca]'}} (e.g. {'2': {'id': '29beef4fadeed09f', 'src': 'hda'}})

    This map may also be indexed by the UUIDs of the workflow steps, as indicated by the uuid property of steps returned from the Galaxy API. Alternatively workflow steps may be addressed by the label that can be set in the workflow editor. If using uuid or label you need to also set the inputs_by parameter to step_uuid or name.

  • params (dict) – A mapping of non-datasets tool parameters (see below)

  • history_id (str) – The encoded history ID where to store the workflow output. Alternatively, history_name may be specified to create a new history.

  • history_name (str) – Create a new history with the given name to store the workflow output. If both history_id and history_name are provided, history_name is ignored. If neither is specified, a new ‘Unnamed history’ is created.

  • import_inputs_to_history (bool) – If True, used workflow inputs will be imported into the history. If False, only workflow outputs will be visible in the given history.

  • allow_tool_state_corrections (bool) – If True, allow Galaxy to fill in missing tool state when running workflows. This may be useful for workflows using tools that have changed over time or for workflows built outside of Galaxy with only a subset of inputs defined.

  • replacement_params (dict) – pattern-based replacements for post-job actions (see below)

  • inputs_by (str) – Determines how inputs are referenced. Can be “step_index|step_uuid” (default), “step_index”, “step_id”, “step_uuid”, or “name”.

Return type

dict

Returns

A dict containing the workflow invocation describing the scheduling of the workflow. For example:

{'history_id': '2f94e8ae9edff68a',
 'id': 'df7a1f0c02a5b08e',
 'inputs': {'0': {'id': 'a7db2fac67043c7e',
                  'src': 'hda',
                  'uuid': '7932ffe0-2340-4952-8857-dbaa50f1f46a'}},
 'model_class': 'WorkflowInvocation',
 'state': 'ready',
 'steps': [{'action': None,
            'id': 'd413a19dec13d11e',
            'job_id': None,
            'model_class': 'WorkflowInvocationStep',
            'order_index': 0,
            'state': None,
            'update_time': '2015-10-31T22:00:26',
            'workflow_step_id': 'cbbbf59e8f08c98c',
            'workflow_step_label': None,
            'workflow_step_uuid': 'b81250fd-3278-4e6a-b269-56a1f01ef485'},
           {'action': None,
            'id': '2f94e8ae9edff68a',
            'job_id': 'e89067bb68bee7a0',
            'model_class': 'WorkflowInvocationStep',
            'order_index': 1,
            'state': 'new',
            'update_time': '2015-10-31T22:00:26',
            'workflow_step_id': '964b37715ec9bd22',
            'workflow_step_label': None,
            'workflow_step_uuid': 'e62440b8-e911-408b-b124-e05435d3125e'}],
 'update_time': '2015-10-31T22:00:26',
 'uuid': 'c8aa2b1c-801a-11e5-a9e5-8ca98228593c',
 'workflow_id': '03501d7626bd192f'}

The params dict should be specified as follows:

{STEP_ID: PARAM_DICT, ...}

where PARAM_DICT is:

{PARAM_NAME: VALUE, ...}

For backwards compatibility, the following (deprecated) format is also supported for params:

{TOOL_ID: PARAM_DICT, ...}

in which case PARAM_DICT affects all steps with the given tool id. If both by-tool-id and by-step-id specifications are used, the latter takes precedence.

Finally (again, for backwards compatibility), PARAM_DICT can also be specified as:

{'param': PARAM_NAME, 'value': VALUE}

Note that this format allows only one parameter to be set per step.

For a repeat parameter, the names of the contained parameters needs to be specified as <repeat name>_<repeat index>|<param name>, with the repeat index starting at 0. For example, if the tool XML contains:

<repeat name="cutoff" title="Parameters used to filter cells" min="1">
    <param name="name" type="text" value="n_genes" label="Name of param...">
        <option value="n_genes">n_genes</option>
        <option value="n_counts">n_counts</option>
    </param>
    <param name="min" type="float" min="0" value="0" label="Min value"/>
</repeat>

then the PARAM_DICT should be something like:

{...
 "cutoff_0|name": "n_genes",
 "cutoff_0|min": "2",
 "cutoff_1|name": "n_counts",
 "cutoff_1|min": "4",
 ...}

At the time of this writing, it is not possible to change the number of times the contained parameters are repeated. Therefore, the parameter indexes can go from 0 to n-1, where n is the number of times the repeated element was added when the workflow was saved in the Galaxy UI.

The replacement_params dict should map parameter names in post-job actions (PJAs) to their runtime values. For instance, if the final step has a PJA like the following:

{'RenameDatasetActionout_file1': {'action_arguments': {'newname': '${output}'},
                                  'action_type': 'RenameDatasetAction',
                                  'output_name': 'out_file1'}}

then the following renames the output dataset to ‘foo’:

replacement_params = {'output': 'foo'}

see also this email thread.

Warning

Historically, the run_workflow method consumed a dataset_map data structure that was indexed by unencoded workflow step IDs. These IDs would not be stable across Galaxy instances. The new inputs property is instead indexed by either the order_index property (which is stable across workflow imports) or the step UUID which is also stable.

run_invocation_step_action(workflow_id, invocation_id, step_id, action)[source]

Execute an action for an active workflow invocation step. The nature of this action and what is expected will vary based on the the type of workflow step (the only currently valid action is True/False for pause steps).

Parameters
  • workflow_id (str) – Encoded workflow ID

  • invocation_id (str) – Encoded workflow invocation ID

  • step_id (str) – Encoded workflow invocation step ID

  • action (object) – Action to use when updating state, semantics depends on step type.

Return type

dict

Returns

Representation of the workflow invocation step

run_workflow(workflow_id, dataset_map=None, params=None, history_id=None, history_name=None, import_inputs_to_history=False, replacement_params=None)[source]

Run the workflow identified by workflow_id.

Deprecated since version 0.7.0: Use invoke_workflow() instead.

Parameters
  • workflow_id (str) – Encoded workflow ID

  • dataset_map (dict) – A mapping of workflow inputs to datasets. The datasets source can be a LibraryDatasetDatasetAssociation (ldda), LibraryDataset (ld), or HistoryDatasetAssociation (hda). The map must be in the following format: {'<input>': {'id': <encoded dataset ID>, 'src': '[ldda, ld, hda]'}} (e.g. {'23': {'id': '29beef4fadeed09f', 'src': 'ld'}})

  • params (dict) – A mapping of non-datasets tool parameters (see below)

  • history_id (str) – The encoded history ID where to store the workflow output. Alternatively, history_name may be specified to create a new history.

  • history_name (str) – Create a new history with the given name to store the workflow output. If both history_id and history_name are provided, history_name is ignored. If neither is specified, a new ‘Unnamed history’ is created.

  • import_inputs_to_history (bool) – If True, used workflow inputs will be imported into the history. If False, only workflow outputs will be visible in the given history.

  • replacement_params (dict) – pattern-based replacements for post-job actions (see below)

Return type

dict

Returns

A dict containing the history ID where the outputs are placed as well as output dataset IDs. For example:

{'history': '64177123325c9cfd',
 'outputs': ['aa4d3084af404259']}

The params dict should be specified as follows:

{STEP_ID: PARAM_DICT, ...}

where PARAM_DICT is:

{PARAM_NAME: VALUE, ...}

For backwards compatibility, the following (deprecated) format is also supported for params:

{TOOL_ID: PARAM_DICT, ...}

in which case PARAM_DICT affects all steps with the given tool id. If both by-tool-id and by-step-id specifications are used, the latter takes precedence.

Finally (again, for backwards compatibility), PARAM_DICT can also be specified as:

{'param': PARAM_NAME, 'value': VALUE}

Note that this format allows only one parameter to be set per step.

The replacement_params dict should map parameter names in post-job actions (PJAs) to their runtime values. For instance, if the final step has a PJA like the following:

{'RenameDatasetActionout_file1': {'action_arguments': {'newname': '${output}'},
                                  'action_type': 'RenameDatasetAction',
                                  'output_name': 'out_file1'}}

then the following renames the output dataset to ‘foo’:

replacement_params = {'output': 'foo'}

see also this email thread.

Warning

This method waits for the whole workflow to be scheduled before returning and does not scale to large workflows as a result. This method has therefore been deprecated in favor of invoke_workflow(), which also features improved default behavior for dataset input handling.

show_invocation(workflow_id, invocation_id)[source]

Get a workflow invocation object representing the scheduling of a workflow. This object may be sparse at first (missing inputs and invocation steps) and will become more populated as the workflow is actually scheduled.

Parameters
  • workflow_id (str) – Encoded workflow ID

  • invocation_id (str) – Encoded workflow invocation ID

Return type

dict

Returns

The workflow invocation. For example:

{'history_id': '2f94e8ae9edff68a',
 'id': 'df7a1f0c02a5b08e',
 'inputs': {'0': {'id': 'a7db2fac67043c7e',
                  'src': 'hda',
                  'uuid': '7932ffe0-2340-4952-8857-dbaa50f1f46a'}},
 'model_class': 'WorkflowInvocation',
 'state': 'ready',
 'steps': [{'action': None,
            'id': 'd413a19dec13d11e',
            'job_id': None,
            'model_class': 'WorkflowInvocationStep',
            'order_index': 0,
            'state': None,
            'update_time': '2015-10-31T22:00:26',
            'workflow_step_id': 'cbbbf59e8f08c98c',
            'workflow_step_label': None,
            'workflow_step_uuid': 'b81250fd-3278-4e6a-b269-56a1f01ef485'},
           {'action': None,
            'id': '2f94e8ae9edff68a',
            'job_id': 'e89067bb68bee7a0',
            'model_class': 'WorkflowInvocationStep',
            'order_index': 1,
            'state': 'new',
            'update_time': '2015-10-31T22:00:26',
            'workflow_step_id': '964b37715ec9bd22',
            'workflow_step_label': None,
            'workflow_step_uuid': 'e62440b8-e911-408b-b124-e05435d3125e'}],
 'update_time': '2015-10-31T22:00:26',
 'uuid': 'c8aa2b1c-801a-11e5-a9e5-8ca98228593c',
 'workflow_id': '03501d7626bd192f'}

show_invocation_step(workflow_id, invocation_id, step_id)[source]

See the details of a particular workflow invocation step.

Parameters
  • workflow_id (str) – Encoded workflow ID

  • invocation_id (str) – Encoded workflow invocation ID

  • step_id (str) – Encoded workflow invocation step ID

Return type

dict

Returns

The workflow invocation step. For example:

{'action': None,
 'id': '63cd3858d057a6d1',
 'job_id': None,
 'model_class': 'WorkflowInvocationStep',
 'order_index': 2,
 'state': None,
 'update_time': '2015-10-31T22:11:14',
 'workflow_step_id': '52e496b945151ee8',
 'workflow_step_label': None,
 'workflow_step_uuid': '4060554c-1dd5-4287-9040-8b4f281cf9dc'}

show_workflow(workflow_id, version=None)[source]

Display information needed to run a workflow.

Parameters
  • workflow_id (str) – Encoded workflow ID

  • version (int) – Workflow version to show

Return type

dict

Returns

A description of the workflow and its inputs. For example:

{'id': '92c56938c2f9b315',
 'inputs': {'23': {'label': 'Input Dataset', 'value': ''}},
 'name': 'Simple',
 'url': '/api/workflows/92c56938c2f9b315'}

update_workflow(workflow_id, **kwds)[source]

Update a given workflow.

Parameters
  • workflow_id (str) – Encoded workflow ID

  • workflow (dict) – dictionary representing the workflow to be updated

  • name (str) – New name of the workflow

  • annotation (str) – New annotation for the workflow

  • menu_entry (bool) – Whether the workflow should appear in the user’s menu

  • tags (list of str) – Replace workflow tags with the given list

Return type

dict

Returns

Dictionary representing the updated workflow

Object-oriented Galaxy API

class bioblend.galaxy.objects.galaxy_instance.GalaxyInstance(url, api_key=None, email=None, password=None, verify=True)[source]

A representation of an instance of Galaxy, identified by a URL and a user’s API key.

Parameters
  • url (str) – a FQDN or IP for a given instance of Galaxy. For example: http://127.0.0.1:8080

  • api_key (str) – user’s API key for the given instance of Galaxy, obtained from the Galaxy web UI.

This is actually a factory class which instantiates the entity-specific clients.

Example: get a list of all histories for a user with API key ‘foo’:

from bioblend.galaxy.objects import *
gi = GalaxyInstance('http://127.0.0.1:8080', 'foo')
histories = gi.histories.list()

Client

Clients for interacting with specific Galaxy entity types.

Classes in this module should not be instantiated directly, but used via their handles in GalaxyInstance.

class bioblend.galaxy.objects.client.ObjClient(obj_gi)[source]
abstract get_previews(**kwargs)[source]

Get a list of object previews.

Previews entity summaries provided by REST collection URIs, e.g. http://host:port/api/libraries. Being the most lightweight objects associated to the various entities, these are the ones that should be used to retrieve their basic info.

Return type

list

Returns

a list of object previews

abstract list(**kwargs)[source]

Get a list of objects.

This method first gets the entity summaries, then gets the complete description for each entity with an additional GET call, so may be slow.

Return type

list

Returns

a list of objects

class bioblend.galaxy.objects.client.ObjDatasetContainerClient(obj_gi)[source]
class bioblend.galaxy.objects.client.ObjHistoryClient(obj_gi)[source]

Interacts with Galaxy histories.

create(name=None)[source]

Create a new Galaxy history, optionally setting its name.

Return type

History

Returns

the history just created

delete(id_=None, name=None, purge=False)[source]

Delete the history with the given id or name.

Note that the same name can map to multiple histories.

Parameters

purge (bool) – if True, also purge (permanently delete) the history

Note

For the purge option to work, the Galaxy instance must have the allow_user_dataset_purge option set to true in the config/galaxy.yml configuration file.

get(id_)[source]

Retrieve the history corresponding to the given id.

Return type

History

Returns

the history corresponding to id_

get_previews(name=None, deleted=False)[source]

Get a list of object previews.

Previews entity summaries provided by REST collection URIs, e.g. http://host:port/api/libraries. Being the most lightweight objects associated to the various entities, these are the ones that should be used to retrieve their basic info.

Return type

list

Returns

a list of object previews

list(name=None, deleted=False)[source]

Get histories owned by the user of this Galaxy instance.

Parameters
  • name (str) – return only histories with this name

  • deleted (bool) – if True, return histories that have been deleted

Return type

list of History

class bioblend.galaxy.objects.client.ObjJobClient(obj_gi)[source]

Interacts with Galaxy jobs.

get(id_, full_details=False)[source]

Retrieve the job corresponding to the given id.

Parameters

full_details (bool) – if True, return the complete list of details for the given job.

Return type

Job

Returns

the job corresponding to id_

get_previews()[source]

Get a list of object previews.

Previews entity summaries provided by REST collection URIs, e.g. http://host:port/api/libraries. Being the most lightweight objects associated to the various entities, these are the ones that should be used to retrieve their basic info.

Return type

list

Returns

a list of object previews

list()[source]

Get the list of jobs of the current user.

Return type

list of Job

class bioblend.galaxy.objects.client.ObjLibraryClient(obj_gi)[source]

Interacts with Galaxy libraries.

create(name, description=None, synopsis=None)[source]

Create a data library with the properties defined in the arguments.

Return type

Library

Returns

the library just created

delete(id_=None, name=None)[source]

Delete the library with the given id or name.

Note that the same name can map to multiple libraries.

Warning

Deleting a data library is irreversible - all of the data from the library will be permanently deleted.

get(id_)[source]

Retrieve the data library corresponding to the given id.

Return type

Library

Returns

the library corresponding to id_

get_previews(name=None, deleted=False)[source]

Get a list of object previews.

Previews entity summaries provided by REST collection URIs, e.g. http://host:port/api/libraries. Being the most lightweight objects associated to the various entities, these are the ones that should be used to retrieve their basic info.

Return type

list

Returns

a list of object previews

list(name=None, deleted=False)[source]

Get libraries owned by the user of this Galaxy instance.

Parameters
  • name (str) – return only libraries with this name

  • deleted (bool) – if True, return libraries that have been deleted

Return type

list of Library

class bioblend.galaxy.objects.client.ObjToolClient(obj_gi)[source]

Interacts with Galaxy tools.

get(id_, io_details=False, link_details=False)[source]

Retrieve the tool corresponding to the given id.

Parameters
  • io_details (bool) – if True, get also input and output details

  • link_details (bool) – if True, get also link details

Return type

Tool

Returns

the tool corresponding to id_

get_previews(name=None, trackster=None)[source]

Get the list of tools installed on the Galaxy instance.

Parameters
  • name (str) – return only tools with this name

  • trackster (bool) – if True, only tools that are compatible with Trackster are returned

Return type

list of Tool

list(name=None, trackster=None)[source]

Get the list of tools installed on the Galaxy instance.

Parameters
  • name (str) – return only tools with this name

  • trackster (bool) – if True, only tools that are compatible with Trackster are returned

Return type

list of Tool

class bioblend.galaxy.objects.client.ObjWorkflowClient(obj_gi)[source]

Interacts with Galaxy workflows.

delete(id_=None, name=None)[source]

Delete the workflow with the given id or name.

Note that the same name can map to multiple workflows.

Warning

Deleting a workflow is irreversible - all of the data from the workflow will be permanently deleted.

get(id_)[source]

Retrieve the workflow corresponding to the given id.

Return type

Workflow

Returns

the workflow corresponding to id_

get_previews(name=None, published=False)[source]

Get a list of object previews.

Previews entity summaries provided by REST collection URIs, e.g. http://host:port/api/libraries. Being the most lightweight objects associated to the various entities, these are the ones that should be used to retrieve their basic info.

Return type

list

Returns

a list of object previews

import_new(src, publish=False)[source]

Imports a new workflow into Galaxy.

Parameters
  • src (dict or str) – deserialized (dictionary) or serialized (str) JSON dump of the workflow (this is normally obtained by exporting a workflow from Galaxy).

  • publish (bool) – if True the uploaded workflow will be published; otherwise it will be visible only by the user which uploads it (default).

Return type

Workflow

Returns

the workflow just imported

import_shared(id_)[source]

Imports a shared workflow to the user’s space.

Parameters

id (str) – workflow id

Return type

Workflow

Returns

the workflow just imported

list(name=None, published=False)[source]

Get workflows owned by the user of this Galaxy instance.

Parameters
  • name (str) – return only workflows with this name

  • published (bool) – if True, return also published workflows

Return type

list of Workflow

Wrappers

A basic object-oriented interface for Galaxy entities.

class bioblend.galaxy.objects.wrappers.Wrapper(wrapped, parent=None, gi=None)[source]

Abstract base class for Galaxy entity wrappers.

Wrapper instances wrap deserialized JSON dictionaries such as the ones obtained by the Galaxy web API, converting key-based access to attribute-based access (e.g., library['name'] -> library.name).

Dict keys that are converted to attributes are listed in the BASE_ATTRS class variable: this is the ‘stable’ interface. Note that the wrapped dictionary is accessible via the wrapped attribute.

Parameters
  • wrapped (dict) – JSON-serializable dictionary

  • parent (Wrapper) – the parent of this wrapper

  • gi (GalaxyInstance) – the GalaxyInstance through which we can access this wrapper

BASE_ATTRS = ('id', 'name')
clone()[source]

Return an independent copy of this wrapper.

classmethod from_json(jdef)[source]

Build a new wrapper from a JSON dump.

abstract property gi_module

The GalaxyInstance module that deals with objects of this type.

property is_mapped

True if this wrapper is mapped to an actual Galaxy entity.

property parent

The parent of this wrapper.

to_json()[source]

Return a JSON dump of this wrapper.

touch()[source]

Mark this wrapper as having been modified since its creation.

unmap()[source]

Disconnect this wrapper from Galaxy.

class bioblend.galaxy.objects.wrappers.Step(step_dict, parent)[source]

Abstract base class for workflow steps.

Steps are the main building blocks of a Galaxy workflow. A step can be: an input (type data_collection_input, data_input or parameter_input), a computational tool (type tool), a subworkflow (type subworkflow) or a pause (type pause).

Parameters
  • wrapped (dict) – JSON-serializable dictionary

  • parent (Wrapper) – the parent of this wrapper

  • gi (GalaxyInstance) – the GalaxyInstance through which we can access this wrapper

BASE_ATTRS = ('id', 'name', 'input_steps', 'tool_id', 'tool_inputs', 'tool_version', 'type')
property gi_module

The GalaxyInstance module that deals with objects of this type.

class bioblend.galaxy.objects.wrappers.Workflow(wf_dict, gi=None)[source]

Workflows represent ordered sequences of computations on Galaxy.

A workflow defines a sequence of steps that produce one or more results from an input dataset.

Parameters
  • wrapped (dict) – JSON-serializable dictionary

  • parent (Wrapper) – the parent of this wrapper

  • gi (GalaxyInstance) – the GalaxyInstance through which we can access this wrapper

BASE_ATTRS = ('id', 'name', 'deleted', 'inputs', 'published', 'steps', 'tags')
POLLING_INTERVAL = 10
convert_input_map(input_map)[source]

Convert input_map to the format required by the Galaxy web API.

Parameters

input_map (dict) – a mapping from input labels to datasets

Return type

dict

Returns

a mapping from input slot ids to dataset ids in the format required by the Galaxy web API.

property data_collection_input_ids

Return the ids of data collection input steps for this workflow.

property data_input_ids

Return the ids of data input steps for this workflow.

delete()[source]

Delete this workflow.

Warning

Deleting a workflow is irreversible - all of the data from the workflow will be permanently deleted.

export()[source]

Export a re-importable representation of the workflow.

Return type

dict

Returns

a JSON-serializable dump of the workflow

property gi_module

The GalaxyInstance module that deals with objects of this type.

property input_labels

Return the labels of this workflow’s input steps.

property is_runnable

Return True if the workflow can be run on Galaxy.

A workflow is considered runnable on a Galaxy instance if all of the tools it uses are installed in that instance.

property parameter_input_ids

Return the ids of parameter input steps for this workflow.

preview()[source]
run(input_map=None, history='', params=None, import_inputs=False, replacement_params=None, wait=False, polling_interval=10, break_on_error=True)[source]

Run the workflow in the current Galaxy instance.

Parameters
  • input_map (dict) – a mapping from workflow input labels to datasets, e.g.: dict(zip(workflow.input_labels, library.get_datasets()))

  • history (History or str) – either a valid history object (results will be stored there) or a string (a new history will be created with the given name).

  • params (dict) – a mapping of non-datasets tool parameters (see below)

  • import_inputs (bool) – If True, workflow inputs will be imported into the history; if False, only workflow outputs will be visible in the history.

  • replacement_params (dict) – pattern-based replacements for post-job actions (see the docs for invoke_workflow())

  • wait (bool) – whether to wait while the returned datasets are in a pending state

  • polling_interval (float) – polling interval in seconds

  • break_on_error (bool) – whether to break as soon as at least one of the returned datasets is in the ‘error’ state

Return type

tuple

Returns

list of output datasets, output history

The params dict should be specified as follows:

{STEP_ID: PARAM_DICT, ...}

where PARAM_DICT is:

{PARAM_NAME: VALUE, ...}

For backwards compatibility, the following (deprecated) format is also supported for params:

{TOOL_ID: PARAM_DICT, ...}

in which case PARAM_DICT affects all steps with the given tool id. If both by-tool-id and by-step-id specifications are used, the latter takes precedence.

Finally (again, for backwards compatibility), PARAM_DICT can also be specified as:

{'param': PARAM_NAME, 'value': VALUE}

Note that this format allows only one parameter to be set per step.

Example: set ‘a’ to 1 for the third workflow step:

params = {workflow.steps[2].id: {'a': 1}}

Warning

This is a blocking operation that can take a very long time. If wait is set to False, the method will return as soon as the workflow has been scheduled, otherwise it will wait until the workflow has been run. With a large number of steps, however, the delay may not be negligible even in the former case (e.g. minutes for 100 steps).

sorted_step_ids()[source]

Return a topological sort of the workflow’s DAG.

property tool_ids

Return the ids of tool steps for this workflow.

class bioblend.galaxy.objects.wrappers.ContentInfo(info_dict, gi=None)[source]

Instances of this class wrap dictionaries obtained by getting /api/{histories,libraries}/<ID>/contents from Galaxy.

Parameters
  • wrapped (dict) – JSON-serializable dictionary

  • parent (Wrapper) – the parent of this wrapper

  • gi (GalaxyInstance) – the GalaxyInstance through which we can access this wrapper

BASE_ATTRS = ('id', 'name', 'type')
class bioblend.galaxy.objects.wrappers.LibraryContentInfo(info_dict, gi=None)[source]

Instances of this class wrap dictionaries obtained by getting /api/libraries/<ID>/contents from Galaxy.

Parameters
  • wrapped (dict) – JSON-serializable dictionary

  • parent (Wrapper) – the parent of this wrapper

  • gi (GalaxyInstance) – the GalaxyInstance through which we can access this wrapper

property gi_module

The GalaxyInstance module that deals with objects of this type.

class bioblend.galaxy.objects.wrappers.HistoryContentInfo(info_dict, gi=None)[source]

Instances of this class wrap dictionaries obtained by getting /api/histories/<ID>/contents from Galaxy.

Parameters
  • wrapped (dict) – JSON-serializable dictionary

  • parent (Wrapper) – the parent of this wrapper

  • gi (GalaxyInstance) – the GalaxyInstance through which we can access this wrapper

BASE_ATTRS = ('id', 'name', 'type', 'deleted', 'state', 'visible')
property gi_module

The GalaxyInstance module that deals with objects of this type.

class bioblend.galaxy.objects.wrappers.DatasetContainer(c_dict, content_infos=None, gi=None)[source]

Abstract base class for dataset containers (histories and libraries).

Parameters

content_infos (list of ContentInfo) – info objects for the container’s contents

BASE_ATTRS = ('id', 'name', 'deleted')
property dataset_ids

Return the ids of the contained datasets.

get_dataset(ds_id)[source]

Retrieve the dataset corresponding to the given id.

Parameters

ds_id (str) – dataset id

Return type

HistoryDatasetAssociation or LibraryDataset

Returns

the dataset corresponding to ds_id

get_datasets(name=None)[source]

Get all datasets contained inside this dataset container.

Parameters

name (str) – return only datasets with this name

Return type

list of HistoryDatasetAssociation or list of LibraryDataset

Returns

datasets with the given name contained inside this container

Note

when filtering library datasets by name, specify their full paths starting from the library’s root folder, e.g., /seqdata/reads.fastq. Full paths are available through the content_infos attribute of Library objects.

preview()[source]
refresh()[source]

Re-fetch the attributes pertaining to this object.

Returns: self

class bioblend.galaxy.objects.wrappers.History(hist_dict, content_infos=None, gi=None)[source]

Maps to a Galaxy history.

Parameters

content_infos (list of ContentInfo) – info objects for the container’s contents

API_MODULE = 'histories'
BASE_ATTRS = ('id', 'name', 'deleted', 'annotation', 'published', 'state', 'state_ids', 'state_details', 'tags')
CONTENT_INFO_TYPE

alias of HistoryContentInfo

DSC_TYPE

alias of HistoryDatasetCollectionAssociation

DS_TYPE

alias of HistoryDatasetAssociation

create_dataset_collection(collection_description)[source]

Create a new dataset collection in the history by providing a collection description.

Parameters

collection_description (bioblend.galaxy.dataset_collections.CollectionDescription) – a description of the dataset collection

Return type

HistoryDatasetCollectionAssociation

Returns

the new dataset collection

delete(purge=False)[source]

Delete this history.

Parameters

purge (bool) – if True, also purge (permanently delete) the history

Note

For the purge option to work, the Galaxy instance must have the allow_user_dataset_purge option set to true in the config/galaxy.yml configuration file.

download(jeha_id, outf, chunk_size=4096)[source]

Download an export archive for this history. Use export() to create an export and get the required jeha_id. See download_history() for parameter and return value info.

export(gzip=True, include_hidden=False, include_deleted=False, wait=False, maxwait=None)[source]

Start a job to create an export archive for this history. See export_history() for parameter and return value info.

get_dataset_collection(dsc_id)[source]

Retrieve the dataset collection corresponding to the given id.

Parameters

dsc_id (str) – dataset collection id

Return type

HistoryDatasetCollectionAssociation

Returns

the dataset collection corresponding to dsc_id

property gi_module

The GalaxyInstance module that deals with objects of this type.

import_dataset(lds)[source]

Import a dataset into the history from a library.

Parameters

lds (LibraryDataset) – the library dataset to import

Return type

HistoryDatasetAssociation

Returns

the imported history dataset

paste_content(content, **kwargs)[source]

Upload a string to a new dataset in this history.

Parameters

content (str) – content of the new dataset to upload

See upload_file() for the optional parameters (except file_name).

Return type

HistoryDatasetAssociation

Returns

the uploaded dataset

update(**kwds)[source]

Update history metadata information. Some of the attributes that can be modified are documented below.

Parameters
  • name (str) – Replace history name with the given string

  • annotation (str) – Replace history annotation with the given string

  • deleted (bool) – Mark or unmark history as deleted

  • purged (bool) – If True, mark history as purged (permanently deleted).

  • published (bool) – Mark or unmark history as published

  • importable (bool) – Mark or unmark history as importable

  • tags (list) – Replace history tags with the given list

upload_dataset(path, **kwargs)

Upload the file specified by path to this history.

Parameters

path (str) – path of the file to upload

See upload_file() for the optional parameters.

Return type

HistoryDatasetAssociation

Returns

the uploaded dataset

upload_file(path, **kwargs)[source]

Upload the file specified by path to this history.

Parameters

path (str) – path of the file to upload

See upload_file() for the optional parameters.

Return type

HistoryDatasetAssociation

Returns

the uploaded dataset

upload_from_ftp(path, **kwargs)[source]

Upload the file specified by path from the user’s FTP directory to this history.

Parameters

path (str) – path of the file in the user’s FTP directory

See upload_file() for the optional parameters.

Return type

HistoryDatasetAssociation

Returns

the uploaded dataset

class bioblend.galaxy.objects.wrappers.Library(lib_dict, content_infos=None, gi=None)[source]

Maps to a Galaxy library.

Parameters

content_infos (list of ContentInfo) – info objects for the container’s contents

API_MODULE = 'libraries'
BASE_ATTRS = ('id', 'name', 'deleted', 'description', 'synopsis')
CONTENT_INFO_TYPE

alias of LibraryContentInfo

DS_TYPE

alias of LibraryDataset

copy_from_dataset(hda, folder=None, message='')[source]

Copy a history dataset into this library.

Parameters

hda (HistoryDatasetAssociation) – history dataset to copy into the library

See upload_data() for info on other params.

create_folder(name, description=None, base_folder=None)[source]

Create a folder in this library.

Parameters
  • name (str) – folder name

  • description (str) – optional folder description

  • base_folder (Folder) – parent folder, or None to create in the root folder

Return type

Folder

Returns

the folder just created

delete()[source]

Delete this library.

property folder_ids

Return the ids of the contained folders.

get_folder(f_id)[source]

Retrieve the folder corresponding to the given id.

Return type

Folder

Returns

the folder corresponding to f_id

property gi_module

The GalaxyInstance module that deals with objects of this type.

property root_folder

The root folder of this library.

Return type

Folder

Returns

the root folder of this library

upload_data(data, folder=None, **kwargs)[source]

Upload data to this library.

Parameters
  • data (str) – dataset contents

  • folder (Folder) – a folder object, or None to upload to the root folder

Return type

LibraryDataset

Returns

the dataset object that represents the uploaded content

Optional keyword arguments: file_type, dbkey.

upload_from_galaxy_fs(paths, folder=None, link_data_only=None, **kwargs)[source]

Upload data to this library from filesystem paths on the server.

Note

For this method to work, the Galaxy instance must have the allow_path_paste option set to true in the config/galaxy.yml configuration file.

Parameters
  • paths (str or Iterable of str) – server-side file paths from which data should be read

  • link_data_only (str) – either ‘copy_files’ (default) or ‘link_to_files’. Setting to ‘link_to_files’ symlinks instead of copying the files

Return type

list of LibraryDataset

Returns

the dataset objects that represent the uploaded content

See upload_data() for info on other params.

upload_from_local(path, folder=None, **kwargs)[source]

Upload data to this library from a local file.

Parameters

path (str) – local file path from which data should be read

See upload_data() for info on other params.

upload_from_url(url, folder=None, **kwargs)[source]

Upload data to this library from the given URL.

Parameters

url (str) – URL from which data should be read

See upload_data() for info on other params.

class bioblend.galaxy.objects.wrappers.Folder(f_dict, container, gi=None)[source]

Maps to a folder in a Galaxy library.

Parameters
  • wrapped (dict) – JSON-serializable dictionary

  • parent (Wrapper) – the parent of this wrapper

  • gi (GalaxyInstance) – the GalaxyInstance through which we can access this wrapper

BASE_ATTRS = ('id', 'name', 'description', 'deleted', 'item_count')
property container_id

Deprecated property.

Id of the folder container. Use container.id instead.

property gi_module

The GalaxyInstance module that deals with objects of this type.

property parent

The parent folder of this folder. The parent of the root folder is None.

Return type

Folder

Returns

the parent of this folder

refresh()[source]

Re-fetch the attributes pertaining to this object.

Returns: self

class bioblend.galaxy.objects.wrappers.Dataset(ds_dict, container, gi=None)[source]

Abstract base class for Galaxy datasets.

Parameters
  • wrapped (dict) – JSON-serializable dictionary

  • parent (Wrapper) – the parent of this wrapper

  • gi (GalaxyInstance) – the GalaxyInstance through which we can access this wrapper

BASE_ATTRS = ('id', 'name', 'data_type', 'file_ext', 'file_name', 'file_size', 'genome_build', 'misc_info', 'state')
POLLING_INTERVAL = 1
property container_id

Deprecated property.

Id of the dataset container. Use container.id instead.

download(file_object, chunk_size=4096)[source]

Open dataset for reading and save its contents to file_object.

Parameters

file_object (file) – output file object

See get_stream() for info on other params.

get_contents(chunk_size=4096)[source]

Open dataset for reading and return its full contents.

See get_stream() for param info.

get_stream(chunk_size=4096)[source]

Open dataset for reading and return an iterator over its contents.

Parameters

chunk_size (int) – read this amount of bytes at a time

peek(chunk_size=4096)[source]

Open dataset for reading and return the first chunk.

See get_stream() for param info.

refresh()[source]

Re-fetch the attributes pertaining to this object.

Returns: self

wait(polling_interval=1, break_on_error=True)[source]

Wait for this dataset to come out of the pending states.

Parameters
  • polling_interval (float) – polling interval in seconds

  • break_on_error (bool) – if True, raise a RuntimeError exception if the dataset ends in the ‘error’ state.

Warning

This is a blocking operation that can take a very long time. Also, note that this method does not return anything; however, this dataset is refreshed (possibly multiple times) during the execution.

class bioblend.galaxy.objects.wrappers.HistoryDatasetAssociation(ds_dict, container, gi=None)[source]

Maps to a Galaxy HistoryDatasetAssociation.

Parameters
  • wrapped (dict) – JSON-serializable dictionary

  • parent (Wrapper) – the parent of this wrapper

  • gi (GalaxyInstance) – the GalaxyInstance through which we can access this wrapper

BASE_ATTRS = ('id', 'name', 'data_type', 'file_ext', 'file_name', 'file_size', 'genome_build', 'misc_info', 'state', 'annotation', 'deleted', 'purged', 'tags', 'visible')
SRC = 'hda'
delete(purge=False)[source]

Delete this history dataset.

Parameters

purge (bool) – if True, also purge (permanently delete) the dataset

Note

For the purge option to work, the Galaxy instance must have the allow_user_dataset_purge option set to true in the config/galaxy.yml configuration file.

property gi_module

The GalaxyInstance module that deals with objects of this type.

update(**kwds)[source]

Update this history dataset metadata. Some of the attributes that can be modified are documented below.

Parameters
  • name (str) – Replace history dataset name with the given string

  • genome_build (str) – Replace history dataset genome build (dbkey)

  • annotation (str) – Replace history dataset annotation with given string

  • deleted (bool) – Mark or unmark history dataset as deleted

  • visible (bool) – Mark or unmark history dataset as visible

class bioblend.galaxy.objects.wrappers.DatasetCollection(dsc_dict, container, gi=None)[source]

Abstract base class for Galaxy dataset collections.

Parameters
  • wrapped (dict) – JSON-serializable dictionary

  • parent (Wrapper) – the parent of this wrapper

  • gi (GalaxyInstance) – the GalaxyInstance through which we can access this wrapper

BASE_ATTRS = ('id', 'name', 'state', 'deleted', 'collection_type')
refresh()[source]

Re-fetch the attributes pertaining to this object.

Returns: self

class bioblend.galaxy.objects.wrappers.HistoryDatasetCollectionAssociation(dsc_dict, container, gi=None)[source]

Maps to a Galaxy HistoryDatasetCollectionAssociation.

Parameters
  • wrapped (dict) – JSON-serializable dictionary

  • parent (Wrapper) – the parent of this wrapper

  • gi (GalaxyInstance) – the GalaxyInstance through which we can access this wrapper

BASE_ATTRS = ('id', 'name', 'state', 'deleted', 'collection_type', 'tags', 'visible', 'elements')
SRC = 'hdca'
delete()[source]

Delete this dataset collection.

property gi_module

The GalaxyInstance module that deals with objects of this type.

class bioblend.galaxy.objects.wrappers.LibraryDatasetDatasetAssociation(ds_dict, container, gi=None)[source]

Maps to a Galaxy LibraryDatasetDatasetAssociation.

Parameters
  • wrapped (dict) – JSON-serializable dictionary

  • parent (Wrapper) – the parent of this wrapper

  • gi (GalaxyInstance) – the GalaxyInstance through which we can access this wrapper

BASE_ATTRS = ('id', 'name', 'data_type', 'file_ext', 'file_name', 'file_size', 'genome_build', 'misc_info', 'state', 'deleted')
SRC = 'ldda'
class bioblend.galaxy.objects.wrappers.LibraryDataset(ds_dict, container, gi=None)[source]

Maps to a Galaxy LibraryDataset.

Parameters
  • wrapped (dict) – JSON-serializable dictionary

  • parent (Wrapper) – the parent of this wrapper

  • gi (GalaxyInstance) – the GalaxyInstance through which we can access this wrapper

SRC = 'ld'
delete(purged=False)[source]

Delete this library dataset.

Parameters

purged (bool) – if True, also purge (permanently delete) the dataset

update(**kwds)[source]

Update this library dataset metadata. Some of the attributes that can be modified are documented below.

Parameters
  • name (str) – Replace history dataset name with the given string

  • genome_build (str) – Replace history dataset genome build (dbkey)

class bioblend.galaxy.objects.wrappers.Tool(t_dict, gi=None)[source]

Maps to a Galaxy tool.

Parameters
  • wrapped (dict) – JSON-serializable dictionary

  • parent (Wrapper) – the parent of this wrapper

  • gi (GalaxyInstance) – the GalaxyInstance through which we can access this wrapper

BASE_ATTRS = ('id', 'name', 'version')
POLLING_INTERVAL = 10
property gi_module

The GalaxyInstance module that deals with objects of this type.

run(inputs, history, wait=False, polling_interval=10)[source]

Execute this tool in the given history with inputs from dict inputs.

Parameters
  • inputs (dict) – dictionary of input datasets and parameters for the tool (see below)

  • history (History) – the history where to execute the tool

  • wait (bool) – whether to wait while the returned datasets are in a pending state

  • polling_interval (float) – polling interval in seconds

Return type

list of HistoryDatasetAssociation

Returns

list of output datasets

The inputs dict should contain input datasets and parameters in the (largely undocumented) format used by the Galaxy API. Some examples can be found in Galaxy’s API test suite. The value of an input dataset can also be a Dataset object, which will be automatically converted to the needed format.

class bioblend.galaxy.objects.wrappers.Job(j_dict, gi=None)[source]

Maps to a Galaxy job.

Parameters
  • wrapped (dict) – JSON-serializable dictionary

  • parent (Wrapper) – the parent of this wrapper

  • gi (GalaxyInstance) – the GalaxyInstance through which we can access this wrapper

BASE_ATTRS = ('id', 'state')
property gi_module

The GalaxyInstance module that deals with objects of this type.

class bioblend.galaxy.objects.wrappers.Preview(pw_dict, gi=None)[source]

Abstract base class for Galaxy entity ‘previews’.

Classes derived from this one model the short summaries returned by global getters such as /api/libraries.

Parameters
  • wrapped (dict) – JSON-serializable dictionary

  • parent (Wrapper) – the parent of this wrapper

  • gi (GalaxyInstance) – the GalaxyInstance through which we can access this wrapper

BASE_ATTRS = ('id', 'name', 'deleted')
class bioblend.galaxy.objects.wrappers.LibraryPreview(pw_dict, gi=None)[source]

Models Galaxy library ‘previews’.

Instances of this class wrap dictionaries obtained by getting /api/libraries from Galaxy.

Parameters
  • wrapped (dict) – JSON-serializable dictionary

  • parent (Wrapper) – the parent of this wrapper

  • gi (GalaxyInstance) – the GalaxyInstance through which we can access this wrapper

property gi_module

The GalaxyInstance module that deals with objects of this type.

class bioblend.galaxy.objects.wrappers.HistoryPreview(pw_dict, gi=None)[source]

Models Galaxy history ‘previews’.

Instances of this class wrap dictionaries obtained by getting /api/histories from Galaxy.

Parameters
  • wrapped (dict) – JSON-serializable dictionary

  • parent (Wrapper) – the parent of this wrapper

  • gi (GalaxyInstance) – the GalaxyInstance through which we can access this wrapper

BASE_ATTRS = ('id', 'name', 'deleted', 'tags')
property gi_module

The GalaxyInstance module that deals with objects of this type.

class bioblend.galaxy.objects.wrappers.WorkflowPreview(pw_dict, gi=None)[source]

Models Galaxy workflow ‘previews’.

Instances of this class wrap dictionaries obtained by getting /api/workflows from Galaxy.

Parameters
  • wrapped (dict) – JSON-serializable dictionary

  • parent (Wrapper) – the parent of this wrapper

  • gi (GalaxyInstance) – the GalaxyInstance through which we can access this wrapper

BASE_ATTRS = ('id', 'name', 'deleted', 'published', 'tags')
property gi_module

The GalaxyInstance module that deals with objects of this type.