-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpreprocessPE
More file actions
executable file
·152 lines (126 loc) · 7.38 KB
/
Copy pathpreprocessPE
File metadata and controls
executable file
·152 lines (126 loc) · 7.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
###############################################################################
########################## CONFIG ###########################
###############################################################################
import os
CONFIGFILE = os.environ.get("SEQWORKFLOWS_CONFIG", "config/configPreprocessPE.yaml")
configfile: CONFIGFILE
SEQWORKFLOWS_CONTAINER = config.get(
"container",
os.environ.get("SEQWORKFLOWS_CONTAINER", "docker://ghcr.io/natmurad/seqworkflows:1.0.0"),
)
###############################################################################
######################## LIBRARIES ##########################
###############################################################################
import shutil
import time
start = time.time()
wildcard_constraints:
lane=".*",
reads=".*"
###############################################################################
###################### SET VARIABLES ########################
###############################################################################
THREADS = config["threads"]
STEP_QC = config["step_qC"] # quality control
STEP_MAP = config["step_map"] # indexing and mapping
STEP_COUNTS = config["step_counts"] # quantify counts
SAMPLES = config["samples"].split() # sample files
#SRALIST = config["sralist"]
LANE = str(config.get("lane") or "")
FQ = config["fq"]
READS = str(config.get("reads") or "")
ADAPTERS = config["adapters"] # adapters sequences
REF_GENOME = config["ref_genome"]
GTF_FILE = config["gtf_file"]
GTF_GFF = config["gtf_gff"]
PREF = config["prefix_ref"]
STRANDEDNESS = config.get("strandedness", config.get("strandness", "reverse"))
RSEM_FORWARD_PROB = {
"unstranded": "0.5",
"forward": "1",
"reverse": "0",
}
if STRANDEDNESS not in RSEM_FORWARD_PROB:
raise ValueError(
f"Invalid strandedness '{STRANDEDNESS}'. Use one of: "
f"{', '.join(RSEM_FORWARD_PROB)}"
)
RSEM_FORWARD_PROB_VALUE = RSEM_FORWARD_PROB[STRANDEDNESS]
INPUTDIR = config["raw_data_dir"] # /home/dataset/raw_data - fastq reads
DIR = config["base_dir"] # /home/user/
TRIMMEDDIR = config["trimmed_dir"] # /home/dataset/trimmed
STARINDEXDIR = config['rsemprepref'] # /home/dataset/reference
RSEMPREPREF = config['rsemprepref'] # /home/dataset/reference
OUT_STEP_QC = os.path.join(DIR, STEP_QC) # /home/dataset/qC
OUT_STEP_MAP = os.path.join(DIR, STEP_MAP) # /home/dataset/map
OUT_STEP_COUNTS = os.path.join(DIR, STEP_COUNTS) # /home/dataset/counts
###############################################################################
######################### RULE ALL ##########################
###############################################################################
rule all:
input:
###------ QUALITY CONTROL ------###
# fastqc output before trimming
fastq_html = expand("{out_dir_name}fastqcRaw/{sample}{lane}_{reads}1_fastqc.html", out_dir_name=OUT_STEP_QC, sample=SAMPLES, lane=LANE, reads=READS),
fastq_html2 = expand("{out_dir_name}fastqcRaw/{sample}{lane}_{reads}2_fastqc.html", out_dir_name=OUT_STEP_QC, sample=SAMPLES, lane=LANE, reads=READS),
# fastqc output after trimming
trimmed = expand("{trim_dir}{sample}{lane}_{reads}1_trimmed.fq.gz", trim_dir = TRIMMEDDIR, sample=SAMPLES, lane=LANE, reads=READS),
html_trim = expand("{out_dir_name}fastqcTrim/{sample}{lane}_{reads}1_trimmed2_fastqc.html", out_dir_name=OUT_STEP_QC, sample=SAMPLES, lane=LANE, reads=READS),
trimmed2 = expand("{trim_dir}{sample}{lane}_{reads}2_trimmed.fq.gz", trim_dir = TRIMMEDDIR, sample=SAMPLES, lane=LANE, reads=READS),
html_trim2 = expand("{out_dir_name}fastqcTrim/{sample}{lane}_{reads}2_trimmed2_fastqc.html", out_dir_name=OUT_STEP_QC, sample=SAMPLES, lane=LANE, reads=READS),
# merged reports before trimming
raw_html = f"{OUT_STEP_QC}fastqcRaw/multiqc_report.html",
# merged reports after trimming
trim_html = f"{OUT_STEP_QC}fastqcTrim/multiqc_report.html",
###------ PREPARE REFERENCE ------###
# reference for alignments
rsemref = f"{RSEMPREPREF}{PREF}.seq",
###------ MAPPING ------###
# star align
reads_map = expand("{out_dir}{sample}{lane}_{reads}Aligned.sortedByCoord.out.bam", out_dir = OUT_STEP_MAP, sample=SAMPLES, lane=LANE, reads=READS),
###------ COUNT MATRIX ------###
# rsem
counts = expand("{out_dir}{sample}{lane}_{reads}.genes.results", out_dir = OUT_STEP_COUNTS, sample=SAMPLES, lane=LANE, reads=READS),
###############################################################################
########################### RULES ###########################
###############################################################################
#>>>>>>>>>>>>>>------ QUALITY CONTROL --------<<<<<<<<<<<<<<<<
###############################################################################
################# QUALITY REPORT RAW DATA ###################
###############################################################################
include: "rules/PE/fastqcRAW.smk"
###############################################################################
######################### TRIMMING ##########################
###############################################################################
include: "rules/PE/trimmomatic.smk"
###############################################################################
######################### FASTP ##########################
###############################################################################
include: "rules/PE/fastp.smk"
###############################################################################
############### QUALITY REPORT TRIMMED DATA #################
###############################################################################
include: "rules/PE/fastqcTRIM.smk"
###############################################################################
###################### MERGE REPORTS ########################
###############################################################################
include: "rules/PE/multiqc.smk"
#>>>>>>>>>>>>>>------ MAPPING TO REFERENCE --------<<<<<<<<<<<<<<<<
###############################################################################
################### RSEM PREPARE REFERENCE ######################
###############################################################################
include: "rules/BOTH/rsemref.smk"
###############################################################################
###################### STAR MAPPING ########################
###############################################################################
include: "rules/PE/starmap.smk"
#>>>>>>>>>>>>>>------ COUNT MATRIX --------<<<<<<<<<<<<<<<<
###############################################################################
###################### RSEM COUNTS ########################
###############################################################################
include: "rules/PE/rsemcounts.smk"
onsuccess:
print("\n\n#######################################################\n")
print("########------ PREPROCESSING FINISHED! ------##########\n")
print("#######################################################\n")
print("\n\nRunning time in minutes: %s\n" % round((time.time() - start)/60,1))