Mercurial > repos > rhpvorderman > data_manager_select_index_by_path
changeset 35:645c33d0786a draft
planemo upload for repository https://github.com/LUMC/lumc-galaxy-tools/tree/master/data_manager_select_index_by_path commit cb6d569e0496fac22e0e9c7fffa884338cef09c8
author | rhpvorderman |
---|---|
date | Wed, 11 Jul 2018 10:03:37 -0400 |
parents | cd78c64fe35b |
children | 8c3c1cfa8956 |
files | README data_manager/.pytest_cache/v/cache/nodeids data_manager/__pycache__/path_name_value_key_manager.cpython-35.pyc data_manager/__pycache__/test_path_name_value_key_manager.cpython-35-PYTEST.pyc data_manager/data_manager_select_index_by_path.xml data_manager/indexes.yml data_manager/path_name_value_key_manager.py |
diffstat | 7 files changed, 66 insertions(+), 16 deletions(-) [+] |
line wrap: on
line diff
--- a/README Thu Jul 05 09:29:08 2018 -0400 +++ b/README Wed Jul 11 10:03:37 2018 -0400 @@ -8,4 +8,4 @@ The tool has drastically changed since then, with a complete refactoring of the python script and the addition of unit tests for all functionality within the python script. A lot of indexes are now supported in addition to -just the all_fasta one. \ No newline at end of file +just the all_fasta one.
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/data_manager/.pytest_cache/v/cache/nodeids Wed Jul 11 10:03:37 2018 -0400 @@ -0,0 +1,27 @@ +[ + "test_path_name_value_key_manager.py::test_validate_indexes_yaml", + "test_path_name_value_key_manager.py::test_schema", + "test_path_name_value_key_manager.py::test_schema_fail", + "test_path_name_value_key_manager.py::test_application", + "test_path_name_value_key_manager.py::test_application_overwrite_file", + "test_path_name_value_key_manager.py::test_application_star_index", + "test_path_name_value_key_manager.py::test_application_star_index_fail_wrong_yaml", + "test_path_name_value_key_manager.py::test_check_tab", + "test_path_name_value_key_manager.py::test_check_tab_fail", + "test_path_name_value_key_manager.py::test_data_table", + "test_path_name_value_key_manager.py::test_non_existing_table", + "test_path_name_value_key_manager.py::test_rnastar_index_fail_no_extra_column", + "test_path_name_value_key_manager.py::test_rnastar_index_fail_wrong_dir", + "test_path_name_value_key_manager.py::test_all_fasta_table_fail_extra_columns", + "test_path_name_value_key_manager.py::test_all_fasta_table", + "test_path_name_value_key_manager.py::test_index_path_not_exist", + "test_path_name_value_key_manager.py::test_index_path_is_a_dir", + "test_path_name_value_key_manager.py::test_bowtie2_index", + "test_path_name_value_key_manager.py::test_bowtie2_index_fail", + "test_path_name_value_key_manager.py::test_bwa_index", + "test_path_name_value_key_manager.py::test_bowtie_index", + "test_path_name_value_key_manager.py::test_bowtie_index_color", + "test_path_name_value_key_manager.py::test_hisat2_index", + "test_path_name_value_key_manager.py::test_picard_index", + "test_path_name_value_key_manager.py::test_sam_index" +] \ No newline at end of file
Binary file data_manager/__pycache__/test_path_name_value_key_manager.cpython-35-PYTEST.pyc has changed
--- a/data_manager/data_manager_select_index_by_path.xml Thu Jul 05 09:29:08 2018 -0400 +++ b/data_manager/data_manager_select_index_by_path.xml Wed Jul 11 10:03:37 2018 -0400 @@ -3,6 +3,7 @@ <!-- Away with python 2! --> <requirement type="package" version="3.5">python</requirement> <requirement type="package" version="3.12">pyyaml</requirement> + <requirement type="package" version="0.6.6">schema</requirement> </requirements> <description>Link to indexes on the filesystem that have already been built</description> <command detect_errors="exit_code"><![CDATA[
--- a/data_manager/indexes.yml Thu Jul 05 09:29:08 2018 -0400 +++ b/data_manager/indexes.yml Wed Jul 11 10:03:37 2018 -0400 @@ -1,5 +1,5 @@ --- -# This is a file containing information about all the indexes. +# This file contains information about all the indexes. # # Top keys are table names as used in Galaxy. # These names can be viewed in the 'local data' part of the admin menu
--- a/data_manager/path_name_value_key_manager.py Thu Jul 05 09:29:08 2018 -0400 +++ b/data_manager/path_name_value_key_manager.py Wed Jul 11 10:03:37 2018 -0400 @@ -6,6 +6,17 @@ from pathlib import Path import yaml +from schema import Schema, Optional + + +def indexes_schema(): + return Schema( + {'name': str, + Optional('prefix'): bool, + Optional('extensions'): [str], + Optional('prefix_strip_extension'): bool, + Optional('extra_columns'): [str], + Optional('folder'): [str]}) def argument_parser(): @@ -31,8 +42,8 @@ def check_tab(name: str, value: str): if '\t' in value: raise ValueError( - '\'{0}\' is not a valid \'{1}\'. It may not contain a tab because ' - 'these are used as seperators by galaxy .'.format( + "'{0}' is not a valid '{1}'. It may not contain a tab because " + "these are used as seperators by galaxy .".format( value, name)) @@ -92,7 +103,7 @@ str(index_extra_columns).strip("{}"))) if len(index_extra_columns) == 0: raise ValueError( - "The table \'{0}\' does not have extra columns".format( + "The table '{0}' does not have extra columns".format( self.data_table_name)) for key, value in self.extra_columns.items(): check_tab(key, value) @@ -103,14 +114,16 @@ index_properties = indexes.get(self.data_table_name) if index_properties is None: raise ValueError( - "\'{0}\' not a supported table name".format( + "'{0}' not a supported table name".format( self.data_table_name)) - return index_properties + return indexes_schema().validate(index_properties) def check_index_file_presence(self): - index_name = self.index_properties.get( - 'name', - '[Index name not found. Please report to developers]') + index_name = self.index_properties.get('name') + if index_name is None: + raise NotImplementedError( + "Property 'name' not defined for '{0}'," + " please contact the developers to correct the mistake.") index_extensions = self.index_properties.get('extensions', ['']) # Sometimes an index path is a prefix. @@ -132,8 +145,8 @@ if not prefix_plus_extension_exists(self.index_path.parent, prefix, extension): raise FileNotFoundError( - 'Unable to find files with prefix \'{0}\' ' - 'and extension \'{1}\' in {2}. Is this a valid {3}?' + "Unable to find files with prefix '{0}' " + "and extension '{1}' in {2}. Is this a valid {3}?" .format( prefix, extension, @@ -143,12 +156,21 @@ for file in self.index_properties.get('folder'): if not (self.index_path / Path(file)).exists(): raise FileNotFoundError( - "A file named \'{0}\' was not found in \'{1}\'".format( + "A file named '{0}' was not found in '{1}'".format( file, str(self.index_path))) + elif not self.index_path.exists() and not self.index_path.is_dir(): + raise FileNotFoundError( + 'Unable to find path {0}.'.format(self.index_path)) + elif self.index_path.is_dir() and self.index_properties.get( + 'folder') is None: + raise IsADirectoryError( + '{0} is a directory not a file'.format(self.index_path)) + elif self.index_path.exists(): + pass else: - if not self.index_path.exists(): - raise FileNotFoundError( - 'Unable to find path {0}.'.format(self.index_path)) + raise NotImplementedError("This condition was not expected " + "and should not be reached. Please " + "contact the developers.") @property def data_manager_dict(self) -> dict: