Changeset 2961
- Timestamp:
- Nov 27, 2006, 2:32:05 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.1/src/plugins/core/net/sf/basedb/plugins/BioAssaySetExporter.java
r2956 r2961 69 69 import net.sf.basedb.core.query.JoinType; 70 70 import net.sf.basedb.core.query.Orders; 71 import net.sf.basedb.core.query.Selects; 71 72 import net.sf.basedb.core.query.SqlResult; 72 73 import net.sf.basedb.util.BioAssaySetUtil; … … 186 187 187 188 188 private void exportBASE(BioAssaySet bas, File file, Map<String, String> parameters, List<String> reporterFields, List<String> spotFields) 189 private void exportBASE(BioAssaySet bas, File file, Map<String, String> parameters, List<String> reporterFields, List<String> spotFields, Boolean serialFormat, Boolean mergeReporters) 190 throws IOException, SQLException 189 191 { 190 192 DbControl dc = bas.getDbControl(); … … 205 207 // assay section 206 208 out.println("section\tassays"); 207 209 out.println("count\t" + bas.getBioAssays().count(dc)); 210 String annotationString = ""; 211 for (AnnotationType at : getExperimentalFactors(dc, bas)) 212 { 213 annotationString += "\t" + at.getName(); 214 } 215 out.println("columns\tid\tname" + annotationString); 216 out.println("annotationColumns" + annotationString); 208 217 out.println("%"); 209 218 for (BioAssay ba : bas.getBioAssays().list(dc)) … … 214 223 out.print("\t"); 215 224 Set<Object> values = BioAssaySetUtil.getAnnotationValues(dc, ba, at); 216 for (Object v : values) out.print("\t"+v);225 if (!values.isEmpty()) out.print(values.iterator().next()); 217 226 } 218 227 } … … 220 229 221 230 // spot section(s) 222 out.println("section\tspots"); 223 out.println("%"); 224 out.println(); 231 String fieldString = spotFields.toString().substring(1, spotFields.toString().length() - 1).replace(", ", "\t"); 232 String columnString = reporterFields.toString().substring(1, reporterFields.toString().length() - 1).replace(", ", "\t") + "\tassayData"; 233 234 if (serialFormat) 235 { 236 for (BioAssay ba : bas.getBioAssays().list(dc)) 237 { 238 out.println("section\tspots"); 239 out.println("channels\t" + bas.getRawDataType().getChannels()); 240 out.println("assayFields\t" + fieldString); 241 out.println("columns\t" + columnString); 242 out.println("assays\t" + ba.getId()); 243 out.println("count\t" + ba.getNumSpots()); 244 out.println("%"); 245 246 DynamicSpotQuery query = ba.getSpotData(); 247 for (String field : reporterFields) 248 { 249 query.select(Selects.expression(BioAssaySetUtil.createJepExpression(dc, bas, field), field)); 250 } 251 for (String field : spotFields) 252 { 253 query.select(Selects.expression(BioAssaySetUtil.createJepExpression(dc, bas, field), field)); 254 } 255 if (mergeReporters) 256 { 257 // not implemented 258 } 259 DynamicResultIterator result = query.iterate(dc); 260 261 List<Integer> reporterIndex = new ArrayList<Integer>(reporterFields.size()); 262 List<Integer> spotIndex = new ArrayList<Integer>(spotFields.size()); 263 for (String column : reporterFields) 264 { 265 reporterIndex.add(result.getIndex(column)); 266 } 267 for (String field : spotFields) 268 { 269 spotIndex.add(result.getIndex(field)); 270 } 271 272 while (result.hasNext()) 273 { 274 SqlResult r = result.next(); 275 boolean del = false; 276 for (Integer column : reporterIndex) 277 { 278 if (del) 279 { 280 out.print("\t"); 281 } 282 out.print(r.getString(column) != null ? r.getString(column) : ""); 283 del = true; 284 } 285 for (Integer field : spotIndex) 286 { 287 out.print("\t"); 288 out.print(r.getString(field) != null ? r.getString(field) : ""); 289 } 290 out.println(); 291 } 292 293 out.println(); 294 } 295 } 296 else 297 { 298 299 } 300 225 301 } 226 302 … … 644 720 645 721 722 @SuppressWarnings("unchecked") 646 723 public void run(Request request, Response response, ProgressReporter progress) 647 724 { … … 671 748 List<String> spotFields = new ArrayList<String>((List<String>) job.getValues(usedFieldsParameter.getName())); 672 749 673 exportBASE(bioassayset, file, null, reporterFields, spotFields); 750 boolean serialFormat = (Boolean) job.getValue(serialFormatParameter.getName()); 751 boolean geneAverage = (Boolean) job.getValue(geneAveragesParameter.getName()); 752 753 exportBASE(bioassayset, file, null, reporterFields, spotFields, serialFormat, geneAverage); 674 754 } 675 755 else
Note: See TracChangeset
for help on using the changeset viewer.