Virus_Assembler_Megahit.snakefile 2.55 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
import os
import re
import snakemake.utils
import csv

#############
# Wildcards #
#############

STEPS = config["steps"]
PREPARE_REPORT_OUTPUTS = config["prepare_report_outputs"]
PREPARE_REPORT_SCRIPTS = config["prepare_report_scripts"]
OUTPUTS = config["outputs"]
14
PARAMS_INFO = config["params_info"]
15
16
17
18
19
20
config = config["params"]

##########
# Inputs #
##########

21
22
# raw_inputs function call
raw_reads = raw_reads(config['results_dir'], config['sample_dir'], config['SeOrPe'])
mmassaviol's avatar
mmassaviol committed
23
config.update(raw_reads)
24
SAMPLES = raw_reads['samples']
25
26
27

# Tools inputs functions

mmassaviol's avatar
mmassaviol committed
28
29
30
31
32
33
34
35
36
37
def fastqc_SE_inputs():
	inputs = dict()
	inputs["read"] = raw_reads["read"]
	return inputs

def fastqc_PE_inputs():
	inputs = dict()
	inputs["read"] = raw_reads["read"]
	inputs["read2"] = raw_reads["read2"]
	return inputs
38
39
40

def megahit_inputs():
    inputs = dict()
41
    inputs["read"] = expand(raw_reads["read"],sample=SAMPLES)
42
    if (config["SeOrPe"] == "PE"):
43
        inputs["read2"] = expand(raw_reads["read2"],sample=SAMPLES)
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
    return inputs

def blast_refseq_inputs():
    inputs = dict()
    inputs["query"] = config["results_dir"] + "/" + config["megahit_"+config["SeOrPe"]+"_output_dir"] + "/assembly.contigs.fa"
    inputs["db"] = "/blast_db_virus/refseq_virus.nhr"
    return inputs

def map_box_index_inputs():
    inputs = dict()
    inputs["fasta_refseq"] = rules.blast_refseq.output.top_contigs
    return inputs

def map_box_align_inputs():
    inputs = dict()
59
    inputs["read"] = raw_reads["read"]
60
    if config["SeOrPe"] == "PE":
61
        inputs["read2"] = raw_reads["read2"]
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
    return inputs

{import global_functions}

###########
# Outputs #
###########

def step_outputs(step):
    outputs = list()
    if (step == "quality_check"):
        if (config[step] == "fastqc"):
            if(config["SeOrPe"] == "PE"):
                outputs = expand(rules.fastqc_PE.output,sample=SAMPLES)
            else:
                outputs = expand(rules.fastqc_SE.output,sample=SAMPLES)

    if (step == "assembling"):
        if(config["SeOrPe"] == "PE"):
            outputs = rules.megahit_PE.output
        else:
            outputs = rules.megahit_SE.output
    
    if (step == "blasting"):
        outputs = rules.blast_refseq.output

    if (step == "mapping"):
        outputs = expand(rules.map_box_align.output,sample=SAMPLES)

    elif (step == "all"):
        outputs = list(rules.multiqc.output)

    return outputs

# get outputs for each choosen tools
def workflow_outputs(step):
    outputs = list()
    outputs.extend(step_outputs(step))
    return outputs

#########
# Rules #
#########

{import rules}

{import global_rules}