File: list_histories.py

package info (click to toggle)
python-bioblend 1.2.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,096 kB
  • sloc: python: 7,596; sh: 219; makefile: 158
file content (32 lines) | stat: -rw-r--r-- 943 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
"""
This example retrieves details of all the Histories in our Galaxy account and lists information on them.

Usage: python list_histories.py <galaxy-url> <galaxy-API-key>
"""

import sys

from bioblend.galaxy import GalaxyInstance

if len(sys.argv) != 3:
    print("Usage: python list_histories.py <galaxy-url> <galaxy-API-key>")
    sys.exit(1)
galaxy_url = sys.argv[1]
galaxy_key = sys.argv[2]

print("Initiating Galaxy connection")

gi = GalaxyInstance(url=galaxy_url, key=galaxy_key)

print("Retrieving History list")

histories = gi.histories.get_histories()

if len(histories) == 0:
    print("There are no Histories in your account.")
else:
    print("\nHistories:")
    for hist_dict in histories:
        # As an example, we retrieve a piece of metadata (the size) using show_history
        hist_details = gi.histories.show_history(hist_dict["id"])
        print(f"{hist_dict['name']} ({hist_details['size']}) : {hist_dict['id']}")