Mercurial > repos > bgruening > data_manager_motus
annotate data_manager/data_manager_fetch_motus_db.py @ 0:0370fe3cf518 draft default tip
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/data_managers/ commit f42263c2875a78500f141027803a38606ecb0f14
author | bgruening |
---|---|
date | Thu, 10 Oct 2024 11:00:40 +0000 |
parents | |
children |
rev | line source |
---|---|
0
0370fe3cf518
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/data_managers/ commit f42263c2875a78500f141027803a38606ecb0f14
bgruening
parents:
diff
changeset
|
1 #!/usr/bin/env python |
0370fe3cf518
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/data_managers/ commit f42263c2875a78500f141027803a38606ecb0f14
bgruening
parents:
diff
changeset
|
2 |
0370fe3cf518
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/data_managers/ commit f42263c2875a78500f141027803a38606ecb0f14
bgruening
parents:
diff
changeset
|
3 import argparse |
0370fe3cf518
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/data_managers/ commit f42263c2875a78500f141027803a38606ecb0f14
bgruening
parents:
diff
changeset
|
4 import json |
0370fe3cf518
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/data_managers/ commit f42263c2875a78500f141027803a38606ecb0f14
bgruening
parents:
diff
changeset
|
5 import os |
0370fe3cf518
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/data_managers/ commit f42263c2875a78500f141027803a38606ecb0f14
bgruening
parents:
diff
changeset
|
6 import shutil |
0370fe3cf518
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/data_managers/ commit f42263c2875a78500f141027803a38606ecb0f14
bgruening
parents:
diff
changeset
|
7 import subprocess |
0370fe3cf518
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/data_managers/ commit f42263c2875a78500f141027803a38606ecb0f14
bgruening
parents:
diff
changeset
|
8 import sys |
0370fe3cf518
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/data_managers/ commit f42263c2875a78500f141027803a38606ecb0f14
bgruening
parents:
diff
changeset
|
9 import tarfile |
0370fe3cf518
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/data_managers/ commit f42263c2875a78500f141027803a38606ecb0f14
bgruening
parents:
diff
changeset
|
10 from datetime import datetime |
0370fe3cf518
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/data_managers/ commit f42263c2875a78500f141027803a38606ecb0f14
bgruening
parents:
diff
changeset
|
11 |
0370fe3cf518
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/data_managers/ commit f42263c2875a78500f141027803a38606ecb0f14
bgruening
parents:
diff
changeset
|
12 import wget |
0370fe3cf518
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/data_managers/ commit f42263c2875a78500f141027803a38606ecb0f14
bgruening
parents:
diff
changeset
|
13 |
0370fe3cf518
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/data_managers/ commit f42263c2875a78500f141027803a38606ecb0f14
bgruening
parents:
diff
changeset
|
14 version_mapping = { |
0370fe3cf518
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/data_managers/ commit f42263c2875a78500f141027803a38606ecb0f14
bgruening
parents:
diff
changeset
|
15 "3.1.0": "https://zenodo.org/records/7778108/files/db_mOTU_v3.1.0.tar.gz", |
0370fe3cf518
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/data_managers/ commit f42263c2875a78500f141027803a38606ecb0f14
bgruening
parents:
diff
changeset
|
16 "3.0.1": "https://zenodo.org/records/5140350/files/db_mOTU_v3.0.1.tar.gz", |
0370fe3cf518
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/data_managers/ commit f42263c2875a78500f141027803a38606ecb0f14
bgruening
parents:
diff
changeset
|
17 "3.0.0": "https://zenodo.org/records/5012106/files/db_mOTU_v3.0.0.tar.gz", |
0370fe3cf518
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/data_managers/ commit f42263c2875a78500f141027803a38606ecb0f14
bgruening
parents:
diff
changeset
|
18 } |
0370fe3cf518
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/data_managers/ commit f42263c2875a78500f141027803a38606ecb0f14
bgruening
parents:
diff
changeset
|
19 |
0370fe3cf518
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/data_managers/ commit f42263c2875a78500f141027803a38606ecb0f14
bgruening
parents:
diff
changeset
|
20 |
0370fe3cf518
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/data_managers/ commit f42263c2875a78500f141027803a38606ecb0f14
bgruening
parents:
diff
changeset
|
21 def download_untar_store(url, tmp_path, dest_path): |
0370fe3cf518
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/data_managers/ commit f42263c2875a78500f141027803a38606ecb0f14
bgruening
parents:
diff
changeset
|
22 """ |
0370fe3cf518
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/data_managers/ commit f42263c2875a78500f141027803a38606ecb0f14
bgruening
parents:
diff
changeset
|
23 Download a tar.gz file containing one folder, |
0370fe3cf518
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/data_managers/ commit f42263c2875a78500f141027803a38606ecb0f14
bgruening
parents:
diff
changeset
|
24 extract that folder and move the content inside dest_path |
0370fe3cf518
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/data_managers/ commit f42263c2875a78500f141027803a38606ecb0f14
bgruening
parents:
diff
changeset
|
25 """ |
0370fe3cf518
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/data_managers/ commit f42263c2875a78500f141027803a38606ecb0f14
bgruening
parents:
diff
changeset
|
26 |
0370fe3cf518
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/data_managers/ commit f42263c2875a78500f141027803a38606ecb0f14
bgruening
parents:
diff
changeset
|
27 extract_path = os.path.join(tmp_path, "extract") |
0370fe3cf518
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/data_managers/ commit f42263c2875a78500f141027803a38606ecb0f14
bgruening
parents:
diff
changeset
|
28 |
0370fe3cf518
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/data_managers/ commit f42263c2875a78500f141027803a38606ecb0f14
bgruening
parents:
diff
changeset
|
29 os.makedirs(tmp_path, exist_ok=True) |
0370fe3cf518
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/data_managers/ commit f42263c2875a78500f141027803a38606ecb0f14
bgruening
parents:
diff
changeset
|
30 |
0370fe3cf518
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/data_managers/ commit f42263c2875a78500f141027803a38606ecb0f14
bgruening
parents:
diff
changeset
|
31 # download data |
0370fe3cf518
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/data_managers/ commit f42263c2875a78500f141027803a38606ecb0f14
bgruening
parents:
diff
changeset
|
32 filename = wget.download(url, out=tmp_path) |
0370fe3cf518
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/data_managers/ commit f42263c2875a78500f141027803a38606ecb0f14
bgruening
parents:
diff
changeset
|
33 tarfile_path = os.path.join(tmp_path, filename) |
0370fe3cf518
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/data_managers/ commit f42263c2875a78500f141027803a38606ecb0f14
bgruening
parents:
diff
changeset
|
34 tar = tarfile.open(tarfile_path) |
0370fe3cf518
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/data_managers/ commit f42263c2875a78500f141027803a38606ecb0f14
bgruening
parents:
diff
changeset
|
35 tar.extractall(extract_path) |
0370fe3cf518
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/data_managers/ commit f42263c2875a78500f141027803a38606ecb0f14
bgruening
parents:
diff
changeset
|
36 |
0370fe3cf518
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/data_managers/ commit f42263c2875a78500f141027803a38606ecb0f14
bgruening
parents:
diff
changeset
|
37 if len(list(os.listdir(extract_path))) > 1: |
0370fe3cf518
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/data_managers/ commit f42263c2875a78500f141027803a38606ecb0f14
bgruening
parents:
diff
changeset
|
38 print("More then one folder in zipped file, aborting !") |
0370fe3cf518
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/data_managers/ commit f42263c2875a78500f141027803a38606ecb0f14
bgruening
parents:
diff
changeset
|
39 else: |
0370fe3cf518
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/data_managers/ commit f42263c2875a78500f141027803a38606ecb0f14
bgruening
parents:
diff
changeset
|
40 for folder in os.listdir(extract_path): |
0370fe3cf518
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/data_managers/ commit f42263c2875a78500f141027803a38606ecb0f14
bgruening
parents:
diff
changeset
|
41 folder_path = os.path.join(extract_path, folder) |
0370fe3cf518
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/data_managers/ commit f42263c2875a78500f141027803a38606ecb0f14
bgruening
parents:
diff
changeset
|
42 |
0370fe3cf518
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/data_managers/ commit f42263c2875a78500f141027803a38606ecb0f14
bgruening
parents:
diff
changeset
|
43 print(f"Copy data to {dest_path}") |
0370fe3cf518
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/data_managers/ commit f42263c2875a78500f141027803a38606ecb0f14
bgruening
parents:
diff
changeset
|
44 shutil.copytree(folder_path, dest_path) |
0370fe3cf518
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/data_managers/ commit f42263c2875a78500f141027803a38606ecb0f14
bgruening
parents:
diff
changeset
|
45 print("Done !") |
0370fe3cf518
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/data_managers/ commit f42263c2875a78500f141027803a38606ecb0f14
bgruening
parents:
diff
changeset
|
46 |
0370fe3cf518
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/data_managers/ commit f42263c2875a78500f141027803a38606ecb0f14
bgruening
parents:
diff
changeset
|
47 shutil.rmtree(tmp_path) |
0370fe3cf518
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/data_managers/ commit f42263c2875a78500f141027803a38606ecb0f14
bgruening
parents:
diff
changeset
|
48 |
0370fe3cf518
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/data_managers/ commit f42263c2875a78500f141027803a38606ecb0f14
bgruening
parents:
diff
changeset
|
49 |
0370fe3cf518
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/data_managers/ commit f42263c2875a78500f141027803a38606ecb0f14
bgruening
parents:
diff
changeset
|
50 def main(): |
0370fe3cf518
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/data_managers/ commit f42263c2875a78500f141027803a38606ecb0f14
bgruening
parents:
diff
changeset
|
51 # Parse Command Line |
0370fe3cf518
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/data_managers/ commit f42263c2875a78500f141027803a38606ecb0f14
bgruening
parents:
diff
changeset
|
52 parser = argparse.ArgumentParser(description="Create data manager JSON.") |
0370fe3cf518
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/data_managers/ commit f42263c2875a78500f141027803a38606ecb0f14
bgruening
parents:
diff
changeset
|
53 parser.add_argument("--out", dest="output", action="store", help="JSON filename") |
0370fe3cf518
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/data_managers/ commit f42263c2875a78500f141027803a38606ecb0f14
bgruening
parents:
diff
changeset
|
54 parser.add_argument( |
0370fe3cf518
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/data_managers/ commit f42263c2875a78500f141027803a38606ecb0f14
bgruening
parents:
diff
changeset
|
55 "--version", dest="version", action="store", help="Version of the DB" |
0370fe3cf518
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/data_managers/ commit f42263c2875a78500f141027803a38606ecb0f14
bgruening
parents:
diff
changeset
|
56 ) |
0370fe3cf518
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/data_managers/ commit f42263c2875a78500f141027803a38606ecb0f14
bgruening
parents:
diff
changeset
|
57 parser.add_argument( |
0370fe3cf518
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/data_managers/ commit f42263c2875a78500f141027803a38606ecb0f14
bgruening
parents:
diff
changeset
|
58 "--test", |
0370fe3cf518
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/data_managers/ commit f42263c2875a78500f141027803a38606ecb0f14
bgruening
parents:
diff
changeset
|
59 action="store_true", |
0370fe3cf518
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/data_managers/ commit f42263c2875a78500f141027803a38606ecb0f14
bgruening
parents:
diff
changeset
|
60 help="option to test the script with an lighted database", |
0370fe3cf518
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/data_managers/ commit f42263c2875a78500f141027803a38606ecb0f14
bgruening
parents:
diff
changeset
|
61 ) |
0370fe3cf518
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/data_managers/ commit f42263c2875a78500f141027803a38606ecb0f14
bgruening
parents:
diff
changeset
|
62 |
0370fe3cf518
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/data_managers/ commit f42263c2875a78500f141027803a38606ecb0f14
bgruening
parents:
diff
changeset
|
63 args = parser.parse_args() |
0370fe3cf518
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/data_managers/ commit f42263c2875a78500f141027803a38606ecb0f14
bgruening
parents:
diff
changeset
|
64 |
0370fe3cf518
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/data_managers/ commit f42263c2875a78500f141027803a38606ecb0f14
bgruening
parents:
diff
changeset
|
65 # the output file of a DM is a json containing args that can be used by the DM |
0370fe3cf518
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/data_managers/ commit f42263c2875a78500f141027803a38606ecb0f14
bgruening
parents:
diff
changeset
|
66 # most tools mainly use these args to find the extra_files_path for the DM, which can be used |
0370fe3cf518
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/data_managers/ commit f42263c2875a78500f141027803a38606ecb0f14
bgruening
parents:
diff
changeset
|
67 # to store the DB data |
0370fe3cf518
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/data_managers/ commit f42263c2875a78500f141027803a38606ecb0f14
bgruening
parents:
diff
changeset
|
68 with open(args.output) as fh: |
0370fe3cf518
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/data_managers/ commit f42263c2875a78500f141027803a38606ecb0f14
bgruening
parents:
diff
changeset
|
69 params = json.load(fh) |
0370fe3cf518
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/data_managers/ commit f42263c2875a78500f141027803a38606ecb0f14
bgruening
parents:
diff
changeset
|
70 |
0370fe3cf518
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/data_managers/ commit f42263c2875a78500f141027803a38606ecb0f14
bgruening
parents:
diff
changeset
|
71 workdir = params["output_data"][0]["extra_files_path"] |
0370fe3cf518
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/data_managers/ commit f42263c2875a78500f141027803a38606ecb0f14
bgruening
parents:
diff
changeset
|
72 os.mkdir(workdir) |
0370fe3cf518
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/data_managers/ commit f42263c2875a78500f141027803a38606ecb0f14
bgruening
parents:
diff
changeset
|
73 |
0370fe3cf518
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/data_managers/ commit f42263c2875a78500f141027803a38606ecb0f14
bgruening
parents:
diff
changeset
|
74 time = datetime.utcnow().strftime("%Y-%m-%dT%H%M%SZ") |
0370fe3cf518
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/data_managers/ commit f42263c2875a78500f141027803a38606ecb0f14
bgruening
parents:
diff
changeset
|
75 db_value = "db_from_{0}".format(time) |
0370fe3cf518
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/data_managers/ commit f42263c2875a78500f141027803a38606ecb0f14
bgruening
parents:
diff
changeset
|
76 db_path = os.path.join(workdir, db_value) |
0370fe3cf518
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/data_managers/ commit f42263c2875a78500f141027803a38606ecb0f14
bgruening
parents:
diff
changeset
|
77 tmp_path = os.path.join(workdir, "tmp") |
0370fe3cf518
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/data_managers/ commit f42263c2875a78500f141027803a38606ecb0f14
bgruening
parents:
diff
changeset
|
78 url = version_mapping[args.version] |
0370fe3cf518
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/data_managers/ commit f42263c2875a78500f141027803a38606ecb0f14
bgruening
parents:
diff
changeset
|
79 |
0370fe3cf518
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/data_managers/ commit f42263c2875a78500f141027803a38606ecb0f14
bgruening
parents:
diff
changeset
|
80 # create DB |
0370fe3cf518
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/data_managers/ commit f42263c2875a78500f141027803a38606ecb0f14
bgruening
parents:
diff
changeset
|
81 if args.test: # the test only checks that the pharokka download script is available |
0370fe3cf518
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/data_managers/ commit f42263c2875a78500f141027803a38606ecb0f14
bgruening
parents:
diff
changeset
|
82 |
0370fe3cf518
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/data_managers/ commit f42263c2875a78500f141027803a38606ecb0f14
bgruening
parents:
diff
changeset
|
83 # check if link is there |
0370fe3cf518
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/data_managers/ commit f42263c2875a78500f141027803a38606ecb0f14
bgruening
parents:
diff
changeset
|
84 command_args = ["wget", "--spider", url] |
0370fe3cf518
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/data_managers/ commit f42263c2875a78500f141027803a38606ecb0f14
bgruening
parents:
diff
changeset
|
85 proc = subprocess.Popen(args=command_args, shell=False) |
0370fe3cf518
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/data_managers/ commit f42263c2875a78500f141027803a38606ecb0f14
bgruening
parents:
diff
changeset
|
86 return_code = proc.wait() |
0370fe3cf518
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/data_managers/ commit f42263c2875a78500f141027803a38606ecb0f14
bgruening
parents:
diff
changeset
|
87 if return_code: |
0370fe3cf518
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/data_managers/ commit f42263c2875a78500f141027803a38606ecb0f14
bgruening
parents:
diff
changeset
|
88 print("Error downloading motus database.", file=sys.stderr) |
0370fe3cf518
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/data_managers/ commit f42263c2875a78500f141027803a38606ecb0f14
bgruening
parents:
diff
changeset
|
89 sys.exit(return_code) |
0370fe3cf518
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/data_managers/ commit f42263c2875a78500f141027803a38606ecb0f14
bgruening
parents:
diff
changeset
|
90 |
0370fe3cf518
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/data_managers/ commit f42263c2875a78500f141027803a38606ecb0f14
bgruening
parents:
diff
changeset
|
91 # copy the test DB |
0370fe3cf518
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/data_managers/ commit f42263c2875a78500f141027803a38606ecb0f14
bgruening
parents:
diff
changeset
|
92 # TODO ones available: https://github.com/motu-tool/mOTUs/issues/121 |
0370fe3cf518
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/data_managers/ commit f42263c2875a78500f141027803a38606ecb0f14
bgruening
parents:
diff
changeset
|
93 test_db_path = os.path.join( |
0370fe3cf518
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/data_managers/ commit f42263c2875a78500f141027803a38606ecb0f14
bgruening
parents:
diff
changeset
|
94 os.path.dirname(os.path.realpath(__file__)), "motus_test_DB_non_functional" |
0370fe3cf518
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/data_managers/ commit f42263c2875a78500f141027803a38606ecb0f14
bgruening
parents:
diff
changeset
|
95 ) |
0370fe3cf518
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/data_managers/ commit f42263c2875a78500f141027803a38606ecb0f14
bgruening
parents:
diff
changeset
|
96 command_args = ["cp", "-r", test_db_path, db_path] |
0370fe3cf518
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/data_managers/ commit f42263c2875a78500f141027803a38606ecb0f14
bgruening
parents:
diff
changeset
|
97 proc = subprocess.Popen(args=command_args, shell=False) |
0370fe3cf518
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/data_managers/ commit f42263c2875a78500f141027803a38606ecb0f14
bgruening
parents:
diff
changeset
|
98 return_code = proc.wait() |
0370fe3cf518
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/data_managers/ commit f42263c2875a78500f141027803a38606ecb0f14
bgruening
parents:
diff
changeset
|
99 if return_code: |
0370fe3cf518
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/data_managers/ commit f42263c2875a78500f141027803a38606ecb0f14
bgruening
parents:
diff
changeset
|
100 print("Error copying motus database.", file=sys.stderr) |
0370fe3cf518
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/data_managers/ commit f42263c2875a78500f141027803a38606ecb0f14
bgruening
parents:
diff
changeset
|
101 sys.exit(return_code) |
0370fe3cf518
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/data_managers/ commit f42263c2875a78500f141027803a38606ecb0f14
bgruening
parents:
diff
changeset
|
102 |
0370fe3cf518
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/data_managers/ commit f42263c2875a78500f141027803a38606ecb0f14
bgruening
parents:
diff
changeset
|
103 else: |
0370fe3cf518
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/data_managers/ commit f42263c2875a78500f141027803a38606ecb0f14
bgruening
parents:
diff
changeset
|
104 |
0370fe3cf518
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/data_managers/ commit f42263c2875a78500f141027803a38606ecb0f14
bgruening
parents:
diff
changeset
|
105 # download data |
0370fe3cf518
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/data_managers/ commit f42263c2875a78500f141027803a38606ecb0f14
bgruening
parents:
diff
changeset
|
106 download_untar_store(url, tmp_path, db_path) |
0370fe3cf518
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/data_managers/ commit f42263c2875a78500f141027803a38606ecb0f14
bgruening
parents:
diff
changeset
|
107 |
0370fe3cf518
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/data_managers/ commit f42263c2875a78500f141027803a38606ecb0f14
bgruening
parents:
diff
changeset
|
108 # Update Data Manager JSON and write to file |
0370fe3cf518
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/data_managers/ commit f42263c2875a78500f141027803a38606ecb0f14
bgruening
parents:
diff
changeset
|
109 data_manager_entry = { |
0370fe3cf518
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/data_managers/ commit f42263c2875a78500f141027803a38606ecb0f14
bgruening
parents:
diff
changeset
|
110 "data_tables": { |
0370fe3cf518
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/data_managers/ commit f42263c2875a78500f141027803a38606ecb0f14
bgruening
parents:
diff
changeset
|
111 "motus_db_versioned": { |
0370fe3cf518
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/data_managers/ commit f42263c2875a78500f141027803a38606ecb0f14
bgruening
parents:
diff
changeset
|
112 "value": db_value, |
0370fe3cf518
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/data_managers/ commit f42263c2875a78500f141027803a38606ecb0f14
bgruening
parents:
diff
changeset
|
113 "version": args.version, |
0370fe3cf518
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/data_managers/ commit f42263c2875a78500f141027803a38606ecb0f14
bgruening
parents:
diff
changeset
|
114 "name": f"mOTUs DB version {args.version} downloaded at {datetime.now()}", |
0370fe3cf518
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/data_managers/ commit f42263c2875a78500f141027803a38606ecb0f14
bgruening
parents:
diff
changeset
|
115 "path": db_path, |
0370fe3cf518
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/data_managers/ commit f42263c2875a78500f141027803a38606ecb0f14
bgruening
parents:
diff
changeset
|
116 } |
0370fe3cf518
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/data_managers/ commit f42263c2875a78500f141027803a38606ecb0f14
bgruening
parents:
diff
changeset
|
117 } |
0370fe3cf518
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/data_managers/ commit f42263c2875a78500f141027803a38606ecb0f14
bgruening
parents:
diff
changeset
|
118 } |
0370fe3cf518
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/data_managers/ commit f42263c2875a78500f141027803a38606ecb0f14
bgruening
parents:
diff
changeset
|
119 |
0370fe3cf518
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/data_managers/ commit f42263c2875a78500f141027803a38606ecb0f14
bgruening
parents:
diff
changeset
|
120 with open(os.path.join(args.output), "w+") as fh: |
0370fe3cf518
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/data_managers/ commit f42263c2875a78500f141027803a38606ecb0f14
bgruening
parents:
diff
changeset
|
121 json.dump(data_manager_entry, fh, sort_keys=True) |
0370fe3cf518
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/data_managers/ commit f42263c2875a78500f141027803a38606ecb0f14
bgruening
parents:
diff
changeset
|
122 |
0370fe3cf518
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/data_managers/ commit f42263c2875a78500f141027803a38606ecb0f14
bgruening
parents:
diff
changeset
|
123 |
0370fe3cf518
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/data_managers/ commit f42263c2875a78500f141027803a38606ecb0f14
bgruening
parents:
diff
changeset
|
124 if __name__ == "__main__": |
0370fe3cf518
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/data_managers/ commit f42263c2875a78500f141027803a38606ecb0f14
bgruening
parents:
diff
changeset
|
125 main() |