2 # This is makefile of Sample for 3D-Reconstrucion.
5 #### Root Makefile ####
6 MAKE_ROOT=3DReconstruction0
8 #### Input extention ####
9 # These extensions must all be different.
29 #### Suffixes rule ####
30 .SUFFIXES: .$(IN_PDB_EXT) .$(IN_3D_EXT) .$(IN_ROI_EXT) .$(IN_2D_EXT) .$(REF_3D_EXT) .$(REF_2D_EXT) .$(IN_PAD_EXT) .$(IN_CORR_EXT) .$(OUT_CORR_EXT) .$(NOR_CORR_EXT) .cordst .cornor1 .cornor2 .cornor3 .cornor4 .$(3D_INFO_EXT) .$(OUT_FIT_EXT) .$(3D_LIST_EXT) $(3D_DIV_EXT) .$(OUT_3D_EXT) .$(IN_TIFF_EXT) .tiff .txt
36 -include ${EOS_HOME}/tutorial/TIPS/Help/Makefile/Makefile-lib
40 -include OUT_CORR_LIST
42 -include NOR_CORR_LIST
49 # Target structure name
52 # Interpolation mode(CommonSetting: Input, Ref, Output)
56 ## For mrc3Dto2D(Input)
63 IN_ROT1N=`expr \( $(IN_ROT1MAX) - $(IN_ROT1MIN) \) / $(IN_ROT1D) + 1`
68 IN_ROT2N=`expr \( $(IN_ROT2MAX) - $(IN_ROT2MIN) \) / $(IN_ROT2D) + 1`
73 IN_ROT3N=`expr \( $(IN_ROT3MAX) - $(IN_ROT3MIN) \) / $(IN_ROT3D) + 1`
74 # 0:Mercator 1:Mollweide
76 # Noise/Signal-Ratio(if you wish no-noise, set 0)
79 ## Pre-processing(Pad)
97 ROT1N=`expr \( $(ROT1MAX) - $(ROT1MIN) \) / $(ROT1D) + 1`
100 ROT2MAX=$(IN_ROT2MAX)
102 ROT2N=`expr \( $(ROT2MAX) - $(ROT2MIN) \) / $(ROT2D) + 1`
104 ROT3MIN=$(IN_ROT3MIN)
105 ROT3MAX=$(IN_ROT3MAX)
107 ROT3N=`expr \( $(ROT3MAX) - $(ROT3MIN) \) / $(ROT3D) + 1`
109 # 0:Mercator 1:Mollweide
110 EX_MODE=$(IN_EX_MODE)
112 ### For mrcImageCorrelation
117 nROT=`echo "" | awk 'BEGIN {printf 360 / $(STEP)}'`
122 # For Reduce List(range :0 <= p < 100)(if you wish no-reduce, set 0.)
125 # For Divide List(range: 0 <= p < 100)(if you wish no-divide, set 0.)
128 # For Fourier Shell Correlation
135 #### Rules of the list created ####
136 $(IN_PAD_EXT):$(IN_ROI_LIST:.$(IN_ROI_EXT)=.$(IN_PAD_EXT))
137 $(IN_CORR_EXT):$(IN_PAD_LIST:.$(IN_PAD_EXT)=.$(IN_CORR_EXT))
138 $(OUT_CORR_EXT):$(IN_CORR_LIST:.$(IN_CORR_EXT)=.$(OUT_CORR_EXT))
139 $(NOR_CORR_EXT):$(OUT_CORR_LIST:.$(OUT_CORR_EXT)=.$(NOR_CORR_EXT))
140 cordst:$(OUT_CORR_LIST:.$(OUT_CORR_EXT)=.cordst)
141 $(3D_INFO_EXT):$(NOR_CORR_LIST:.$(NOR_CORR_EXT)=.$(3D_INFO_EXT))
142 $(OUT_FIT_EXT):$(3D_INFO_LIST:.$(3D_INFO_EXT)=.$(OUT_FIT_EXT))
143 $(IN_TIFF_EXT):$(OUT_3D_LIST:.$(OUT_3D_EXT)=.$(IN_TIFF_EXT))
144 tiff:$(IN_TIFF_LIST:.$(IN_TIFF_EXT)=.tiff)
145 txt:$(3D_LIST_LIST:.$(3D_LIST_EXT)=.txt)
149 echo "IN_ROI_LIST=\\" > IN_ROI_LIST
150 # ls -1 *.$(IN_ROI_EXT) >> IN_ROI_LIST
151 # ls -1 *.$(IN_ROI_EXT) | sed s/$(IN_ROI_EXT)/$(IN_ROI_EXT)\\\\/ >> IN_ROI_LIST
152 ls -1 *.$(IN_ROI_EXT) | sort -t - -k1,1 -k2,2 -k3,3 -k4 -n | sed s/$(IN_ROI_EXT)/$(IN_ROI_EXT)\\\\/ >> IN_ROI_LIST
153 echo "" >> IN_ROI_LIST
157 echo "IN_PAD_LIST=\\" > IN_PAD_LIST
158 # ls -1 *.$(IN_PAD_EXT) >> IN_PAD_LIST
159 # ls -1 *.$(IN_PAD_EXT) | sed s/$(IN_PAD_EXT)/$(IN_PAD_EXT)\\\\/ >> IN_PAD_LIST
160 ls -1 *.$(IN_PAD_EXT) | sort -t - -k1,1 -k2,2 -k3,3 -k4 -n | sed s/$(IN_PAD_EXT)/$(IN_PAD_EXT)\\\\/ >> IN_PAD_LIST
161 echo "" >> IN_PAD_LIST
165 echo "IN_CORR_LIST=\\" > IN_CORR_LIST
166 # ls -1 *.$(IN_CORR_EXT) >> IN_CORR_LIST
167 # ls -1 *.$(IN_CORR_EXT) | sed s/$(IN_CORR_EXT)/$(IN_CORR_EXT)\\\\/ >> IN_CORR_LIST
168 ls -1 *.$(IN_CORR_EXT) | sort -t - -k1,1 -k2,2 -k3,3 -k4 -n | sed s/$(IN_CORR_EXT)/$(IN_CORR_EXT)\\\\/ >> IN_CORR_LIST
169 echo "" >> IN_CORR_LIST
173 echo "OUT_CORR_LIST=\\" > OUT_CORR_LIST
174 # ls -1 *.$(OUT_CORR_EXT) >> OUT_CORR_LIST
175 # ls -1 *.$(OUT_CORR_EXT) | sed s/$(OUT_CORR_EXT)/$(OUT_CORR_EXT)\\\\/ >> OUT_CORR_LIST
176 ls -1 *.$(OUT_CORR_EXT) | sort -t - -k1,1 -k2,2 -k3,3 -k4 -n | sed s/$(OUT_CORR_EXT)/$(OUT_CORR_EXT)\\\\/ >> OUT_CORR_LIST
177 echo "" >> OUT_CORR_LIST
181 echo "3D_INFO_LIST=\\" > 3D_INFO_LIST
182 # ls -1 *.$(3D_INFO_EXT) >> 3D_INFO_LIST
183 # ls -1 *.$(3D_INFO_EXT) | sed s/$(3D_INFO_EXT)/$(3D_INFO_EXT)\\\\/ >> 3D_INFO_LIST
184 ls -1 *.$(3D_INFO_EXT) | sort -t - -k1,1 -k2,2 -k3,3 -k4 -n | sed s/$(3D_INFO_EXT)/$(3D_INFO_EXT)\\\\/ >> 3D_INFO_LIST
185 echo "" >> 3D_INFO_LIST
189 echo "NOR_CORR_LIST=\\" > NOR_CORR_LIST
190 # ls -1 *.$(NOR_CORR_EXT) >> NOR_CORR_LIST
191 # ls -1 *.$(NOR_CORR_EXT) | sed s/$(NOR_CORR_EXT)/$(NOR_CORR_EXT)\\\\/ >> NOR_CORR_LIST
192 ls -1 *.$(NOR_CORR_EXT) | sort -t - -k1,1 -k2,2 -k3,3 -k4 -n | sed s/$(NOR_CORR_EXT)/$(NOR_CORR_EXT)\\\\/ >> NOR_CORR_LIST
193 echo "" >> NOR_CORR_LIST
197 echo "OUT_3D_LIST=\\" > OUT_3D_LIST
198 # ls -1 *.$(OUT_3D_EXT) >> OUT_3D_LIST
199 # ls -1 *.$(OUT_3D_EXT) | sed s/$(OUT_3D_EXT)/$(OUT_3D_EXT)\\\\/ >> OUT_3D_LIST
200 ls -1 *.$(OUT_3D_EXT) | sort -t - -k1,1 -k2,2 -k3,3 -k4 -n | sed s/$(OUT_3D_EXT)/$(OUT_3D_EXT)\\\\/ >> OUT_3D_LIST
201 echo "" >> OUT_3D_LIST
205 echo "IN_TIFF_LIST=\\" > IN_TIFF_LIST
206 # ls -1 *.$(IN_TIFF_EXT) >> IN_TIFF_LIST
207 # ls -1 *.$(IN_TIFF_EXT) | sed s/$(IN_TIFF_EXT)/$(IN_TIFF_EXT)\\\\/ >> IN_TIFF_LIST
208 ls -1 *.$(IN_TIFF_EXT) | sort -t - -k1,1 -k2,2 -k3,3 -k4 -n | sed s/$(IN_TIFF_EXT)/$(IN_TIFF_EXT)\\\\/ >> IN_TIFF_LIST
209 echo "" >> IN_TIFF_LIST
214 # ls -1 *.$(IN_TIFF_EXT) >> IN_TIFF_LIST2
215 ls -1 *.$(IN_TIFF_EXT) | sort -t - -k1,1 -k2,2 -k3,3 -k4 -n >> IN_TIFF_LIST2
216 echo "" >> IN_TIFF_LIST2
220 echo "3D_LIST_LIST=\\" > 3D_LIST_LIST
221 # ls -1 *.$(3D_LIST_EXT) >> 3D_LIST_LIST
222 # ls -1 *.$(3D_LIST_EXT) | sed s/$(3D_LIST_EXT)/$(3D_LIST_EXT)\\\\/ >> 3D_LIST_LIST
223 ls -1 *.$(3D_LIST_EXT) | sort -t . -k1,1 -k2 -n | sed s/$(3D_LIST_EXT)/$(3D_LIST_EXT)\\\\/ >> 3D_LIST_LIST
224 echo "" >> 3D_LIST_LIST
227 help_3DReconstruction0::
228 @echo "This is makefile of Sample."
231 make $(TARGET).$(IN_3D_EXT);
232 make $(TARGET).$(IN_2D_EXT);
239 cp $(TARGET).$(REF_3D_EXT)ini $(TARGET).$(REF_3D_EXT);
240 make $(JOP_NUM) $(IN_CORR_EXT);
244 make $(TARGET).$(REF_2D_EXT);
245 make $(JOP_NUM) $(OUT_CORR_EXT);
246 # make OUT_CORR_LIST;
248 # make CorDistribution;
249 # make $(TARGET).$(NOR_CMAP_EXT);
252 touch $(TARGET).$(3D_LIST_EXT);
253 rm $(TARGET).$(3D_LIST_EXT);
254 make $(JOP_NUM) $(3D_INFO_EXT);
256 make $(JOP_NUM) $(OUT_FIT_EXT);
262 touch *.$(IN_CORR_EXT);
263 cp $(TARGET).$(OUT_3D_EXT) $(TARGET).$(REF_3D_EXT);
264 TMPNAME=`date +%y%m%d%H%M%S`; \
265 mv $(TARGET).$(3D_LIST_EXT) $(TARGET).$$TMPNAME.$(3D_LIST_EXT); \
266 mv $(TARGET).$(OUT_3D_EXT) $(TARGET).$$TMPNAME.$(OUT_3D_EXT);
269 mrcInfo -i $(TARGET).$(IN_2D_EXT) -o INFO;
270 @loopmax=$$(cat INFO | awk '/Tailer/ {printf("%d\n", $$3)}'); \
271 LineMax=`expr $$loopmax \* 4`; \
272 for (( LoopNum = 0; LoopNum < $$loopmax; LoopNum++ )) \
274 WorkNum=`expr $$LoopNum \* 4 + 4`; \
275 rdata=$$(tail -$$LineMax INFO | head -$$WorkNum | tail -1); \
276 rot1=$$(echo $$rdata | awk '{printf"%s", $$1}' ); \
277 rot2=$$(echo $$rdata | awk '{printf"%s", $$2}' ); \
278 rot3=$$(echo $$rdata | awk '{printf"%s", $$3}' ); \
279 mrcImageSectionGet -i $(TARGET).$(IN_2D_EXT) -o $(TARGET)-$$rot1-$$rot2-$$rot3.$(IN_ROI_EXT) -z $$LoopNum; \
284 make $(JOP_NUM) $(IN_PAD_EXT);
287 rfile=$$(head -2 IN_PAD_LIST | tail -1 | sed -e s/\\\\//); \
288 mrcInfo -i $$rfile -o RINFO;
289 pdbPCA -i $(TARGET).pdb -oPDB PDB -oU ARRAY;
290 pdbInfo -i PDB -o PINFO;
291 pData=$$(head -3 PINFO | tail -1); \
292 rData=$$(head -5 RINFO | tail -1); \
293 length=$$(echo $$rData | awk '{printf("%f", $$4)}'); \
294 rx=$$(echo $$pData | awk -v v=$$length '{printf("%f", $$8)}'); \
295 ry=$$(echo $$pData | awk -v v=$$length '{printf("%f", $$7)}'); \
296 rz=$$(echo $$pData | awk -v v=$$length '{printf("%f", $$9)}'); \
297 nx=$$(echo "$$rx * $$length" | bc); \
298 ny=$$(echo "$$ry * $$length" | bc); \
299 nz=$$(echo "$$rz * $$length" | bc); \
300 mrcImageGaussSphere -o $(TARGET).tmp -m 2 \
301 -sigmax $$rx -sigmay $$ry -sigmaz $$rz \
302 -W $$nx -H $$ny -S $$nz \
304 mrcImageVolumeCalc -i $(TARGET).tmp -o RINFO -M $(MOLNUM) -D $$length -I 1; \
305 volume=$$(cat RINFO | awk '/ContourLevel\(100\):/ {printf("%f\n", $$2)}'); \
306 mrcImageBinalization -i $(TARGET).tmp -o $(TARGET).$(REF_3D_EXT)ini -t $$volume;
314 touch $(TARGET).cordst;
316 @rfile=$$(head -2 OUT_CORR_LIST | tail -1 | sed -e s/\\\\//); \
317 lmax=`expr $$(cat $$rfile | tail -2 | head -1 | awk '{printf("%d\n", $$1)}') \* 2 + 2`; \
318 fmax=$$(wc -w OUT_CORR_LIST | awk '{printf("%d\n", $$1)}'); \
319 for (( LoopNum = 1; LoopNum <= lmax ; LoopNum += 2 )) \
321 echo CorDistribution: $$LoopNum / $$lmax; \
323 for (( LoopFile = 2; LoopFile <= fmax; LoopFile++ )) \
325 rfile=$$(head -$$LoopFile OUT_CORR_LIST | tail -1 | sed -e s/\\\\//); \
326 Data+="$$(head -$$LoopNum $$rfile | tail -1 | awk '{printf("%15.6f", $$7)}') "; \
328 echo $$Data >> $(TARGET).cordst; \
332 @lmax=$$(wc -l $(TARGET).$(NOR_CMAP_EXT) | awk '{printf("%d\n", $$1)}'); \
333 fmax=`expr $$(wc -w $(TARGET).$(NOR_CMAP_EXT) | awk '{printf("%d\n", $$1)}') / $$lmax`; \
334 for (( LoopFile = 1; LoopFile <= fmax; LoopFile++ )) \
336 echo CorNormalize: $$LoopFile / $$fmax; \
337 WorkNum=`expr $$LoopFile + 1`; \
338 rfile=$$(head -$$WorkNum OUT_CORR_LIST | tail -1 | sed -e s/\\\\//); \
339 wfile=$$(echo $$rfile | sed -e s/$(OUT_CORR_EXT)/$(NOR_CORR_EXT)/); \
342 for (( LoopNum = 1; LoopNum <= lmax ; LoopNum++ )) \
344 NorData=$$(head -$$LoopNum $(TARGET).$(NOR_CMAP_EXT) | tail -1 | awk -v x=$$LoopFile '{printf("%15.6f", $$x)}'); \
345 WorkNum=`expr $$LoopNum \* 2 - 1`; \
346 Data=$$(head -$$WorkNum $$rfile | tail -1 | awk -v v="$$NorData" '{printf("%s %s %s %s %s %s ", $$1, $$2, $$3, $$4, $$5, $$6)}; {printf("%15.6f", v)}; {printf(" %s %s %s %s %s %s %s %s %s %s %s %s\n\n", $$8, $$9, $$10, $$11, $$12, $$13, $$14, $$15, $$16, $$17, $$18, $$19)}'); \
347 echo $$Data >> $$wfile; \
352 @if [ $(DEVIDE_P) -eq 0 ]; then \
353 make $(TARGET).$(OUT_3D_EXT); \
358 make CompareRandom; \
362 mrcImageNormalizedSubtraction -i1 $(TARGET).$(OUT_3D_EXT) -i2 $(TARGET).$(IN_3D_EXT) -o $(TARGET).tmp > INFO;
363 cat INFO | awk '/RMSD/ {printf("%s "), $$0}' >> $(TARGET).rmsd;
364 mrcImageNormalizedSubtraction -i1 $(TARGET).$(OUT_3D_EXT) -i2 $(TARGET).$(REF_3D_EXT) -o $(TARGET).tmp > INFO;
365 cat INFO | awk '/RMSD/ {printf("%s\n"), $$0}' >> $(TARGET).rmsd;
366 @rmsd=$$(cat INFO | awk '/RMSD/ {printf("%f"), $$2}'); \
367 if [ $$(echo "$$rmsd <= 0" | bc ) -eq 1 ]; then \
372 @for (( loop_num = 0; loop_num <= 2; loop_num++ )) \
375 make $(TARGET).$(IN_TIFF_EXT); \
376 mv $(TARGET).$(IN_TIFF_EXT) $(TARGET)$$loop_num.$(IN_TIFF_EXT); \
383 @for (( loop_num = 0; loop_num <= 2; loop_num++ )) \
386 make $(IN_TIFF_EXT); \
388 rm *.$(IN_TIFF_EXT); \
393 Number=`expr $$(wc -l IN_TIFF_LIST2 | awk '{printf("%d", $$1)}') / 1`; \
394 mrcImageMake2DArrayImage -i IN_TIFF_LIST2 -o $(TARGET).tmp -N $$Number;
395 mrc2tiff -i $(TARGET).tmp -o $(TARGET)$$loop_num.tiff;
398 @line=`expr $$(wc -l OUT_CORR_LIST | awk '{printf("%d", $$1)}') - 2`; \
399 endline=`expr $$line \* \( 100 - $(REDUCE_P) \) / 100 + 1`; \
400 worknum=`expr $$line + 1`; \
401 cp OUT_CORR_LIST TMP$$worknum; \
402 cp OUT_CORR_LIST OUT_CORR_LIST_TMP; \
403 for (( ; $$endline < $$line; line-- )) \
405 worknum=`expr $$line + 1`; \
406 random=`expr $$RANDOM % $$line + 2`; \
407 sed -e "$$random , $$random d" TMP$$worknum > TMP$$line; \
409 echo $$line / $$endline Delete L:$$random; \
411 cat TMP`expr $$line + 1` > OUT_CORR_LIST; \
412 rm TMP`expr $$line + 1`;
415 touch $(TARGET).$(3D_DIV_EXT);
416 rm $(TARGET).$(3D_DIV_EXT);
417 @line=$$(wc -l $(TARGET).$(3D_LIST_EXT) | awk '{printf("%d", $$1)}'); \
418 endline=`expr $$line \* \( 100 - $(DEVIDE_P) \) / 100 + 1`; \
419 worknum=`expr $$line + 1`; \
420 cp $(TARGET).$(3D_LIST_EXT) TMP$$worknum; \
421 cp $(TARGET).$(3D_LIST_EXT) $(TARGET)_TMP.$(3D_LIST_EXT); \
422 for (( ; $$endline < $$line; line-- )) \
424 worknum=`expr $$line + 1`; \
425 random=`expr $$RANDOM % $$line + 2`; \
426 head -$$random TMP$$worknum | tail -1 >> $(TARGET).$(3D_DIV_EXT); \
427 sed -e "$$random , $$random d" TMP$$worknum > TMP$$line; \
429 echo $$line / $$endline Select L:$$random; \
431 cat TMP`expr $$line + 1` > $(TARGET).$(3D_LIST_EXT); \
432 rm TMP`expr $$line + 1`;
435 mrc2Dto3D -I $(TARGET).$(3D_LIST_EXT) -o TMP.$(OUT_3D_EXT) -InterpolationMode $(IN_MODE) -Double -CounterThreshold 0.5 -m 1 -WeightMode 2 -DoubleCounter TMP.dc;
438 touch TMP0.$(OUT_3D_EXT);
439 rm TMP0.$(OUT_3D_EXT);
440 @line=$$(wc -l $(TARGET).$(3D_DIV_EXT) | awk '{printf("%d", $$1)}'); \
441 for (( LoopNum = 1; $$LoopNum <= $$line; LoopNum++ )) \
443 echo "CompareRandom $$LoopNum / $$line"; \
444 head -$$LoopNum $(TARGET).$(3D_DIV_EXT) | tail -1 > TMP1; \
445 lmax=$$(wc -l $(TARGET).cordst | awk '{printf("%d\n", $$1)}'); \
446 randomline=`expr $$RANDOM % $$lmax + 1`; \
447 rData=$$(head -$$randomline REF_ANGLE_LIST | tail -1); \
448 randomRot1=$$(echo $$rData | awk '{printf("%f", $$1)}'); \
449 randomRot2=$$(echo $$rData | awk '{printf("%f", $$2)}'); \
450 randomRot3=$$(echo $$rData | awk '{printf("%f", $$3)}'); \
451 echo $$randomRot1 $$randomRot2 $$randomRot3; \
452 cat TMP1 | awk -v v1=$$randomRot1 -v v2=$$randomRot2 -v v3=$$randomRot3 '{printf("%s %s %d %d %d\n", $$1, $$2, v1, v2, v3)}' > TMP2; \
453 mrc2Dto3D -I TMP1 -o TMP1.$(OUT_3D_EXT) -InterpolationMode $(IN_MODE) -Double -CounterThreshold 0.5 -m 1 -WeightMode 2 -DoubleCounter TMP1.dc; \
454 mrc2Dto3D -I TMP2 -o TMP2.$(OUT_3D_EXT) -InterpolationMode $(IN_MODE) -Double -CounterThreshold 0.5 -m 1 -WeightMode 2 -DoubleCounter TMP2.dc; \
455 mrcImageFourierShellCorrelation -i1 TMP1.$(OUT_3D_EXT) -i2 TMP.$(OUT_3D_EXT) | awk '$(THRES_FSC) <= $$2 {print $$0} $(THRES_FSC) > $$2 {exit}' | tail -1 > TMP; \
456 mrcImageFourierShellCorrelation -i1 TMP2.$(OUT_3D_EXT) -i2 TMP.$(OUT_3D_EXT) | awk '$(THRES_FSC) <= $$2 {print $$0} $(THRES_FSC) > $$2 {exit}' | tail -1 >> TMP; \
458 r1=$$(echo $$rData | awk '{print $$1}'); \
459 c1=$$(echo $$rData | awk '{print $$2}'); \
460 r2=$$(echo $$rData | awk '{print $$4}'); \
461 c2=$$(echo $$rData | awk '{print $$5}'); \
462 echo "TMP0.$(OUT_3D_EXT)" > AVR_LIST; \
463 echo "TMP0.dc" > WGT_LIST; \
464 if [ $$(echo "$$r1 > $$r2" | bc) -eq 1 ]; then \
466 elif [ $$(echo "$$r1 < $$r2" | bc) -eq 1 ]; then \
469 elif [ $$(echo "$$c1 >= $$c2" | bc) -eq 1 ]; then \
475 if [ -e TMP0.$(OUT_3D_EXT) ]; then \
476 echo "TMP$$UseNum.$(OUT_3D_EXT)" >> AVR_LIST; \
477 echo "TMP$$UseNum.dc" >> WGT_LIST; \
478 mrcImageAverage -i AVR_LIST -o TMPTMP.$(OUT_3D_EXT) -w WGT_LIST -oW TMPTMP.dc; \
479 cp TMPTMP.$(OUT_3D_EXT) TMP0.$(OUT_3D_EXT); \
480 cp TMP0.dc TMPTMP.dc; \
482 cp TMP$$UseNum.$(OUT_3D_EXT) TMP0.$(OUT_3D_EXT); \
483 cp TMP$$UseNum.dc TMP0.dc; \
486 if [ -e TMP0.$(OUT_3D_EXT) ]; then \
487 echo "TMP.$(OUT_3D_EXT)" > AVR_LIST; \
488 echo "TMP.dc" > WGT_LIST; \
489 echo "TMP0.$(OUT_3D_EXT)" >> AVR_LIST; \
490 echo "TMP0.dc" >> WGT_LIST; \
491 mrcImageAverage -i AVR_LIST -o $(TARGET).$(OUT_3D_EXT) -w WGT_LIST -oW $(TARGET).dc; \
493 cp TMP.$(OUT_3D_EXT) $(TARGET).$(OUT_3D_EXT); \
494 cp TMP.dc $(TARGET).dc; \
498 touch REF_ANGLE_LIST;
500 mrcInfo -i $(TARGET).$(REF_2D_EXT) -o INFO;
501 @loopmax=$$(cat INFO | awk '/Tailer/ {printf("%d\n", $$3)}'); \
502 LineMax=`expr $$loopmax \* 4`; \
503 for (( LoopNum = 0; LoopNum < $$loopmax; LoopNum++ )) \
505 WorkNum=`expr $$LoopNum \* 4 + 4`; \
506 rdata=$$(tail -$$LineMax INFO | head -$$WorkNum | tail -1); \
507 echo $$rdata | awk '{printf"%s %s %s\n", $$1, $$2, $$3}' >> REF_ANGLE_LIST; \
519 rm *.$(OUT_CORR_EXT);
520 rm *.$(NOR_CMAP_EXT);
521 rm *.$(NOR_CORR_EXT);
532 ##### Commands(Input to Output) #####
533 .$(IN_PDB_EXT).$(IN_3D_EXT):
534 pdb2mrc -i $(TARGET).$(IN_PDB_EXT) -o $(TARGET).$(IN_3D_EXT) -m 1;
536 .$(IN_3D_EXT).$(IN_2D_EXT):
537 mrc3Dto2D -i $(TARGET).$(IN_3D_EXT) -o $(TARGET).$(IN_2D_EXT) -EulerMode $(IN_ROTMODE) \
538 -Rot1 $(IN_ROT1MIN) $(IN_ROT1MAX) $(IN_ROT1D) \
539 -Rot2 $(IN_ROT2MIN) $(IN_ROT2MAX) $(IN_ROT2D) \
540 -Rot3 $(IN_ROT3MIN) $(IN_ROT3MAX) $(IN_ROT3D) \
541 -m $(IN_EX_MODE) -InterpolationMode $(IN_MODE);
543 .$(IN_ROI_EXT).$(IN_PAD_EXT):
544 mrcImageNoiseAdd -i $*.$(IN_ROI_EXT) -o $*.$(IN_PAD_EXT) -NS $(NSRATIO);
546 .$(IN_PAD_EXT).$(IN_CORR_EXT):
547 mrcImageWindowing -i $*.$(IN_PAD_EXT) -o $*.mask -W 0.1 0.0 0.05 0.0 -m 18;
548 mrcImagePad -i $*.mask -o $*.padtmp -W $(PAD_W) -H $(PAD_H) -m 3;
549 mrcImageWindowing -i $*.padtmp -o $*.$(IN_CORR_EXT) -W 0.1 0.0 0.1 0.0 -m 2;
553 .$(REF_3D_EXT).$(REF_2D_EXT):
554 mrc3Dto2D -i $*.$(REF_3D_EXT) -o $*.tmp -EulerMode $(ROTMODE) -InterpolationMode $(IN_MODE) -Rot2 $(ROT2MIN) $(ROT2MAX) $(ROT2D) -Rot1 $(ROT1MIN) $(ROT1MAX) $(ROT1D) -Rot3 $(ROT3MIN) $(ROT3MAX) $(ROT3D) -m $(EX_MODE);
555 rfile=$$(head -2 IN_CORR_LIST | tail -1 | sed -e s/\\\\//); \
556 mrcInfo -i $$rfile -o INFO;
557 Data=$$(head -1 INFO | tail -1); \
558 xPad=$$(echo $$Data | awk '{printf("%d", $$4)}'); \
559 yPad=$$(echo $$Data | awk '{printf("%d", $$5)}'); \
560 mrcImage3DPad -i $*.tmp -o $*.$(REF_2D_EXT) -Nx $$xPad -Ny $$yPad -M 1 -v 0;
564 .$(IN_CORR_EXT).$(OUT_CORR_EXT):
565 mrcImageAutoRotationCorrelation -i $*.$(IN_CORR_EXT) -r $(TARGET).$(REF_2D_EXT) -cor $*.cor -O $*.$(OUT_CORR_EXT) -n $(nRot) -m $(COR_MODE) -range $(ROTMIN) $(ROTMAX) -nRot1 $(ROT1N) -nRot2 $(ROT2N) -nRot3 $(ROT3N) 2> /dev/null
570 @lmax=$$(wc -l $*.cordst | awk '{printf("%d\n", $$1)}'); \
571 fmax=`expr $$(wc -w $*.cordst | awk '{printf("%d\n", $$1)}') / $$lmax`; \
572 for (( LoopNum = 1; LoopNum <= $$lmax; LoopNum++ )) \
574 echo CorNormalize1: $$LoopNum / $$lmax; \
576 DataL="$$(head -$$LoopNum $*.cordst | tail -1) "; \
577 for (( LoopFile = 1; LoopFile <= fmax; LoopFile++ )) \
579 ave=$$(echo $$DataL | awk -v x=$$LoopFile -v v=$$ave '{v+=$$x} END{print v}'); \
581 ave=$$(echo $$ave | awk -v v=$$ave -v u=$$fmax '{v/=u} END{print v}'); \
583 for (( LoopFile = 1; LoopFile <= fmax; LoopFile++ )) \
585 sigma=$$(echo $$DataL | awk -v x=$$LoopFile -v ave=$$ave -v v=$$sigma '{v+=($$x - ave)^2} END{print v}'); \
587 sigma=$$(echo $$sigma | awk -v v=$$sigma -v u=$$fmax '{v=sqrt(v/u)} END{print v}'); \
589 for (( LoopFile = 1; LoopFile <= fmax; LoopFile++ )) \
591 Data+="$$(echo $$DataL | awk -v x=$$LoopFile -v ave=$$ave -v sigma=$$sigma '{zvalue=($$x - ave) / sigma; print zvalue}') "; \
593 echo $$Data >> $*.cornor1; \
599 @lmax=$$(wc -l $*.cordst | awk '{printf("%d\n", $$1)}'); \
600 fmax=`expr $$(wc -w $*.cordst | awk '{printf("%d\n", $$1)}') / $$lmax`; \
601 for (( LoopFile = 1; LoopFile <= $$fmax ; LoopFile++ )) \
603 avelist+="$$(cat $*.cordst | awk -v x=$$LoopFile '{v=v+$$x} END{v=v/NR; print v}') "; \
605 for (( LoopFile = 1; LoopFile <= $$fmax ; LoopFile++ )) \
607 ave=$$(echo $$avelist | awk -v x=$$LoopFile '{print $$x}'); \
608 sigmalist+="$$(cat $*.cordst | awk -v x=$$LoopFile -v ave=$$ave '{sigma+=($$x - ave)^2} END{sigma=sqrt(sigma/NR); print (sigma)}') "; \
610 for (( LoopNum =1; LoopNum <= $$lmax; LoopNum++ )) \
612 echo CorNormalize2: $$LoopNum / $$lmax; \
614 for (( LoopFile = 1; LoopFile <= $$fmax; LoopFile++ )) \
616 ave=$$(echo $$avelist | awk -v x=$$LoopFile '{print $$x}'); \
617 sigma=$$(echo $$sigmalist | awk -v x=$$LoopFile '{print $$x}'); \
618 Data+="$$(head -$$LoopNum $*.cordst | tail -1 | awk -v x=$$LoopFile -v ave=$$ave -v sigma=$$sigma '{zvalue=($$x - ave) / sigma; print zvalue}') "; \
620 echo $$Data >> $*.cornor2; \
625 mv $*.cornor1 $*.cornor1.cordst;
626 make $*.cornor1.cornor2;
627 mv $*.cornor1.cornor2 $*.cornor3;
631 mv $*.cornor2 $*.cornor2.cordst;
632 make $*.cornor2.cornor1;
633 mv $*.cornor2.cornor1 $*.cornor4;
635 .$(NOR_CORR_EXT).$(3D_INFO_EXT):
636 touch $*.$(3D_INFO_EXT);
637 rm $*.$(3D_INFO_EXT);
638 awk '/Cor/ { printf("%15.6f %s %s %s %s %s %s %s %s %s\n", $$7,$$16,$$2,$$3,$$4,$$5,$$9,$$11,$$12,$$1)}' $*.$(NOR_CORR_EXT) | sort -n -r | sed -e s/.$(IN_CORR_EXT)/.$(OUT_FIT_EXT)/ >> $*.$(3D_INFO_EXT)
639 head -n 1 $*.$(3D_INFO_EXT) | awk '{print $$2,$$3,$$4,$$5,$$6,$$1}' >> $(TARGET).$(3D_LIST_EXT)
641 .$(3D_INFO_EXT).$(OUT_FIT_EXT):
642 Data=$$(head -1 $*.$(3D_INFO_EXT) | tail -1); \
643 Number=$$(echo $$Data | awk '{printf("%f\n", $$10)}'); \
644 mrcImageSectionGet -i $(TARGET).$(REF_2D_EXT) -o $*.tmp -z $$Number;
645 mrcImageAutoRotationCorrelation -i $*.$(IN_CORR_EXT) -r $*.tmp -fit $*.$(OUT_FIT_EXT) -cor $*.cor -n $(nRot) -m $(COR_MODE) -range $(ROTMIN) $(ROTMAX) -nRot1 $(ROT1N) -nRot2 $(ROT2N) -nRot3 $(ROT3N) 2> /dev/null
647 .$(3D_LIST_EXT).$(OUT_3D_EXT):
648 mrc2Dto3D -I $(TARGET).$(3D_LIST_EXT) -o $(TARGET).$(OUT_3D_EXT) -InterpolationMode $(IN_MODE) -Double -CounterThreshold 0.5 -m 1 -WeightMode 2;
650 .$(OUT_3D_EXT).$(IN_TIFF_EXT):
652 mrcImageProjection -i $*.$(OUT_3D_EXT) -o $*.$(IN_TIFF_EXT) -m $$loop_num;
654 .$(IN_TIFF_EXT).tiff:
655 mrc2tiff -i $*.$(IN_TIFF_EXT) -o $*.tiff;
658 sort -t - -k1,1 -k2,2 -k3,3 -k4 -n $*.$(3D_LIST_EXT) >> $*.txt;