Hi,
I'm hoping that the list can help me out.
I'm trying to write some tools to capture elements to ease migration from a
course development
server to a training server. I'm using the Bioblend API which I am a newbie at
using.
In the code for extracting the data files from shared data libraries all is
well except for 'Tabular' data
(e.g. fasta and txt are OK). The error seems to be at the stage where the
program calls the Bioblend
.datasets.download_dataset() function.
NB The tabular files in question can be downloaded fine from the server on the
appropriate Galaxy page.
(My code is at the end of this message - Please forgive the quality of my
Python code).
If a tabular data file is present then I get the following output & errors from
my program:-
Root path: /usr/users/fr009/fernande/gal_exports/data
Library: Intro Galaxy Training
No. of items in library 11
>> /usr/users/fr009/fernande/gal_exports/data/Intro Galaxy
>> Training/Getting_started/NBARC/BM361007.fasta <<
>> /usr/users/fr009/fernande/gal_exports/data/Intro Galaxy
>> Training/Getting_started/NBARC/NB_domains.tabular <<
---
DatasetStateException Traceback (most recent call last)
in ()
52 filepath =
os.path.join(rootpathplus,fname.strip("/"))
53 print '>>',filepath,'<<'
---> 54
gi.datasets.download_dataset(items['id'],filepath,False)
/usr/local/lib/python2.7/dist-packages/bioblend/galaxy/datasets/__init__.pyc in
download_dataset(self, dataset_id, file_path, use_default_filename,
wait_for_completion, maxwait)
81 dataset = self.show_dataset(dataset_id)
82 if not dataset['state'] == 'ok':
---> 83 raise DatasetStateException("Dataset not ready. Dataset id:
%s, current state: %s" % (dataset_id, dataset['state']))
84
85 # Galaxy release_13.01 and earlier does not have file_ext in
the dataset
DatasetStateException: u'Dataset not ready. Dataset id: 1cd8e2f6b131e891,
current state: error'
Also note that :
g_vers = gi.config.get_config()
g_vers['version_major']
Outputs]:
u'15.03'
Any help/elucidation gratefully received (I'm on a learning curve here) :-)
Thanks in anticipation.
Mark Fernandes
#Code omitting the template files##
-
import bioblend.galaxy
import os
# Ipython Notebook version - MAF Oct 2015
# Server specific bit. in Real code get this from environ & args (argv)
server = 'http://N85460.nbi.ac.uk:8080/'
api_key = 'secret_squirrel'
rootpath = os.path.join(os.environ['HOME'],'gal_exports/data')
print 'Root path: ',rootpath
#connect to galaxy server instance
gi = bioblend.galaxy.GalaxyInstance(url=server, key=api_key)
#fetch names info about data libraries
dl = gi.libraries.get_libraries()
# for each library, get the folder names for each set & create the sub-dirs if
they do not exist
for libs in dl:
print 'Library: ', libs['name']
rootpathplus = os.path.join(rootpath,libs['name'])
# Code to check directory pre-esistence and create it if it doesn't
# Move this out to a support module in finished code
try:
os.makedirs(rootpathplus, 0755)
except OSError:
if not os.path.isdir(rootpathplus):
raise
# for each library, get the folder names for each set & create the sub-dirs if
they do not exist
fold = gi.libraries.get_folders(libs['id'])
print 'No. of items in library',len(fold)
if len(fold) > 1:
for items in fold:
dirpath =
os.path.join(rootpathplus,os.path.normpath(items['name'].strip("/")))
try:
os.makedirs(dirpath, 0755)
except OSError:
if not os.path.isdir(dirpath):
raise
#
# for each folder create the sub-dir off of user rootdir
cl = gi.libraries.show_library(libs['id'],True)
for items in cl:
if items['type']=='file':
fname = os.path.normpath(items['name'])
file_ext = os.path.splitext(fname)[1]
#check for tabular data file and omit to avoid error message
if file_ext != '.tabular':
# Swap above if with this one to let the bad stuff happen...
# if file_ext != '.untrapped':
filepath = os.path.join(rootpathplus,fname.strip("/"))
print '>>',filepath,'<<'
gi.datasets.download_dataset(items['id'],filepath,False)
Root path: /usr/users/fr009/fernande/gal_exports/data
Library: Intro Galaxy Training
No. of items in library 11
>> /usr/users/fr009/fernande/gal_exports/data/Intro Galaxy
>> Training/Getting_started/NBARC/BM361007.fasta <<
>> /usr/users/fr009/fernande/gal_exports/data/Intro Galaxy
>> Training/Getting_started/Pinfestans/PinfestansAVH9.fasta <<
>>