API documentation for interacting with Galaxy

class blend.galaxy.GalaxyInstance(url, key)[source]

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

After you have created an GalaxyInstance object, access various modules via the class fields (see the source for the most up-to-date list): libraries, histories, workflows, datasets, and users are the minimum set supported. For example, to work with histories, and get a list of all the user’s histories, the following should be done:

from blend import galaxy

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

hl = gi.histories.get_histories()
print "List of histories:", hl
Parameters:
  • url (string) – A FQDN or IP for a given instance of Galaxy. For example: http://127.0.0.1:8080
  • key (string) – User’s API key for the given instance of Galaxy, obtained from the user preferences.
__init__(url, key)[source]

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

After you have created an GalaxyInstance object, access various modules via the class fields (see the source for the most up-to-date list): libraries, histories, workflows, datasets, and users are the minimum set supported. For example, to work with histories, and get a list of all the user’s histories, the following should be done:

from blend import galaxy

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

hl = gi.histories.get_histories()
print "List of histories:", hl
Parameters:
  • url (string) – A FQDN or IP for a given instance of Galaxy. For example: http://127.0.0.1:8080
  • key (string) – User’s API key for the given instance of Galaxy, obtained from the user preferences.
make_delete_request(url, payload=None, params=None)[source]

Make a DELETE request using the provided url and the optional arguments. The payload must be a dict that can be converted into a JSON object (via simplejson.dumps)

If the params are not provided, use default_params class field. If params are provided and the provided dict does not have key key, the default self.key value will be included in what’s passed to the server via the request.

make_get_request(url, params=None)[source]

Make a GET request using the provided url.

If the params are not provided, use default_params class field. If params are provided and the provided dict does not have key key, the default self.key value will be included in what’s passed to the server via the request.

make_post_request(url, payload, params=None)[source]

Make a POST request using the provided url and payload. The payload must be a dict that can be converted into a JSON object (via simplejson.dumps)

If the params are not provided, use default_params class field. If params are provided and the provided dict does not have key key, the default self.key value will be included in what’s passed to the server via the request.


Contains possible interactions with the Galaxy Data Libraries

class blend.galaxy.libraries.LibraryClient(galaxy_instance)[source]
create_folder(library_id, folder_name, description=None, base_folder_id=None)[source]

Create a folder in the given library and the base folder. If base_folder_id is not provided, the new folder will be created in the root folder.

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

Create a data library with the properties defined in the arguments. Return a list of JSON dicts, looking like so:

[{"id": "f740ab636b360a70", 
  "name": "Library from blend", 
  "url": "/api/libraries/f740ab636b360a70"}]
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.

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

Return a list of JSON formatted dicts each containing basic information about a library.

show_library(library_id, contents=False)[source]

Get information about a library.

If want to get contents of the library (rather than just the library details), set contents to True.

Return a list of JSON formatted dicts containing library details.

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

Upload pasted_contents to a data library as a new file. If folder_id is not specified, the file will be placed in the root folder.

upload_file_from_server(library_id, server_dir, folder_id=None, file_type='auto', dbkey='?')[source]

Upload a file to a library from a path on the server where Galaxy is running. If folder_id is not provided, the file will be placed in the root folder.

Note that for this method to work, the Galaxy instance you’re connecting to must have the configuration option library_import_dir set in universe_wsgi.ini. The value of that configuration option should be a base directory from where more specific directories can be specified as part of the server_dir argument. All and only the files (ie, no folders) specifed by the server_dir argument will be uploaded to the data library.

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

Upload a file to a library from a URL. If folder_id is not specified, the file will be uploaded to the root folder.


Contains possible interactions with the Galaxy Histories

class blend.galaxy.histories.HistoryClient(galaxy_instance)[source]
create_history(name=None)[source]

Create a new history, optionally setting the name.

delete_history(history_id, purge=False)[source]

Delete a history.

If purge is set to True, also purge the history. Note that for the purge option to work, allow_user_dataset_purge option must be set in the Galaxy’s configuration file universe_wsgi.ini

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.

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.

show_dataset(history_id, dataset_id)[source]

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

show_history(history_id, contents=False)[source]

Get details of a given history. By default, just get the history meta information. If contents is set to True, get the complete list of datasets in the given history.

undelete_history(history_id)[source]

Undelete a history

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.


Contains possible interactions with the Galaxy Workflows

class blend.galaxy.workflows.WorkflowClient(galaxy_instance)[source]
get_workflows()[source]

Get a list of all workflows

Return type:list
Returns:A list of workflow dicts. For example:
[{u'id': u'92c56938c2f9b315',
  u'name': u'Simple',
  u'url': u'/api/workflows/92c56938c2f9b315'}]
run_workflow(workflow_id, dataset_map, history_id=None, history_name=None, import_inputs_to_history=False)[source]

Run the workflow identified by workflow_id

Parameters:
  • workflow_id (string) – Encoded workflow ID
  • dataset_map (string or 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]'}} (eg, {'23': {'id': '29beef4fadeed09f', 'src': 'ld'}})
  • history_id (string) – The encoded history ID where to store the workflow output. history_id OR history_name should be provided but not both!
  • history_name (string) – Create a new history with the given name to store the workflow output. history_id OR history_name should be provided but not both!
  • 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.
Return type:

dict

Returns:

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

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

show_workflow(workflow_id)[source]

Display information needed to run a workflow

Parameters:workflow_id (string) – Encoded workflow ID
Return type:list
Returns:A description of the workflow and its inputs as a JSON object. For example:
{u'id': u'92c56938c2f9b315',
 u'inputs': {u'23': {u'label': u'Input Dataset', u'value': u''}},
 u'name': u'Simple',
 u'url': u'/api/workflows/92c56938c2f9b315'}

Contains possible interactions with the Galaxy Datasets

class blend.galaxy.datasets.DatasetClient(galaxy_instance)[source]
show_dataset(dataset_id, deleted=False)[source]

Display information about and/or content of a dataset. This can be a history or a library dataset.


Contains possible interaction dealing with Galaxy users.

These methods must be executed by a registered Galaxy admin user.

class blend.galaxy.users.UserClient(galaxy_instance)[source]
create_user(user_email)[source]

Create a new Galaxy user.

Note

For this method to work, the Galaxy instance must have allow_user_creation and use_remote_user options set to True in the universe_wsgi.ini 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.

get_users(deleted=False)[source]

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

Return type:list
Returns:A list of dicts with user details. For example:
[{u'email': u'a_user@example.com',
  u'id': u'dda47097d9189f15',
  u'url': u'/api/users/dda47097d9189f15'}]
show_user(user_id, deleted=False)[source]

Display information about a user. If deleted is set to True, display information about a deleted user.

Previous topic

API documentation for interacting with CloudMan

This Page