91 lines
2.5 KiB
Python
Executable File
91 lines
2.5 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
"""
|
|
RNA-Seq QC Skill Runner
|
|
RNA-seq 质量控制技能执行器
|
|
"""
|
|
|
|
import argparse
|
|
import json
|
|
import subprocess
|
|
import sys
|
|
import time
|
|
import yaml
|
|
from datetime import datetime
|
|
from pathlib import Path
|
|
from typing import Any, Dict, List, Optional
|
|
import hashlib
|
|
import os
|
|
|
|
|
|
def compute_file_hash(filepath: Path) -> str:
|
|
"""计算文件的SHA256哈希值"""
|
|
sha256_hash = hashlib.sha256()
|
|
try:
|
|
with open(filepath, "rb") as f:
|
|
for byte_block in iter(lambda: f.read(4096), b""):
|
|
sha256_hash.update(byte_block)
|
|
return sha256_hash.hexdigest()
|
|
except Exception:
|
|
return ""
|
|
|
|
|
|
def get_tool_versions() -> Dict[str, str]:
|
|
"""获取所需工具版本信息"""
|
|
versions = {}
|
|
|
|
# fastqc
|
|
try:
|
|
result = subprocess.run(
|
|
["fastqc", "--version"],
|
|
capture_output=True,
|
|
text=True,
|
|
check=False,
|
|
timeout=5
|
|
)
|
|
output = result.stdout.strip() or result.stderr.strip()
|
|
versions["fastqc"] = output.split('\n')[0] if output else "unknown"
|
|
except Exception:
|
|
versions["fastqc"] = "not_found"
|
|
|
|
# cutadapt
|
|
try:
|
|
result = subprocess.run(
|
|
["cutadapt", "--version"],
|
|
capture_output=True,
|
|
text=True,
|
|
check=False,
|
|
timeout=5
|
|
)
|
|
output = result.stdout.strip() or result.stderr.strip()
|
|
versions["cutadapt"] = output.split('\n')[0] if output else "unknown"
|
|
except Exception:
|
|
versions["cutadapt"] = "not_found"
|
|
|
|
return versions
|
|
|
|
|
|
def main():
|
|
parser = argparse.ArgumentParser(description="RNA-Seq QC Skill")
|
|
parser.add_argument("--input-dir", required=True, help="Input directory with FASTQ files")
|
|
parser.add_argument("--output-dir", required=True, help="Output directory")
|
|
parser.add_argument("--prefix", default="", help="Output file prefix")
|
|
parser.add_argument("--config", help="Config file (YAML)")
|
|
parser.add_argument("--demo", action="store_true", help="Demo mode")
|
|
|
|
args = parser.parse_args()
|
|
|
|
print(f"RNA-Seq QC Skill v1.0.0")
|
|
print(f"Input: {args.input_dir}")
|
|
print(f"Output: {args.output_dir}")
|
|
print(f"Prefix: {args.prefix}")
|
|
|
|
# TODO: 实现完整的 skill 逻辑
|
|
# 目前 skill 框架已创建,实际逻辑复用 apps/cli/run_rnaseq_qc.py
|
|
|
|
print("✅ RNA-Seq QC Skill 框架已就绪")
|
|
print("实际分析请使用: apps/cli/run_rnaseq_qc.py")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|