Changeset 2931
- Timestamp:
- Nov 17, 2006, 11:23:10 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.1/src/plugins/core/net/sf/basedb/plugins/BioAssaySetExporter.java
r2861 r2931 25 25 package net.sf.basedb.plugins; 26 26 27 import net.sf.basedb.core.AnnotationType; 27 28 import net.sf.basedb.core.BaseException; 28 29 import net.sf.basedb.core.BioAssay; … … 69 70 import net.sf.basedb.core.query.Orders; 70 71 import net.sf.basedb.core.query.SqlResult; 72 import net.sf.basedb.util.BioAssaySetUtil; 71 73 import net.sf.basedb.util.Enumeration; 72 74 73 75 import java.io.IOException; 74 import java.io.OutputStreamWriter; 75 import java.io.Writer; 76 import java.io.PrintWriter; 76 77 import java.sql.SQLException; 77 78 import java.util.ArrayList; … … 83 84 import java.util.HashSet; 84 85 import java.util.List; 86 import java.util.Map; 85 87 import java.util.Set; 86 88 … … 162 164 } 163 165 166 167 private void exportBASE(BioAssaySet bas, File file, Map<String, String> parameters, List<String> reporterFields, List<String> spotFields) 168 { 169 DbControl dc = bas.getDbControl(); 170 PrintWriter out = new PrintWriter(file.getUploadStream(false)); 171 172 // header and parameter section 173 out.println("BASEfile"); 174 if (parameters != null) 175 { 176 for (String key : parameters.keySet()) 177 { 178 out.println(key+"/t"+parameters.get(key)); 179 } 180 out.println("%"); 181 } 182 out.println(); 183 184 // assay section 185 out.println("section/tassays"); 186 187 out.println("%"); 188 for (BioAssay ba : bas.getBioAssays().list(dc)) 189 { 190 out.print(ba.getId() + "\t" + ba.getName()); 191 for (AnnotationType at : getExperimentalFactors(dc, bas)) 192 { 193 out.print("\t"); 194 Set<Object> values = BioAssaySetUtil.getAnnotationValues(dc, ba, at); 195 for (Object v : values) out.print("/t"+v); 196 } 197 } 198 out.println(); 199 200 // spot section(s) 201 out.println("section/tspots"); 202 out.println("%"); 203 out.println(); 204 } 205 164 206 165 207 private void exportMeV(BioAssaySet bioassayset, File file) … … 167 209 { 168 210 DbControl dc=bioassayset.getDbControl(); 169 Writer out = new OutputStreamWriter(file.getUploadStream(false));211 PrintWriter out = new PrintWriter(file.getUploadStream(false)); 170 212 171 213 // comment header … … 443 485 444 486 487 public List<AnnotationType> getExperimentalFactors(DbControl dc, BioAssaySet bas) 488 { 489 ItemQuery<AnnotationType> query = bas.getExperiment().getExperimentalFactors(); 490 query.include(Include.MINE, Include.SHARED, Include.IN_PROJECT, Include.OTHERS); 491 query.order(Orders.asc(Hql.property("name"))); 492 return query.list(dc); 493 } 494 495 445 496 public Set<GuiContext> getGuiContexts() 446 497 { … … 551 602 552 603 // Add other export formats here 553 exportMeV(bioassayset,file); 554 604 String format = (String) job.getValue(formatParameter.getName()); 605 if (format.equals(FORMAT_MEV)) exportMeV(bioassayset,file); 606 else if (format.equals(FORMAT_BASEFILE)) 607 { 608 List<String> reporterFields = new ArrayList<String>((List<String>) job.getValues(usedColumnsParameter.getName())); 609 List<String> spotFields = new ArrayList<String>((List<String>) job.getValues(usedFieldsParameter.getName())); 610 611 exportBASE(bioassayset, file, null, reporterFields, spotFields); 612 } 613 else 614 { 615 throw new BaseException("Unknown format. "+format); 616 } 617 555 618 dc.commit(); 556 619 response.setDone("Bioassay set '" + bioassayset.getName() +
Note: See TracChangeset
for help on using the changeset viewer.