derive_masks: keep pysam's downloaded tabix indexes in data/pgx/cache, not the working directory

This commit is contained in:
kemal committed 2026-09-29 16:00:25 +01:00
1 parent feb1d993b5
commit 08d7fe6840
1 file changed
+6
+6
View File
@@ -38,6 +38,7 @@ def main() -> int:
ap.add_argument("--manifest", required=True) ap.add_argument("--manifest", required=True)
ap.add_argument("--min-concordance", type=float, default=0.95) ap.add_argument("--min-concordance", type=float, default=0.95)
ap.add_argument("--out", required=True, type=Path) ap.add_argument("--out", required=True, type=Path)
ap.add_argument("--cache", type=Path, default=Path("data/pgx/cache"), help="where pysam keeps remote .tbi files")
a = ap.parse_args() a = ap.parse_args()
ident = {} ident = {}
with a.identity.open() as fh: with a.identity.open() as fh:
@@ -86,6 +87,11 @@ def main() -> int:
for c, p, r, al, g in keys: for c, p, r, al, g in keys:
by_gene[(g, c)].append((p, r, al)) by_gene[(g, c)].append((p, r, al))
inds = sorted(set(use.values())) inds = sorted(set(use.values()))
import os
a.out = a.out.resolve()
a.cache.mkdir(parents=True, exist_ok=True)
os.chdir(a.cache) # pysam downloads the remote tabix indexes into the working directory
for (g, c), vs in sorted(by_gene.items()): for (g, c), vs in sorted(by_gene.items()):
core = c.removeprefix("chr") core = c.removeprefix("chr")
chrom = "chrM" if core in ("MT", "M") else f"chr{core}" chrom = "chrM" if core in ("MT", "M") else f"chr{core}"