-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpreprocessPE
executable file
·127 lines (107 loc) · 6.58 KB
/
preprocessPE
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
###############################################################################
########################## CONFIG ###########################
###############################################################################
configfile: "/home/user/seqWorkflows/config/configPreprocessPE.yaml"
###############################################################################
######################## LIBRARIES ##########################
###############################################################################
import os
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 = config["lane"]
NUM = config["reads"].split()
FQ = config["fq"]
READS = config["reads"].split()
ADAPTERS = config["adapters"] # adapters sequences
REF_GENOME = config["ref_genome"]
GTF_FILE = config["gtf_file"]
GTF_GFF = config["gtf_gff"]
PREF = config["prefix_ref"]
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_trimmed_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_trimmed_fastqc.html", out_dir_name=OUT_STEP_QC, sample=SAMPLES, lane=LANE, reads=READS),
# merged reports before trimming
raw_html = OUT_STEP_QC + "fastqcRaw/multiqc_report.html",
# merged reports after trimming
trim_html = OUT_STEP_QC + "fastqcTrim/multiqc_report.html",
###------ PREPARE REFERENCE ------###
# reference for alignments
rsemref = 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"
###############################################################################
############### 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))
shutil.rmtree(".snakemake")