-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathtm.snkmk
195 lines (141 loc) · 6.14 KB
/
tm.snkmk
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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
from string import Template
## needs to be passed by command line
##movie="PA_Sample_NoCorrection"
##movieDbDir="/projects/project-raphael/movie_dbs/db_tests/copy_test/PA_Sample_NoCorrection"
##movieDbDir=config["movie_dir"]
## todo test if movie_dir is present in config array and use instead
movieDbDir=os.path.abspath('.')
movie = os.path.basename(movieDbDir)
DB = movie + ".sqlite"
T1_COUNTS = "topochanges/topoChangeSummary.RData"
TRACKED_ROIS = "roi_bt/lgRoiSmoothed.RData"
TRIANGLES = "shear_contrib/triList.RData"
# https://bitbucket.org/johanneskoester/snakemake/wiki/Documentation#markdown-header-local-rules
localrules: parse_tables, make_db
## grep output /projects/project-raphael/scripts/tissue_miner/workflow/tm.snkmk | tail -n+2 | cut -d: -f2- | sort -u | tr "\\n" ","
rule all:
input: "4way_vertices/not3_vertices.mp4", DB, "dbTablesFromParser/vertex_in_frame.dat", "lg_color_optimization/lg_colors.txt", "lineage/generation_limit_range.mp4", "nematics_movies/" + movie + "_cell_elongation.mp4", "polygon_class/polygon_class_discrete.mp4", "shear_contrib/thirdInt.RData", TRIANGLES, "state_movies/" + movie + "_cell_area_rainbow.mp4", "state_movies/" + movie + "_DBelong_nematics.mp4", "state_movies/" + movie + "_cell_elong_norm.mp4", "stripe_movies/blue_square_tracking.mp4", T1_COUNTS, "topochanges/t1_balance_smoothed.mp4", "topochanges/t1_rates_smoothed.mp4", TRACKED_ROIS, "tri_categories/triangleCategories.RData", "roi_bt/corrected_border.mp4", "shear_contrib/raw/Ta_t.RData"
# rule hello:
# run:
# print(vars())
#
#
## merged into CreateDbFromParser for convenience and better readability
#rule rotate_originals:
# shell: "RotateOriginals.sh" + movieDbDir
rule prepare_movie:
params: name="prepare_movie"
output: "Segmentation/movieInformation.dat"
#shell: "CreateMovieInfoDat.sh " + movieDbDir
shell: "PrepareDataForParser.sh " + movieDbDir # also generate original.png needed by the parser
rule parse_tables:
params: name="parse_tables"
input: "Segmentation/movieInformation.dat"
output: "dbTablesFromParser/vertex_in_frame.dat"
# shell: Template("/sw/bin/xvfb-run imageParser $(dirname $movieDbDir) $(basename $movieDbDir) %03d").safe_substitute(vars())
# shell: "/sw/bin/xvfb-run imageParser $(dirname {movieDbDir}) $(basename {movieDbDir}) %03d" #optionally remove tracked and divided pngs
shell: "imageParser $(dirname {movieDbDir}) $(basename {movieDbDir}) %03d" #optionally remove tracked and divided pngs
rule make_db:
params: name="make_db"
input: "dbTablesFromParser/vertex_in_frame.dat", "Segmentation/cumultimesec.txt"
output: DB, "cellshapes.RData"
shell: "CreateDbFromParser.R " + movieDbDir
# shell: "$TM_HOME/db/movie_rotation/RotateOriginals.sh " + movieDbDir +" ; CreateDbFromParser.R " + movieDbDir
rule roi_tracking:
params: name="roi_tracking"
input: DB
output: TRACKED_ROIS
shell: "UserRoiTracking.R " + movieDbDir
rule roi_movies:
params: name="roi_movies"
input: TRACKED_ROIS
output: "roi_bt/corrected_border.mp4"
shell: "RoiTrackingMovies.R " + movieDbDir
rule roi_deform:
params: name="roi_deform"
input: DB
shell: "RoiDeformation.R " + movieDbDir
### Lineage Analysis
rule lineage_colors:
params: name="lineage_colors"
input: DB
output: "lg_color_optimization/lg_colors.txt"
shell: "LineageGroupColoring.R " + movieDbDir
rule lineage_movies:
params: name="lineage_movies"
input: "lg_color_optimization/lg_colors.txt"
output: "lineage/generation_limit_range.mp4"
shell: "LineageMovies.R " + movieDbDir
### Topology Analysis
rule topo_countt1:
params: name="topo_countt1"
input: DB, TRACKED_ROIS
output: T1_COUNTS
shell: "CountT1.R " + movieDbDir
rule topo_movies:
params: name="topo_movies"
input: T1_COUNTS
output: "topochanges/t1_rates_smoothed.mp4"
shell: "TopologyMovies.R " + movieDbDir
rule topo_unbalance:
params: name="topo_unbalance"
input: T1_COUNTS
output: "topochanges/t1_balance_smoothed.mp4"
shell: "UnbalanceT1Movie.R " + movieDbDir
rule four_way:
params: name="four_way"
input: DB
output: "4way_vertices/not3_vertices.mp4"
shell: "FourWayVertices.R " + movieDbDir
rule polygon_class:
params: name="polygon_class"
input: TRACKED_ROIS
output: "polygon_class/polygon_class_discrete.mp4"
shell: "PolygonClass.R " + movieDbDir
## triangles
rule tri_create:
params: name="tri_create"
input: DB
output: TRIANGLES
shell: "CreateTriangles.R " + movieDbDir
rule tri_categorize:
params: name="tri_categorize"
input: T1_COUNTS, TRIANGLES
output: "tri_categories/triangleCategories.RData"
## todo use function here to simplify log creation
shell: "CategorizeTriangles.R " + movieDbDir # direct log redirection: + "2>tri_categorize.err.log 1>tri_categorize.out.log"
### misc
rule area_movies:
params: name="area_movies"
input: DB
output: "state_movies/" + movie + "_cell_area_rainbow.mp4"
shell: "AreaMovies.R " + movieDbDir
rule db_elongation_movies:
params: name="db_elongation_movies"
input: DB
output: "state_movies/" + movie + "_DBelong_nematics.mp4", "state_movies/" + movie + "_cell_elong_norm.mp4"
shell: "DbElongationMovie.R " + movieDbDir
rule density_movies:
params: name="density_movies"
input: DB
output: "state_movies/cell_density.mp4"
shell: "DensityMovies.R " + movieDbDir
rule deformation_movies:
params: name="deformation_movies"
input: DB
output: "stripe_movies/blue_square_tracking.mp4"
shell: "StripeMovies.R " + movieDbDir
### shear
#def redirect_out(ruleName):
# return " 2>logs/"+ruleName+".err.log 1>logs/"+ ruleName + ".out.log"
## usage: + redirect_out("shear_calculate")
rule shear_calculate:
params: name="shear_calculate"
input: TRACKED_ROIS, TRIANGLES
output: "shear_contrib/thirdInt.RData", "shear_contrib/raw/Ta_t.RData"
shell: "CalculateShearContributions.R " + movieDbDir
rule shear_movies:
params: name="shear_movies"
input: "shear_contrib/thirdInt.RData"
output: "nematics_movies/" + movie + "_cell_elongation.mp4"
shell: "NematicsMovies.R " + movieDbDir