Mercurial > repos > richard-burhans > batched_lastz
diff run_lastz_tarball.py @ 15:f6090d2a5722 draft
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/batched_lastz commit 439b32f4ac520e4b22770fa2becd363230e198e0
| author | richard-burhans |
|---|---|
| date | Mon, 08 Sep 2025 22:32:10 +0000 |
| parents | aa5586d83ae3 |
| children | 79182c2a8c80 |
line wrap: on
line diff
--- a/run_lastz_tarball.py Fri Aug 30 15:32:44 2024 +0000 +++ b/run_lastz_tarball.py Mon Sep 08 22:32:10 2025 +0000 @@ -2,6 +2,8 @@ import argparse import concurrent.futures +import contextlib +import gzip import json import multiprocessing import os @@ -16,6 +18,16 @@ import typing +@contextlib.contextmanager +def open_file(filename: str): + if filename.endswith(".gz"): + with gzip.open(filename, "wt", compresslevel=6) as f: + yield f + else: + with open(filename, "w") as f: + yield f + + lastz_output_format_regex = re.compile( r"^(?:axt\+?|blastn|cigar|differences|general-?.+|lav|lav\+text|maf[-+]?|none|paf(?::wfmash)?|rdotplot|sam-?|softsam-?|text)$", re.IGNORECASE, @@ -214,7 +226,7 @@ except FileNotFoundError: sys.exit(f"ERROR: input tarball missing galaxy/format.txt: {self.pathname}") - if format_name in ["bam", "maf"]: + if format_name in ["axt", "bam", "maf"]: self.format_name = format_name elif format_name == "differences": self.format_name = "interval" @@ -341,10 +353,12 @@ sys.exit(f"ERROR: expecting a single output file, found {num_output_files}") final_output_format = self.batch_tar.final_output_format() + if final_output_format in ["axt", "maf"]: + final_output_format = f"{final_output_format}.gz" for file_type, file_list in self.output_files.items(): - with open(f"output.{final_output_format}", "w") as ofh: - if final_output_format == "maf": + with open_file(f"output.{final_output_format}") as ofh: + if final_output_format == "maf.gz": print("##maf version=1", file=ofh) for filename in file_list:
