feat: add gdc-client downloader
This commit is contained in:
parent
7e8497decb
commit
4b41fa002f
28
tcga_downloader/download.py
Normal file
28
tcga_downloader/download.py
Normal 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
9
tests/test_download.py
Normal 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
|
||||||
Loading…
Reference in New Issue
Block a user