Snakemake调用Docker容器执行vcf2maf时文件找不到问题求助
Let's break down the root causes of your file-not-found error and fix them step by step:
1. Mismatched Local vs. Container Filesystem Paths
The core issue is that you're passing local filesystem paths (from snakemake.input['read'] and snakemake.output['out']) directly to the Docker container. The container can't access your local files unless they're covered by the -v volume mounts you defined.
Your local directory /home/data/TEST/ is mapped to /data3 inside the container, so:
- Local input path:
/home/data/TEST/CALL/{sample}.muetect2.vt.clean.vcf.gz - Container equivalent input path:
/data3/CALL/{sample}.muetect2.vt.clean.vcf.gz - Local output path:
/home/data/TEST/MAF/{sample}.muetect2.vt.vep.maf - Container equivalent output path:
/data3/MAF/{sample}.muetect2.vt.vep.maf
You need to convert these local paths to their container-side equivalents before passing them to the vcf2maf command.
2. Incorrect vcf2maf.pl Parameter Syntax
You’re passing the output file directly after the input VCF, but vcf2maf.pl requires the explicit --output-maf flag to specify the output location. Omitting this flag makes the script misinterpret your arguments, leading to unexpected file lookup failures.
3. Docker Interactive Mode Conflict
Using -it in your Docker command is designed for interactive terminal sessions. When running from a non-interactive Snakemake script, this can cause hangs or silent failures. Replace -it with --rm to automatically clean up the container after it finishes running (a best practice for ephemeral jobs).
4. Wrong VEP Data Path
Your --vep-data parameter is set to /mnt/, but you mapped your VEP database to /mnt/homo_sapiens inside the container. You need to point --vep-data to this correct container-side path.
Fixed report.py Script
from subprocess import run # Convert local paths to container-side paths using the volume mapping container_input = snakemake.input['read'].replace("/home/data/TEST/", "/data3/") container_output = snakemake.output['out'].replace("/home/data/TEST/", "/data3/") cmd = [ 'docker', 'container', 'run', '--rm', # Replace -it with --rm for non-interactive use '-v', snakemake.params['db_ens'], '-v', snakemake.params['data'], 'vcf2maf_87', 'perl', 'vcf2maf.pl', '--input-vcf', container_input, '--output-maf', container_output, # Explicitly define output with --output-maf '--vep-data', '/mnt/homo_sapiens', # Correct VEP data path in container '--ref-fasta', snakemake.params['fst'], '--tumor-id', snakemake.params['tumor_id'], '--normal-id', 'NORMAL' ] # Add check=True to fail fast if the command encounters an error (easier debugging) run(cmd, check=True)
Additional Debugging Tips
- Ensure the local output directory
/home/data/TEST/MAF/exists before running Snakemake. You can add this to your rule to auto-create it:rule create_maf: # ... existing input/output/params ... shell: "mkdir -p /home/data/TEST/MAF/" script: "scripts/report.py" - Verify that your VEP reference fasta path (
/mnt/homo_sapiens/87_GRCh37/Homo_sapiens.GRCh37.75.dna.primary_assembly.fa) exists inside the container by running a quick test command:docker run --rm -v /mnt/mpwork/vep/homo_sapiens:/mnt/homo_sapiens vcf2maf_87 ls /mnt/homo_sapiens/87_GRCh37/
内容的提问来源于stack exchange,提问作者mau_who

