annotate package_output.py @ 16:4966e095e3c3 draft

planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 6cf972d7f1c9ecb097994494a27d00906c6c3e4d
author richard-burhans
date Tue, 30 Jul 2024 17:19:56 +0000
parents 168b0a92edd3
children cefa7625d6cb
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
1 #!/usr/bin/env python
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
2
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
3 import argparse
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
4 import configparser
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
5 import json
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
6 import os
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
7 import sys
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
8 import tarfile
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
9 import typing
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
10
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
11 import bashlex
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
12
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
13
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
14 class PackageFile:
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
15 def __init__(
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
16 self,
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
17 pathname: str = "data_package.tgz",
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
18 top_dir: str = "galaxy",
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
19 data_dir: str = "files",
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
20 config_file: str = "commands.json",
16
4966e095e3c3 planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 6cf972d7f1c9ecb097994494a27d00906c6c3e4d
richard-burhans
parents: 11
diff changeset
21 format_file: str = "format.txt"
0
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
22 ) -> None:
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
23 self.pathname: str = os.path.realpath(pathname)
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
24 self.data_root: str = os.path.join(top_dir, data_dir)
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
25 self.config_path: str = os.path.join(top_dir, config_file)
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
26 self.config_file: str = config_file
16
4966e095e3c3 planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 6cf972d7f1c9ecb097994494a27d00906c6c3e4d
richard-burhans
parents: 11
diff changeset
27 self.format_path: str = os.path.join(top_dir, format_file)
4966e095e3c3 planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 6cf972d7f1c9ecb097994494a27d00906c6c3e4d
richard-burhans
parents: 11
diff changeset
28 self.format_file: str = format_file
0
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
29 self.tarfile: typing.Optional[tarfile.TarFile] = None
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
30 self.name_cache: typing.Dict[typing.Any, typing.Any] = {}
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
31 self.working_dir: str = os.path.realpath(os.getcwd())
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
32
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
33 def _initialize(self) -> None:
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
34 if self.tarfile is None:
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
35 self.tarfile = tarfile.open(
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
36 name=self.pathname,
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
37 mode="w:gz",
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
38 format=tarfile.GNU_FORMAT,
4
36cafb694dd2 planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit b8aa943b38b865defab8a27e4404bb8a2131f919
richard-burhans
parents: 0
diff changeset
39 compresslevel=6,
0
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
40 )
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
41
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
42 def add_config(self, pathname: str) -> None:
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
43 if self.tarfile is None:
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
44 self._initialize()
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
45
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
46 source_path = os.path.realpath(pathname)
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
47
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
48 if self.tarfile is not None:
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
49 self.tarfile.add(source_path, arcname=self.config_path, recursive=False)
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
50
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
51 def add_file(self, pathname: str, arcname: typing.Optional[str] = None) -> None:
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
52 if self.tarfile is None:
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
53 self._initialize()
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
54
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
55 source_path = os.path.realpath(pathname)
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
56
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
57 dest_path = None
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
58
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
59 if arcname is None:
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
60 dest_path = os.path.join(self.data_root, os.path.basename(source_path))
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
61 else:
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
62 arc_path = os.path.realpath(arcname)
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
63 rel_path = os.path.relpath(arc_path, self.working_dir)
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
64 if not (os.path.isabs(rel_path) or rel_path.startswith("../")):
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
65 dest_path = os.path.join(self.data_root, rel_path)
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
66 else:
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
67 sys.exit("path fail")
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
68
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
69 if dest_path is not None:
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
70 if self.tarfile is not None:
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
71 if dest_path not in self.name_cache:
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
72 try:
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
73 self.tarfile.add(
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
74 source_path, arcname=dest_path, recursive=False
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
75 )
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
76 except FileNotFoundError:
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
77 sys.exit(f"missing source file {source_path}")
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
78
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
79 self.name_cache[dest_path] = 1
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
80 # print(f"added: {dest_path}", flush=True)
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
81
16
4966e095e3c3 planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 6cf972d7f1c9ecb097994494a27d00906c6c3e4d
richard-burhans
parents: 11
diff changeset
82 def add_format(self, pathname: str) -> None:
4966e095e3c3 planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 6cf972d7f1c9ecb097994494a27d00906c6c3e4d
richard-burhans
parents: 11
diff changeset
83 if self.tarfile is None:
4966e095e3c3 planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 6cf972d7f1c9ecb097994494a27d00906c6c3e4d
richard-burhans
parents: 11
diff changeset
84 self._initialize()
4966e095e3c3 planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 6cf972d7f1c9ecb097994494a27d00906c6c3e4d
richard-burhans
parents: 11
diff changeset
85
4966e095e3c3 planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 6cf972d7f1c9ecb097994494a27d00906c6c3e4d
richard-burhans
parents: 11
diff changeset
86 source_path = os.path.realpath(pathname)
4966e095e3c3 planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 6cf972d7f1c9ecb097994494a27d00906c6c3e4d
richard-burhans
parents: 11
diff changeset
87
4966e095e3c3 planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 6cf972d7f1c9ecb097994494a27d00906c6c3e4d
richard-burhans
parents: 11
diff changeset
88 if self.tarfile is not None:
4966e095e3c3 planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 6cf972d7f1c9ecb097994494a27d00906c6c3e4d
richard-burhans
parents: 11
diff changeset
89 self.tarfile.add(source_path, arcname=self.format_path, recursive=False)
4966e095e3c3 planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 6cf972d7f1c9ecb097994494a27d00906c6c3e4d
richard-burhans
parents: 11
diff changeset
90
0
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
91 def close(self) -> None:
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
92 if self.tarfile is not None:
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
93 self.tarfile.close()
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
94 self.tarfile = None
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
95
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
96
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
97 class bashCommandLineFile:
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
98 def __init__(
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
99 self,
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
100 pathname: str,
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
101 config: configparser.ConfigParser,
16
4966e095e3c3 planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 6cf972d7f1c9ecb097994494a27d00906c6c3e4d
richard-burhans
parents: 11
diff changeset
102 args: argparse.Namespace,
0
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
103 package_file: PackageFile,
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
104 ) -> None:
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
105 self.pathname: str = pathname
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
106 self.config = config
16
4966e095e3c3 planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 6cf972d7f1c9ecb097994494a27d00906c6c3e4d
richard-burhans
parents: 11
diff changeset
107 self.args = args
0
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
108 self.package_file = package_file
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
109 self.executable: typing.Optional[str] = None
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
110 self._parse_lines()
16
4966e095e3c3 planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 6cf972d7f1c9ecb097994494a27d00906c6c3e4d
richard-burhans
parents: 11
diff changeset
111 self._write_format()
0
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
112
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
113 def _parse_lines(self) -> None:
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
114 with open("commands.json", "w") as ofh:
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
115 with open(self.pathname) as f:
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
116 line: str
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
117 for line in f:
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
118 line = line.rstrip("\n")
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
119 command_dict = self._parse_line(line)
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
120 # we may want to re-write args here
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
121 new_args_list = []
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
122
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
123 args_list = command_dict.get("args", [])
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
124 for arg in args_list:
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
125 if arg.startswith("--target="):
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
126 pathname = arg[9:]
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
127 new_args_list.append(arg)
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
128 if "[" in pathname:
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
129 elems = pathname.split("[")
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
130 sequence_file = elems.pop(0)
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
131 self.package_file.add_file(sequence_file, sequence_file)
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
132 for elem in elems:
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
133 if elem.endswith("]"):
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
134 elem = elem[:-1]
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
135 if elem.startswith("subset="):
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
136 subset_file = elem[7:]
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
137 self.package_file.add_file(subset_file)
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
138
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
139 elif arg.startswith("--query="):
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
140 pathname = arg[8:]
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
141 new_args_list.append(arg)
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
142 if "[" in pathname:
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
143 elems = pathname.split("[")
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
144 sequence_file = elems.pop(0)
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
145 self.package_file.add_file(sequence_file, sequence_file)
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
146 for elem in elems:
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
147 if elem.endswith("]"):
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
148 elem = elem[:-1]
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
149 if elem.startswith("subset="):
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
150 subset_file = elem[7:]
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
151 self.package_file.add_file(subset_file)
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
152 elif arg.startswith("--segments="):
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
153 pathname = arg[11:]
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
154 new_args_list.append(arg)
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
155 self.package_file.add_file(pathname)
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
156 elif arg.startswith("--scores="):
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
157 pathname = arg[9:]
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
158 new_args_list.append("--scores=data/scores.txt")
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
159 self.package_file.add_file(pathname, "data/scores.txt")
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
160 else:
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
161 new_args_list.append(arg)
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
162
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
163 command_dict["args"] = new_args_list
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
164 print(json.dumps(command_dict), file=ofh)
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
165
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
166 self.package_file.add_config("commands.json")
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
167
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
168 def _parse_line(self, line: str) -> typing.Dict[str, typing.Any]:
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
169 # resolve shell redirects
4
36cafb694dd2 planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit b8aa943b38b865defab8a27e4404bb8a2131f919
richard-burhans
parents: 0
diff changeset
170 trees: typing.List[typing.Any] = bashlex.parse(line, strictmode=False)
0
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
171 positions: typing.List[typing.Tuple[int, int]] = []
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
172
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
173 for tree in trees:
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
174 visitor = nodevisitor(positions)
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
175 visitor.visit(tree)
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
176
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
177 # do replacements from the end so the indicies will be correct
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
178 positions.reverse()
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
179
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
180 processed = list(line)
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
181 for start, end in positions:
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
182 processed[start:end] = ""
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
183
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
184 processed_line: str = "".join(processed)
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
185
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
186 command_dict = self._parse_processed_line(processed_line)
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
187 command_dict["stdin"] = visitor.stdin
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
188 command_dict["stdout"] = visitor.stdout
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
189 command_dict["stderr"] = visitor.stderr
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
190
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
191 return command_dict
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
192
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
193 def _parse_processed_line(self, line: str) -> typing.Dict[str, typing.Any]:
4
36cafb694dd2 planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit b8aa943b38b865defab8a27e4404bb8a2131f919
richard-burhans
parents: 0
diff changeset
194 argv: typing.List[str] = list(bashlex.split(line))
0
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
195 self.executable = argv.pop(0)
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
196
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
197 parser: argparse.ArgumentParser = argparse.ArgumentParser(add_help=False)
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
198 if "arguments" in self.config:
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
199 arguments_section = self.config["arguments"]
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
200
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
201 arg: str
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
202 if "flag_args" in arguments_section:
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
203 for arg in arguments_section["flag_args"].split():
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
204 parser.add_argument(f"--{arg}", action="store_true")
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
205
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
206 if "str_args" in arguments_section:
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
207 for arg in arguments_section["str_args"].split():
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
208 parser.add_argument(f"--{arg}", type=str)
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
209
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
210 if "bool_str_args" in arguments_section:
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
211 for arg in arguments_section["bool_str_args"].split():
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
212 parser.add_argument(
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
213 f"--{arg}", nargs="?", const=True, default=False
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
214 )
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
215
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
216 if "int_args" in arguments_section:
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
217 for arg in arguments_section["int_args"].split():
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
218 parser.add_argument(f"--{arg}", type=int)
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
219
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
220 if "bool_int_args" in arguments_section:
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
221 for arg in arguments_section["bool_int_args"].split():
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
222 parser.add_argument(
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
223 f"--{arg}", nargs="?", const=True, default=False
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
224 )
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
225
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
226 namespace, rest = parser.parse_known_intermixed_args(argv)
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
227 vars_dict = vars(namespace)
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
228
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
229 command_dict: typing.Dict[str, typing.Any] = {
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
230 "executable": self.executable,
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
231 "args": [],
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
232 }
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
233
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
234 for var in vars_dict.keys():
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
235 value = vars_dict[var]
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
236 if value is not None:
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
237 if isinstance(value, bool):
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
238 if value is True:
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
239 command_dict["args"].append(f"--{var}")
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
240 else:
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
241 command_dict["args"].append(f"--{var}={value}")
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
242
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
243 if len(rest) >= 0:
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
244 value = rest.pop(0)
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
245 command_dict["args"].append(f"--target={value}")
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
246
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
247 if len(rest) >= 0:
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
248 value = rest.pop(0)
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
249 command_dict["args"].append(f"--query={value}")
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
250
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
251 return command_dict
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
252
16
4966e095e3c3 planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 6cf972d7f1c9ecb097994494a27d00906c6c3e4d
richard-burhans
parents: 11
diff changeset
253 def _write_format(self) -> None:
4966e095e3c3 planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 6cf972d7f1c9ecb097994494a27d00906c6c3e4d
richard-burhans
parents: 11
diff changeset
254 if self.args.format_selector == "bam":
4966e095e3c3 planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 6cf972d7f1c9ecb097994494a27d00906c6c3e4d
richard-burhans
parents: 11
diff changeset
255 format_name = "bam"
4966e095e3c3 planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 6cf972d7f1c9ecb097994494a27d00906c6c3e4d
richard-burhans
parents: 11
diff changeset
256 elif self.args.format_selector == "maf":
4966e095e3c3 planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 6cf972d7f1c9ecb097994494a27d00906c6c3e4d
richard-burhans
parents: 11
diff changeset
257 format_name = "maf"
4966e095e3c3 planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 6cf972d7f1c9ecb097994494a27d00906c6c3e4d
richard-burhans
parents: 11
diff changeset
258 elif self.args.format_selector == "differences":
4966e095e3c3 planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 6cf972d7f1c9ecb097994494a27d00906c6c3e4d
richard-burhans
parents: 11
diff changeset
259 format_name = "interval"
4966e095e3c3 planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 6cf972d7f1c9ecb097994494a27d00906c6c3e4d
richard-burhans
parents: 11
diff changeset
260 else:
4966e095e3c3 planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 6cf972d7f1c9ecb097994494a27d00906c6c3e4d
richard-burhans
parents: 11
diff changeset
261 format_name = "tabular"
4966e095e3c3 planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 6cf972d7f1c9ecb097994494a27d00906c6c3e4d
richard-burhans
parents: 11
diff changeset
262
4966e095e3c3 planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 6cf972d7f1c9ecb097994494a27d00906c6c3e4d
richard-burhans
parents: 11
diff changeset
263 with open("format.txt", "w") as ofh:
4966e095e3c3 planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 6cf972d7f1c9ecb097994494a27d00906c6c3e4d
richard-burhans
parents: 11
diff changeset
264 print(f"{format_name}", file=ofh)
4966e095e3c3 planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 6cf972d7f1c9ecb097994494a27d00906c6c3e4d
richard-burhans
parents: 11
diff changeset
265
4966e095e3c3 planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 6cf972d7f1c9ecb097994494a27d00906c6c3e4d
richard-burhans
parents: 11
diff changeset
266 self.package_file.add_format("format.txt")
4966e095e3c3 planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 6cf972d7f1c9ecb097994494a27d00906c6c3e4d
richard-burhans
parents: 11
diff changeset
267
0
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
268
4
36cafb694dd2 planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit b8aa943b38b865defab8a27e4404bb8a2131f919
richard-burhans
parents: 0
diff changeset
269 class nodevisitor(bashlex.ast.nodevisitor): # type: ignore[misc]
0
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
270 def __init__(self, positions: typing.List[typing.Tuple[int, int]]) -> None:
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
271 self.positions = positions
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
272 self.stdin = None
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
273 self.stdout = None
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
274 self.stderr = None
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
275
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
276 def visitredirect(
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
277 self,
4
36cafb694dd2 planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit b8aa943b38b865defab8a27e4404bb8a2131f919
richard-burhans
parents: 0
diff changeset
278 n: bashlex.ast.node,
0
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
279 n_input: int,
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
280 n_type: str,
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
281 output: typing.Any,
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
282 heredoc: typing.Any,
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
283 ) -> None:
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
284 if isinstance(n_input, int) and 0 <= n_input <= 2:
4
36cafb694dd2 planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit b8aa943b38b865defab8a27e4404bb8a2131f919
richard-burhans
parents: 0
diff changeset
285 if isinstance(output, bashlex.ast.node) and output.kind == "word":
0
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
286 self.positions.append(n.pos)
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
287 if n_input == 0:
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
288 self.stdin = output.word
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
289 elif n_input == 1:
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
290 self.stdout = output.word
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
291 elif n_input == 2:
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
292 self.stderr = output.word
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
293 else:
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
294 sys.exit(f"oops 1: {type(n_input)}")
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
295 else:
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
296 sys.exit(f"oops 2: {type(n_input)}")
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
297
4
36cafb694dd2 planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit b8aa943b38b865defab8a27e4404bb8a2131f919
richard-burhans
parents: 0
diff changeset
298 def visitheredoc(self, n: bashlex.ast.node, value: typing.Any) -> None:
0
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
299 pass
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
300
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
301
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
302 def main() -> None:
11
168b0a92edd3 planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 53e28d4dd9ab352c94f91f952ac855b89197f032
richard-burhans
parents: 9
diff changeset
303 parser = argparse.ArgumentParser()
168b0a92edd3 planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 53e28d4dd9ab352c94f91f952ac855b89197f032
richard-burhans
parents: 9
diff changeset
304 parser.add_argument("--tool_directory", type=str, required=True, help="tool directory")
16
4966e095e3c3 planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 6cf972d7f1c9ecb097994494a27d00906c6c3e4d
richard-burhans
parents: 11
diff changeset
305 parser.add_argument("--format_selector", type=str, required=True, help="format selector")
11
168b0a92edd3 planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 53e28d4dd9ab352c94f91f952ac855b89197f032
richard-burhans
parents: 9
diff changeset
306 args = parser.parse_args()
168b0a92edd3 planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 53e28d4dd9ab352c94f91f952ac855b89197f032
richard-burhans
parents: 9
diff changeset
307
168b0a92edd3 planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 53e28d4dd9ab352c94f91f952ac855b89197f032
richard-burhans
parents: 9
diff changeset
308 lastz_command_config_file: str = os.path.join(args.tool_directory, "lastz-cmd.ini")
0
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
309
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
310 config: configparser.ConfigParser = configparser.ConfigParser()
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
311 config.read(lastz_command_config_file)
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
312
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
313 package_file = PackageFile()
9
08e987868f0f planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 062a761a340e095ea7ef7ed7cd1d3d55b1fdc5c4
richard-burhans
parents: 4
diff changeset
314 lastz_command_file = "lastz-commands.txt"
16
4966e095e3c3 planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 6cf972d7f1c9ecb097994494a27d00906c6c3e4d
richard-burhans
parents: 11
diff changeset
315 bashCommandLineFile(lastz_command_file, config, args, package_file)
0
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
316 package_file.close()
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
317
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
318
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
319 if __name__ == "__main__":
5c72425b7f1b planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 98a4dd44360447aa96d92143384d78e116d7581b
richard-burhans
parents:
diff changeset
320 main()