Mercurial > repos > richard-burhans > batched_lastz
annotate run_lastz_tarball.py @ 8:3a67d287d19f draft
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit a5a11ffe6ec0c36c5997499a50d58c38c36d54ec
author | richard-burhans |
---|---|
date | Fri, 09 Aug 2024 21:10:40 +0000 |
parents | 4cd7884635c2 |
children | d10e7502aba8 |
rev | line source |
---|---|
0
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
1 #!/usr/bin/env python |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
2 |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
3 import argparse |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
4 import concurrent.futures |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
5 import json |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
6 import multiprocessing |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
7 import os |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
8 import queue |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
9 import re |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
10 import shutil |
6
34d51e66256c
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 2ab3532f7a45153eb0f945ac22c37cdcaea8c1e1
richard-burhans
parents:
2
diff
changeset
|
11 import subprocess |
0
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
12 import sys |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
13 import tarfile |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
14 import tempfile |
6
34d51e66256c
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 2ab3532f7a45153eb0f945ac22c37cdcaea8c1e1
richard-burhans
parents:
2
diff
changeset
|
15 import time |
0
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
16 import typing |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
17 |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
18 |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
19 lastz_output_format_regex = re.compile( |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
20 r"^(?:axt\+?|blastn|cigar|differences|general-?.+|lav|lav\+text|maf[-+]?|none|paf(?::wfmash)?|rdotplot|sam-?|softsam-?|text)$", |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
21 re.IGNORECASE, |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
22 ) |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
23 |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
24 |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
25 # Specifies the output format: lav, lav+text, axt, axt+, maf, maf+, maf-, sam, softsam, sam-, softsam-, cigar, BLASTN, PAF, PAF:wfmash, differences, rdotplot, text, general[:<fields>], or general-[:<fields>]. |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
26 # ‑‑format=none can be used when no alignment output is desired. |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
27 |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
28 |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
29 def run_command( |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
30 instance: int, |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
31 input_queue: "queue.Queue[typing.Dict[str, typing.Any]]", |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
32 output_queue: "queue.Queue[float]", |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
33 debug: bool = False, |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
34 ) -> None: |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
35 os.chdir("galaxy/files") |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
36 |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
37 while True: |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
38 command_dict = input_queue.get() |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
39 |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
40 if not command_dict: |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
41 return |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
42 |
8
3a67d287d19f
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit a5a11ffe6ec0c36c5997499a50d58c38c36d54ec
richard-burhans
parents:
7
diff
changeset
|
43 args = ["lastz", "--allocate:traceback=1.99G"] |
0
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
44 args.extend(command_dict["args"]) |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
45 |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
46 stdin = command_dict["stdin"] |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
47 if stdin is not None: |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
48 stdin = open(stdin, "r") |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
49 |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
50 stdout = command_dict["stdout"] |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
51 if stdout is not None: |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
52 stdout = open(stdout, "w") |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
53 |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
54 stderr = command_dict["stderr"] |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
55 if stderr is not None: |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
56 stderr = open(stderr, "w") |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
57 |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
58 begin = time.perf_counter() |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
59 p = subprocess.run(args, stdin=stdin, stdout=stdout, stderr=stderr) |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
60 |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
61 for var in [stdin, stdout, stderr]: |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
62 if var is not None: |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
63 var.close() |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
64 |
8
3a67d287d19f
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit a5a11ffe6ec0c36c5997499a50d58c38c36d54ec
richard-burhans
parents:
7
diff
changeset
|
65 if p.returncode == 0: |
0
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
66 stderr = command_dict["stderr"] |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
67 if stderr is not None: |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
68 try: |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
69 statinfo = os.stat(stderr, follow_symlinks=False) |
6
34d51e66256c
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 2ab3532f7a45153eb0f945ac22c37cdcaea8c1e1
richard-burhans
parents:
2
diff
changeset
|
70 except Exception: |
0
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
71 statinfo = None |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
72 |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
73 if statinfo is None: |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
74 sys.exit(f"unable to stat stderr file: {' '.join(args)}") |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
75 |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
76 if statinfo.st_size != 0: |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
77 sys.exit(f"stderr file is not empty: {' '.join(args)}") |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
78 |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
79 elapsed = time.perf_counter() - begin |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
80 output_queue.put(elapsed) |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
81 |
8
3a67d287d19f
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit a5a11ffe6ec0c36c5997499a50d58c38c36d54ec
richard-burhans
parents:
7
diff
changeset
|
82 elif p.returncode == 1: |
3a67d287d19f
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit a5a11ffe6ec0c36c5997499a50d58c38c36d54ec
richard-burhans
parents:
7
diff
changeset
|
83 # should be more robust |
3a67d287d19f
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit a5a11ffe6ec0c36c5997499a50d58c38c36d54ec
richard-burhans
parents:
7
diff
changeset
|
84 traceback_warning = True |
3a67d287d19f
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit a5a11ffe6ec0c36c5997499a50d58c38c36d54ec
richard-burhans
parents:
7
diff
changeset
|
85 |
3a67d287d19f
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit a5a11ffe6ec0c36c5997499a50d58c38c36d54ec
richard-burhans
parents:
7
diff
changeset
|
86 stderr_file = command_dict["stderr"] |
3a67d287d19f
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit a5a11ffe6ec0c36c5997499a50d58c38c36d54ec
richard-burhans
parents:
7
diff
changeset
|
87 if stderr_file is None: |
3a67d287d19f
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit a5a11ffe6ec0c36c5997499a50d58c38c36d54ec
richard-burhans
parents:
7
diff
changeset
|
88 traceback_warning = False |
3a67d287d19f
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit a5a11ffe6ec0c36c5997499a50d58c38c36d54ec
richard-burhans
parents:
7
diff
changeset
|
89 else: |
3a67d287d19f
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit a5a11ffe6ec0c36c5997499a50d58c38c36d54ec
richard-burhans
parents:
7
diff
changeset
|
90 with open(stderr_file) as f: |
3a67d287d19f
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit a5a11ffe6ec0c36c5997499a50d58c38c36d54ec
richard-burhans
parents:
7
diff
changeset
|
91 for stderr_line in f: |
3a67d287d19f
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit a5a11ffe6ec0c36c5997499a50d58c38c36d54ec
richard-burhans
parents:
7
diff
changeset
|
92 for prefix in ["truncating alignment", "truncation can be reduced"]: |
3a67d287d19f
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit a5a11ffe6ec0c36c5997499a50d58c38c36d54ec
richard-burhans
parents:
7
diff
changeset
|
93 if stderr_line.startswith(prefix): |
3a67d287d19f
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit a5a11ffe6ec0c36c5997499a50d58c38c36d54ec
richard-burhans
parents:
7
diff
changeset
|
94 continue |
3a67d287d19f
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit a5a11ffe6ec0c36c5997499a50d58c38c36d54ec
richard-burhans
parents:
7
diff
changeset
|
95 |
3a67d287d19f
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit a5a11ffe6ec0c36c5997499a50d58c38c36d54ec
richard-burhans
parents:
7
diff
changeset
|
96 stderr_line = stderr_line.strip() |
3a67d287d19f
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit a5a11ffe6ec0c36c5997499a50d58c38c36d54ec
richard-burhans
parents:
7
diff
changeset
|
97 if stderr_line: |
3a67d287d19f
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit a5a11ffe6ec0c36c5997499a50d58c38c36d54ec
richard-burhans
parents:
7
diff
changeset
|
98 traceback_warning = False |
3a67d287d19f
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit a5a11ffe6ec0c36c5997499a50d58c38c36d54ec
richard-burhans
parents:
7
diff
changeset
|
99 |
3a67d287d19f
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit a5a11ffe6ec0c36c5997499a50d58c38c36d54ec
richard-burhans
parents:
7
diff
changeset
|
100 if traceback_warning: |
3a67d287d19f
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit a5a11ffe6ec0c36c5997499a50d58c38c36d54ec
richard-burhans
parents:
7
diff
changeset
|
101 elapsed = time.perf_counter() - begin |
3a67d287d19f
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit a5a11ffe6ec0c36c5997499a50d58c38c36d54ec
richard-burhans
parents:
7
diff
changeset
|
102 output_queue.put(elapsed) |
3a67d287d19f
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit a5a11ffe6ec0c36c5997499a50d58c38c36d54ec
richard-burhans
parents:
7
diff
changeset
|
103 else: |
3a67d287d19f
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit a5a11ffe6ec0c36c5997499a50d58c38c36d54ec
richard-burhans
parents:
7
diff
changeset
|
104 sys.exit(f"command failed: {' '.join(args)}") |
3a67d287d19f
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit a5a11ffe6ec0c36c5997499a50d58c38c36d54ec
richard-burhans
parents:
7
diff
changeset
|
105 |
3a67d287d19f
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit a5a11ffe6ec0c36c5997499a50d58c38c36d54ec
richard-burhans
parents:
7
diff
changeset
|
106 else: |
3a67d287d19f
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit a5a11ffe6ec0c36c5997499a50d58c38c36d54ec
richard-burhans
parents:
7
diff
changeset
|
107 sys.exit(f"command failed: {' '.join(args)}") |
3a67d287d19f
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit a5a11ffe6ec0c36c5997499a50d58c38c36d54ec
richard-burhans
parents:
7
diff
changeset
|
108 |
0
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
109 if debug: |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
110 print(f"runtime {elapsed}", file=sys.stderr, flush=True) |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
111 |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
112 |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
113 class BatchTar: |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
114 def __init__(self, pathname: str, debug: bool = False) -> None: |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
115 self.pathname = pathname |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
116 self.debug = debug |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
117 self.tarfile = None |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
118 self.commands: typing.List[typing.Dict[str, typing.Any]] = [] |
7
4cd7884635c2
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 869a01abe21b6283d3c83da38fc68761c2e94ba1
richard-burhans
parents:
6
diff
changeset
|
119 self.format_name = "tabular" |
0
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
120 self._extract() |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
121 self._load_commands() |
7
4cd7884635c2
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 869a01abe21b6283d3c83da38fc68761c2e94ba1
richard-burhans
parents:
6
diff
changeset
|
122 self._load_format() |
0
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
123 |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
124 def batch_commands(self) -> typing.Iterator[typing.Dict[str, typing.Any]]: |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
125 for command in self.commands: |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
126 yield command |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
127 |
7
4cd7884635c2
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 869a01abe21b6283d3c83da38fc68761c2e94ba1
richard-burhans
parents:
6
diff
changeset
|
128 def final_output_format(self) -> str: |
4cd7884635c2
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 869a01abe21b6283d3c83da38fc68761c2e94ba1
richard-burhans
parents:
6
diff
changeset
|
129 return self.format_name |
4cd7884635c2
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 869a01abe21b6283d3c83da38fc68761c2e94ba1
richard-burhans
parents:
6
diff
changeset
|
130 |
4cd7884635c2
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 869a01abe21b6283d3c83da38fc68761c2e94ba1
richard-burhans
parents:
6
diff
changeset
|
131 def _extract(self) -> None: |
4cd7884635c2
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 869a01abe21b6283d3c83da38fc68761c2e94ba1
richard-burhans
parents:
6
diff
changeset
|
132 try: |
4cd7884635c2
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 869a01abe21b6283d3c83da38fc68761c2e94ba1
richard-burhans
parents:
6
diff
changeset
|
133 self.tarball = tarfile.open( |
4cd7884635c2
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 869a01abe21b6283d3c83da38fc68761c2e94ba1
richard-burhans
parents:
6
diff
changeset
|
134 name=self.pathname, mode="r:*", format=tarfile.GNU_FORMAT |
4cd7884635c2
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 869a01abe21b6283d3c83da38fc68761c2e94ba1
richard-burhans
parents:
6
diff
changeset
|
135 ) |
4cd7884635c2
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 869a01abe21b6283d3c83da38fc68761c2e94ba1
richard-burhans
parents:
6
diff
changeset
|
136 except FileNotFoundError: |
4cd7884635c2
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 869a01abe21b6283d3c83da38fc68761c2e94ba1
richard-burhans
parents:
6
diff
changeset
|
137 sys.exit(f"ERROR: unable to find input tarball: {self.pathname}") |
4cd7884635c2
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 869a01abe21b6283d3c83da38fc68761c2e94ba1
richard-burhans
parents:
6
diff
changeset
|
138 except tarfile.ReadError: |
4cd7884635c2
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 869a01abe21b6283d3c83da38fc68761c2e94ba1
richard-burhans
parents:
6
diff
changeset
|
139 sys.exit(f"ERROR: error reading input tarball: {self.pathname}") |
4cd7884635c2
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 869a01abe21b6283d3c83da38fc68761c2e94ba1
richard-burhans
parents:
6
diff
changeset
|
140 |
4cd7884635c2
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 869a01abe21b6283d3c83da38fc68761c2e94ba1
richard-burhans
parents:
6
diff
changeset
|
141 begin = time.perf_counter() |
4cd7884635c2
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 869a01abe21b6283d3c83da38fc68761c2e94ba1
richard-burhans
parents:
6
diff
changeset
|
142 self.tarball.extractall(filter="data") |
4cd7884635c2
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 869a01abe21b6283d3c83da38fc68761c2e94ba1
richard-burhans
parents:
6
diff
changeset
|
143 self.tarball.close() |
4cd7884635c2
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 869a01abe21b6283d3c83da38fc68761c2e94ba1
richard-burhans
parents:
6
diff
changeset
|
144 elapsed = time.perf_counter() - begin |
4cd7884635c2
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 869a01abe21b6283d3c83da38fc68761c2e94ba1
richard-burhans
parents:
6
diff
changeset
|
145 |
4cd7884635c2
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 869a01abe21b6283d3c83da38fc68761c2e94ba1
richard-burhans
parents:
6
diff
changeset
|
146 if self.debug: |
4cd7884635c2
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 869a01abe21b6283d3c83da38fc68761c2e94ba1
richard-burhans
parents:
6
diff
changeset
|
147 print( |
4cd7884635c2
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 869a01abe21b6283d3c83da38fc68761c2e94ba1
richard-burhans
parents:
6
diff
changeset
|
148 f"Extracted tarball in {elapsed} seconds", file=sys.stderr, flush=True |
4cd7884635c2
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 869a01abe21b6283d3c83da38fc68761c2e94ba1
richard-burhans
parents:
6
diff
changeset
|
149 ) |
4cd7884635c2
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 869a01abe21b6283d3c83da38fc68761c2e94ba1
richard-burhans
parents:
6
diff
changeset
|
150 |
0
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
151 def _load_commands(self) -> None: |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
152 try: |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
153 f = open("galaxy/commands.json") |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
154 except FileNotFoundError: |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
155 sys.exit( |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
156 f"ERROR: input tarball missing galaxy/commands.json: {self.pathname}" |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
157 ) |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
158 |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
159 begin = time.perf_counter() |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
160 for json_line in f: |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
161 json_line = json_line.rstrip("\n") |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
162 try: |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
163 command_dict = json.loads(json_line) |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
164 except json.JSONDecodeError: |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
165 sys.exit( |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
166 f"ERROR: bad json line in galaxy/commands.json: {self.pathname}" |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
167 ) |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
168 |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
169 self._load_command(command_dict) |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
170 |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
171 f.close() |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
172 elapsed = time.perf_counter() - begin |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
173 |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
174 if self.debug: |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
175 print( |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
176 f"loaded {len(self.commands)} commands in {elapsed} seconds ", |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
177 file=sys.stderr, |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
178 flush=True, |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
179 ) |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
180 |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
181 def _load_command(self, command_dict: typing.Dict[str, typing.Any]) -> None: |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
182 # check command_dict structure |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
183 field_types: typing.Dict[str, typing.List[typing.Any]] = { |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
184 "executable": [str], |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
185 "args": [list], |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
186 "stdin": [str, "None"], |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
187 "stdout": [str, "None"], |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
188 "stderr": [str, "None"], |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
189 } |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
190 |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
191 bad_format = False |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
192 for field_name in field_types.keys(): |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
193 # missing field |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
194 if field_name not in command_dict: |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
195 bad_format = True |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
196 break |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
197 |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
198 # incorrect field type |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
199 good_type = False |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
200 for field_type in field_types[field_name]: |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
201 if isinstance(field_type, str) and field_type == "None": |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
202 if command_dict[field_name] is None: |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
203 good_type = True |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
204 break |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
205 elif isinstance(command_dict[field_name], field_type): |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
206 good_type = True |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
207 break |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
208 |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
209 if good_type is False: |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
210 bad_format = True |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
211 |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
212 if not bad_format: |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
213 # all args must be strings |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
214 for arg in command_dict["args"]: |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
215 if not isinstance(arg, str): |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
216 bad_format = True |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
217 break |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
218 |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
219 if bad_format: |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
220 sys.exit( |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
221 f"ERROR: unexpected json format in line in galaxy/commands.json: {self.pathname}" |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
222 ) |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
223 |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
224 self.commands.append(command_dict) |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
225 |
7
4cd7884635c2
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 869a01abe21b6283d3c83da38fc68761c2e94ba1
richard-burhans
parents:
6
diff
changeset
|
226 def _load_format(self) -> None: |
0
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
227 try: |
7
4cd7884635c2
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 869a01abe21b6283d3c83da38fc68761c2e94ba1
richard-burhans
parents:
6
diff
changeset
|
228 with open("galaxy/format.txt") as f: |
4cd7884635c2
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 869a01abe21b6283d3c83da38fc68761c2e94ba1
richard-burhans
parents:
6
diff
changeset
|
229 format_name = f.readline() |
4cd7884635c2
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 869a01abe21b6283d3c83da38fc68761c2e94ba1
richard-burhans
parents:
6
diff
changeset
|
230 format_name = format_name.rstrip("\n") |
4cd7884635c2
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 869a01abe21b6283d3c83da38fc68761c2e94ba1
richard-burhans
parents:
6
diff
changeset
|
231 except FileNotFoundError: |
4cd7884635c2
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 869a01abe21b6283d3c83da38fc68761c2e94ba1
richard-burhans
parents:
6
diff
changeset
|
232 sys.exit( |
4cd7884635c2
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 869a01abe21b6283d3c83da38fc68761c2e94ba1
richard-burhans
parents:
6
diff
changeset
|
233 f"ERROR: input tarball missing galaxy/format.txt: {self.pathname}" |
0
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
234 ) |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
235 |
7
4cd7884635c2
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 869a01abe21b6283d3c83da38fc68761c2e94ba1
richard-burhans
parents:
6
diff
changeset
|
236 if format_name in ["bam", "maf"]: |
4cd7884635c2
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 869a01abe21b6283d3c83da38fc68761c2e94ba1
richard-burhans
parents:
6
diff
changeset
|
237 self.format_name = format_name |
4cd7884635c2
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 869a01abe21b6283d3c83da38fc68761c2e94ba1
richard-burhans
parents:
6
diff
changeset
|
238 elif format_name == "differences": |
4cd7884635c2
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 869a01abe21b6283d3c83da38fc68761c2e94ba1
richard-burhans
parents:
6
diff
changeset
|
239 self.format_name = "interval" |
0
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
240 |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
241 |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
242 class TarRunner: |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
243 def __init__( |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
244 self, |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
245 input_pathname: str, |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
246 output_pathname: str, |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
247 parallel: int, |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
248 debug: bool = False, |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
249 ) -> None: |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
250 self.input_pathname = input_pathname |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
251 self.output_pathname = output_pathname |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
252 self.parallel = parallel |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
253 self.debug = debug |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
254 self.batch_tar = BatchTar(self.input_pathname, debug=self.debug) |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
255 self.output_file_format: typing.Dict[str, str] = {} |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
256 self.output_files: typing.Dict[str, typing.List[str]] = {} |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
257 self._set_output() |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
258 self._set_target_query() |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
259 |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
260 def _set_output(self) -> None: |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
261 for command_dict in self.batch_tar.batch_commands(): |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
262 output_file = None |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
263 output_format = None |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
264 |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
265 for arg in command_dict["args"]: |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
266 if arg.startswith("--format="): |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
267 output_format = arg[9:] |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
268 elif arg.startswith("--output="): |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
269 output_file = arg[9:] |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
270 |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
271 if output_file is None: |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
272 f = tempfile.NamedTemporaryFile(dir="galaxy/files", delete=False) |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
273 output_file = os.path.basename(f.name) |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
274 f.close() |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
275 command_dict["args"].append(f"--output={output_file}") |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
276 |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
277 if output_format is None: |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
278 output_format = "lav" |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
279 command_dict["args"].append(f"--format={output_format}") |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
280 |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
281 if not lastz_output_format_regex.match(output_format): |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
282 sys.exit(f"ERROR: invalid output format: {output_format}") |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
283 |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
284 self.output_file_format[output_file] = output_format |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
285 |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
286 for output_file, output_format in self.output_file_format.items(): |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
287 self.output_files.setdefault(output_format, []) |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
288 self.output_files[output_format].append(output_file) |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
289 |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
290 def _set_target_query(self) -> None: |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
291 for command_dict in self.batch_tar.batch_commands(): |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
292 new_args: typing.List[str] = [] |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
293 |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
294 for arg in command_dict["args"]: |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
295 if arg.startswith("--target="): |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
296 new_args.insert(0, arg[9:]) |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
297 elif arg.startswith("--query="): |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
298 new_args.insert(1, arg[8:]) |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
299 else: |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
300 new_args.append(arg) |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
301 |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
302 command_dict["args"] = new_args |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
303 |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
304 def run(self) -> None: |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
305 run_times = [] |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
306 begin = time.perf_counter() |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
307 |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
308 with multiprocessing.Manager() as manager: |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
309 input_queue: queue.Queue[typing.Dict[str, typing.Any]] = manager.Queue() |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
310 output_queue: queue.Queue[float] = manager.Queue() |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
311 |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
312 for command_dict in self.batch_tar.batch_commands(): |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
313 input_queue.put(command_dict) |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
314 |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
315 # use the empty dict as a sentinel |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
316 for _ in range(self.parallel): |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
317 input_queue.put({}) |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
318 |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
319 with concurrent.futures.ProcessPoolExecutor( |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
320 max_workers=self.parallel |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
321 ) as executor: |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
322 futures = [ |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
323 executor.submit( |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
324 run_command, |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
325 instance, |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
326 input_queue, |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
327 output_queue, |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
328 debug=self.debug, |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
329 ) |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
330 for instance in range(self.parallel) |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
331 ] |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
332 |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
333 for f in concurrent.futures.as_completed(futures): |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
334 if not f.done() or f.cancelled() or f.exception() is not None: |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
335 sys.exit("lastz command failed") |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
336 |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
337 while not output_queue.empty(): |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
338 run_time = output_queue.get() |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
339 run_times.append(run_time) |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
340 |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
341 elapsed = time.perf_counter() - begin |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
342 |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
343 if self.debug: |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
344 print(f"elapsed {elapsed}", file=sys.stderr, flush=True) |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
345 |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
346 self._cleanup() |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
347 |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
348 def _cleanup(self) -> None: |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
349 num_output_files = len(self.output_files.keys()) |
7
4cd7884635c2
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 869a01abe21b6283d3c83da38fc68761c2e94ba1
richard-burhans
parents:
6
diff
changeset
|
350 if num_output_files != 1: |
4cd7884635c2
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 869a01abe21b6283d3c83da38fc68761c2e94ba1
richard-burhans
parents:
6
diff
changeset
|
351 sys.exit(f"ERROR: expecting a single output file, found {num_output_files}") |
4cd7884635c2
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 869a01abe21b6283d3c83da38fc68761c2e94ba1
richard-burhans
parents:
6
diff
changeset
|
352 |
4cd7884635c2
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 869a01abe21b6283d3c83da38fc68761c2e94ba1
richard-burhans
parents:
6
diff
changeset
|
353 final_output_format = self.batch_tar.final_output_format() |
0
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
354 |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
355 for file_type, file_list in self.output_files.items(): |
7
4cd7884635c2
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 869a01abe21b6283d3c83da38fc68761c2e94ba1
richard-burhans
parents:
6
diff
changeset
|
356 with open(f"output.{final_output_format}", "w") as ofh: |
4cd7884635c2
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 869a01abe21b6283d3c83da38fc68761c2e94ba1
richard-burhans
parents:
6
diff
changeset
|
357 if final_output_format == "maf": |
4cd7884635c2
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 869a01abe21b6283d3c83da38fc68761c2e94ba1
richard-burhans
parents:
6
diff
changeset
|
358 print("##maf version=1", file=ofh) |
0
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
359 for filename in file_list: |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
360 with open(f"galaxy/files/{filename}") as ifh: |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
361 for line in ifh: |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
362 ofh.write(line) |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
363 |
7
4cd7884635c2
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 869a01abe21b6283d3c83da38fc68761c2e94ba1
richard-burhans
parents:
6
diff
changeset
|
364 src_filename = f"output.{final_output_format}" |
4cd7884635c2
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 869a01abe21b6283d3c83da38fc68761c2e94ba1
richard-burhans
parents:
6
diff
changeset
|
365 shutil.copy2(src_filename, self.output_pathname) |
4cd7884635c2
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 869a01abe21b6283d3c83da38fc68761c2e94ba1
richard-burhans
parents:
6
diff
changeset
|
366 |
4cd7884635c2
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 869a01abe21b6283d3c83da38fc68761c2e94ba1
richard-burhans
parents:
6
diff
changeset
|
367 output_metadata = { |
4cd7884635c2
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 869a01abe21b6283d3c83da38fc68761c2e94ba1
richard-burhans
parents:
6
diff
changeset
|
368 "output": { |
4cd7884635c2
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 869a01abe21b6283d3c83da38fc68761c2e94ba1
richard-burhans
parents:
6
diff
changeset
|
369 "ext": final_output_format, |
4cd7884635c2
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 869a01abe21b6283d3c83da38fc68761c2e94ba1
richard-burhans
parents:
6
diff
changeset
|
370 } |
4cd7884635c2
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 869a01abe21b6283d3c83da38fc68761c2e94ba1
richard-burhans
parents:
6
diff
changeset
|
371 } |
4cd7884635c2
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 869a01abe21b6283d3c83da38fc68761c2e94ba1
richard-burhans
parents:
6
diff
changeset
|
372 |
4cd7884635c2
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 869a01abe21b6283d3c83da38fc68761c2e94ba1
richard-burhans
parents:
6
diff
changeset
|
373 with open("galaxy.json", "w") as ofh: |
4cd7884635c2
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 869a01abe21b6283d3c83da38fc68761c2e94ba1
richard-burhans
parents:
6
diff
changeset
|
374 json.dump(output_metadata, ofh) |
0
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
375 |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
376 |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
377 def main() -> None: |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
378 if not hasattr(tarfile, "data_filter"): |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
379 sys.exit("ERROR: extracting may be unsafe; consider updating Python") |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
380 |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
381 parser = argparse.ArgumentParser() |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
382 parser.add_argument("--input", type=str, required=True) |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
383 parser.add_argument("--output", type=str, required=True) |
2
007990f98551
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 3bbc9b941798f866a1d8b7af1e3c0444e5130fd9
richard-burhans
parents:
0
diff
changeset
|
384 parser.add_argument("--parallel", type=int, default=2, required=False) |
0
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
385 parser.add_argument("--debug", action="store_true", required=False) |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
386 |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
387 args = parser.parse_args() |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
388 runner = TarRunner(args.input, args.output, args.parallel, args.debug) |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
389 runner.run() |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
390 |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
391 |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
392 if __name__ == "__main__": |
103538753e81
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 7b119b432f721e228a73396d4e8f0d54350b0481
richard-burhans
parents:
diff
changeset
|
393 main() |