Mercurial > repos > richard-burhans > segalign
comparison package_output.py @ 19:cefa7625d6cb draft
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 2840545abeeca2dc0a6e6df138633e561d379e52
| author | richard-burhans |
|---|---|
| date | Thu, 01 Aug 2024 18:39:46 +0000 |
| parents | 4966e095e3c3 |
| children |
comparison
equal
deleted
inserted
replaced
| 18:a5769923297c | 19:cefa7625d6cb |
|---|---|
| 2 | 2 |
| 3 import argparse | 3 import argparse |
| 4 import configparser | 4 import configparser |
| 5 import json | 5 import json |
| 6 import os | 6 import os |
| 7 import resource | |
| 7 import sys | 8 import sys |
| 8 import tarfile | 9 import tarfile |
| 10 import time | |
| 9 import typing | 11 import typing |
| 10 | 12 |
| 11 import bashlex | 13 import bashlex |
| 14 | |
| 15 RUSAGE_ATTRS: typing.Final = ["ru_utime", "ru_stime", "ru_maxrss", "ru_minflt", "ru_majflt", "ru_inblock", "ru_oublock", "ru_nvcsw", "ru_nivcsw"] | |
| 12 | 16 |
| 13 | 17 |
| 14 class PackageFile: | 18 class PackageFile: |
| 15 def __init__( | 19 def __init__( |
| 16 self, | 20 self, |
| 301 | 305 |
| 302 def main() -> None: | 306 def main() -> None: |
| 303 parser = argparse.ArgumentParser() | 307 parser = argparse.ArgumentParser() |
| 304 parser.add_argument("--tool_directory", type=str, required=True, help="tool directory") | 308 parser.add_argument("--tool_directory", type=str, required=True, help="tool directory") |
| 305 parser.add_argument("--format_selector", type=str, required=True, help="format selector") | 309 parser.add_argument("--format_selector", type=str, required=True, help="format selector") |
| 310 parser.add_argument("--debug", action="store_true", help="enable debug messages") | |
| 306 args = parser.parse_args() | 311 args = parser.parse_args() |
| 312 | |
| 313 if args.debug: | |
| 314 r_beg = resource.getrusage(resource.RUSAGE_SELF) | |
| 315 beg: int = time.monotonic_ns() | |
| 307 | 316 |
| 308 lastz_command_config_file: str = os.path.join(args.tool_directory, "lastz-cmd.ini") | 317 lastz_command_config_file: str = os.path.join(args.tool_directory, "lastz-cmd.ini") |
| 309 | 318 |
| 310 config: configparser.ConfigParser = configparser.ConfigParser() | 319 config: configparser.ConfigParser = configparser.ConfigParser() |
| 311 config.read(lastz_command_config_file) | 320 config.read(lastz_command_config_file) |
| 313 package_file = PackageFile() | 322 package_file = PackageFile() |
| 314 lastz_command_file = "lastz-commands.txt" | 323 lastz_command_file = "lastz-commands.txt" |
| 315 bashCommandLineFile(lastz_command_file, config, args, package_file) | 324 bashCommandLineFile(lastz_command_file, config, args, package_file) |
| 316 package_file.close() | 325 package_file.close() |
| 317 | 326 |
| 327 if args.debug: | |
| 328 ns: int = time.monotonic_ns() - beg | |
| 329 r_end = resource.getrusage(resource.RUSAGE_SELF) | |
| 330 print(f"package output clock time: {ns} ns", file=sys.stderr, flush=True) | |
| 331 for rusage_attr in RUSAGE_ATTRS: | |
| 332 value = getattr(r_end, rusage_attr) - getattr(r_beg, rusage_attr) | |
| 333 print(f" package output {rusage_attr}: {value}", file=sys.stderr, flush=True) | |
| 334 | |
| 318 | 335 |
| 319 if __name__ == "__main__": | 336 if __name__ == "__main__": |
| 320 main() | 337 main() |
