# HG changeset patch # User pjbriggs # Date 1422439486 18000 # Node ID d9032bb158b9c3eed6e3c5e011883bc5c2224d1a # Parent 8b25779ee26120e86c51dc8a4be6d20edf529a1d Add in data manager for CEAS annotation databases. diff -r 8b25779ee261 -r d9032bb158b9 data_manager/data_manager_ceas_fetch_annotations.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/data_manager/data_manager_ceas_fetch_annotations.py Wed Jan 28 05:04:46 2015 -0500 @@ -0,0 +1,75 @@ +#!/usr/bin/env python +# + +import sys +import os +import optparse +import urllib2 +import gzip + +from galaxy.util.json import from_json_string, to_json_string + +# Download file from specified URL and put into local subdir + +if __name__ == '__main__': + #Parse Command Line + parser = optparse.OptionParser() + parser.add_option('--download',dest='url',action='store', + type="string",default=None,help='URL to download') + options,args = parser.parse_args() + print "options: %s" % options + print "args : %s" % args + if len(args) != 2: + p.error("Need to supply JSON file name and description text") + + # Read the JSON supplied from the data manager tool + # Results from this program will be returned via the + # same file + jsonfile = args[0] + params = from_json_string(open(jsonfile).read() ) + print "%s" % params + + # Extract the data from the input JSON + # See https://wiki.galaxyproject.org/Admin/Tools/DataManagers/HowTo/Define?highlight=%28\bAdmin%2FTools%2FDataManagers\b%29 + # for example of JSON + # + # We want the values set in the data manager XML + dbkey = params['param_dict']['dbkey'] + description = params['param_dict']['description'] + # Where to put the output file + # Nb we have to make this ourselves, it doesn't exist by default + target_dir = params['output_data'][0]['extra_files_path'] + os.mkdir(target_dir) + + # Dictionary for returning to data manager + data_manager_dict = {} + + # Download from URL + if options.url is not None: + print "Downloading: %s" % options.url + annotation_file_name = os.path.basename(options.url) + annotation_file_path = os.path.join(target_dir,annotation_file_name) + print "Annotation file name: %s" % annotation_file_name + print "Annotation file path: %s" % annotation_file_path + open(annotation_file_path,'wb').write(urllib2.urlopen(options.url).read()) + if annotation_file_name.endswith('.gz'): + # Uncompress + uncompressed_file = annotation_file_path[:-3] + open(uncompressed_file,'wb').write(gzip.open(annotation_file_path,'rb').read()) + # Remove gzipped file + os.remove(annotation_file_path) + annotation_file_name = os.path.basename(uncompressed_file) + annotation_file_path = uncompressed_file + # Update the output dictionary + data_manager_dict['data_tables'] = dict() + data_manager_dict['data_tables']['ceas_annotations'] = { + 'dbkey': dbkey, + 'name': description, + 'value': annotation_file_name, + } + else: + raise NotImplementedError("Non-download options not implemented") + + #save info to json file + open(jsonfile,'wb').write(to_json_string(data_manager_dict)) + diff -r 8b25779ee261 -r d9032bb158b9 data_manager/data_manager_ceas_fetch_annotations.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/data_manager/data_manager_ceas_fetch_annotations.xml Wed Jan 28 05:04:46 2015 -0500 @@ -0,0 +1,73 @@ + + Fetch and install annotation databases for CEAS + data_manager_ceas_fetch_annotations.py + #if str( $reference_source.reference_source_selector ) == "ceas_web" + --download=$reference_source.annotation_url + #end if + "${out_file}" + "${description}" + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +**What it does** + +Fetches an annotation database from the CEAS website, Galaxy history, or a server directory +and populates the "ceas_annotations" data table. + +------ + + + +.. class:: infomark + +**Notice:** If you leave name, description, or id blank, it will be generated automatically. + + + diff -r 8b25779ee261 -r d9032bb158b9 data_manager_conf.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/data_manager_conf.xml Wed Jan 28 05:04:46 2015 -0500 @@ -0,0 +1,22 @@ + + + + + + + + + + + ${value} + ceas/${dbkey}/${value} + + ${GALAXY_DATA_MANAGER_DATA_PATH}/ceas/${dbkey}/${value} + abspath + + + + +