# HG changeset patch # User brenninc # Date 1462694898 14400 # Node ID af7b7c99ae9f4cdb369374a5c9b48a4151aef107 Uploaded diff -r 000000000000 -r af7b7c99ae9f data_manager/gene_transfer_by_path_data_manager.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/data_manager/gene_transfer_by_path_data_manager.xml Sun May 08 04:08:18 2016 -0400 @@ -0,0 +1,37 @@ + + path inputer + + path_name_value_key_manager.py + --value "${value}" + --dbkey "${dbkey}" + --name "${name}" + --path "${path}" + --data_table_name "gene_transfer" + --json_output_file "${json_output_file}" + + + + + + + + + + + + +Adds a server path to the gene_transfer data table. + +The tool will check the path exists but NOT check that it holds the expected data type. + +If name is not provided the filename from path less the exstension is used. + +If value is not provided, the name will be used (or its default) + +If dbkey is not provided, the value will be used (or its default) + + + + + + diff -r 000000000000 -r af7b7c99ae9f data_manager/path_name_value_key_manager.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/data_manager/path_name_value_key_manager.py Sun May 08 04:08:18 2016 -0400 @@ -0,0 +1,70 @@ +#!/usr/bin/env python + +import json +import optparse +import os.path + +def _add_data_table_entry( data_manager_dict, data_table_name, data_table_entry ): + data_manager_dict['data_tables'] = data_manager_dict.get( 'data_tables', {} ) + data_manager_dict['data_tables'][ data_table_name ] = data_manager_dict['data_tables'].get( data_table_name, [] ) + data_manager_dict['data_tables'][ data_table_name ].append( data_table_entry ) + return data_manager_dict + + +def check_param(name, value, default=None, check_tab=True): + if value in [ None, '', '?' ]: + if default: + print "Using {0} for {1} as no value provided".format( default, name ) + value = default + else: + raise Exception( '{0} is not a valid {1}. You must specify a valid {1}.'.format( value, name ) ) + if check_tab and "\t" in value: + raise Exception( '{0} is not a valid {1}. It may not contain a tab because these are used as seperators by galaxy .'.format( value, name ) ) + return value + + +def main(): + + #value = "test_value" + #name = "test_name" + #print '{0} other {1} more{0}'.format(value, name ) + #print '{0} is not a valid {1}. It may not contain a tab.'.format( value, name ) + + #Parse Command Line + parser = optparse.OptionParser() + parser.add_option( '--value', action='store', type="string", default=None, help='value' ) + parser.add_option( '--dbkey', action='store', type="string", default=None, help='dbkey' ) + parser.add_option( '--name', action='store', type="string", default=None, help='name' ) + parser.add_option( '--path', action='store', type="string", default=None, help='path' ) + parser.add_option( '--data_table_name', action='store', type="string", default=None, help='path' ) + parser.add_option( '--json_output_file', action='store', type="string", default=None, help='path' ) + (options, args) = parser.parse_args() + + path = check_param("path", options.path) + if not os.path.exists(path): + raise Exception( 'Unable to find path {0}.'.format( path ) ) + basename = os.path.basename(path) + filename = os.path.splitext(basename)[0] + name = check_param("name", options.name, default=filename) + value = check_param("value", options.value, default=name) + dbkey = check_param("dbkey", options.dbkey, default=value) + data_table_name = check_param("data_table_name", options.data_table_name) + json_output_file = check_param("json_output_file", options.json_output_file, check_tab=False) + + if os.path.exists(json_output_file): + params = json.loads( open( json_output_file ).read() ) + print "params", params + else: + params = {} + + data_manager_dict = {} + data_table_entry = dict( value=value, dbkey=dbkey, name=name, path=path ) + _add_data_table_entry( data_manager_dict, data_table_name, data_table_entry ) + + #save info to json file + with open( json_output_file, 'wb' ) as output_file: + output_file.write( json.dumps( data_manager_dict ) ) + output_file.write( "\n" ) + +if __name__ == "__main__": + main() diff -r 000000000000 -r af7b7c99ae9f data_manager_conf.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/data_manager_conf.xml Sun May 08 04:08:18 2016 -0400 @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff -r 000000000000 -r af7b7c99ae9f tool-data/gene_transfer.loc.sample --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tool-data/gene_transfer.loc.sample Sun May 08 04:08:18 2016 -0400 @@ -0,0 +1,14 @@ +#This file lists the locations and dbkeys of all the gene transfer files + +#This file has the format (white space characters are TAB characters): +# +# +# +#So, gene_transfer.loc could look something like this: +# +#vm5 vm5 vM5 annotation /path/to/vM5.annotation.gtf +# +#Your gene_transfer.loc file should contain an entry for each individual +#gtf file. +# + diff -r 000000000000 -r af7b7c99ae9f tool_data_table_conf.xml.sample --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tool_data_table_conf.xml.sample Sun May 08 04:08:18 2016 -0400 @@ -0,0 +1,7 @@ + + + + value, dbkey, name, path + +
+