# HG changeset patch
# User iuc
# Date 1693006444 0
# Node ID d74850cf4e425e81e47775bc347663971cfaf437
# Parent 3e73c97f025d1e39dfac522ec7d42181461654d1
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_build_bakta_database commit 404dc5eae30884c5814e463921eb3678bbd6878e
diff -r 3e73c97f025d -r d74850cf4e42 data_manager/bakta_build_database.py
--- a/data_manager/bakta_build_database.py Fri Jun 23 21:37:05 2023 +0000
+++ b/data_manager/bakta_build_database.py Fri Aug 25 23:34:04 2023 +0000
@@ -3,6 +3,7 @@
import json
import os
import re
+import shutil
import sys
import tarfile
from datetime import datetime
@@ -20,17 +21,16 @@
def __init__(
self,
data_table_name="bakta_database",
- db_name=Path.cwd().joinpath("db"),
db_version="latest",
tarball_name="db.tar.gz",
test_mode=False,
):
self.bakta_table_list = None
self.db_url = None
+ self.db_name = "bakta-db"
self.db_type = ""
self.data_table_entry = None
self.data_table_name = data_table_name
- self.db_name = db_name
self.tar_name = tarball_name
self.db_version = db_version
self.DB_VERSIONS_URL = "https://raw.githubusercontent.com/oschwengers/bakta/master/db-versions.json"
@@ -103,7 +103,7 @@
value=bakta_name,
dbkey=bakta_database_info["record"],
bakta_version=tool_version,
- path="db",
+ path=self.db_name,
)
self.bakta_table_list["data_tables"][self.data_table_name] = [data_info]
return self.bakta_table_list
@@ -117,7 +117,11 @@
"""
def __init__(
- self, db_dir=Path.cwd(), db_name="bakta", db_version="latest", test_mode=False
+ self,
+ db_dir=Path.cwd(),
+ db_name="bakta-db",
+ db_version="latest",
+ test_mode=False
):
super().__init__()
self.md5 = None
@@ -129,7 +133,6 @@
self.get_database_type()
def download(self):
- self.db_name = f"{self.db_name}_{self.db_version}{self.db_type}"
bakta_path = Path(self.db_dir).joinpath(self.tar_name)
try:
with bakta_path.open("wb") as fh_out, requests.get(
@@ -150,16 +153,31 @@
)
def untar(self):
- db_path = Path(self.db_dir).as_posix()
+ db_path = Path(self.db_dir).joinpath(self.db_name)
try:
with self.tarball_path.open("rb") as fh_in, tarfile.open(
fileobj=fh_in, mode="r:gz"
) as tar_file:
tar_file.extractall(path=db_path)
print(f"Untar the database in {db_path}")
- return db_path
+
+ if not self.test_mode:
+ self.moove_files(db_path=db_path)
+
except OSError:
- sys.exit(f"ERROR: Could not extract {self.tar_name} " f"to {self.db_name}")
+ 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")):
+ input_dir = db_path.joinpath("db-light")
+ elif os.path.isdir(db_path.joinpath("db")):
+ 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)
def calc_md5_sum(self, buffer_size=1048576):
tarball_path = Path(self.db_dir).joinpath(self.tar_name)
diff -r 3e73c97f025d -r d74850cf4e42 data_manager/macro.xml
--- a/data_manager/macro.xml Fri Jun 23 21:37:05 2023 +0000
+++ b/data_manager/macro.xml Fri Aug 25 23:34:04 2023 +0000
@@ -2,7 +2,7 @@
1.8.1
2.27.1
3.8
- 1
+ 2
21.05
diff -r 3e73c97f025d -r d74850cf4e42 test-data/bakta_test.loc
--- a/test-data/bakta_test.loc Fri Jun 23 21:37:05 2023 +0000
+++ b/test-data/bakta_test.loc Fri Aug 25 23:34:04 2023 +0000
@@ -1,6 +1,3 @@
-V1.0_2022-10-12 7197299 1.4 /tmp/tmpq5t7s3c5/galaxy-dev/tool-data/bakta_database/7197299
-V5.0_2023-06-08 8021027 1.8 /tmp/tmpq5t7s3c5/galaxy-dev/tool-data/bakta_database/8021027
-V5.0light_2023-06-08 8021027 1.8 /tmp/tmpq5t7s3c5/galaxy-dev/tool-data/bakta_database/8021027
-V1.0_2022-10-12 7197299 1.4 /tmp/tmpydhjlpxl/galaxy-dev/tool-data/bakta_database/7197299
-V5.0_2023-06-08 8021027 1.8 /tmp/tmpydhjlpxl/galaxy-dev/tool-data/bakta_database/8021027
-V5.0light_2023-06-08 8021027 1.8 /tmp/tmpydhjlpxl/galaxy-dev/tool-data/bakta_database/8021027
+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
diff -r 3e73c97f025d -r d74850cf4e42 test-data/bakta_test_data_manager1.json
--- a/test-data/bakta_test_data_manager1.json Fri Jun 23 21:37:05 2023 +0000
+++ b/test-data/bakta_test_data_manager1.json Fri Aug 25 23:34:04 2023 +0000
@@ -1,1 +1,1 @@
-{"data_tables": {"bakta_database": [{"bakta_version": "1.4", "dbkey": "7197299", "path": "db", "value": "V1.0_2022-10-12"}]}}
\ No newline at end of file
+{"data_tables": {"bakta_database": [{"bakta_version": "1.4", "dbkey": "7197299", "path": "bakta-db", "value": "V1.0_2022-10-12"}]}}
\ No newline at end of file
diff -r 3e73c97f025d -r d74850cf4e42 test-data/bakta_test_data_manager2.json
--- a/test-data/bakta_test_data_manager2.json Fri Jun 23 21:37:05 2023 +0000
+++ b/test-data/bakta_test_data_manager2.json Fri Aug 25 23:34:04 2023 +0000
@@ -1,1 +1,1 @@
-{"data_tables": {"bakta_database": [{"bakta_version": "1.8", "dbkey": "8021027", "path": "db", "value": "V5.0_2023-06-08"}]}}
\ No newline at end of file
+{"data_tables": {"bakta_database": [{"bakta_version": "1.8", "dbkey": "8021027", "path": "bakta-db", "value": "V5.0_2023-06-08"}]}}
\ No newline at end of file
diff -r 3e73c97f025d -r d74850cf4e42 test-data/bakta_test_data_manager3.json
--- a/test-data/bakta_test_data_manager3.json Fri Jun 23 21:37:05 2023 +0000
+++ b/test-data/bakta_test_data_manager3.json Fri Aug 25 23:34:04 2023 +0000
@@ -1,1 +1,1 @@
-{"data_tables": {"bakta_database": [{"bakta_version": "1.8", "dbkey": "8021027", "path": "db", "value": "V5.0light_2023-06-08"}]}}
\ No newline at end of file
+{"data_tables": {"bakta_database": [{"bakta_version": "1.8", "dbkey": "8021027", "path": "bakta-db", "value": "V5.0light_2023-06-08"}]}}
\ No newline at end of file