-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSnakefile_test
79 lines (52 loc) · 2.04 KB
/
Snakefile_test
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
#!/usr/bin/env python
import os
import sys
import re
import glob
configfile: "config.yaml"
###
extension = config["extension"]
FILES = [ os.path.basename(x) for x in glob.glob("Experience/*") ]
if config["design"]["paired"]:
SAMPLES = list(set([ "_".join(x.split("_")[:2]) for x in FILES]))
else:
SAMPLES = list(set([ x.rstrip(extension) for x in FILES]))
DIR_COMPARAISON = "DAS/"+config["design"]["condition_1"]+"_VS_"+config["design"]["condition_2"]
CONDITIONS = list(set(x.split("_")[0] for x in SAMPLES))
CONDITION_TO_SAMPLES = {}
for condition in CONDITIONS:
CONDITION_TO_SAMPLES[condition] = [sample for sample in SAMPLES if sample.split("_")[0] == condition]
DIRS = ['Reference','Reference/star/','Mapping','Mapping/Out','Trimming','featureCounts','DEG','logs']
for path in DIRS:
if not os.path.exists(path):
os.mkdir(path)
###
rule all:
input:
xp = "experimentalDesign.txt",
trim = expand("Trimming/{sample}_R1.trim.fastq.gz", sample=SAMPLES)
rule experimental_design: # Création d'un fichier txt qui décrit simplement le design expérimental, ceci est nécessaire pour l'étape d'analyse des gènes différentiellement exprimés sous R
output:
"experimentalDesign.txt"
priority: 100
run:
with open("experimentalDesign.txt","w") as xpDesign:
xpDesign.write("batch,condition\n")
for condition,samples in CONDITION_TO_SAMPLES.items():
for sample in samples:
xpDesign.write(sample+".sorted.bam,"+condition+"\n")
rule trimming_PE:
input:
xpDesign = 'experimentalDesign.txt',
adapters = config["ref_files"]["adapters"],
r1 = 'Experience/{sample}_R1.'+config["extension"],
r2 = 'Experience/{sample}_R2.'+config["extension"]
output:
r1 = 'Trimming/{sample}_R1.trim.fastq.gz',
r2 = 'Trimming/{sample}_R2.trim.fastq.gz'
log:
"logs/Trimming/{sample}.log"
priority: 90
message: ''' --- Trimming --- '''
shell: ' bbduk.sh in1="{input.r1}" in2="{input.r2}" out1="{output.r1}" out2="{output.r2}" \
ref="{input.adapters}" minlen=25 ktrim=r k=22 qtrim=rl trimq=20 hdist=1 tpe tbo ziplevel=7 >{log} 2>&1'