Entering edit mode
3.8 years ago
juliepevernagie
•
0
I'm having some issues using python library bioblend with galaxy. Creating a new history, adding files and invoking a workflow works. But the workflow never actually starts. The jobs have all been in the queue for weeks. Maybe I'm forgetting a step? Could someone here help me?
This is my code:
import sys
import os
from bioblend import galaxy
import re
GALAXY_URL = '...'
API_KEY= '...'
file_list = [
# list of filenames to search in shared data libraries
]
def main():
gi = galaxy.GalaxyInstance(url=GALAXY_URL, key=API_KEY)
sysbio_library = gi.libraries.get_libraries(name = 'NAME')
files = gi.libraries.show_library(sysbio_library[0]['id'], contents=True)
workflows = gi.workflows.get_workflows(name = 'WORKFLOWNAME')
# unlist by keeping only element in list
workflow = workflows[0]
# show details of workflow
#wf = gi.workflows.show_workflow(workflow['id'])
# see inputs needed
# wf['inputs'] # ==> '0' : forward read ; '1' : reverse read
# get list of files in folder sysbio_library (is also list)
files = gi.libraries.show_library(sysbio_library[0]['id'], contents=True)
for i in file_list:
forward_file = list(filter(lambda file: re.search( (i+"1"),file["name"]), files))
reverse_file = list(filter(lambda file: re.search( (i+"2"),file["name"]), files))
if forward_file and reverse_file:
# should have only 1 match, we need first element of list
forward_file = forward_file[0]
reverse_file = reverse_file [0]
new_history_name=forward_file['name']
hist = gi.histories.create_history(name=new_history_name)
dataset_F = gi.histories.upload_dataset_from_library(hist['id'], forward_file['id'])
dataset_R = gi.histories.upload_dataset_from_library(hist['id'], reverse_file['id'])
# create empty dictionary
datamap = {} # or datamap = dict()
# specify inputs, source = history data
datamap['0'] = { 'src':'hda', 'id': forward_file['id'] }
datamap['1'] = { 'src':'hda', 'id': reverse_file['id'] }
w = gi.workflows.invoke_workflow(workflow['id'], inputs = datamap, history_id=hist['id'])
print('Created new history for ' + i)
else:
print(i +' not found.')
if __name__ == '__main__':
main()