63 lines
1.5 KiB
Python
Executable File
63 lines
1.5 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
|
|
"""
|
|
Example: Advanced filtering with sample type and platform.
|
|
"""
|
|
|
|
from pathlib import Path
|
|
|
|
from tcga_downloader.manifest import (
|
|
ManifestRecord,
|
|
format_manifest_stats,
|
|
get_manifest_stats,
|
|
write_manifest,
|
|
)
|
|
from tcga_downloader.query import query_files
|
|
|
|
|
|
def main():
|
|
project = "TCGA-BRCA"
|
|
data_type = "Gene Expression"
|
|
sample_type = "Primary Tumor"
|
|
platform = "Illumina HiSeq"
|
|
manifest_path = Path("filtered_manifest.tsv")
|
|
|
|
print("Advanced Query Parameters:")
|
|
print(f" Project: {project}")
|
|
print(f" Data Type: {data_type}")
|
|
print(f" Sample Type: {sample_type}")
|
|
print(f" Platform: {platform}")
|
|
|
|
hits = query_files(
|
|
project=project,
|
|
data_type=data_type,
|
|
sample_type=sample_type,
|
|
platform=platform,
|
|
)
|
|
|
|
records = [
|
|
ManifestRecord(
|
|
file_id=h["file_id"],
|
|
file_name=h["file_name"],
|
|
data_type=h["data_type"],
|
|
data_format=h["data_format"],
|
|
size=int(h["file_size"]),
|
|
md5=h["md5sum"],
|
|
)
|
|
for h in hits
|
|
]
|
|
|
|
write_manifest(records, manifest_path, fmt="tsv")
|
|
|
|
stats = get_manifest_stats(records)
|
|
print("\nManifest Statistics:")
|
|
print(format_manifest_stats(stats))
|
|
|
|
print(f"\nManifest written to: {manifest_path}")
|
|
print("You can now download with:")
|
|
print(f" tcga-downloader download --manifest {manifest_path} --out-dir ./data")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|