Changeset 29 for GSEXmlParser
- Timestamp:
- Apr 17, 2008, 2:04:16 PM (17 years ago)
- Location:
- GSEXmlParser
- Files:
-
- 1 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
GSEXmlParser/GSEXmlParser.cpp
r26 r29 24 24 XmlTag("Descriptions") (descs) 25 25 ); 26 } 27 28 String Data::ToTSV() 29 { 30 String tsv, tab, nl; 31 tab = "\t"; 32 nl = "\n"; 33 tsv = source + tab + "Sample-iid" + tab + iid + nl + 34 source + tab + "Supplementary-Data:" + supp_type + tab + supp_data + nl; 35 for(int i = 0; i < desc.GetCount(); i++) 36 tsv += source + tab + "Description:" + desc.GetKey(i) + tab + desc[i] + nl; 37 38 return tsv; 26 39 } 27 40 … … 91 104 } 92 105 106 String GSEParser::ToTSV() 107 { 108 String tsv, tab; 109 tab = "\t"; 110 tsv = "# rowkey" + tab + "columnkey" + tab + "value\n"; 111 for (int i = 0; i < data.GetCount(); i++) { 112 tsv << data[i].ToTSV(); 113 } 114 return tsv; 115 } 116 93 117 String TrimSpace(String str) { 94 118 while (str.StartsWith(" ") && str.GetLength()) { … … 103 127 CONSOLE_APP_MAIN 104 128 { 105 String in, out, arg_flag; 129 String in, out, fmt, arg_flag; 130 /* 106 131 in = "GSE2109_family.xml"; 107 out = "GSEFamily.xml"; 108 132 out = "GSEFamily.tsv"; 133 fmt = "tsv"; 134 */ 109 135 const Vector<String>& cmdline = CommandLine(); 136 110 137 for(int i = 0; i < cmdline.GetCount(); i++) { 111 138 if (cmdline[i].StartsWith("-")){ 112 139 arg_flag = cmdline[i]; 113 140 } else if (arg_flag.IsEqual("-i")) { 114 in = cmdline[i]; 115 //Cout() << "in: " << in << "\n"; 141 in = cmdline[i]; 116 142 } else if (arg_flag.IsEqual("-o")) { 117 out = cmdline[i]; 118 //Cout() << "out: " << out << "\n"; 143 out = cmdline[i]; 144 } else if (arg_flag.IsEqual("-f")) { 145 fmt = cmdline[i]; 146 } else if (arg_flag.StartsWith("-")) { 147 //Error argument 148 Cout() << "Usage Error: invalid argument "<< arg_flag << "\n"; 149 exit(0); 119 150 } 151 } 152 153 if (cmdline.GetCount()==0 || in.IsEmpty() || out.IsEmpty() || fmt.IsEmpty()) { 154 Cout() << "Usage: GSEXmlParser.exe -f (xml|tsv) -i (input file) -o (output file)\n"; 155 exit(0); 120 156 } 121 157 122 158 GSEParser parser; 123 159 parser.LoadXML(in); 124 SaveFile(out,parser.ToXML()); 160 if (fmt.IsEqual("xml")) 161 SaveFile(out,parser.ToXML()); 162 else if (fmt.IsEqual("tsv")) { 163 SaveFile(out,parser.ToTSV()); 164 } 165 166 125 167 126 168 } -
GSEXmlParser/GSEXmlParser.h
r26 r29 17 17 String supp_data; //Supplementary-Data 18 18 void Dump(); 19 String ToXML(); 19 String ToXML(); 20 String ToTSV(); 20 21 }; 21 22 … … 24 25 void Dump(); 25 26 String ToXML(); 27 String ToTSV(); 26 28 void LoadXML(String filename); 27 29 }; -
GSEXmlParser/GSEXmlParser.upp
r26 r29 1 optimize_speed; 2 1 3 uses 2 4 Core;
Note: See TracChangeset
for help on using the changeset viewer.