本帖最后由 bailong360 于 2015-3-31 23:33 编辑
- # 2>nul&@Gawk -f %0 drugdata.txt &Exit
- BEGIN{printf("ENTRY ATC code Drug group Therapeutic category PATHWAY\n")>>"$Data.txt";A[2]=D[2]=T[2]=P="~"}
- END{printf("\n拥有ATC code的药物有%d种\n拥有Drug group的药物有%d种\n拥有Therapeutic category的药物有%d种\n拥有PATHWAY的药物有%d种\n",_A,_D,_T,_P)>>"$Data.txt"}
- $1~"///"{
- A[2]!="~"?_A++:0;D[2]!="~"?_D++:0;T[2]!="~"?_T++:0;P!="~"?_P++:0
- printf("%-16s %-15s %-16s %-31s %s\n",E,A[2],D[2],T[2],P)>>"$Data.txt"
- A[2]=D[2]=T[2]=P="~"
- }
- $1~"ENTRY"{E=$2}
- $0~"ATC code"{split($0,A,"ATC code: ");gsub(" ",",",A[2])}
- $0~"Drug group"{split($0,D,"Drug group: ");gsub(" ",",",D[2])}
- $0~"Therapeutic category"&&$0!~"of"{split($0,T,"Therapeutic category: ");gsub(" ",",",T[2])}
- Jud==0&&$0~/[a-z]+[0-9]+/&&$0!~"COMMENT"{split($1,P2,"(");P=P!="~"?P","P2[1]:P2[1] }
- $0!~/[a-z]+[0-9]+/{Jud=1}
- $0~"PATHWAY"{split($2,P2,"(");P=P!="~"?P","P2[1]:P2[1];Jud=0}
复制代码
|