In [27]:
from bioblend.galaxy import GalaxyInstance
# API access is only possible for registered users.
# Unregistered users can use the webinterface of https://hicexplorer.usegalaxy.eu
API_KEY = ""
gi = GalaxyInstance(url='https://hicexplorer.usegalaxy.eu', key=API_KEY)
In [2]:
# Create a history
history_id = gi.histories.create_history('Hi-C example NAR 2020')['id']
In [3]:
# Upload a dataset from an URL
upload = gi.tools.put_url('https://zenodo.org/record/1183661/files/HiC_S2_1p_10min_lowU_R1.fastq.gz', history_id, file_name='R1.fastq', file_type='fastqsanger.gz')
In [11]:
# get the uploaded dataset ids
# wait until the data has been uploaded
dataset_ids = []
all_items = gi.histories.show_history(history_id, contents=False)['state_ids']['ok']
datatype = 'fastqsanger.gz'
# get the files with the correct data type
for items in all_items:
items_data = gi.datasets.show_dataset(items)
if items_data['extension'] == datatype:
dataset_ids.append(items)
In [12]:
# get the correct bowtie version
all_versions = gi.tools.get_tools(name='Bowtie2')
latest_version = None
latest_version_id = None
latest_version_number = '2.3.4.3+galaxy0'
for tool in all_versions:
if tool['version'] == latest_version_number:
latest_version = tool
latest_version_id = latest_version['id']
In [ ]:
# prepare bowtie input
In [13]:
from bioblend.galaxy.tools.inputs import inputs, dataset
In [14]:
# run mapping
my_input = inputs().set("inputName",'value').set("input",dataset(dataset_ids[0]))
job_run = gi.tools.run_tool(history_id, latest_version_id, tool_inputs=my_input)
In [26]:
# get the computed dataset ids
# wait until the data has been computed
dataset_ids = []
all_items = gi.histories.show_history(history_id, contents=False)['state_ids']['ok']
datatype = 'fastqsanger.gz'
# get the files with the correct data type
for items in all_items:
items_data = gi.datasets.show_dataset(items)
# print(items_data)
if items_data['extension'] == datatype:
dataset_ids.append(items)
In [ ]:
# Download data
In [25]:
import os
download_path = 'download_galaxy'
os.mkdir(download_path)
gi.datasets.download_dataset(dataset_ids[0], file_path=download_path)
Out[25]: