Changeset 1007
- Timestamp:
- Mar 27, 2009, 10:59:20 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
plugins/base2/net.sf.basedb.normalizers/trunk/src/net/sf/basedb/plugins/qQuantileNormalization.java
r1003 r1007 54 54 import java.io.PrintWriter; // Jari, remove this? 55 55 import java.sql.SQLException; 56 import java.util.ArrayList; // Jari, remove this? 56 57 import java.util.EnumSet; 57 58 import java.util.List; // Jari, remove this? … … 111 112 // http://base.thep.lu.se/ticket/1256, and 112 113 // http://baseplugins.thep.lu.se/ticket/183. 114 @SuppressWarnings("unchecked") 113 115 private void exportData() 114 116 throws IOException … … 128 130 } 129 131 130 // creating a meta-data file to track the information in the plain131 // matrix file created above. This will be removed when BASE132 // B ioAssaySetExporter is refactored. Of course, the current133 // meta-data file is highly specific for the needs here, but this134 // use case should be covered hete. Or, way not fall back on a135 // BASEfile?132 // creating a reporter meta data file to track the information in 133 // the plain matrix file created above. This will be removed when 134 // BASE BioAssaySetExporter is refactored. Of course, the current 135 // reporter meta data file is highly specific for the needs here, 136 // but this use case should be covered hete. Or, way not fall back 137 // on a BASEfile? 136 138 137 139 // The query must be the same as the one done in BASE core plug-in … … 155 157 column_channel[i]=spotData.getIndex(VirtualColumn.channel(i+1).getName()); 156 158 157 PrintWriter output = new PrintWriter(getExecDirectory() + 158 java.io.File.separator + metadata); 159 160 // first line in meta data is assay column numbers in BASE data cube 159 ArrayList<Short> referenceSelection=new ArrayList<Short>(); 160 List<BioAssay> assays = (List<BioAssay>)job.getValues(selectBASid); 161 for (BioAssay assay : assays) 162 { 163 assay = BioAssay.getById(dc, assay.getId()); 164 referenceSelection.add(assay.getDataCubeColumnNo()); 165 } 166 167 PrintWriter assayWriter = new PrintWriter(getExecDirectory() + 168 java.io.File.separator + 169 assaydata); 161 170 List<BioAssay> sourceAssays = sourceBAS.getBioAssays().list(dc); 162 171 int nofAssays=sourceAssays.size(); 163 172 for (int i=0; i<nofAssays; ++i) 164 173 { 165 if (i>0) output.print('\t'); 166 output.print(sourceAssays.get(i).getDataCubeColumnNo()); 167 } 168 output.println(); 169 174 Short colno=sourceAssays.get(i).getDataCubeColumnNo(); 175 String ref=(referenceSelection.contains(colno) ? "yes" : "no"); 176 assayWriter.println(colno + "\t" + ref); 177 } 178 assayWriter.close(); 179 180 PrintWriter reporterWriter = new PrintWriter(getExecDirectory() + 181 java.io.File.separator + 182 reporterdata); 170 183 // write positions needed for storing result in BASE. 171 184 int position=0; … … 175 188 SqlResult item = spotData.next(); 176 189 position=item.getInt(column_position); 177 if (position!=prev_position) output.println(position);178 } 179 output.close();190 if (position!=prev_position) reporterWriter.println(position); 191 } 192 reporterWriter.close(); 180 193 } 181 194 catch (SQLException e) … … 198 211 subprocess_stdin="in.data"; 199 212 subprocess_stdout="out.data"; 200 metadata="meta.data"; 213 reporterdata="reporter.data"; 214 assaydata="assay.data"; 201 215 exportData(); 202 216 String[] cmd = { "qQN" }; … … 211 225 try 212 226 { 213 BufferedReader metainput =227 BufferedReader assayinput = 214 228 new BufferedReader(new FileReader(getExecDirectory() + 215 java.io.File.separator + metadata)); 229 java.io.File.separator + assaydata)); 230 // first column on each row in assay meta data is assay column 231 // numbers in BASE data cube 232 String inputline=null; 233 ArrayList<Short> column=new ArrayList<Short>(); 234 while ((inputline = assayinput.readLine()) != null) 235 { 236 String[] lineSplit = inputline.split("\\s"); 237 column.add(Short.parseShort(lineSplit[0])); 238 } 239 assayinput.close(); 240 241 BufferedReader reporterinput = 242 new BufferedReader(new FileReader(getExecDirectory() + 243 java.io.File.separator + 244 reporterdata)); 216 245 BufferedReader input = 217 246 new BufferedReader(new FileReader(getExecDirectory() + … … 219 248 subprocess_stdout)); 220 249 221 // first line in meta data is assay column numbers in BASE data cube222 String inputline=metainput.readLine();223 String[] lineSplit = inputline.split("\\s");224 Short[] column=new Short[lineSplit.length];225 for (int i=0; i<lineSplit.length; ++i)226 column[i]=Short.parseShort(lineSplit[i]);227 250 while ((inputline = input.readLine()) != null) 228 251 { 229 lineSplit = inputline.split("\\s");230 if (lineSplit.length != column. length)252 String[] lineSplit = inputline.split("\\s"); 253 if (lineSplit.length != column.size()) 231 254 throw new BaseException("File/bioassay set size mismatch"); 232 if ((inputline = metainput.readLine()) == null)255 if ((inputline = reporterinput.readLine()) == null) 233 256 throw new BaseException("Data and result file size mismatch"); 234 257 int position = Integer.parseInt(inputline); 235 for (int i=0; i<column. length; ++i)258 for (int i=0; i<column.size(); ++i) 236 259 { 237 260 // C/C++ style string nan's (Java expects NaN) will cause a … … 240 263 // resulting matrix. Postponing exception catching until 241 264 // they start occuring. 242 batcher.insert(column[i], position, Float.parseFloat(lineSplit[i])); 265 batcher.insert(column.get(i), position, 266 Float.parseFloat(lineSplit[i])); 243 267 } 244 268 } 245 269 input.close(); 270 reporterinput.close(); 246 271 } 247 272 catch (Exception e)
Note: See TracChangeset
for help on using the changeset viewer.