Loading examples/5_register_dataset/README.md 0 → 100644 +7 −0 Original line number Diff line number Diff line #### Description This is a simple script to demonstrate how one can in-place register a dataset in Galaxy without copying it to Galaxy storage. #### To run it: see README in a root folder examples/5_register_dataset/register.py 0 → 100644 +36 −0 Original line number Diff line number Diff line import os,sys 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") file_to_register = sys.argv[1] # 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"] # or create a new one # history_id = galaxy_instance.histories.create_history(name="New history")["id"] # set tool inputs, run tool and wait it finishes # The neutrons_register tool takes a filepath # and returns a single output file (hence ['outputs'][0]['id']) tool_inputs = inputs().set("input", file_to_register) result_dataset_id = galaxy_instance.tools.run_tool(history_id, 'neutrons_register', tool_inputs)['outputs'][0]['id'] res = dataset_client.wait_for_dataset(result_dataset_id, check=False) if res["state"] == "ok": print("register successful") print("dataset is now in history under id: ", res["hid"]) else: details = galaxy_instance.histories.show_dataset_provenance(history_id, result_dataset_id) raise Exception("register failed", details) # uncomment to delete history and all data, purge=True might be not allowed by Galaxy admin # galaxy_instance.histories.delete_history(history_id, purge=True) Loading
examples/5_register_dataset/README.md 0 → 100644 +7 −0 Original line number Diff line number Diff line #### Description This is a simple script to demonstrate how one can in-place register a dataset in Galaxy without copying it to Galaxy storage. #### To run it: see README in a root folder
examples/5_register_dataset/register.py 0 → 100644 +36 −0 Original line number Diff line number Diff line import os,sys 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") file_to_register = sys.argv[1] # 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"] # or create a new one # history_id = galaxy_instance.histories.create_history(name="New history")["id"] # set tool inputs, run tool and wait it finishes # The neutrons_register tool takes a filepath # and returns a single output file (hence ['outputs'][0]['id']) tool_inputs = inputs().set("input", file_to_register) result_dataset_id = galaxy_instance.tools.run_tool(history_id, 'neutrons_register', tool_inputs)['outputs'][0]['id'] res = dataset_client.wait_for_dataset(result_dataset_id, check=False) if res["state"] == "ok": print("register successful") print("dataset is now in history under id: ", res["hid"]) else: details = galaxy_instance.histories.show_dataset_provenance(history_id, result_dataset_id) raise Exception("register failed", details) # uncomment to delete history and all data, purge=True might be not allowed by Galaxy admin # galaxy_instance.histories.delete_history(history_id, purge=True)