-
Notifications
You must be signed in to change notification settings - Fork 1
/
preprocessing.snakefile
161 lines (113 loc) · 4.19 KB
/
preprocessing.snakefile
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
configfile: "./config.yaml"
#create directory structure
snakemake.utils.makedirs('AGapEs_analysis/results_AGapEs/assemblies/consistent/')
snakemake.utils.makedirs('AGapEs_analysis/results_AGapEs/finishing/all_extant_IS/')
snakemake.utils.makedirs('AGapEs_analysis/results_AGapEs/assemblies/IS_gaps/')
snakemake.utils.makedirs('AGapEs_analysis/results_AGapEs/finishing/alignments/consistent/')
snakemake.utils.makedirs('AGapEs_analysis/results_AGapEs/finishing/alignments/IS/')
rule all:
input:
"divide.SUCCESS",
"IS.SUCCESS"
rule fpsac_start:
input:
tree=config["tree"],
contigs=config["contigs"],
references=config["references"],
output:
"AGapEs_analysis/results_AGapEs/scaffold/adjacencies",
"AGapEs_analysis/results_AGapEs/scaffold/gaps_coordinates_and_length",
"AGapEs_analysis/input/extant_genomes.fasta",
"AGapEs_analysis/results_AGapEs/contigs/families.fasta",
"AGapEs_analysis/input/species"
log:
"logs/fpsac/start.log"
shell:
"cd FPSAC; ./run_example.sh AGapEs_analysis {input}; cd .."
rule computeGapSequences:
input:
ext="AGapEs_analysis/input/extant_genomes.fasta",
coords="AGapEs_analysis/results_AGapEs/scaffold/gaps_coordinates_and_length"
output:
dynamic("AGapEs_analysis/results_AGapEs/finishing/alignments/{gap}.fasta")
log:
"logs/computeGapSequences.log"
shell:
"cd FPSAC; python2 src/fpsac_extract_extant_gaps_sequences.py ../{input.ext} ../{input.coords} ../AGapEs_analysis/results_AGapEs/finishing/alignments/ ; cd .."
rule prep_IS:
input:
gen="AGapEs_analysis/input/extant_genomes.fasta",
len="AGapEs_analysis/results_AGapEs/scaffold/gaps_coordinates_and_length",
adjinfo="AGapEs_analysis/adjacencies.info"
output:
dynamic("AGapEs_analysis/results_AGapEs/finishing/all_extant_IS/{Igap}.fasta_extant")
log:
"logs/prepIS.log"
shell:
"python2 ./scripts/fpsac_extract_extant_gaps_sequences.py {input.gen} {input.len} AGapEs_analysis/results_AGapEs/finishing/all_extant_IS/ ; python2 ./scripts/extract_IS_extant.py {input.adjinfo} AGapEs_analysis/results_AGapEs/finishing/all_extant_IS/"
rule muscle:
input:
gapf="AGapEs_analysis/results_AGapEs/finishing/alignments/{gap}.fasta",
tree=config["tree"],
output:
"AGapEs_analysis/results_AGapEs/finishing/alignments/{gap}.fasta_ancestral"
message:
"Alignment of {wildcards.gap} to obtain {wildcards.gap}_ancestral"
log:
"logs/muscle/{gap}.log"
shell:
"cd FPSAC; ./run_muscle.sh {input.gapf} {input.tree}; cd .."
rule muscle2:
input:
gapIS="AGapEs_analysis/results_AGapEs/finishing/all_extant_IS/{Igap}.fasta_extant",
tree=config["tree"],
output:
"AGapEs_analysis/results_AGapEs/finishing/all_extant_IS/{Igap}.fasta_extant_ancestral"
message:
"Alignment of {wildcards.Igap} to obtain {wildcards.Igap}_ancestral"
log:
"logs/muscle2/{Igap}.log"
shell:
"cd FPSAC; ./run_muscle.sh {input.gapIS} {input.tree}; cd .."
rule infos:
input:
adj="AGapEs_analysis/results_AGapEs/scaffold/adjacencies",
iscoords=config["is_coordinates"],
coords="AGapEs_analysis/results_AGapEs/scaffold/gaps_coordinates_and_length",
species="AGapEs_analysis/input/species"
output:
"AGapEs_analysis/adjacencies.info",
"AGapEs_analysis/conflicts.info",
"AGapEs_analysis/nonConserved.info",
"AGapEs_analysis/conserved.info",
"AGapEs_analysis/ISGaps.info"
log:
"logs/comp_infos.log"
shell:
"python2 scripts/adjacency_infos.py {input.adj} {input.iscoords} {input.coords} {output} {input.species}"
rule mvIS:
input:
"AGapEs_analysis/results_AGapEs/finishing/all_extant_IS/{Igap}.fasta_extant_ancestral"
output:
"AGapEs_analysis/results_AGapEs/finishing/all_extant_IS/{Igap}.fasta_ancestral"
shell:
"mv {input} {output}"
rule check_IS:
input:
dynamic("AGapEs_analysis/results_AGapEs/finishing/all_extant_IS/{Igap}.fasta_ancestral"),
output:
"IS.SUCCESS"
shell:
"echo '' > IS.SUCCESS"
rule divideGaps_IS:
input:
adj="AGapEs_analysis/adjacencies.info",
conf="AGapEs_analysis/conflicts.info",
isgaps="AGapEs_analysis/ISGaps.info",
all=dynamic("AGapEs_analysis/results_AGapEs/finishing/alignments/{gap}.fasta_ancestral")
output:
"divide.SUCCESS"
log:
"logs/divideGaps.log"
shell:
"./scripts/divideGaps.sh {input.adj} {input.conf} {input.isgaps}"