Mercurial > repos > iuc > data_manager_mapseq
comparison data_manager_fetch_mapseq_db.py @ 3:a0d77af1d226 draft
planemo upload for repository https://github.com/galaxyproject/tools-iuc/ commit b6798b5213eca0d4b176ad3aeef81127dac6dcab
author | iuc |
---|---|
date | Tue, 03 Dec 2024 16:30:34 +0000 |
parents | 23511530b8fd |
children |
comparison
equal
deleted
inserted
replaced
2:23511530b8fd | 3:a0d77af1d226 |
---|---|
50 filename = wget.download(url, out=tmp_path) | 50 filename = wget.download(url, out=tmp_path) |
51 tarfile_path = os.path.join(tmp_path, filename) | 51 tarfile_path = os.path.join(tmp_path, filename) |
52 tar = tarfile.open(tarfile_path) | 52 tar = tarfile.open(tarfile_path) |
53 tar.extractall(extract_path) | 53 tar.extractall(extract_path) |
54 | 54 |
55 print(f"Content of folder: {extract_path}", os.listdir(extract_path)) | |
56 | |
57 # case for mapseq v6: all DB files are directly in the tar.gz file | |
58 # remove the VERSION.txt file since the tool can only handle on .txt file in the DB | |
55 if len(list(os.listdir(extract_path))) > 1: | 59 if len(list(os.listdir(extract_path))) > 1: |
56 print("More then one folder in zipped file, aborting !") | 60 print(f"Found multiple files in {extract_path}. Copy the content.") |
61 print(f"Copy data to {dest_path}") | |
62 version_file_path = os.path.join(extract_path, "VERSION.txt") | |
63 os.remove(version_file_path) | |
64 shutil.copytree(extract_path, dest_path) | |
65 print("Done !") | |
66 | |
67 # case for mapseq v5: all files are in a subfolder in the tar.gz file | |
57 else: | 68 else: |
69 print(f"Found a folder in {extract_path}. Copy the content of the folder.") | |
58 for folder in os.listdir(extract_path): | 70 for folder in os.listdir(extract_path): |
59 folder_path = os.path.join(extract_path, folder) | 71 folder_path = os.path.join(extract_path, folder) |
60 | 72 |
61 print(f"Copy data to {dest_path}") | 73 print(f"Copy data to {dest_path}") |
62 shutil.copytree(folder_path, dest_path) | 74 shutil.copytree(folder_path, dest_path) |
67 | 79 |
68 def main(): | 80 def main(): |
69 # Parse Command Line | 81 # Parse Command Line |
70 parser = argparse.ArgumentParser(description="Create data manager JSON.") | 82 parser = argparse.ArgumentParser(description="Create data manager JSON.") |
71 parser.add_argument("--out", dest="output", action="store", help="JSON filename") | 83 parser.add_argument("--out", dest="output", action="store", help="JSON filename") |
72 parser.add_argument("--version", dest="version", action="store", help="Version of the DB") | 84 parser.add_argument( |
73 parser.add_argument("--database-type", dest="db_type", action="store", help="Db type") | 85 "--version", dest="version", action="store", help="Version of the DB" |
86 ) | |
87 parser.add_argument( | |
88 "--database-type", dest="db_type", action="store", help="Db type" | |
89 ) | |
74 parser.add_argument( | 90 parser.add_argument( |
75 "--test", | 91 "--test", |
76 action="store_true", | 92 action="store_true", |
77 help="option to test the script with an lighted database", | 93 help="option to test the script with an lighted database", |
78 ) | 94 ) |
82 # the output file of a DM is a json containing args that can be used by the DM | 98 # the output file of a DM is a json containing args that can be used by the DM |
83 # most tools mainly use these args to find the extra_files_path for the DM, which can be used | 99 # most tools mainly use these args to find the extra_files_path for the DM, which can be used |
84 # to store the DB data | 100 # to store the DB data |
85 with open(args.output) as fh: | 101 with open(args.output) as fh: |
86 params = json.load(fh) | 102 params = json.load(fh) |
87 | |
88 print(params) | |
89 | 103 |
90 workdir = params["output_data"][0]["extra_files_path"] | 104 workdir = params["output_data"][0]["extra_files_path"] |
91 os.mkdir(workdir) | 105 os.mkdir(workdir) |
92 | 106 |
93 time = datetime.utcnow().strftime("%Y-%m-%d") | 107 time = datetime.utcnow().strftime("%Y-%m-%d") |