本帖最后由 pcl_test 于 2015-12-27 22:14 编辑
- 1>1/* :
- @echo off
- cscript -nologo -e:jscript "%~f0" "drugbank.txt">结果.txt
- echo;完成
- pause & exit/b
- */
-
- var txt ='';
- var fso = new ActiveXObject('Scripting.FileSystemObject');
- var f = fso.OpenTextFile(WScript.Arguments(0));
- while(!f.AtEndOfStream) {
- var str = f.ReadLine();
- if(/^\s*$/.test(str))var ATC_Codes=Drug_Interactions=Indication=KEGG_Drug_ID=Pathways=0;
- if(ATC_Codes==1){
- tmp+=str+',';
- }else{
- if(Drug_Interactions==1){
- if(!/Not Available/.test(str)){
- tmp+=str.replace(/\s[A-Z].+$/,'')+',';
- }else tmp+=str+',';
- }else{
- if(Indication==1){
- tmp+=str+',';
- }else{
- if(KEGG_Drug_ID==1){
- tmp+=str+',';
- }else{
- if(Pathways==1){
- if(!/Not Available/.test(str)){
- tmp+=str.replace(/^.+\s/,'');
- }else tmp+=str;
- }
- }
- }
- }
- }
- if(/^#\s?BEGIN_DRUGCARD/.test(str)){var tmp='';tmp+=str.replace(/^.+\s/,'')+'\t\t';}
- if(/^# ATC_Codes/.test(str)){var ATC_Codes=1;tmp+='\t';}
- if(/^# Drug_Interactions/.test(str)){var Drug_Interactions=1;tmp+='\t';}
- if(/^# Indication/.test(str)){var Indication=1;tmp+='\t';}
- if(/^# KEGG_Drug_ID/.test(str)){var KEGG_Drug_ID=1;tmp+='\t';}
- if(/^# Pathways/.test(str)){var Pathways=1;tmp+='\t';}
- if(/^#\s?END_DRUGCARD/.test(str))txt+=tmp.replace(/,\t/g,'\t\t')+'\r\n'
- }
- var caption = 'BEGIN_DRUGCARD\t\tATC_Codes\t\tDrug_Interactions\t\tIndication\t\tKEGG_Drug_ID\t\tPathways\r\n'
- WSH.Echo(caption+txt);
复制代码
|