From 48aeb8836b8e1f73626b3454acf5771a552aaaac Mon Sep 17 00:00:00 2001 From: paulzierep Date: Tue, 3 Dec 2024 13:27:13 +0100 Subject: [PATCH 1/2] logic for downloading v6 --- .../data_manager_fetch_mapseq_db.py | 26 ++++++++++++++++--- .../data_manager/mapseq_db_fetcher.xml | 4 +-- 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/data_managers/data_manager_mapseq/data_manager/data_manager_fetch_mapseq_db.py b/data_managers/data_manager_mapseq/data_manager/data_manager_fetch_mapseq_db.py index 6c1d5c41517..34180971d48 100644 --- a/data_managers/data_manager_mapseq/data_manager/data_manager_fetch_mapseq_db.py +++ b/data_managers/data_manager_mapseq/data_manager/data_manager_fetch_mapseq_db.py @@ -52,9 +52,21 @@ def download_untar_store(url, tmp_path, dest_path): tar = tarfile.open(tarfile_path) tar.extractall(extract_path) + print(f"Content of folder: {extract_path}", os.listdir(extract_path)) + + # case for mapseq v6: all DB files are directly in the tar.gz file + # remove the VERSION.txt file since the tool can only handle on .txt file in the DB if len(list(os.listdir(extract_path))) > 1: - print("More then one folder in zipped file, aborting !") + print(f"Found multiple files in {extract_path}. Copy the content.") + print(f"Copy data to {dest_path}") + version_file_path = os.path.join(extract_path, "VERSION.txt") + os.remove(version_file_path) + shutil.copytree(extract_path, dest_path) + print("Done !") + + # case for mapseq v5: all files are in a subfolder in the tar.gz file else: + print(f"Found a folder in {extract_path}. Copy the content of the folder.") for folder in os.listdir(extract_path): folder_path = os.path.join(extract_path, folder) @@ -69,8 +81,12 @@ def main(): # Parse Command Line parser = argparse.ArgumentParser(description="Create data manager JSON.") parser.add_argument("--out", dest="output", action="store", help="JSON filename") - parser.add_argument("--version", dest="version", action="store", help="Version of the DB") - parser.add_argument("--database-type", dest="db_type", action="store", help="Db type") + parser.add_argument( + "--version", dest="version", action="store", help="Version of the DB" + ) + parser.add_argument( + "--database-type", dest="db_type", action="store", help="Db type" + ) parser.add_argument( "--test", action="store_true", @@ -85,7 +101,7 @@ def main(): with open(args.output) as fh: params = json.load(fh) - print(params) + # print(params) workdir = params["output_data"][0]["extra_files_path"] os.mkdir(workdir) @@ -97,6 +113,8 @@ def main(): db_path = os.path.join(workdir, db_value) tmp_path = os.path.join(workdir, "tmp") + print(tmp_path) + # create DB if args.test: url = DB_paths["test_lsu"] diff --git a/data_managers/data_manager_mapseq/data_manager/mapseq_db_fetcher.xml b/data_managers/data_manager_mapseq/data_manager/mapseq_db_fetcher.xml index 0bfaa71bd77..383b3020ce0 100644 --- a/data_managers/data_manager_mapseq/data_manager/mapseq_db_fetcher.xml +++ b/data_managers/data_manager_mapseq/data_manager/mapseq_db_fetcher.xml @@ -17,8 +17,8 @@ - - + + From 6e78a45810c151401c5d7e27be468d7d60625c20 Mon Sep 17 00:00:00 2001 From: paulzierep Date: Tue, 3 Dec 2024 13:28:42 +0100 Subject: [PATCH 2/2] rm unused print --- .../data_manager/data_manager_fetch_mapseq_db.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/data_managers/data_manager_mapseq/data_manager/data_manager_fetch_mapseq_db.py b/data_managers/data_manager_mapseq/data_manager/data_manager_fetch_mapseq_db.py index 34180971d48..40be5a9a343 100644 --- a/data_managers/data_manager_mapseq/data_manager/data_manager_fetch_mapseq_db.py +++ b/data_managers/data_manager_mapseq/data_manager/data_manager_fetch_mapseq_db.py @@ -101,8 +101,6 @@ def main(): with open(args.output) as fh: params = json.load(fh) - # print(params) - workdir = params["output_data"][0]["extra_files_path"] os.mkdir(workdir) @@ -113,8 +111,6 @@ def main(): db_path = os.path.join(workdir, db_value) tmp_path = os.path.join(workdir, "tmp") - print(tmp_path) - # create DB if args.test: url = DB_paths["test_lsu"]