changeset 6:97b1b5ad1cda draft default tip

planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_build_bakta_database commit e0ce56ac52cff0e8f85e546440d28ca46853b11d
author iuc
date Thu, 20 Jun 2024 19:13:58 +0000
parents baceff842902
children
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, 35 insertions(+), 49 deletions(-) [+]
line wrap: on
line diff
--- a/data_manager/bakta_build_database.py	Wed Jun 05 14:20:59 2024 +0000
+++ b/data_manager/bakta_build_database.py	Thu Jun 20 19:13:58 2024 +0000
@@ -135,13 +135,9 @@
         try:
             with bakta_path.open("wb") as fh_out, requests.get(
                     self.db_url, stream=True) as resp:
-                total_length = resp.headers.get("content-length")
-                if total_length is None:  # no content length header
-                    for data in resp.iter_content(chunk_size=1024 * 1024):
-                        fh_out.write(data)
-                else:
-                    for data in resp.iter_content(chunk_size=1024 * 1024):
-                        fh_out.write(data)
+                # total_length = resp.headers.get("content-length")
+                for data in resp.iter_content(chunk_size=1024 * 1024):
+                    fh_out.write(data)
             print(f"Download bakta database {self.db_version}")
             self.tarball_path = bakta_path
         except IOError:
@@ -158,12 +154,19 @@
             ) as tar_file:
                 tar_file.extractall(path=db_path)
                 print(f"Untar the database in {db_path}")
-
-            if not self.test_mode:
-                self.move_files(db_path=db_path)
-
         except OSError:
             sys.exit(f"ERROR: Could not extract {self.tar_name} " f"to {db_path}")
+        if not self.test_mode:
+            self.move_files(db_path=db_path)
+        self.db_dir = db_path.resolve()
+
+    def delete_folder(self, path):
+        for sub in path.iterdir():
+            if sub.is_dir() and sub.name != "latest":
+                self.delete_folder(sub)
+            else:
+                sub.unlink()
+        path.rmdir()
 
     def move_files(self, db_path):
         if db_path.joinpath("db-light").is_dir():
@@ -173,9 +176,9 @@
         output_dir = db_path
         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)
+                output = output_dir.joinpath(file.name)
+                file.rename(output)
+        self.delete_folder(input_dir)
 
     def calc_md5_sum(self, buffer_size=1048576):
         tarball_path = Path(self.db_dir).joinpath(self.tar_name)
--- a/data_manager/bakta_build_database.xml	Wed Jun 05 14:20:59 2024 +0000
+++ b/data_manager/bakta_build_database.xml	Thu Jun 20 19:13:58 2024 +0000
@@ -68,6 +68,19 @@
                 </assert_contents>
             </output>
         </test>
+        <!-- Test 3 with light db -->
+        <test expect_num_outputs="1">
+            <param name="test_data_manager" value=""/>
+            <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>
     </tests>
     <help><![CDATA[
         Download specific version of Bakta database <https://github.com/oschwengers/bakta#database>
--- a/data_manager/macro.xml	Wed Jun 05 14:20:59 2024 +0000
+++ b/data_manager/macro.xml	Thu Jun 20 19:13:58 2024 +0000
@@ -2,7 +2,7 @@
     <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@">0</token>
+    <token name="@VERSION_SUFFIX@">1</token>
     <token name="@PROFILE@">21.05</token>
     <xml name="requirements">
         <requirements>
--- a/test-data/bakta_test.loc	Wed Jun 05 14:20:59 2024 +0000
+++ b/test-data/bakta_test.loc	Thu Jun 20 19:13:58 2024 +0000
@@ -1,34 +1,4 @@
-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
+V1.0_2022-10-12	7197299	1.4	/private/var/folders/7j/21czvpk170zcyjdbqrp0hmsh0000gn/T/tmp4iv55h8k/galaxy-dev/tool-data/bakta_database/7197299
+V5.1light_2024-01-19	11371737	1.7	/private/var/folders/7j/21czvpk170zcyjdbqrp0hmsh0000gn/T/tmp4iv55h8k/galaxy-dev/tool-data/bakta_database/11371737
+V5.0light_2023-06-08	8021027	1.8	/private/var/folders/7j/21czvpk170zcyjdbqrp0hmsh0000gn/T/tmp4iv55h8k/galaxy-dev/tool-data/bakta_database/8021027
+V5.1light_2024-01-19	10522951	1.7	/private/var/folders/7j/21czvpk170zcyjdbqrp0hmsh0000gn/T/tmp4iv55h8k/galaxy-dev/tool-data/bakta_database/10522951