Created
April 10, 2020 22:48
-
-
Save nh13/7c442017b1ea9d1f11a7cf6b5888ff95 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import enum | |
from typing import List | |
from pathlib import Path | |
class Alignment(enum.Enum): | |
BWA = 1 | |
Bowtie = 2 | |
class VariantCalling(enum.Enum): | |
HaplotypeCaller = 1 | |
Manta = 2 | |
class Annotation(enum.Enum): | |
SnpEff = 1 | |
Coovar = 2 | |
terminal_files: List[Path] = [] | |
# Implementation #1: parse the config object to get the list of tools and run all combinations | |
# (ex. "bwa,bowtie,hc,manta") | |
alignment_tools: List[Alignment] = [Alignment(name) for name in config["alignment"].split(",")] | |
variant_calling_tools: List[Alignment] = [VariantCalling(name) for name in config["variant_calling"].split(",")] | |
annotation_tools: List[Alignment] = ... | |
annotation_tools: List[Alignment] = ... | |
for alignment_tool in alignment_tools: | |
for variant_calling_tool in variant_calling_tools: | |
for annotation_tool in annotation_tools: | |
terminal_files.append(f"sample.{alignment_tool}.{variant_calling_tool}.{annotation_tool}.vcf.gz") | |
# Implementation #2: user specifies the combination list to use (ex. "bwa:hc:coovar,bwa:manta:snpeff") | |
for tool_chain in config["tool_chains"].split(",") | |
alignment_tool, variant_calling_tool, annotation_tool = tool_chain.split(":") | |
terminal_files.append(f"sample.{alignment_tool}.{variant_calling_tool}.{annotation_tool}.vcf.gz") | |
# rules | |
rule all: | |
input: | |
terminal_files | |
rule bwa: | |
input: | |
r1 = "{sample}.fastq.gz", | |
r2 = "{sample}.fastq.gz" | |
output: | |
bam = "{sample}.bwa.bam" | |
rule bowtie: | |
... | |
rule hc: | |
input: | |
bam = "{sample}.bam" | |
output: | |
vcf = "{sample}.hc.vcf.gz" | |
... | |
rule manta: | |
input: | |
vcf = "{sample}.vcf" | |
output: | |
vcf = "{sample}.manta.vcf.gz" | |
... | |
rule coovar: | |
... | |
# rules for annotation similarly, exercise left to the reader |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment