# HG changeset patch # User sanbi-uwc # Date 1536834332 14400 # Node ID 52f0767fe68de5ad665d2da678f407881e4ea6ca # Parent f86c65c60056c5479ad28cdf02bf005c26f40bc8 planemo upload for repository https://github.com/pvanheus/data_manager_shapeit_reference commit b42d6cc8358088a50bc4463367c740c1e9dc71d8 diff -r f86c65c60056 -r 52f0767fe68d data_manager/shapeit_ref.py --- a/data_manager/shapeit_ref.py Tue Sep 11 10:39:38 2018 -0400 +++ b/data_manager/shapeit_ref.py Thu Sep 13 06:25:32 2018 -0400 @@ -14,34 +14,46 @@ return data_manager_dict +_add_data_table_entry.__annotations__ = {'data_manager': dict, 'data_table_name': str, 'data_table_entry': dict, 'return': dict} + + +def assert_prefix_exists(prefix, path, prefix_type): + prefix_exists = False + for filename in os.listdir(path): + if filename.startswith(prefix): + prefix_exists = True + break + else: + if not prefix_exists: + exit("Unable to find a file with {} prefix {} in {}".format(prefix_type, prefix, path)) + + +assert_prefix_exists.__annotations__ = {'prefix': str, 'path': str, 'prefix_type': str, 'return': None} + if __name__ == '__main__': parser = argparse.ArgumentParser(description='Generate a data manager output for SHAPEIT reference data') parser.add_argument('key', help='Short key to identify this reference set (no spaces)') parser.add_argument('description', help='Description of reference set') parser.add_argument('path', help='Filesystem path to directory containing this reference set') - parser.add_argument('prefix', help='Filename prefix for files in this reference set') + parser.add_argument('reference_prefix', help='Filename prefix for the reference (.hap / .legend / .sample) files') + parser.add_argument('map_prefix', help='Filename prefix for map files in this reference set') parser.add_argument('output_file', type=argparse.FileType('w'), help='JSON file used to write data manager values to') args = parser.parse_args() if not os.path.exists(args.path): exit("Unable to find specified path {}".format(args.path)) - prefix_exists = False - for filename in os.listdir(args.path): - if filename.startswith(args.prefix): - prefix_exists = True - break - else: - if not prefix_exists: - exit("Unable to find a file with prefix {} in {}".format(args.prefix, args.path)) + assert_prefix_exists(args.reference_prefix, args.path, 'reference') + assert_prefix_exists(args.map_prefix, args.path, 'map') - for column in ('key', 'description', 'path', 'prefix'): + for column in ('key', 'description', 'path', 'reference_prefix', 'map_prefix'): value = getattr(args, column) if '\t' in value: exit("TAB character found in {} argument".format(column)) data_manager_dict = {} - data_table_entry = dict(key=args.key, description=args.description, path=args.path, prefix=args.prefix) + data_table_entry = dict(key=args.key, description=args.description, path=args.path, + reference_prefix=args.reference_prefix, map_prefix=args.map_prefix) _add_data_table_entry(data_manager_dict, 'shapeit_ref', data_table_entry) - args.output_file.write(json.dumps(data_manager_dict) + '\n') + args.output_file.write(json.dumps(data_manager_dict, sort_keys=True) + '\n') diff -r f86c65c60056 -r 52f0767fe68d data_manager/shapeit_ref.xml --- a/data_manager/shapeit_ref.xml Tue Sep 11 10:39:38 2018 -0400 +++ b/data_manager/shapeit_ref.xml Thu Sep 13 06:25:32 2018 -0400 @@ -1,17 +1,19 @@ - + > - + + diff -r f86c65c60056 -r 52f0767fe68d data_manager_conf.xml --- a/data_manager_conf.xml Tue Sep 11 10:39:38 2018 -0400 +++ b/data_manager_conf.xml Thu Sep 13 06:25:32 2018 -0400 @@ -6,7 +6,8 @@ - + + diff -r f86c65c60056 -r 52f0767fe68d test-data/sample.out --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test-data/sample.out Thu Sep 13 06:25:32 2018 -0400 @@ -0,0 +1,1 @@ +{"data_tables": {"shapeit_ref": [{"description": "1000 Genomes Project (phase 3) haplotypes (http://mathgen.stats.ox.ac.uk/impute/1000GPX20Phase3.html)", "key": "1000GP_Phase3", "map_prefix": "genetic_map_", "path": "/tools/databases/1000G/1000GP_Phase3", "reference_prefix": "1000GP_Phase3_"}]}} diff -r f86c65c60056 -r 52f0767fe68d tool-data/shapeit_ref.loc.sample --- a/tool-data/shapeit_ref.loc.sample Tue Sep 11 10:39:38 2018 -0400 +++ b/tool-data/shapeit_ref.loc.sample Thu Sep 13 06:25:32 2018 -0400 @@ -1,7 +1,7 @@ #This file lists the locations of SHAPEIT reference data connections # -# +# # #For example # -#1000G_Phase3 1000 Genomes project haplotypes /path/to/shapeit_ref/1000G 1000GP_Phase3_ +#1000G_Phase3 1000 Genomes project haplotypes /path/to/shapeit_ref/1000G 1000GP_Phase3_ genetic_map_ diff -r f86c65c60056 -r 52f0767fe68d tool_data_tables_conf.xml.sample --- a/tool_data_tables_conf.xml.sample Tue Sep 11 10:39:38 2018 -0400 +++ b/tool_data_tables_conf.xml.sample Thu Sep 13 06:25:32 2018 -0400 @@ -1,7 +1,7 @@ - key, description, path, prefix + key, description, path, reference_prefix, map_prefix
\ No newline at end of file