Changeset 1147
- Timestamp:
- Jul 31, 2009, 2:32:32 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
plugins/base2/net.sf.basedb.illumina/trunk/src/net/sf/basedb/illumina/plugins/BgxMergeControlsInputStream.java
r1085 r1147 28 28 import java.io.InputStreamReader; 29 29 import java.nio.charset.Charset; 30 import java.util.ArrayList; 30 31 import java.util.HashSet; 31 32 import java.util.Iterator; 32 33 import java.util.LinkedHashMap; 34 import java.util.List; 33 35 import java.util.Map; 34 36 import java.util.Set; … … 229 231 if (Thread.interrupted()) throw new SignalException("Aborted by user"); 230 232 String[] cols = line.split("\\t"); 231 if (cols.length >= 6)233 if (cols.length >= 3) 232 234 { 233 235 // Ignore lines that have too few column 234 236 String probeId = cols[0]; // Column 1 = Probe_ID 235 237 String arrayAdressId = cols[1]; // Column 2 = Array_Address_Id 236 String reporterGroupName = cols[2]; // Column 3 = Reporter_Group_Name 237 String reporterGroupId = cols[3]; // Column 4 = Reporter_Group_Id 238 String reporterCompositeMap = cols[4]; // Column 5 = Reporter_Composite_Map 239 String sequence = cols[5]; // Column 6 = Probe_Sequence 238 int numExtraColumns = cols.length - 2; 239 List<String> moreColumns = new ArrayList<String>(numExtraColumns); 240 for (int i = 2; i < cols.length; ++i) 241 { 242 moreColumns.add(cols[i]); 243 } 240 244 241 245 Control control = controls.get(probeId); 242 246 if (control == null) 243 247 { 244 control = new Control(probeId, arrayAdressId, sequence);248 control = new Control(probeId, arrayAdressId, numExtraColumns); 245 249 controls.put(probeId, control); 246 250 } 247 control.merge( reporterGroupName, reporterGroupId, reporterCompositeMap);251 control.merge(moreColumns); 248 252 } 249 253 line = in.readLine(); … … 255 259 /** 256 260 Represents a single control identified by Probe_Id. Merge 257 annotations by calling {@link #merge( String, String, String)}.261 annotations by calling {@link #merge(List)}. 258 262 */ 259 263 private static class Control 260 264 { 261 265 private final String probeId; 262 private final String sequence;263 266 private final String arrayAddressId; 264 private Set<String> reporterGroupNames; 265 private Set<String> reporterGroupIds; 266 private Set<String> reporterCompositeMaps; 267 268 private Control(String probeId, String arrayAddressId, String sequence) 267 private final List<Set<String>> mergedColumns; 268 269 private Control(String probeId, String arrayAddressId, int numColumns) 269 270 { 270 271 this.probeId = probeId; 271 272 this.arrayAddressId = arrayAddressId; 272 this.sequence = sequence; 273 reporterGroupIds = new HashSet<String>(); 274 reporterGroupNames = new HashSet<String>(); 275 reporterCompositeMaps = new HashSet<String>(); 273 this.mergedColumns = new ArrayList<Set<String>>(numColumns); 276 274 } 277 275 278 private void merge(String reporterGroupName, String reporterGroupId, String reporterCompositeMap) 279 { 280 reporterGroupIds.add(reporterGroupId); 281 reporterGroupNames.add(reporterGroupName); 282 reporterCompositeMaps.add(reporterCompositeMap); 276 private void merge(List<String> values) 277 { 278 while (mergedColumns.size() < values.size()) 279 { 280 mergedColumns.add(new HashSet<String>()); 281 } 282 for (int i = 0; i < values.size(); ++i) 283 { 284 mergedColumns.get(i).add(values.get(i)); 285 } 283 286 } 284 287 … … 291 294 { 292 295 StringBuffer sb = new StringBuffer(); 293 sb.append(probeId).append("\t").append("").append("\t"); 294 boolean first = true; 295 for (String s : reporterGroupNames) 296 { 297 if (!first) sb.append(";"); 298 sb.append(s); 299 first = false; 300 } 301 sb.append("\t"); 302 first = true; 303 for (String s : reporterGroupIds) 304 { 305 if (!first) sb.append(";"); 306 sb.append(s); 307 first = false; 308 } 309 sb.append("\t"); 310 first = true; 311 for (String s : reporterCompositeMaps) 312 { 313 if (!first) sb.append(";"); 314 sb.append(s); 315 first = false; 316 } 317 sb.append("\t").append(sequence); 296 sb.append(probeId).append("\t").append(""); 297 for (int i = 0; i < mergedColumns.size(); ++i) 298 { 299 sb.append("\t"); 300 boolean firstValue = true; 301 for (String s : mergedColumns.get(i)) 302 { 303 if (!firstValue) sb.append(";"); 304 sb.append(s); 305 firstValue = false; 306 } 307 } 318 308 return sb.toString(); 319 309 }
Note: See TracChangeset
for help on using the changeset viewer.