• R/O
  • HTTP
  • SSH
  • HTTPS

tutorial: Commit

This repository is for tutorials of Eos.


Commit MetaInfo

Revision33c788aaae2ecfc1cdfec5fc936c4865e8d930ee (tree)
Time2014-10-21 14:03:06
Authorkinoshita-eos <kinoshita@yasu...>
Commiterkinoshita-eos

Log Message

Add: TIPS for extraction of ASCII File.
new file: TIPS/ASCII/Makefile/Makefile
new file: TIPS/ASCII/Makefile/Makefile-lib

Modify: use $(RM) as remove.
modified: Small Tools/Template/Makefile/Makefile-lib
modified: TIPS/Template/Makefile/Makefile

Change Summary

Incremental Difference

--- a/Small Tools/Template/Makefile/Makefile-lib
+++ b/Small Tools/Template/Makefile/Makefile-lib
@@ -20,8 +20,7 @@
2020
2121 ##### Commands #####
2222 InitialData::
23- touch $(FILE_NAME).$(INI);
24- rm $(FILE_NAME).$(INI);
23+ $(RM) $(FILE_NAME).$(INI);
2524 ln -s $(INPUT_PATH) $(FILE_NAME).$(INI)
2625
2726 ##### Commands(Input to Output) #####
--- /dev/null
+++ b/TIPS/ASCII/Makefile/Makefile
@@ -0,0 +1,66 @@
1+#
2+# This is Main Makefile for ASCII.
3+#
4+
5+#### Root Makefile ####
6+MAKE_ROOT=ASCII
7+
8+#### Input extention ####
9+INI=txt
10+
11+#### Suffixes rule ####
12+# Defined at Sub
13+
14+#### INCLUDE ####
15+-include ${EOS_HOME}/tutorial/TIPS/Help/Makefile/Makefile-lib
16+-include Makefile-lib
17+
18+#### Definition ####
19+# Path of Input File
20+# Basically, use a linked data from /SampleData.
21+INPUT_PATH=${EOS_HOME}/tutorial/SampleData/1VOM-N.mrc
22+ASCII_DELIMITER=" "
23+
24+ASCII_S_LINE=3041
25+ASCII_E_LINE=3041
26+
27+ASCII_CLMN= 1 \
28+ 2 \
29+ 3 \
30+
31+### FileData
32+FILE_NAME=Input
33+OUT_FILE_NAME=Output
34+
35+#### Rules of the list created ####
36+# Defined at Sub
37+
38+##### Commands #####
39+# Defined at Sub basically
40+Initial::
41+ $(RM) $(FILE_NAME).$(INI);
42+ ln -s $(INPUT_PATH) $(FILE_NAME).$(INI)3d;
43+ mrcImageProjection -i "$(FILE_NAME).$(INI)3d" -o "$(FILE_NAME).$(INI)2d";
44+ mrcImageMakeDump -i $(FILE_NAME).$(INI)2d -o $(FILE_NAME).$(INI);
45+ mrc2tiff -i "$(FILE_NAME).$(INI)2d" -o "$(FILE_NAME).tiff";
46+ $(RM) "$(FILE_NAME).$(INI)2d";
47+ $(RM) "$(FILE_NAME).$(INI)3d";
48+
49+Exe::
50+ export IN_ASCII_FILE_NAME="$(FILE_NAME)"; \
51+ export IN_ASCII=$(INI); \
52+ export OUT_ASCII_FILE_NAME="$(FILE_NAME)-line"; \
53+ export OUT_ASCII=$(INI); \
54+ make ExtractLine;
55+ export IN_ASCII_FILE_NAME="$(FILE_NAME)-line"; \
56+ export IN_ASCII=$(INI); \
57+ export OUT_ASCII_FILE_NAME="$(OUT_FILE_NAME)"; \
58+ export OUT_ASCII=$(INI); \
59+ make ExtractColumn;
60+
61+all::
62+ make Initial;
63+ make Exe;
64+
65+##### Commands(Input to Output) #####
66+# Defined at Sub
--- /dev/null
+++ b/TIPS/ASCII/Makefile/Makefile-lib
@@ -0,0 +1,98 @@
1+#
2+# This is Sub Makefile to Extract from ASCII.
3+#
4+
5+#### Input extention ####
6+# Defined at Main
7+
8+#### Suffixes rule ####
9+.SUFFIXES:
10+
11+#### INCLUDE ####
12+# Use TIPS File.
13+# -include ${EOS_HOME}/tutorial/TIPS/XXXX/Makefile/Makefile-lib
14+
15+#### Definition ####
16+# Defined at Main
17+
18+#### Rules of the list created ####
19+
20+
21+##### Commands #####
22+help_ASCII::
23+ @echo
24+ @echo "ASCII"
25+ @echo "This is Sub Makefile to Extract from ASCII."
26+ @echo
27+ @echo " (Command):"
28+ @echo " ExtractLine: Extract some lines from ASCII. "
29+ @echo " (Setting Data):"
30+ @echo " ASCII_S_LINE: Start of extracted line. (count from top=1)"
31+ @echo " ASCII_E_LINE: End of extracted line. (count from bottom=1)"
32+ @echo " ExtractColumn: Extract some columns from ASCII. "
33+ @echo " (Setting Data):"
34+ @echo " ASCII_CLMN: extracted column list.(cf. Main Makefile)"
35+ @echo " (NOTE) If the column is undefined, finish extracting."
36+ @echo " If the column is defined to 0, write the line number there."
37+ @echo
38+ @echo " (Setting Data):"
39+ @echo " IN_ASCII_FILE_NAME: Input file name."
40+ @echo " IN_ASCII: Input file extention"
41+ @echo " OUT_ASCII_FILE_NAME: Output file name."
42+ @echo " OUT_ASCII: Output file extetion."
43+ @echo
44+
45+ExtractLine::
46+ @INPUT="$(IN_ASCII_FILE_NAME).$(IN_ASCII)"; \
47+ Tline=$$(wc -l $$INPUT | awk '{printf("%d\n", $$1)}'); \
48+ if [ -z $(ASCII_S_LINE) ]; then \
49+ Sline=1; \
50+ else \
51+ Sline=$(ASCII_S_LINE); \
52+ fi; \
53+ if [ -z $(ASCII_E_LINE) ]; then \
54+ Eline=1; \
55+ else \
56+ Eline=$(ASCII_E_LINE); \
57+ fi; \
58+ HEAD=`expr $$Tline + 1`; \
59+ HEAD=`expr $$HEAD - $$Eline`; \
60+ if [ $$HEAD -lt 1 ] ; then \
61+ HEAD=1; \
62+ elif [ $$Tline -lt $$HEAD ] ; then \
63+ HEAD=$$Tline; \
64+ fi; \
65+ TAIL=`expr $$HEAD + 1`; \
66+ TAIL=`expr $$TAIL - $$Sline`; \
67+ TlineT=`expr $$Tline - $$Eline + 1`; \
68+ if [ $$TAIL -lt 1 ] ; then \
69+ TAIL=1; \
70+ elif [ $$TlineT -lt $$TAIL ] ; then \
71+ TAIL=$$TlineT; \
72+ fi; \
73+ head -$$HEAD $$INPUT | tail -$$TAIL > "$(OUT_ASCII_FILE_NAME).$(OUT_ASCII)"; \
74+ echo "Extract lines `expr $$HEAD - $$TAIL + 1` - $$HEAD"
75+
76+ExtractColumn::
77+ @${RM} $(OUT_ASCII_FILE_NAME).$(OUT_ASCII);
78+ @num=1; \
79+ while read line ; \
80+ do \
81+ for clmn in $(ASCII_CLMN) ; \
82+ do \
83+ if [ $$clmn -gt 0 ] ; then \
84+ echo $$line | awk -v v=$$clmn -v dl=$(ASCII_DELIMITER) '{printf("%d%s"), $$v, dl}' >> "$(OUT_ASCII_FILE_NAME).$(OUT_ASCII)"; \
85+ else \
86+ echo $$line | awk -v v=$$num -v dl=$(ASCII_DELIMITER) '{printf("%d%s"), v, dl}' >> "$(OUT_ASCII_FILE_NAME).$(OUT_ASCII)"; \
87+ fi; \
88+ done; \
89+ echo >> "$(OUT_ASCII_FILE_NAME).$(OUT_ASCII)"; \
90+ numH=`expr $$num % 100`; \
91+ if [ $$numH -eq 0 ] ; then \
92+ echo "$$num line is extracted."; \
93+ fi; \
94+ num=`expr $$num + 1`; \
95+ done < "$(IN_ASCII_FILE_NAME).$(IN_ASCII)";
96+
97+##### Commands(Input to Output) #####
98+
--- a/TIPS/Template/Makefile/Makefile
+++ b/TIPS/Template/Makefile/Makefile
@@ -29,8 +29,7 @@ FILE_NAME=Input
2929 ##### Commands #####
3030 # Defined at Sub basically
3131 Initial::
32- touch $(FILE_NAME).$(INI);
33- rm $(FILE_NAME).$(INI);
32+ $(RM) $(FILE_NAME).$(INI);
3433 ln -s $(INPUT_PATH) $(FILE_NAME).$(INI);
3534
3635 Exe::
Show on old repository browser