VCF2MAF.PL
Convert a VCF into a MAF
URL: https://github.com/mskcc/vcf2maf/tree/main?tab=readme-ov-file#vcfmaf
Example
This wrapper can be used in the following way:
rule test_vcf2maf:
input:
# Optional external VEP install
# vep="path/to/vep/bin",
# vep_cache="path/to/vep_cache",
# vep_config="vep.config",
vcf="small.vcf",
# Optional input files
# chain="small.chain",
fasta="small.fa",
output:
"small.maf",
threads: 1
log:
"test_vcf2maf.log",
params:
extra=" --tumor-id ind1 --normal-id NORMAL ",
wrapper:
"v7.5.0/bio/vcf2maf/vcf2maf"
Note that input, output and log file paths can be chosen freely.
When running with
snakemake --use-conda
the software dependencies will be automatically deployed into an isolated environment before execution.
Notes
In order to use VEP in this wrapper, user must provide an external VEP binary, cache and/or configuration. If none of the VEP-related input parameters are filled, this wrapper automatically turns Ensembl VEP options off.
This wrapper uses only one thread if Ensembl VEP is turned off.
Software dependencies
vcf2maf=1.6.22
Input/Output
Input:
vcf: Path to the VCF to reformatfasta: Optional path to a reference genomechain: Optional chain file to remap variants to a different assemnlyvep: Optional path to a Ensembl VEP install directoryvep_cache: Optional path to Ensembl VEP cachevep_config: Optional path to Ensembl VEP configuration file
Output:
Path to MAF file
Params
extra: Optional parameters besides IO and temporary directory
Code
# coding: utf-8
"""This wrapper handles vcf2maf.pl"""
__author__ = "Thibault Dayris"
__copyright__ = "Copyright 2020, Thibault Dayris"
__email__ = "thibault.dayris@gustaveroussy.fr"
__license__ = "MIT"
from tempfile import TemporaryDirectory
from snakemake.shell import shell
from warnings import warn
from shlex import quote
extra = snakemake.params.get("extra", "")
log = snakemake.log_fmt_shell(stdout=True, stderr=True)
# Optional input files
fasta = snakemake.input.get("fasta")
if fasta:
extra += f" --ref-fasta={quote(fasta)}"
chain = snakemake.input.get("chain")
if chain:
extra += f" --remap-chain={quote(chain)}"
# Acquiring external VEP installation (if any)
vep = ""
vep_path = snakemake.input.get("vep", "")
if vep_path:
vep = f"--vep-path={quote(vep_path)}"
vep_config = snakemake.input.get("vep_config")
if vep_config:
vep += f" --vep-config={quote(vep_config)}"
vep_cache = snakemake.input.get("vep_cache")
if vep_cache:
vep += f" --vep-data={quote(vep_cache)}"
# Automatically turning VEP off if user
# does not provide at least one VEP information
if all([vep_path, vep_cache, vep_config]):
# vcf2maf.pl can run VEP using more than one thread
# This would be the only multithreaded section of the code
vep += f" --vep-forks={snakemake.threads}"
else:
vep = "--inhibit-vep"
if snakemake.threads > 1:
warn("Too many threads requested: only 1 used.")
# Autmatically set temporary directory
with TemporaryDirectory() as tempdir:
shell(
"vcf2maf.pl"
" --input-vcf={snakemake.input.vcf:q}"
" {vep}"
" {extra}"
" --tmp-dir={tempdir:q}"
" --output-maf={snakemake.output:q}"
" {log}"
)