feat: add gdc-client downloader

This commit is contained in:
yunpeng.zhang 2026-01-16 14:50:34 +08:00
parent 7e8497decb
commit 4b41fa002f
2 changed files with 37 additions and 0 deletions

View File

@ -0,0 +1,28 @@
from __future__ import annotations
import shutil
import subprocess
from pathlib import Path
def build_gdc_command(manifest_path: Path, out_dir: Path, processes: int, retries: int) -> list[str]:
return [
"gdc-client",
"download",
"-m",
str(manifest_path),
"-d",
str(out_dir),
"--n-processes",
str(processes),
"--retry-count",
str(retries),
"--checksum",
]
def run_gdc_download(manifest_path: Path, out_dir: Path, processes: int = 4, retries: int = 3) -> None:
if not shutil.which("gdc-client"):
raise RuntimeError("gdc-client not found in PATH")
cmd = build_gdc_command(manifest_path, out_dir, processes, retries)
subprocess.run(cmd, check=True)

9
tests/test_download.py Normal file
View File

@ -0,0 +1,9 @@
from pathlib import Path
from tcga_downloader.download import build_gdc_command
def test_build_gdc_command():
cmd = build_gdc_command(Path("/tmp/m.tsv"), Path("/data"), processes=4, retries=3)
assert "gdc-client" in cmd[0]
assert "-m" in cmd