UPDATE: I originally posted before Christmas but my posts now has updates:
- reflecting the use of the original Bioblend API vs the OO BioBlend API).
- with details about manual upload to Galaxy GUI
I am trying to use BioBlend to upload a file (locally stored on my computer). I have tried doing so in 2 ways:
(1) Using the original Bioblend API
(2) Using the OO BioBlend API
In both cases, I obtain the same error (at least it seems). Here is my code:
Using original BioBlend API (bioblend.galaxy)
import os
from bioblend.galaxy import GalaxyInstance
from bioblend.galaxy.histories import HistoryClient
from bioblend.galaxy.tools import ToolClient
os.chdir("/home/username/Documents/projects/galaxy")
# Set up GalaxyInstance ####
gi = GalaxyInstance("https://usegalaxy.org", "my-instance-number")
# Make a new history ####
historyClient = HistoryClient(gi)
hi = historyClient.create_history("tmp2-100119")
# Upload datasets ####
toolClient = ToolClient(gi)
counts = toolClient.upload_file("example.txt", hi["id"])
counts2 = toolClient.upload_file("counted.txt",hi["id"]) # not working
Using OO BioBlend API (bioblend.galaxy.objects)
import os
from bioblend.galaxy.objects import GalaxyInstance
os.chdir("/home/username/Documents/projects/galaxy")
# Set up GalaxyInstance ####
gi = GalaxyInstance("https://usegalaxy.org", "my-instance-number")
# Make a new history ####
hi = gi.histories.create("tmp-100119")
# Upload datasets ####
counts = hi.upload_file("example.txt")
counts2 = hi.upload_file("counted.txt", file_type="tabular") # not working
In both code version, I have the same problem: I can upload a simple file called space-delimited example.txt which looks like this below. On the Galaxy GUI, I can see this file and it says āformat: txtā and āuploaded txt fileā.
1 2 3
A B C
D E F
However, I cannot upload my counted.txt file. This file is a tab delimited file, which has 51,827 lines. It represents a matrix of counts I want to perform DE analysis on. It looks like so (first few lines):
GeneID S1 S2 S3 S4 S5 S6 S7 S8 S9
gene1 0 1 0 2 0 1 0 13 34
gene2 4 0 0 3 0 5 0 1 13
gene2 13 44 94 30 45 34 46 40 44
gene3 2 0 0 0 0 0 0 5 6
The error I get in my terminal is as follows (the upload_file commands takes a min or so before the error appears). There are slightly different for both codes but they both in a ConnectionError: (āConnection aborted.ā, RemoteDisconnected(āRemote end closed connection without responseā,)) error.
Traceback (most recent call last):
File "<ipython-input-14-345175af4c4e>", line 1, in <module>
counts2 = hi.upload_file("counted.txt", file_type="tabular") # not working
File "/home/username/anaconda3/envs/myenv-3.6/lib/python3.6/site-packages/bioblend/galaxy/objects/wrappers.py", line 1000, in upload_file
out_dict = self.gi.gi.tools.upload_file(path, self.id, **kwargs)
File "/home/username/anaconda3/envs/myenv-3.6/lib/python3.6/site-packages/bioblend/galaxy/tools/__init__.py", line 162, in upload_file
return self._tool_post(payload, files_attached=True)
File "/home/username/anaconda3/envs/myenv-3.6/lib/python3.6/site-packages/bioblend/galaxy/tools/__init__.py", line 232, in _tool_post
return self._post(payload, files_attached=files_attached)
File "/home/username/anaconda3/envs/myenv-3.6/lib/python3.6/site-packages/bioblend/galaxy/client.py", line 152, in _post
files_attached=files_attached)
File "/home/username/anaconda3/envs/myenv-3.6/lib/python3.6/site-packages/bioblend/galaxyclient.py", line 137, in make_post_request
timeout=self.timeout)
File "/home/username/anaconda3/envs/myenv-3.6/lib/python3.6/site-packages/requests/api.py", line 116, in post
return request('post', url, data=data, json=json, **kwargs)
File "/home/username/anaconda3/envs/myenv-3.6/lib/python3.6/site-packages/requests/api.py", line 60, in request
return session.request(method=method, url=url, **kwargs)
File "/home/username/anaconda3/envs/myenv-3.6/lib/python3.6/site-packages/requests/sessions.py", line 533, in request
resp = self.send(prep, **send_kwargs)
File "/home/username/anaconda3/envs/myenv-3.6/lib/python3.6/site-packages/requests/sessions.py", line 646, in send
r = adapter.send(request, **kwargs)
File "/home/username/anaconda3/envs/myenv-3.6/lib/python3.6/site-packages/requests/adapters.py", line 498, in send
raise ConnectionError(err, request=request)
ConnectionError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response',))
I have managed to upload this counted.txt file to the Galaxy GUI successfully. It says āformat: tabularā and āuploaded tabular fileā. I have even manage to run some analyses on it. This file is 2.1 MB in size.
I am very lost as to what is causing this error. Any help would be deeply appreciated.