-
Notifications
You must be signed in to change notification settings - Fork 8
/
upload_file_to_galaxy.py
47 lines (41 loc) · 1.62 KB
/
upload_file_to_galaxy.py
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
"""
Takes a list of ftp links and converts to a yaml file ready for upload with planemo run
(Slightly modified version here compared to ena-cog-uk-wfs)
"""
import argparse
import os
from bioblend import galaxy
if __name__ == '__main__':
import argparse
parser = argparse.ArgumentParser()
parser.add_argument(
'links_file',
help='File with links to upload'
)
parser.add_argument(
'collection_name',
help='The yml key to use for the collection element'
)
parser.add_argument(
'-g', '--galaxy-url', required=True,
help='URL of the Galaxy instance to run query against'
)
parser.add_argument(
'-a', '--api-key', required=True,
help='API key to use for authenticating on the Galaxy server'
)
parser.add_argument(
'-i', '--history_id',
help='History ID for uploading datasets'
)
args = parser.parse_args()
# use the filename without suffix as the collection element identifier
element_id = os.path.splitext(os.path.basename(args.links_file))[0]
gi = galaxy.GalaxyInstance(args.galaxy_url, args.api_key)
dataset_id = gi.tools.upload_file(args.links_file, args.history_id)['outputs'][0]['id']
collection_description = {'collection_type': 'list',
'element_identifiers': [{'id': dataset_id,
'name': element_id,
'src': 'hda'}],
'name': args.collection_name}
gi.histories.create_dataset_collection(args.history_id, collection_description)