Commit 6551b5a1 authored by Yakubov, Sergey's avatar Yakubov, Sergey
Browse files

add example to call oncat tool

parent a3beeb69
Loading
Loading
Loading
Loading
+32 −0
Original line number Diff line number Diff line
import os
import re
from bioblend import galaxy
from bioblend.galaxy.tools.inputs import inputs

galaxy_url = os.getenv("GALAXY_URL")
galaxy_user_api_key = os.getenv("GALAXY_API_KEY")

# connect to a Galaxy instance, create dataset client
galaxy_instance = galaxy.GalaxyInstance(url=galaxy_url, key=galaxy_user_api_key)
dataset_client = galaxy.datasets.DatasetClient(galaxy_instance)

# get active history id
history_id = galaxy_instance.histories.get_histories()[0]["id"]

tool_inputs = inputs()\
    .set("facility", "SNS")\
    .set("instrument", "ARCS")\
    .set("ipts", "28935")\
    .set("run", 243817)

res = galaxy_instance.tools.run_tool(history_id, 'neutrons_import_oncat', tool_inputs)['outputs'][0]
result_dataset_id = res['id']
dataset_client.wait_for_dataset(result_dataset_id)


# export results
outname = re.sub('\W', '_', res["name"]+"."+res["file_ext"])
exported_data = dataset_client.download_dataset(dataset_id=result_dataset_id,
                                                file_path=outname,
                                                use_default_filename=False)