Mercurial > repos > iuc > data_manager_mapseq
annotate 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 |
rev | line source |
---|---|
0
dbf2735e8480
planemo upload for repository https://github.com/galaxyproject/tools-iuc/ commit 66e797aaa79b92c282a8127260cdfd5702207e35
iuc
parents:
diff
changeset
|
1 #!/usr/bin/env python |
dbf2735e8480
planemo upload for repository https://github.com/galaxyproject/tools-iuc/ commit 66e797aaa79b92c282a8127260cdfd5702207e35
iuc
parents:
diff
changeset
|
2 |
dbf2735e8480
planemo upload for repository https://github.com/galaxyproject/tools-iuc/ commit 66e797aaa79b92c282a8127260cdfd5702207e35
iuc
parents:
diff
changeset
|
3 import argparse |
dbf2735e8480
planemo upload for repository https://github.com/galaxyproject/tools-iuc/ commit 66e797aaa79b92c282a8127260cdfd5702207e35
iuc
parents:
diff
changeset
|
4 import json |
dbf2735e8480
planemo upload for repository https://github.com/galaxyproject/tools-iuc/ commit 66e797aaa79b92c282a8127260cdfd5702207e35
iuc
parents:
diff
changeset
|
5 import os |
dbf2735e8480
planemo upload for repository https://github.com/galaxyproject/tools-iuc/ commit 66e797aaa79b92c282a8127260cdfd5702207e35
iuc
parents:
diff
changeset
|
6 import shutil |
dbf2735e8480
planemo upload for repository https://github.com/galaxyproject/tools-iuc/ commit 66e797aaa79b92c282a8127260cdfd5702207e35
iuc
parents:
diff
changeset
|
7 import tarfile |
dbf2735e8480
planemo upload for repository https://github.com/galaxyproject/tools-iuc/ commit 66e797aaa79b92c282a8127260cdfd5702207e35
iuc
parents:
diff
changeset
|
8 from datetime import datetime |
dbf2735e8480
planemo upload for repository https://github.com/galaxyproject/tools-iuc/ commit 66e797aaa79b92c282a8127260cdfd5702207e35
iuc
parents:
diff
changeset
|
9 |
dbf2735e8480
planemo upload for repository https://github.com/galaxyproject/tools-iuc/ commit 66e797aaa79b92c282a8127260cdfd5702207e35
iuc
parents:
diff
changeset
|
10 import wget |
dbf2735e8480
planemo upload for repository https://github.com/galaxyproject/tools-iuc/ commit 66e797aaa79b92c282a8127260cdfd5702207e35
iuc
parents:
diff
changeset
|
11 |
dbf2735e8480
planemo upload for repository https://github.com/galaxyproject/tools-iuc/ commit 66e797aaa79b92c282a8127260cdfd5702207e35
iuc
parents:
diff
changeset
|
12 DB_paths = { |
2
23511530b8fd
planemo upload for repository https://github.com/galaxyproject/tools-iuc/ commit 960c1f69ec78943dfe72eff0a0992a2ce15d2555
iuc
parents:
1
diff
changeset
|
13 "mgnify_v5_lsu": "ftp://ftp.ebi.ac.uk/pub/databases/metagenomics/pipeline-5.0/ref-dbs/silva_lsu-20200130.tar.gz", |
23511530b8fd
planemo upload for repository https://github.com/galaxyproject/tools-iuc/ commit 960c1f69ec78943dfe72eff0a0992a2ce15d2555
iuc
parents:
1
diff
changeset
|
14 "mgnify_v5_ssu": "ftp://ftp.ebi.ac.uk/pub/databases/metagenomics/pipeline-5.0/ref-dbs/silva_ssu-20200130.tar.gz", |
23511530b8fd
planemo upload for repository https://github.com/galaxyproject/tools-iuc/ commit 960c1f69ec78943dfe72eff0a0992a2ce15d2555
iuc
parents:
1
diff
changeset
|
15 "mgnify_v5_its_unite": "ftp://ftp.ebi.ac.uk/pub/databases/metagenomics/pipeline-5.0/ref-dbs/UNITE-20200214.tar.gz", |
23511530b8fd
planemo upload for repository https://github.com/galaxyproject/tools-iuc/ commit 960c1f69ec78943dfe72eff0a0992a2ce15d2555
iuc
parents:
1
diff
changeset
|
16 "mgnify_v5_its_itsonedb": "ftp://ftp.ebi.ac.uk/pub/databases/metagenomics/pipeline-5.0/ref-dbs/ITSoneDB-20200214.tar.gz", |
23511530b8fd
planemo upload for repository https://github.com/galaxyproject/tools-iuc/ commit 960c1f69ec78943dfe72eff0a0992a2ce15d2555
iuc
parents:
1
diff
changeset
|
17 "mgnify_v6_lsu": "ftp://ftp.ebi.ac.uk/pub/databases/metagenomics/pipelines/tool-dbs/silva-lsu/silva-lsu_138.1.tar.gz", |
23511530b8fd
planemo upload for repository https://github.com/galaxyproject/tools-iuc/ commit 960c1f69ec78943dfe72eff0a0992a2ce15d2555
iuc
parents:
1
diff
changeset
|
18 "mgnify_v6_ssu": "ftp://ftp.ebi.ac.uk/pub/databases/metagenomics/pipelines/tool-dbs/silva-ssu/silva-ssu_138.1.tar.gz", |
23511530b8fd
planemo upload for repository https://github.com/galaxyproject/tools-iuc/ commit 960c1f69ec78943dfe72eff0a0992a2ce15d2555
iuc
parents:
1
diff
changeset
|
19 "mgnify_v6_its_unite": "ftp://ftp.ebi.ac.uk/pub/databases/metagenomics/pipelines/tool-dbs/unite/unite_9.0.tar.gz", |
23511530b8fd
planemo upload for repository https://github.com/galaxyproject/tools-iuc/ commit 960c1f69ec78943dfe72eff0a0992a2ce15d2555
iuc
parents:
1
diff
changeset
|
20 "mgnify_v6_its_itsonedb": "ftp://ftp.ebi.ac.uk/pub/databases/metagenomics/pipelines/tool-dbs/itsonedb/itsonedb_1.141.tar.gz", |
23511530b8fd
planemo upload for repository https://github.com/galaxyproject/tools-iuc/ commit 960c1f69ec78943dfe72eff0a0992a2ce15d2555
iuc
parents:
1
diff
changeset
|
21 "mgnify_v6_pr2": "ftp://ftp.ebi.ac.uk/pub/databases/metagenomics/pipelines/tool-dbs/pr2/pr2_5.0.0.tar.gz", |
0
dbf2735e8480
planemo upload for repository https://github.com/galaxyproject/tools-iuc/ commit 66e797aaa79b92c282a8127260cdfd5702207e35
iuc
parents:
diff
changeset
|
22 "test_lsu": "https://zenodo.org/record/8205348/files/test_lsu.tar.gz", |
dbf2735e8480
planemo upload for repository https://github.com/galaxyproject/tools-iuc/ commit 66e797aaa79b92c282a8127260cdfd5702207e35
iuc
parents:
diff
changeset
|
23 } |
dbf2735e8480
planemo upload for repository https://github.com/galaxyproject/tools-iuc/ commit 66e797aaa79b92c282a8127260cdfd5702207e35
iuc
parents:
diff
changeset
|
24 |
dbf2735e8480
planemo upload for repository https://github.com/galaxyproject/tools-iuc/ commit 66e797aaa79b92c282a8127260cdfd5702207e35
iuc
parents:
diff
changeset
|
25 DB_names = { |
2
23511530b8fd
planemo upload for repository https://github.com/galaxyproject/tools-iuc/ commit 960c1f69ec78943dfe72eff0a0992a2ce15d2555
iuc
parents:
1
diff
changeset
|
26 "mgnify_v5_lsu": "MGnify LSU (v5.0.7) - silva_lsu-20200130", |
23511530b8fd
planemo upload for repository https://github.com/galaxyproject/tools-iuc/ commit 960c1f69ec78943dfe72eff0a0992a2ce15d2555
iuc
parents:
1
diff
changeset
|
27 "mgnify_v5_ssu": "MGnify SSU (v5.0.7) - silva_ssu-20200130", |
23511530b8fd
planemo upload for repository https://github.com/galaxyproject/tools-iuc/ commit 960c1f69ec78943dfe72eff0a0992a2ce15d2555
iuc
parents:
1
diff
changeset
|
28 "mgnify_v5_its_unite": "MGnify ITS UNITE (v5.0.7) - UNITE-20200214", |
23511530b8fd
planemo upload for repository https://github.com/galaxyproject/tools-iuc/ commit 960c1f69ec78943dfe72eff0a0992a2ce15d2555
iuc
parents:
1
diff
changeset
|
29 "mgnify_v5_its_itsonedb": "MGnify ITS ITSonedb (v5.0.7) - ITSoneDB-20200214", |
23511530b8fd
planemo upload for repository https://github.com/galaxyproject/tools-iuc/ commit 960c1f69ec78943dfe72eff0a0992a2ce15d2555
iuc
parents:
1
diff
changeset
|
30 "mgnify_v6_lsu": "MGnify LSU (v6.0) - silva_lsu-20240702", |
23511530b8fd
planemo upload for repository https://github.com/galaxyproject/tools-iuc/ commit 960c1f69ec78943dfe72eff0a0992a2ce15d2555
iuc
parents:
1
diff
changeset
|
31 "mgnify_v6_ssu": "MGnify SSU (v6.0) - silva_ssu-20240701", |
23511530b8fd
planemo upload for repository https://github.com/galaxyproject/tools-iuc/ commit 960c1f69ec78943dfe72eff0a0992a2ce15d2555
iuc
parents:
1
diff
changeset
|
32 "mgnify_v6_its_unite": "MGnify ITS UNITE (v6.0) - UNITE-20240702", |
23511530b8fd
planemo upload for repository https://github.com/galaxyproject/tools-iuc/ commit 960c1f69ec78943dfe72eff0a0992a2ce15d2555
iuc
parents:
1
diff
changeset
|
33 "mgnify_v6_its_itsonedb": "MGnify ITS ITSonedb (v6.0) - ITSoneDB-20240702", |
23511530b8fd
planemo upload for repository https://github.com/galaxyproject/tools-iuc/ commit 960c1f69ec78943dfe72eff0a0992a2ce15d2555
iuc
parents:
1
diff
changeset
|
34 "mgnify_v6_pr2": "MGnify PR2 (v6.0) - PR2-20240702", |
0
dbf2735e8480
planemo upload for repository https://github.com/galaxyproject/tools-iuc/ commit 66e797aaa79b92c282a8127260cdfd5702207e35
iuc
parents:
diff
changeset
|
35 "test_lsu": "Trimmed LSU Test DB", |
dbf2735e8480
planemo upload for repository https://github.com/galaxyproject/tools-iuc/ commit 66e797aaa79b92c282a8127260cdfd5702207e35
iuc
parents:
diff
changeset
|
36 } |
dbf2735e8480
planemo upload for repository https://github.com/galaxyproject/tools-iuc/ commit 66e797aaa79b92c282a8127260cdfd5702207e35
iuc
parents:
diff
changeset
|
37 |
dbf2735e8480
planemo upload for repository https://github.com/galaxyproject/tools-iuc/ commit 66e797aaa79b92c282a8127260cdfd5702207e35
iuc
parents:
diff
changeset
|
38 |
dbf2735e8480
planemo upload for repository https://github.com/galaxyproject/tools-iuc/ commit 66e797aaa79b92c282a8127260cdfd5702207e35
iuc
parents:
diff
changeset
|
39 def download_untar_store(url, tmp_path, dest_path): |
dbf2735e8480
planemo upload for repository https://github.com/galaxyproject/tools-iuc/ commit 66e797aaa79b92c282a8127260cdfd5702207e35
iuc
parents:
diff
changeset
|
40 """ |
dbf2735e8480
planemo upload for repository https://github.com/galaxyproject/tools-iuc/ commit 66e797aaa79b92c282a8127260cdfd5702207e35
iuc
parents:
diff
changeset
|
41 Download a tar.gz file containing one folder, |
1
4cd97cc67061
planemo upload for repository https://github.com/galaxyproject/tools-iuc/ commit 373300c0508fc239fa6d1c8a0351fa9cbb9c0426
iuc
parents:
0
diff
changeset
|
42 extract that folder and move the content inside dest_path |
0
dbf2735e8480
planemo upload for repository https://github.com/galaxyproject/tools-iuc/ commit 66e797aaa79b92c282a8127260cdfd5702207e35
iuc
parents:
diff
changeset
|
43 """ |
dbf2735e8480
planemo upload for repository https://github.com/galaxyproject/tools-iuc/ commit 66e797aaa79b92c282a8127260cdfd5702207e35
iuc
parents:
diff
changeset
|
44 |
dbf2735e8480
planemo upload for repository https://github.com/galaxyproject/tools-iuc/ commit 66e797aaa79b92c282a8127260cdfd5702207e35
iuc
parents:
diff
changeset
|
45 extract_path = os.path.join(tmp_path, "extract") |
dbf2735e8480
planemo upload for repository https://github.com/galaxyproject/tools-iuc/ commit 66e797aaa79b92c282a8127260cdfd5702207e35
iuc
parents:
diff
changeset
|
46 |
dbf2735e8480
planemo upload for repository https://github.com/galaxyproject/tools-iuc/ commit 66e797aaa79b92c282a8127260cdfd5702207e35
iuc
parents:
diff
changeset
|
47 os.makedirs(tmp_path, exist_ok=True) |
dbf2735e8480
planemo upload for repository https://github.com/galaxyproject/tools-iuc/ commit 66e797aaa79b92c282a8127260cdfd5702207e35
iuc
parents:
diff
changeset
|
48 |
dbf2735e8480
planemo upload for repository https://github.com/galaxyproject/tools-iuc/ commit 66e797aaa79b92c282a8127260cdfd5702207e35
iuc
parents:
diff
changeset
|
49 # download data |
dbf2735e8480
planemo upload for repository https://github.com/galaxyproject/tools-iuc/ commit 66e797aaa79b92c282a8127260cdfd5702207e35
iuc
parents:
diff
changeset
|
50 filename = wget.download(url, out=tmp_path) |
dbf2735e8480
planemo upload for repository https://github.com/galaxyproject/tools-iuc/ commit 66e797aaa79b92c282a8127260cdfd5702207e35
iuc
parents:
diff
changeset
|
51 tarfile_path = os.path.join(tmp_path, filename) |
dbf2735e8480
planemo upload for repository https://github.com/galaxyproject/tools-iuc/ commit 66e797aaa79b92c282a8127260cdfd5702207e35
iuc
parents:
diff
changeset
|
52 tar = tarfile.open(tarfile_path) |
dbf2735e8480
planemo upload for repository https://github.com/galaxyproject/tools-iuc/ commit 66e797aaa79b92c282a8127260cdfd5702207e35
iuc
parents:
diff
changeset
|
53 tar.extractall(extract_path) |
dbf2735e8480
planemo upload for repository https://github.com/galaxyproject/tools-iuc/ commit 66e797aaa79b92c282a8127260cdfd5702207e35
iuc
parents:
diff
changeset
|
54 |
3
a0d77af1d226
planemo upload for repository https://github.com/galaxyproject/tools-iuc/ commit b6798b5213eca0d4b176ad3aeef81127dac6dcab
iuc
parents:
2
diff
changeset
|
55 print(f"Content of folder: {extract_path}", os.listdir(extract_path)) |
a0d77af1d226
planemo upload for repository https://github.com/galaxyproject/tools-iuc/ commit b6798b5213eca0d4b176ad3aeef81127dac6dcab
iuc
parents:
2
diff
changeset
|
56 |
a0d77af1d226
planemo upload for repository https://github.com/galaxyproject/tools-iuc/ commit b6798b5213eca0d4b176ad3aeef81127dac6dcab
iuc
parents:
2
diff
changeset
|
57 # case for mapseq v6: all DB files are directly in the tar.gz file |
a0d77af1d226
planemo upload for repository https://github.com/galaxyproject/tools-iuc/ commit b6798b5213eca0d4b176ad3aeef81127dac6dcab
iuc
parents:
2
diff
changeset
|
58 # remove the VERSION.txt file since the tool can only handle on .txt file in the DB |
0
dbf2735e8480
planemo upload for repository https://github.com/galaxyproject/tools-iuc/ commit 66e797aaa79b92c282a8127260cdfd5702207e35
iuc
parents:
diff
changeset
|
59 if len(list(os.listdir(extract_path))) > 1: |
3
a0d77af1d226
planemo upload for repository https://github.com/galaxyproject/tools-iuc/ commit b6798b5213eca0d4b176ad3aeef81127dac6dcab
iuc
parents:
2
diff
changeset
|
60 print(f"Found multiple files in {extract_path}. Copy the content.") |
a0d77af1d226
planemo upload for repository https://github.com/galaxyproject/tools-iuc/ commit b6798b5213eca0d4b176ad3aeef81127dac6dcab
iuc
parents:
2
diff
changeset
|
61 print(f"Copy data to {dest_path}") |
a0d77af1d226
planemo upload for repository https://github.com/galaxyproject/tools-iuc/ commit b6798b5213eca0d4b176ad3aeef81127dac6dcab
iuc
parents:
2
diff
changeset
|
62 version_file_path = os.path.join(extract_path, "VERSION.txt") |
a0d77af1d226
planemo upload for repository https://github.com/galaxyproject/tools-iuc/ commit b6798b5213eca0d4b176ad3aeef81127dac6dcab
iuc
parents:
2
diff
changeset
|
63 os.remove(version_file_path) |
a0d77af1d226
planemo upload for repository https://github.com/galaxyproject/tools-iuc/ commit b6798b5213eca0d4b176ad3aeef81127dac6dcab
iuc
parents:
2
diff
changeset
|
64 shutil.copytree(extract_path, dest_path) |
a0d77af1d226
planemo upload for repository https://github.com/galaxyproject/tools-iuc/ commit b6798b5213eca0d4b176ad3aeef81127dac6dcab
iuc
parents:
2
diff
changeset
|
65 print("Done !") |
a0d77af1d226
planemo upload for repository https://github.com/galaxyproject/tools-iuc/ commit b6798b5213eca0d4b176ad3aeef81127dac6dcab
iuc
parents:
2
diff
changeset
|
66 |
a0d77af1d226
planemo upload for repository https://github.com/galaxyproject/tools-iuc/ commit b6798b5213eca0d4b176ad3aeef81127dac6dcab
iuc
parents:
2
diff
changeset
|
67 # case for mapseq v5: all files are in a subfolder in the tar.gz file |
0
dbf2735e8480
planemo upload for repository https://github.com/galaxyproject/tools-iuc/ commit 66e797aaa79b92c282a8127260cdfd5702207e35
iuc
parents:
diff
changeset
|
68 else: |
3
a0d77af1d226
planemo upload for repository https://github.com/galaxyproject/tools-iuc/ commit b6798b5213eca0d4b176ad3aeef81127dac6dcab
iuc
parents:
2
diff
changeset
|
69 print(f"Found a folder in {extract_path}. Copy the content of the folder.") |
0
dbf2735e8480
planemo upload for repository https://github.com/galaxyproject/tools-iuc/ commit 66e797aaa79b92c282a8127260cdfd5702207e35
iuc
parents:
diff
changeset
|
70 for folder in os.listdir(extract_path): |
dbf2735e8480
planemo upload for repository https://github.com/galaxyproject/tools-iuc/ commit 66e797aaa79b92c282a8127260cdfd5702207e35
iuc
parents:
diff
changeset
|
71 folder_path = os.path.join(extract_path, folder) |
dbf2735e8480
planemo upload for repository https://github.com/galaxyproject/tools-iuc/ commit 66e797aaa79b92c282a8127260cdfd5702207e35
iuc
parents:
diff
changeset
|
72 |
dbf2735e8480
planemo upload for repository https://github.com/galaxyproject/tools-iuc/ commit 66e797aaa79b92c282a8127260cdfd5702207e35
iuc
parents:
diff
changeset
|
73 print(f"Copy data to {dest_path}") |
dbf2735e8480
planemo upload for repository https://github.com/galaxyproject/tools-iuc/ commit 66e797aaa79b92c282a8127260cdfd5702207e35
iuc
parents:
diff
changeset
|
74 shutil.copytree(folder_path, dest_path) |
dbf2735e8480
planemo upload for repository https://github.com/galaxyproject/tools-iuc/ commit 66e797aaa79b92c282a8127260cdfd5702207e35
iuc
parents:
diff
changeset
|
75 print("Done !") |
1
4cd97cc67061
planemo upload for repository https://github.com/galaxyproject/tools-iuc/ commit 373300c0508fc239fa6d1c8a0351fa9cbb9c0426
iuc
parents:
0
diff
changeset
|
76 |
0
dbf2735e8480
planemo upload for repository https://github.com/galaxyproject/tools-iuc/ commit 66e797aaa79b92c282a8127260cdfd5702207e35
iuc
parents:
diff
changeset
|
77 shutil.rmtree(tmp_path) |
dbf2735e8480
planemo upload for repository https://github.com/galaxyproject/tools-iuc/ commit 66e797aaa79b92c282a8127260cdfd5702207e35
iuc
parents:
diff
changeset
|
78 |
dbf2735e8480
planemo upload for repository https://github.com/galaxyproject/tools-iuc/ commit 66e797aaa79b92c282a8127260cdfd5702207e35
iuc
parents:
diff
changeset
|
79 |
dbf2735e8480
planemo upload for repository https://github.com/galaxyproject/tools-iuc/ commit 66e797aaa79b92c282a8127260cdfd5702207e35
iuc
parents:
diff
changeset
|
80 def main(): |
dbf2735e8480
planemo upload for repository https://github.com/galaxyproject/tools-iuc/ commit 66e797aaa79b92c282a8127260cdfd5702207e35
iuc
parents:
diff
changeset
|
81 # Parse Command Line |
dbf2735e8480
planemo upload for repository https://github.com/galaxyproject/tools-iuc/ commit 66e797aaa79b92c282a8127260cdfd5702207e35
iuc
parents:
diff
changeset
|
82 parser = argparse.ArgumentParser(description="Create data manager JSON.") |
dbf2735e8480
planemo upload for repository https://github.com/galaxyproject/tools-iuc/ commit 66e797aaa79b92c282a8127260cdfd5702207e35
iuc
parents:
diff
changeset
|
83 parser.add_argument("--out", dest="output", action="store", help="JSON filename") |
3
a0d77af1d226
planemo upload for repository https://github.com/galaxyproject/tools-iuc/ commit b6798b5213eca0d4b176ad3aeef81127dac6dcab
iuc
parents:
2
diff
changeset
|
84 parser.add_argument( |
a0d77af1d226
planemo upload for repository https://github.com/galaxyproject/tools-iuc/ commit b6798b5213eca0d4b176ad3aeef81127dac6dcab
iuc
parents:
2
diff
changeset
|
85 "--version", dest="version", action="store", help="Version of the DB" |
a0d77af1d226
planemo upload for repository https://github.com/galaxyproject/tools-iuc/ commit b6798b5213eca0d4b176ad3aeef81127dac6dcab
iuc
parents:
2
diff
changeset
|
86 ) |
a0d77af1d226
planemo upload for repository https://github.com/galaxyproject/tools-iuc/ commit b6798b5213eca0d4b176ad3aeef81127dac6dcab
iuc
parents:
2
diff
changeset
|
87 parser.add_argument( |
a0d77af1d226
planemo upload for repository https://github.com/galaxyproject/tools-iuc/ commit b6798b5213eca0d4b176ad3aeef81127dac6dcab
iuc
parents:
2
diff
changeset
|
88 "--database-type", dest="db_type", action="store", help="Db type" |
a0d77af1d226
planemo upload for repository https://github.com/galaxyproject/tools-iuc/ commit b6798b5213eca0d4b176ad3aeef81127dac6dcab
iuc
parents:
2
diff
changeset
|
89 ) |
0
dbf2735e8480
planemo upload for repository https://github.com/galaxyproject/tools-iuc/ commit 66e797aaa79b92c282a8127260cdfd5702207e35
iuc
parents:
diff
changeset
|
90 parser.add_argument( |
dbf2735e8480
planemo upload for repository https://github.com/galaxyproject/tools-iuc/ commit 66e797aaa79b92c282a8127260cdfd5702207e35
iuc
parents:
diff
changeset
|
91 "--test", |
dbf2735e8480
planemo upload for repository https://github.com/galaxyproject/tools-iuc/ commit 66e797aaa79b92c282a8127260cdfd5702207e35
iuc
parents:
diff
changeset
|
92 action="store_true", |
dbf2735e8480
planemo upload for repository https://github.com/galaxyproject/tools-iuc/ commit 66e797aaa79b92c282a8127260cdfd5702207e35
iuc
parents:
diff
changeset
|
93 help="option to test the script with an lighted database", |
dbf2735e8480
planemo upload for repository https://github.com/galaxyproject/tools-iuc/ commit 66e797aaa79b92c282a8127260cdfd5702207e35
iuc
parents:
diff
changeset
|
94 ) |
dbf2735e8480
planemo upload for repository https://github.com/galaxyproject/tools-iuc/ commit 66e797aaa79b92c282a8127260cdfd5702207e35
iuc
parents:
diff
changeset
|
95 |
dbf2735e8480
planemo upload for repository https://github.com/galaxyproject/tools-iuc/ commit 66e797aaa79b92c282a8127260cdfd5702207e35
iuc
parents:
diff
changeset
|
96 args = parser.parse_args() |
dbf2735e8480
planemo upload for repository https://github.com/galaxyproject/tools-iuc/ commit 66e797aaa79b92c282a8127260cdfd5702207e35
iuc
parents:
diff
changeset
|
97 |
dbf2735e8480
planemo upload for repository https://github.com/galaxyproject/tools-iuc/ commit 66e797aaa79b92c282a8127260cdfd5702207e35
iuc
parents:
diff
changeset
|
98 # the output file of a DM is a json containing args that can be used by the DM |
dbf2735e8480
planemo upload for repository https://github.com/galaxyproject/tools-iuc/ commit 66e797aaa79b92c282a8127260cdfd5702207e35
iuc
parents:
diff
changeset
|
99 # most tools mainly use these args to find the extra_files_path for the DM, which can be used |
dbf2735e8480
planemo upload for repository https://github.com/galaxyproject/tools-iuc/ commit 66e797aaa79b92c282a8127260cdfd5702207e35
iuc
parents:
diff
changeset
|
100 # to store the DB data |
dbf2735e8480
planemo upload for repository https://github.com/galaxyproject/tools-iuc/ commit 66e797aaa79b92c282a8127260cdfd5702207e35
iuc
parents:
diff
changeset
|
101 with open(args.output) as fh: |
dbf2735e8480
planemo upload for repository https://github.com/galaxyproject/tools-iuc/ commit 66e797aaa79b92c282a8127260cdfd5702207e35
iuc
parents:
diff
changeset
|
102 params = json.load(fh) |
dbf2735e8480
planemo upload for repository https://github.com/galaxyproject/tools-iuc/ commit 66e797aaa79b92c282a8127260cdfd5702207e35
iuc
parents:
diff
changeset
|
103 |
dbf2735e8480
planemo upload for repository https://github.com/galaxyproject/tools-iuc/ commit 66e797aaa79b92c282a8127260cdfd5702207e35
iuc
parents:
diff
changeset
|
104 workdir = params["output_data"][0]["extra_files_path"] |
dbf2735e8480
planemo upload for repository https://github.com/galaxyproject/tools-iuc/ commit 66e797aaa79b92c282a8127260cdfd5702207e35
iuc
parents:
diff
changeset
|
105 os.mkdir(workdir) |
dbf2735e8480
planemo upload for repository https://github.com/galaxyproject/tools-iuc/ commit 66e797aaa79b92c282a8127260cdfd5702207e35
iuc
parents:
diff
changeset
|
106 |
dbf2735e8480
planemo upload for repository https://github.com/galaxyproject/tools-iuc/ commit 66e797aaa79b92c282a8127260cdfd5702207e35
iuc
parents:
diff
changeset
|
107 time = datetime.utcnow().strftime("%Y-%m-%d") |
dbf2735e8480
planemo upload for repository https://github.com/galaxyproject/tools-iuc/ commit 66e797aaa79b92c282a8127260cdfd5702207e35
iuc
parents:
diff
changeset
|
108 db_value = f"{args.db_type}_from_{time}" |
dbf2735e8480
planemo upload for repository https://github.com/galaxyproject/tools-iuc/ commit 66e797aaa79b92c282a8127260cdfd5702207e35
iuc
parents:
diff
changeset
|
109 |
dbf2735e8480
planemo upload for repository https://github.com/galaxyproject/tools-iuc/ commit 66e797aaa79b92c282a8127260cdfd5702207e35
iuc
parents:
diff
changeset
|
110 # output paths |
dbf2735e8480
planemo upload for repository https://github.com/galaxyproject/tools-iuc/ commit 66e797aaa79b92c282a8127260cdfd5702207e35
iuc
parents:
diff
changeset
|
111 db_path = os.path.join(workdir, db_value) |
dbf2735e8480
planemo upload for repository https://github.com/galaxyproject/tools-iuc/ commit 66e797aaa79b92c282a8127260cdfd5702207e35
iuc
parents:
diff
changeset
|
112 tmp_path = os.path.join(workdir, "tmp") |
dbf2735e8480
planemo upload for repository https://github.com/galaxyproject/tools-iuc/ commit 66e797aaa79b92c282a8127260cdfd5702207e35
iuc
parents:
diff
changeset
|
113 |
dbf2735e8480
planemo upload for repository https://github.com/galaxyproject/tools-iuc/ commit 66e797aaa79b92c282a8127260cdfd5702207e35
iuc
parents:
diff
changeset
|
114 # create DB |
1
4cd97cc67061
planemo upload for repository https://github.com/galaxyproject/tools-iuc/ commit 373300c0508fc239fa6d1c8a0351fa9cbb9c0426
iuc
parents:
0
diff
changeset
|
115 if args.test: |
0
dbf2735e8480
planemo upload for repository https://github.com/galaxyproject/tools-iuc/ commit 66e797aaa79b92c282a8127260cdfd5702207e35
iuc
parents:
diff
changeset
|
116 url = DB_paths["test_lsu"] |
dbf2735e8480
planemo upload for repository https://github.com/galaxyproject/tools-iuc/ commit 66e797aaa79b92c282a8127260cdfd5702207e35
iuc
parents:
diff
changeset
|
117 else: |
dbf2735e8480
planemo upload for repository https://github.com/galaxyproject/tools-iuc/ commit 66e797aaa79b92c282a8127260cdfd5702207e35
iuc
parents:
diff
changeset
|
118 url = DB_paths[args.db_type] |
dbf2735e8480
planemo upload for repository https://github.com/galaxyproject/tools-iuc/ commit 66e797aaa79b92c282a8127260cdfd5702207e35
iuc
parents:
diff
changeset
|
119 |
dbf2735e8480
planemo upload for repository https://github.com/galaxyproject/tools-iuc/ commit 66e797aaa79b92c282a8127260cdfd5702207e35
iuc
parents:
diff
changeset
|
120 # download data |
dbf2735e8480
planemo upload for repository https://github.com/galaxyproject/tools-iuc/ commit 66e797aaa79b92c282a8127260cdfd5702207e35
iuc
parents:
diff
changeset
|
121 download_untar_store(url, tmp_path, db_path) |
dbf2735e8480
planemo upload for repository https://github.com/galaxyproject/tools-iuc/ commit 66e797aaa79b92c282a8127260cdfd5702207e35
iuc
parents:
diff
changeset
|
122 |
dbf2735e8480
planemo upload for repository https://github.com/galaxyproject/tools-iuc/ commit 66e797aaa79b92c282a8127260cdfd5702207e35
iuc
parents:
diff
changeset
|
123 db_name = DB_names[args.db_type] |
dbf2735e8480
planemo upload for repository https://github.com/galaxyproject/tools-iuc/ commit 66e797aaa79b92c282a8127260cdfd5702207e35
iuc
parents:
diff
changeset
|
124 # Update Data Manager JSON and write to file |
dbf2735e8480
planemo upload for repository https://github.com/galaxyproject/tools-iuc/ commit 66e797aaa79b92c282a8127260cdfd5702207e35
iuc
parents:
diff
changeset
|
125 data_manager_entry = { |
dbf2735e8480
planemo upload for repository https://github.com/galaxyproject/tools-iuc/ commit 66e797aaa79b92c282a8127260cdfd5702207e35
iuc
parents:
diff
changeset
|
126 "data_tables": { |
dbf2735e8480
planemo upload for repository https://github.com/galaxyproject/tools-iuc/ commit 66e797aaa79b92c282a8127260cdfd5702207e35
iuc
parents:
diff
changeset
|
127 "mapseq_db": { |
dbf2735e8480
planemo upload for repository https://github.com/galaxyproject/tools-iuc/ commit 66e797aaa79b92c282a8127260cdfd5702207e35
iuc
parents:
diff
changeset
|
128 "value": db_value, |
dbf2735e8480
planemo upload for repository https://github.com/galaxyproject/tools-iuc/ commit 66e797aaa79b92c282a8127260cdfd5702207e35
iuc
parents:
diff
changeset
|
129 "name": f"{db_name} downloaded at {time}", |
dbf2735e8480
planemo upload for repository https://github.com/galaxyproject/tools-iuc/ commit 66e797aaa79b92c282a8127260cdfd5702207e35
iuc
parents:
diff
changeset
|
130 "version": args.version, |
dbf2735e8480
planemo upload for repository https://github.com/galaxyproject/tools-iuc/ commit 66e797aaa79b92c282a8127260cdfd5702207e35
iuc
parents:
diff
changeset
|
131 "path": db_path, |
dbf2735e8480
planemo upload for repository https://github.com/galaxyproject/tools-iuc/ commit 66e797aaa79b92c282a8127260cdfd5702207e35
iuc
parents:
diff
changeset
|
132 } |
dbf2735e8480
planemo upload for repository https://github.com/galaxyproject/tools-iuc/ commit 66e797aaa79b92c282a8127260cdfd5702207e35
iuc
parents:
diff
changeset
|
133 } |
dbf2735e8480
planemo upload for repository https://github.com/galaxyproject/tools-iuc/ commit 66e797aaa79b92c282a8127260cdfd5702207e35
iuc
parents:
diff
changeset
|
134 } |
dbf2735e8480
planemo upload for repository https://github.com/galaxyproject/tools-iuc/ commit 66e797aaa79b92c282a8127260cdfd5702207e35
iuc
parents:
diff
changeset
|
135 |
dbf2735e8480
planemo upload for repository https://github.com/galaxyproject/tools-iuc/ commit 66e797aaa79b92c282a8127260cdfd5702207e35
iuc
parents:
diff
changeset
|
136 with open(os.path.join(args.output), "w+") as fh: |
dbf2735e8480
planemo upload for repository https://github.com/galaxyproject/tools-iuc/ commit 66e797aaa79b92c282a8127260cdfd5702207e35
iuc
parents:
diff
changeset
|
137 json.dump(data_manager_entry, fh, sort_keys=True) |
dbf2735e8480
planemo upload for repository https://github.com/galaxyproject/tools-iuc/ commit 66e797aaa79b92c282a8127260cdfd5702207e35
iuc
parents:
diff
changeset
|
138 |
dbf2735e8480
planemo upload for repository https://github.com/galaxyproject/tools-iuc/ commit 66e797aaa79b92c282a8127260cdfd5702207e35
iuc
parents:
diff
changeset
|
139 |
dbf2735e8480
planemo upload for repository https://github.com/galaxyproject/tools-iuc/ commit 66e797aaa79b92c282a8127260cdfd5702207e35
iuc
parents:
diff
changeset
|
140 if __name__ == "__main__": |
dbf2735e8480
planemo upload for repository https://github.com/galaxyproject/tools-iuc/ commit 66e797aaa79b92c282a8127260cdfd5702207e35
iuc
parents:
diff
changeset
|
141 main() |