Question: bioblend invoking galaxy workflow, but doesn't start
0
gravatar for juliepevernagie
5 months ago by
juliepevernagie0 wrote:

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()
python galaxy bioblend • 131 views
ADD COMMENTlink modified 5 months ago by Biostar ♦♦ 20 • written 5 months ago by juliepevernagie0
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1645 users visited in the last hour