OPENCRAVAT RUN
Runs OpenCRAVAT. Annotate variant calls with OpenCRAVAT. For more details, see https://github.com/KarchinLab/open-cravat/wiki.
Example
This wrapper can be used in the following way:
rule opencravat:
input:
'example_input.tsv',
'modules/commons/hg38wgs',
'modules/converters/cravat-converter',
'modules/mappers/hg38',
'modules/annotators/biogrid',
'modules/annotators/clinvar',
'modules/postaggregators/tagsampler',
'modules/postaggregators/varmeta',
'modules/postaggregators/vcfinfo',
'modules/reporters/excelreporter',
'modules/reporters/tsvreporter',
'modules/reporters/csvreporter',
output:
'example_input.tsv.xlsx',
'example_input.tsv.variant.tsv',
'example_input.tsv.variant.csv'
log:
"logs/open-cravat/run.log"
threads: 1 # set number of threads for parallel processing
wrapper:
"v4.6.0/bio/open-cravat/run"
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.
Software dependencies
open-cravat=2.8.0
Code
__author__ = "Rick Kim"
__copyright__ = "Copyright 2020, Rick Kim"
__license__ = "GPLv3"
from snakemake.shell import shell
import os
log = snakemake.log_fmt_shell(stdout=True, stderr=True)
inputfiles = []
annotators = []
reporters = []
modules_dir = set()
for v in snakemake.input:
if os.path.isfile(v):
inputfiles.append(v)
elif os.path.isdir(v):
(module_group_dir, module_name) = os.path.split(v)
(in_modules_dir, module_group) = os.path.split(module_group_dir)
modules_dir.add(in_modules_dir)
if module_group == "annotators":
annotators.append(module_name)
elif module_group == "reporters" and module_name.endswith("reporter"):
reporters.append(module_name[:-8])
if len(modules_dir) > 1:
print(f'Multiple modules directory detected: {",".join(list(modules_dir))}')
exit()
cmd = ["oc", "run"]
cmd.extend(inputfiles)
genome = snakemake.params.get("genome", "hg38")
mp = snakemake.threads
cmd.extend(["-l", genome])
cmd.extend(["--mp", str(mp)])
if len(annotators) > 0:
cmd.append("-a")
cmd.extend(annotators)
if len(reporters) > 0:
cmd.append("-t")
cmd.extend(reporters)
extra = snakemake.params.get("extra", "")
if len(extra) > 0 and type(extra) == str:
cmd.extend(extra.split(" "))
shell("{cmd} {log}")