# HG changeset patch # User rhpvorderman # Date 1505129035 14400 # Node ID 8ccfeedd1f037b2d0ab1d57a8d5c6452972795ce # Parent 442b983d948e556347826c7b407a4ad67ce16aba planemo upload for repository https://github.com/LUMC/lumc-galaxy-tools/tree/master/data_manager_select_index_by_path commit 6fd3421f2405e0e56147f1ee807c297dad8e547d diff -r 442b983d948e -r 8ccfeedd1f03 data_manager/data_manager_select_index_by_path.xml --- a/data_manager/data_manager_select_index_by_path.xml Mon Sep 11 07:22:49 2017 -0400 +++ b/data_manager/data_manager_select_index_by_path.xml Mon Sep 11 07:23:55 2017 -0400 @@ -1,4 +1,4 @@ - + path inputer path_name_value_key_manager.py @@ -14,8 +14,8 @@ - - + + @@ -23,10 +23,9 @@ - - + diff -r 442b983d948e -r 8ccfeedd1f03 data_manager/indexes.yml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/data_manager/indexes.yml Mon Sep 11 07:23:55 2017 -0400 @@ -0,0 +1,48 @@ +all_fasta: + name: fasta file + extensions: + - .fa +bowtie2_indexes: + name: bowtie2 index + extensions: + - .bt2 +bowtie_indexes: + name: bowtie index + extensions: + - .ebwt +bowtie_indexes_color: + name: bowtie color index + extensions: + - .ebwt +bwa_mem_indexes: + name: bwa mem index + extensions: + - .amb + - .ann + - .bwt + - .pac + - .sa +bwameth_indexes: + name: bwa_meth_index +fasta_indexes: + name: fasta index + extensions: + - .fai +gatk_picard_index: + name: picard index for GATK +gene_transfer: + name: Gene Transfer File + extensions: + - .gtf +hisat2_indexes: + name: hisat2 index + extensions: + - .ht2 +kallisto_indexes: + name: kallisto index +picard_indexes: + name: picard index +tophat2_indexes: + name: tophat2 index + extensions: + - .bt2 diff -r 442b983d948e -r 8ccfeedd1f03 data_manager/path_name_value_key_manager.py --- a/data_manager/path_name_value_key_manager.py Mon Sep 11 07:22:49 2017 -0400 +++ b/data_manager/path_name_value_key_manager.py Mon Sep 11 07:23:55 2017 -0400 @@ -3,6 +3,7 @@ import json import argparse import os +import yaml 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', {} ) @@ -32,6 +33,16 @@ # Empty list should return False return bool(matched_files) +def prefix_plus_extension_exists(directory, prefix, extension): + '''checks if files exist with prefix in a directory. Returns Boolean''' + matched_files = [] + directory_files = os.listdir(directory) + for directory_file in directory_files: + if directory_file.startswith(prefix) and directory_file.endswith(extension): + matched_files.append(directory_file) + # Empty list should return False + return bool(matched_files) + def main(): #value = "test_value" @@ -51,17 +62,6 @@ options = parser.parse_args() path = check_param("path", options.path) - - # Check if file or prefix exists - if not options.no_prefix: - dirname = os.path.dirname(path) - prefix = os.path.basename(path) - if not prefix_exists(dirname,prefix): - raise Exception( 'Unable to find files with prefix "{0}" in {1}.'.format( prefix, dirname ) ) - else: - 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) @@ -70,6 +70,21 @@ 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) + # Check if file or prefix exists + indexes = yaml.load(file(os.path.join(os.path.dirname(__file__), 'indexes.yml'))) + index_dict = indexes.get(data_table_name,{}) + index_name = index_dict.get('name','index') + index_extensions = index_dict.get('extensions', ['']) + if not options.no_prefix: + dirname = os.path.dirname(path) + prefix = basename + for extension in index_extensions: + if not prefix_plus_extension_exists(dirname,prefix,extension): + raise Exception( 'Unable to find files with prefix "{0}" and extension "{1}" in {2}. Is this a valid {3}?'.format( prefix, extension, dirname, index_name ) ) + else: + if not os.path.exists(path): + raise Exception( 'Unable to find path {0}.'.format( path ) ) + if os.path.exists(json_output_file): params = json.loads( open( json_output_file ).read() ) print "params", params diff -r 442b983d948e -r 8ccfeedd1f03 data_manager_conf.xml --- a/data_manager_conf.xml Mon Sep 11 07:22:49 2017 -0400 +++ b/data_manager_conf.xml Mon Sep 11 07:23:55 2017 -0400 @@ -1,6 +1,6 @@ - + @@ -65,14 +65,6 @@ - - - - - - - - diff -r 442b983d948e -r 8ccfeedd1f03 tool-data/gemini_databases.loc.sample --- a/tool-data/gemini_databases.loc.sample Mon Sep 11 07:22:49 2017 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,3 +0,0 @@ -## GEMINI databases -#Version dbkey Description -#08_08_2014 hg19 Database (08-08-2014) diff -r 442b983d948e -r 8ccfeedd1f03 tool_data_table_conf.xml.sample --- a/tool_data_table_conf.xml.sample Mon Sep 11 07:22:49 2017 -0400 +++ b/tool_data_table_conf.xml.sample Mon Sep 11 07:23:55 2017 -0400 @@ -32,10 +32,6 @@ value, dbkey, name, path - - value, dbkey, name, path - -
value, dbkey, name, path