Mercurial > repos > iuc > data_manager_bakta
changeset 5:baceff842902 draft
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_build_bakta_database commit e277883fca66013904bae930f04e7f3be5fcb1a2
author | iuc |
---|---|
date | Wed, 05 Jun 2024 14:20:59 +0000 |
parents | d74850cf4e42 |
children | 97b1b5ad1cda |
files | data_manager/bakta_build_database.py data_manager/bakta_build_database.xml data_manager/macro.xml test-data/bakta_test.loc |
diffstat | 4 files changed, 88 insertions(+), 37 deletions(-) [+] |
line wrap: on
line diff
--- a/data_manager/bakta_build_database.py Fri Aug 25 23:34:04 2023 +0000 +++ b/data_manager/bakta_build_database.py Wed Jun 05 14:20:59 2024 +0000 @@ -1,9 +1,7 @@ import argparse import hashlib import json -import os import re -import shutil import sys import tarfile from datetime import datetime @@ -34,7 +32,7 @@ self.tar_name = tarball_name self.db_version = db_version self.DB_VERSIONS_URL = "https://raw.githubusercontent.com/oschwengers/bakta/master/db-versions.json" - self.DB_TEST_URL = "https://zenodo.org/record/8021032/files/db-versions.json" + self.DB_TEST_URL = "https://zenodo.org/record/11381156/files/db-versions.json" self.test_mode = test_mode def get_database_type(self): @@ -162,22 +160,22 @@ print(f"Untar the database in {db_path}") if not self.test_mode: - self.moove_files(db_path=db_path) + self.move_files(db_path=db_path) except OSError: sys.exit(f"ERROR: Could not extract {self.tar_name} " f"to {db_path}") - def moove_files(self, db_path): - if os.path.isdir(db_path.joinpath("db-light")): + def move_files(self, db_path): + if db_path.joinpath("db-light").is_dir(): input_dir = db_path.joinpath("db-light") - elif os.path.isdir(db_path.joinpath("db")): + elif db_path.joinpath("db").is_dir(): input_dir = db_path.joinpath("db") - file_list = os.listdir(input_dir) output_dir = db_path - for file in file_list: - input = input_dir.joinpath(file) - output = output_dir.joinpath(file) - shutil.move(input, output) + for file in input_dir.iterdir(): + if file.is_file(): # to avoid moving amrfinder-plus folder + input = input_dir.joinpath(file) + output = output_dir.joinpath(file) + input.rename(output) def calc_md5_sum(self, buffer_size=1048576): tarball_path = Path(self.db_dir).joinpath(self.tar_name) @@ -223,15 +221,15 @@ all_args = parse_arguments() with open(all_args.data_manager_json) as fh: params = json.load(fh) - target_dir = params["output_data"][0]["extra_files_path"] - os.makedirs(target_dir) + target_dir = Path(params["output_data"][0]["extra_files_path"]) + target_dir.mkdir(parents=True, exist_ok=True) # init the class to download bakta db bakta_upload = InstallBaktaDatabase( test_mode=all_args.test, db_version=all_args.database_version ) bakta_db = bakta_upload.fetch_db_versions() # update the path for galaxy - bakta_upload.db_dir = target_dir + bakta_upload.db_dir = target_dir.absolute() # download the database bakta_upload.download() # check md5 sum
--- a/data_manager/bakta_build_database.xml Fri Aug 25 23:34:04 2023 +0000 +++ b/data_manager/bakta_build_database.xml Wed Jun 05 14:20:59 2024 +0000 @@ -4,24 +4,24 @@ <import>macro.xml</import> </macros> <expand macro="requirements"/> - <command detect_errors="exit_code"> - <![CDATA[ - python '$__tool_directory__/bakta_build_database.py' - '$output_file' - --database_version '$database_select' - $test_data_manager - ]]></command> + <command detect_errors="exit_code"><![CDATA[ +python '$__tool_directory__/bakta_build_database.py' + '$output_file' + --database_version '$database_select' + $test_data_manager +]]></command> <inputs> <param name="database_select" type="select" label="Database version" help="Choose a database version to download (default latest version)"> - <option value="latest" selected="true">Latest available version</option> - <option value="1.0">V1.0_2020-11-20</option> - <option value="1.1">V1.1_2020-12-18</option> - <option value="2.0">V2.0_2021-04-05</option> - <option value="3.0">V3.0_2021-08-05</option> - <option value="3.1">V3.1_2022-02-03</option> - <option value="4.0">V4.0_2022-08-29</option> - <option value="5.0">V5.0_2023-02-20</option> - <option value="5.0_light">V5.0_light_2023-02-20</option> + <option value="5.1" selected="true">V5.1 (2024-01-19)</option> + <option value="5.1_light">V5.1 light (2024-01-19)</option> + <option value="5.0">V5.0 (2023-02-20)</option> + <option value="5.0_light">V5.0 light (2023-02-20)</option> + <option value="4.0">V4.0 (2022-08-29)</option> + <option value="3.1">V3.1 (2022-02-03)</option> + <option value="3.0">V3.0 (2021-08-05)</option> + <option value="2.0">V2.0 (2021-04-05)</option> + <option value="1.1">V1.1 (2020-12-18)</option> + <option value="1.0">V1.0 (2020-11-20)</option> </param> <param name="test_data_manager" type="hidden" value=""/> </inputs> @@ -33,19 +33,40 @@ <test expect_num_outputs="1"> <param name="test_data_manager" value="--test"/> <param name="database_select" value="1.0"/> - <output name="output_file" value="bakta_test_data_manager1.json" /> + <output name="output_file" ftype="data_manager_json"> + <assert_contents> + <has_text text="data_tables"/> + <has_text text="bakta_database"/> + <has_text text="bakta_version"/> + <has_text text="V1.0_2022-10-12"/> + </assert_contents> + </output> </test> <!-- Test 2 with the latest option --> <test expect_num_outputs="1"> <param name="test_data_manager" value="--test"/> - <param name="database_select" value="latest"/> - <output name="output_file" value="bakta_test_data_manager2.json" /> + <param name="database_select" value="5.1_light"/> + <output name="output_file" ftype="data_manager_json"> + <assert_contents> + <has_text text="data_tables"/> + <has_text text="bakta_database"/> + <has_text text="bakta_version"/> + <has_text text="V5.1light_2024-01-19"/> + </assert_contents> + </output> </test> <!-- Test 3 with light db --> <test expect_num_outputs="1"> <param name="test_data_manager" value="--test"/> <param name="database_select" value="5.0_light"/> - <output name="output_file" value="bakta_test_data_manager3.json" /> + <output name="output_file" ftype="data_manager_json"> + <assert_contents> + <has_text text="data_tables"/> + <has_text text="bakta_database"/> + <has_text text="bakta_version"/> + <has_text text="V5.0light_2023-06-08"/> + </assert_contents> + </output> </test> </tests> <help><![CDATA[
--- a/data_manager/macro.xml Fri Aug 25 23:34:04 2023 +0000 +++ b/data_manager/macro.xml Wed Jun 05 14:20:59 2024 +0000 @@ -1,13 +1,14 @@ <macros> - <token name="@TOOL_VERSION@">1.8.1</token> + <token name="@TOOL_VERSION@">1.9.3</token> <token name="@REQUESTS_VERSION@">2.27.1</token> <token name="@PYTHON_VERSION@">3.8</token> - <token name="@VERSION_SUFFIX@">2</token> + <token name="@VERSION_SUFFIX@">0</token> <token name="@PROFILE@">21.05</token> <xml name="requirements"> <requirements> <requirement type="package" version="@PYTHON_VERSION@">python</requirement> <requirement type="package" version="@REQUESTS_VERSION@">requests</requirement> + <requirement type="package" version="@TOOL_VERSION@">bakta</requirement> </requirements> </xml> </macros>
--- a/test-data/bakta_test.loc Fri Aug 25 23:34:04 2023 +0000 +++ b/test-data/bakta_test.loc Wed Jun 05 14:20:59 2024 +0000 @@ -1,3 +1,34 @@ V1.0_2022-10-12 7197299 1.4 bakta-db V5.0_2023-06-08 8021027 1.8 bakta-db V5.0light_2023-06-08 8021027 1.8 bakta-db +V1.0_2022-10-12 7197299 1.4 /private/var/folders/7j/21czvpk170zcyjdbqrp0hmsh0000gn/T/tmpmw3oj2pm/galaxy-dev/tool-data/bakta_database/7197299 +V5.0light_2023-06-08 8021027 1.8 /private/var/folders/7j/21czvpk170zcyjdbqrp0hmsh0000gn/T/tmpmw3oj2pm/galaxy-dev/tool-data/bakta_database/8021027 +V1.0_2022-10-12 7197299 1.4 /private/var/folders/7j/21czvpk170zcyjdbqrp0hmsh0000gn/T/tmpe_k2ghko/galaxy-dev/tool-data/bakta_database/7197299 +V5.0light_2023-06-08 8021027 1.8 /private/var/folders/7j/21czvpk170zcyjdbqrp0hmsh0000gn/T/tmpe_k2ghko/galaxy-dev/tool-data/bakta_database/8021027 +V1.0_2020-11-20 4247253 0.3 /private/var/folders/7j/21czvpk170zcyjdbqrp0hmsh0000gn/T/tmpfggmpn80/galaxy-dev/tool-data/bakta_database/4247253 +V1.0_2020-11-20 4247253 0.3 /private/var/folders/7j/21czvpk170zcyjdbqrp0hmsh0000gn/T/tmpcp1hbj74/galaxy-dev/tool-data/bakta_database/4247253 +V5.0light_2023-02-20 7669534 1.7 /private/var/folders/7j/21czvpk170zcyjdbqrp0hmsh0000gn/T/tmpcp1hbj74/galaxy-dev/tool-data/bakta_database/7669534 +V1.0_2020-11-20 4247253 0.3 /private/var/folders/7j/21czvpk170zcyjdbqrp0hmsh0000gn/T/tmpch1mha23/galaxy-dev/tool-data/bakta_database/4247253 +V5.1_2024-01-19 10522951 1.7 /private/var/folders/7j/21czvpk170zcyjdbqrp0hmsh0000gn/T/tmpch1mha23/galaxy-dev/tool-data/bakta_database/10522951 +V5.0light_2023-02-20 7669534 1.7 /private/var/folders/7j/21czvpk170zcyjdbqrp0hmsh0000gn/T/tmpch1mha23/galaxy-dev/tool-data/bakta_database/7669534 +V1.0_2020-11-20 4247253 0.3 /private/var/folders/7j/21czvpk170zcyjdbqrp0hmsh0000gn/T/tmpdntg5lkb/galaxy-dev/tool-data/bakta_database/4247253 +V5.1light_2024-01-19 10522951 1.7 /private/var/folders/7j/21czvpk170zcyjdbqrp0hmsh0000gn/T/tmpdntg5lkb/galaxy-dev/tool-data/bakta_database/10522951 +V5.0light_2023-02-20 7669534 1.7 /private/var/folders/7j/21czvpk170zcyjdbqrp0hmsh0000gn/T/tmpdntg5lkb/galaxy-dev/tool-data/bakta_database/7669534 +V1.0_2020-11-20 4247253 0.3 /private/var/folders/7j/21czvpk170zcyjdbqrp0hmsh0000gn/T/tmp2dxsmaz6/galaxy-dev/tool-data/bakta_database/4247253 +V5.0light_2023-02-20 7669534 1.7 /private/var/folders/7j/21czvpk170zcyjdbqrp0hmsh0000gn/T/tmp2dxsmaz6/galaxy-dev/tool-data/bakta_database/7669534 +V5.1light_2024-01-19 10522951 1.7 /private/var/folders/7j/21czvpk170zcyjdbqrp0hmsh0000gn/T/tmpxo577qsb/galaxy-dev/tool-data/bakta_database/10522951 +V5.0light_2023-02-20 7669534 1.7 /private/var/folders/7j/21czvpk170zcyjdbqrp0hmsh0000gn/T/tmpxo577qsb/galaxy-dev/tool-data/bakta_database/7669534 +V1.0_2020-11-20 4247253 0.3 /private/var/folders/7j/21czvpk170zcyjdbqrp0hmsh0000gn/T/tmpw560binc/galaxy-dev/tool-data/bakta_database/4247253 +V5.1light_2024-01-19 10522951 1.7 /private/var/folders/7j/21czvpk170zcyjdbqrp0hmsh0000gn/T/tmpw560binc/galaxy-dev/tool-data/bakta_database/10522951 +V5.0light_2023-02-20 7669534 1.7 /private/var/folders/7j/21czvpk170zcyjdbqrp0hmsh0000gn/T/tmpw560binc/galaxy-dev/tool-data/bakta_database/7669534 +V1.0_2020-11-20 4247253 0.3 /private/var/folders/7j/21czvpk170zcyjdbqrp0hmsh0000gn/T/tmpaehfoqch/galaxy-dev/tool-data/bakta_database/4247253 +V5.0light_2023-02-20 7669534 1.7 /private/var/folders/7j/21czvpk170zcyjdbqrp0hmsh0000gn/T/tmpaehfoqch/galaxy-dev/tool-data/bakta_database/7669534 +V1.0_2020-11-20 4247253 0.3 /private/var/folders/7j/21czvpk170zcyjdbqrp0hmsh0000gn/T/tmpj53k33oy/galaxy-dev/tool-data/bakta_database/4247253 +V5.1light_2024-01-19 10522951 1.7 /private/var/folders/7j/21czvpk170zcyjdbqrp0hmsh0000gn/T/tmpj53k33oy/galaxy-dev/tool-data/bakta_database/10522951 +V5.0light_2023-02-20 7669534 1.7 /private/var/folders/7j/21czvpk170zcyjdbqrp0hmsh0000gn/T/tmpj53k33oy/galaxy-dev/tool-data/bakta_database/7669534 +V1.0_2022-10-12 7197299 1.4 /private/var/folders/7j/21czvpk170zcyjdbqrp0hmsh0000gn/T/tmpdn_di5v_/galaxy-dev/tool-data/bakta_database/7197299 +V5.1light_2024-01-19 11371737 1.7 /private/var/folders/7j/21czvpk170zcyjdbqrp0hmsh0000gn/T/tmpdn_di5v_/galaxy-dev/tool-data/bakta_database/11371737 +V5.0light_2023-06-08 8021027 1.8 /private/var/folders/7j/21czvpk170zcyjdbqrp0hmsh0000gn/T/tmpdn_di5v_/galaxy-dev/tool-data/bakta_database/8021027 +V1.0_2022-10-12 7197299 1.4 /private/var/folders/7j/21czvpk170zcyjdbqrp0hmsh0000gn/T/tmp7n51m5jb/galaxy-dev/tool-data/bakta_database/7197299 +V5.1light_2024-01-19 11371737 1.7 /private/var/folders/7j/21czvpk170zcyjdbqrp0hmsh0000gn/T/tmp7n51m5jb/galaxy-dev/tool-data/bakta_database/11371737 +V5.0light_2023-06-08 8021027 1.8 /private/var/folders/7j/21czvpk170zcyjdbqrp0hmsh0000gn/T/tmp7n51m5jb/galaxy-dev/tool-data/bakta_database/8021027