def show_workflow( workflow_id ): # http://galaxy-central.readthedocs.org/en/latest/lib/galaxy.webapps.galaxy.api.html#galaxy.webapps.galaxy.api.workflows.WorkflowsAPIController.show # lib/galaxy/webapps/galaxy/api/workflows.py, def import #EXERCISE: return... # ----------------------------------------------------------------------------- if __name__ == '__main__': response = show_workflow( sys.argv[1] ) output.output_response( response )
def list_workflows(): # http://galaxy-central.readthedocs.org/en/latest/lib/galaxy.webapps.galaxy.api.html#galaxy.webapps.galaxy.api.workflows.WorkflowsAPIController.index # lib/galaxy/webapps/galaxy/api/workflows.py, def index #EXERCISE: GET/index available workflows # ----------------------------------------------------------------------------- if __name__ == '__main__': response = list_workflows() output.output_response( response )
def show_tool( tool_id ): #EXERCISE: build params, including 'io_details' : True, and request # ----------------------------------------------------------------------------- if __name__ == '__main__': response = None # if passed an id, show details for that; if no id: return info for all tools if len( sys.argv ) == 1: response = list_tools() else: response = show_tool( sys.argv[1] ) output.output_response( response )
'file_type' : 'auto', } data = { # like any post, the api key can go directly into the data 'key' : open( '.api-key' ).readline().strip(), # the id of the upload tool - tool ids are more human readable but don't # always correspond to the name in the tool panel; use api/tools to get more info 'tool_id' : 'upload1', # to which history are we uploading? 'history_id' : history_id, # for many tools the inputs need to be sent as a json encoded string 'inputs' : json.dumps( inputs ) } # for upload, we're using a special post parameter named 'files' which allows # us to attach the file data to the request # requests makes this much easier than urllib or other libraries response = None with open( filepath, 'rb' ) as file_to_upload: files = { 'files_0|file_data' : file_to_upload } response = requests.post( full_url, data=data, files=files ) return response # ----------------------------------------------------------------------------- if __name__ == '__main__': history_id, filepath = sys.argv[1:3] response = upload_file( history_id, filepath ) output.output_response( response )
#!/usr/bin/env python import sys import json import output import requests BASE_URL = 'http://localhost:8080' # ----------------------------------------------------------------------------- # http://galaxy-central.readthedocs.org/en/latest/lib/galaxy.webapps.galaxy.api.html#galaxy.webapps.galaxy.api.history_contents.HistoryContentsController.show # lib/galaxy/webapps/galaxy/api/history_contents.py, def index def show_history_contents( history_id, contents_id ): # even further specify a resource by using the URL - this time telling the # API to look for a specific element (contents_id) in a specific history full_url = #... # ----------------------------------------------------------------------------- if __name__ == '__main__': history_id, contents_id = sys.argv[1:3] response = show_history_contents( history_id, contents_id ) output.output_response( response )