annotate data_store_utils.py @ 2:269d246ce6d0 draft default tip

Uploaded
author damion
date Fri, 23 Oct 2015 17:53:29 -0400
parents 5c5027485f7d
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
5c5027485f7d Uploaded correct file
damion
parents:
diff changeset
1
5c5027485f7d Uploaded correct file
damion
parents:
diff changeset
2 def version_cache_setup(dataset_id, data_file_cache_folder, cacheable_dataset):
5c5027485f7d Uploaded correct file
damion
parents:
diff changeset
3 """ UNUSED: Idea was to enable caching of workflow products outside of galaxy for use by others.
5c5027485f7d Uploaded correct file
damion
parents:
diff changeset
4 CONSIDER METACODE. NOT INTEGRATED, NOT TESTED.
5c5027485f7d Uploaded correct file
damion
parents:
diff changeset
5 """
5c5027485f7d Uploaded correct file
damion
parents:
diff changeset
6 data_file_cache_name = os.path.join(data_file_cache_folder, dataset_id ) #'blastdb.txt'
5c5027485f7d Uploaded correct file
damion
parents:
diff changeset
7 if os.path.isfile(data_file_cache_name):
5c5027485f7d Uploaded correct file
damion
parents:
diff changeset
8 pass
5c5027485f7d Uploaded correct file
damion
parents:
diff changeset
9 else:
5c5027485f7d Uploaded correct file
damion
parents:
diff changeset
10 if os.path.isdir(data_file_cache_folder):
5c5027485f7d Uploaded correct file
damion
parents:
diff changeset
11 shutil.rmtree(data_file_cache_folder)
5c5027485f7d Uploaded correct file
damion
parents:
diff changeset
12 os.makedirs(data_file_cache_folder)
5c5027485f7d Uploaded correct file
damion
parents:
diff changeset
13 # Default filename=false means we're supplying the filename.
5c5027485f7d Uploaded correct file
damion
parents:
diff changeset
14 gi.datasets.download_dataset(dataset_id, file_path=data_file_cache_name, use_default_filename=False, wait_for_completion=True) # , maxwait=12000) is a default of 3 hours
5c5027485f7d Uploaded correct file
damion
parents:
diff changeset
15
5c5027485f7d Uploaded correct file
damion
parents:
diff changeset
16 # Generically, any dataset might have subfolders - to check we have to
5c5027485f7d Uploaded correct file
damion
parents:
diff changeset
17 # see if galaxy dataset file path has contents at _files suffix.
5c5027485f7d Uploaded correct file
damion
parents:
diff changeset
18 # Find dataset_id in version retrieval history datasets, and get its folder path, and copy _files over...
5c5027485f7d Uploaded correct file
damion
parents:
diff changeset
19 galaxy_dataset_folder = cacheable_dataset['file_name'][0:-4] + '_files'
5c5027485f7d Uploaded correct file
damion
parents:
diff changeset
20 time.sleep(2)
5c5027485f7d Uploaded correct file
damion
parents:
diff changeset
21 if os.path.isdir(galaxy_dataset_folder) \
5c5027485f7d Uploaded correct file
damion
parents:
diff changeset
22 and not os.path.isdir(data_file_cache_folder + '/files/'):
5c5027485f7d Uploaded correct file
damion
parents:
diff changeset
23 print 'Copying ' + galaxy_dataset_folder + ' to ' + data_file_cache_folder
5c5027485f7d Uploaded correct file
damion
parents:
diff changeset
24 # Copy program makes target folder.
5c5027485f7d Uploaded correct file
damion
parents:
diff changeset
25 shutil.copytree(galaxy_dataset_folder, data_file_cache_folder + '/files/') # , symlinks=False, ignore=None
5c5027485f7d Uploaded correct file
damion
parents:
diff changeset
26