Changeset 6205
- Timestamp:
- Apr 12, 2021, 11:09:03 AM (2 years ago)
- Location:
- extensions/net.sf.basedb.reggie/trunk
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/net.sf.basedb.reggie/trunk/resources/batch/import-external-specimen.js
r6199 r6205 101 101 if (jsonFile && jsonFile.errors) 102 102 { 103 html += '<div class="messagecontainer error">'+Strings.encodeTags(jsonFile.errors.join('\n'))+'</div>'; 103 html += '<div class="messagecontainer error"><ol>'; 104 for (var errNo = 0; errNo < jsonFile.errors.length; errNo++) 105 { 106 html += '<li>'+Strings.encodeTags(jsonFile.errors[errNo]); 107 } 108 html += '</ol><div>'; 104 109 } 105 110 else if (jsonFile && jsonFile.warnings) -
extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/plugins/FutureSpecimenImporter.java
r6203 r6205 3 3 import java.text.DateFormat; 4 4 import java.text.SimpleDateFormat; 5 import java.util.Date;6 import java.util.HashMap;7 import java.util.List;8 import java.util.Map;9 5 import org.json.simple.JSONObject; 10 6 … … 15 11 import net.sf.basedb.core.DerivedBioAssay; 16 12 import net.sf.basedb.core.Extract; 17 import net.sf.basedb.core.ItemQuery;18 13 import net.sf.basedb.core.PhysicalBioAssay; 19 14 import net.sf.basedb.core.Sample; 20 15 import net.sf.basedb.core.data.PlateCoordinate; 21 import net.sf.basedb.core.query.Annotations;22 import net.sf.basedb.core.query.Expressions;23 import net.sf.basedb.core.query.Hql;24 import net.sf.basedb.core.query.Restrictions;25 import net.sf.basedb.reggie.Reggie;26 16 import net.sf.basedb.reggie.dao.Annotationtype; 27 17 import net.sf.basedb.reggie.dao.BioplateType; … … 46 36 import net.sf.basedb.reggie.plugins.cmd.PoolInfo; 47 37 import net.sf.basedb.reggie.plugins.cmd.SequencingRunInfo; 48 import net.sf.basedb.util.Coordinate;49 38 import net.sf.basedb.util.MD5; 50 39 … … 68 57 private JsonFile currentFile; 69 58 70 private Map<String, Extract> poolCache;71 private Map<String, PhysicalBioAssay> flowCellCache;72 private Map<String, DerivedBioAssay> seqRunCache;73 private Map<String, DerivedBioAssay> demuxCache;74 private Map<String, BioPlate> libPlateCache;75 59 76 60 public FutureSpecimenImporter() 77 { 78 this.poolCache = new HashMap<>(); 79 this.flowCellCache = new HashMap<>(); 80 this.seqRunCache = new HashMap<>(); 81 this.demuxCache = new HashMap<>(); 82 this.libPlateCache = new HashMap<>(); 83 } 61 {} 84 62 85 63 … … 208 186 lib.setItemSubtype(Subtype.LIBRARY.get(dc)); 209 187 lib.setName(rna.getNextLibOrMRnaName(dc, Subtype.LIBRARY)); 210 Annotationtype.PIPELINE.setAnnotationValue(dc, lib, Pipeline.RNA_SEQ.getName());188 Pipeline.RNA_SEQ.setAnnotation(dc, lib); 211 189 BioMaterialEvent creationEvent = lib.getCreationEvent(); 212 190 creationEvent.setSource(rna.getItem()); 213 191 214 192 // Library annotations 215 Date libDate = info.libDate; 216 creationEvent.setEventDate(libDate); 217 creationEvent.setProtocol(null); // TODO 193 if (info.barcode != null) addDebugMessage("Found: " + info.barcode.getName()); 194 lib.setTag(info.barcode); 195 creationEvent.setEventDate(info.libDate); 196 if (info.protocol != null) addDebugMessage("Found: " + info.protocol.getName()); 197 creationEvent.setProtocol(info.protocol); 218 198 creationEvent.setHardware(null); 219 199 … … 221 201 Annotationtype.LIBRARY_SIZE_EST.setAnnotationValue(dc, lib, info.libSize); 222 202 Annotationtype.LIBRARY_MOLARITY_EST.setAnnotationValue(dc, lib, info.libMolarity); 223 224 203 Annotationtype.EXTERNAL_OPERATOR.setAnnotationValue(dc, lib, info.operator); 225 226 204 dc.saveItem(lib); 227 205 … … 233 211 if (pos != null) 234 212 { 235 String coordinate = Coordinate.numericToAlpha(pos.getRow()+1)+(pos.getColumn()+1);236 213 BioWell well = libPlate.getBioWell(pos); 237 if (well == null) 238 { 239 addErrorMessage("Well not found: "+libPlate.getName()+"["+ coordinate+"; ref="+info.plateId+"]"); 240 } 241 else if (!well.isEmpty()) 242 { 243 addErrorMessage("Well is not empty: "+libPlate.getName()+"["+ coordinate+"; ref="+info.plateId+"]"); 244 } 245 else 246 { 247 lib.setBioWell(well); 248 addDebugMessage("Using well: "+libPlate.getName()+"["+ coordinate+"; ref="+info.plateId+"]"); 249 } 214 lib.setBioWell(well); 215 addDebugMessage("Using well: "+libPlate.getName()+"["+ well.getCoordinate()+"; ref="+info.plateId+"]"); 250 216 } 251 217 } … … 260 226 if (plateId == null) return null; 261 227 262 BioPlate plate = libPlateCache.get(plateId); 263 if (plate == null) 264 { 265 ItemQuery<BioPlate> query = BioPlate.getQuery(); 266 query.setIncludes(Reggie.INCLUDE_IN_CURRENT_PROJECT); 267 BioplateType.EXTERNAL_LIBRARY.addFilter(dc, query, false); 268 query.join(Annotations.innerJoin(null, Annotationtype.EXTERNAL_REF.load(dc), "eref")); 269 query.restrict(Restrictions.eq(Hql.alias("eref"), Expressions.string(plateId))); 270 List<BioPlate> list = query.list(dc); 271 if (list.size() > 1) 272 { 273 addErrorMessage("Found "+list.size()+" library plates with ExternalRef="+plateId); 274 return null; 275 } 276 277 if (list.size() == 1) 278 { 279 plate = list.get(0); 280 addDebugMessage("Found: "+plate.getName()+"[ref="+plateId+"]"); 281 } 282 else 283 { 284 BioplateType plateType = BioplateType.EXTERNAL_LIBRARY; 285 plate = BioPlate.getNew(dc, plateType.getPlateGeometry(dc), plateType.get(dc)); 286 plate.setName(plateType.getNextPlateName(dc, true)); 287 Annotationtype.EXTERNAL_REF.setAnnotationValue(dc, plate, plateId); 288 plate.setEventDate(info.libDate); 289 290 Annotationtype.EXTERNAL_OPERATOR.setAnnotationValue(dc, plate, info.operator); 291 Annotationtype.PLATE_PROCESS_RESULT.setAnnotationValue(dc, plate, ReactionPlate.PROCESS_SUCCESSFUL); 292 // TODO -- more libplate annotations? 293 294 dc.saveItem(plate); 295 addDebugMessage("Created: "+plate.getName()+"[ref="+plateId+"]"); 296 } 297 libPlateCache.put(plateId, plate); 298 } 299 else 300 { 228 BioPlate plate = info.libPlate; 229 if (plate != null) 230 { 231 301 232 addDebugMessage("Found: "+plate.getName()+"[ref="+plateId+"]"); 302 233 } 234 else 235 { 236 BioplateType plateType = BioplateType.EXTERNAL_LIBRARY; 237 plate = BioPlate.getNew(dc, plateType.getPlateGeometry(dc), plateType.get(dc)); 238 plate.setName(plateType.getNextPlateName(dc, true)); 239 Annotationtype.EXTERNAL_REF.setAnnotationValue(dc, plate, plateId); 240 plate.setEventDate(info.libDate); 241 242 Annotationtype.EXTERNAL_OPERATOR.setAnnotationValue(dc, plate, info.operator); 243 Annotationtype.PLATE_PROCESS_RESULT.setAnnotationValue(dc, plate, ReactionPlate.PROCESS_SUCCESSFUL); 244 // TODO -- more libplate annotations? 245 246 dc.saveItem(plate); 247 addDebugMessage("Created: "+plate.getName()+"[ref="+plateId+"]"); 248 } 303 249 return plate; 304 } 305 250 } 306 251 307 252 private PooledLibrary getOrCreatePool(DbControl dc, Library lib, PoolInfo info) … … 310 255 if (poolId == null) return null; 311 256 312 Extract pool = poolCache.get(poolId); 313 if (pool == null) 314 { 315 ItemQuery<Extract> query = Extract.getQuery(); 316 query.setIncludes(Reggie.INCLUDE_IN_CURRENT_PROJECT); 317 Subtype.POOLED_LIBRARY.addFilter(dc, query); 318 query.join(Annotations.innerJoin(null, Annotationtype.EXTERNAL_REF.load(dc), "eref")); 319 query.restrict(Restrictions.eq(Hql.alias("eref"), Expressions.string(poolId))); 320 List<Extract> list = query.list(dc); 321 if (list.size() > 1) 322 { 323 addErrorMessage("Found "+list.size()+" pools with ExternalRef="+poolId); 324 return null; 325 } 326 327 if (list.size() == 1) 328 { 329 pool = list.get(0); 330 addDebugMessage("Found: "+pool.getName()+"[ref="+poolId+"]"); 331 } 332 else 333 { 334 335 pool = Extract.getNew(dc); 336 pool.setItemSubtype(Subtype.POOLED_LIBRARY.get(dc)); 337 pool.setName(PooledLibrary.getNextNames(dc, 1).get(0)); 338 Pipeline.RNA_SEQ.setAnnotation(dc, pool); 339 Annotationtype.EXTERNAL_REF.setAnnotationValue(dc, pool, poolId); 340 Annotationtype.POOL_DATE.setAnnotationValue(dc, pool, info.poolDate); 341 Annotationtype.POOL_OPERATOR.setAnnotationValue(dc, pool, info.operator); 342 343 BioMaterialEvent poolEvent = pool.getCreationEvent(); 344 poolEvent.setEventDate(info.poolDate); 345 poolEvent.setProtocol(null); // To avoid that a 'project default' is used 346 poolEvent.setHardware(null); 347 348 dc.saveItem(pool); 349 addDebugMessage("Created: "+pool.getName()+"[ref="+poolId+"]"); 350 } 351 poolCache.put(poolId, pool); 352 } 353 else 257 Extract pool = info.pool; 258 if (pool != null) 354 259 { 355 260 addDebugMessage("Found: "+pool.getName()+"[ref="+poolId+"]"); 356 261 } 357 262 else 263 { 264 pool = Extract.getNew(dc); 265 pool.setItemSubtype(Subtype.POOLED_LIBRARY.get(dc)); 266 pool.setName(PooledLibrary.getNextNames(dc, 1).get(0)); 267 Pipeline.RNA_SEQ.setAnnotation(dc, pool); 268 Annotationtype.EXTERNAL_REF.setAnnotationValue(dc, pool, poolId); 269 Annotationtype.POOL_DATE.setAnnotationValue(dc, pool, info.poolDate); 270 Annotationtype.POOL_OPERATOR.setAnnotationValue(dc, pool, info.operator); 271 272 BioMaterialEvent poolEvent = pool.getCreationEvent(); 273 poolEvent.setEventDate(info.poolDate); 274 poolEvent.setProtocol(null); // To avoid that a 'project default' is used 275 poolEvent.setHardware(null); 276 277 dc.saveItem(pool); 278 addDebugMessage("Created: "+pool.getName()+"[ref="+poolId+"]"); 279 } 280 358 281 pool.getCreationEvent().addSource(lib.getItem()); 359 282 return PooledLibrary.get(pool); … … 366 289 if (flowCellId == null) return null; 367 290 368 PhysicalBioAssay flowCell = flowCellCache.get(flowCellId); 369 if (flowCell == null) 370 { 371 ItemQuery<PhysicalBioAssay> query = PhysicalBioAssay.getQuery(); 372 query.setIncludes(Reggie.INCLUDE_IN_CURRENT_PROJECT); 373 Subtype.FLOW_CELL.addFilter(dc, query); 374 query.join(Annotations.innerJoin(null, Annotationtype.FLOWCELL_ID.load(dc), "ref")); 375 query.restrict(Restrictions.eq(Hql.alias("ref"), Expressions.string(flowCellId))); 376 List<PhysicalBioAssay> list = query.list(dc); 377 if (list.size() > 1) 291 PhysicalBioAssay flowCell = flowCellInfo.flowCell; 292 if (flowCell != null) 293 { 294 addDebugMessage("Found: "+flowCell.getName()+"[ref="+flowCellId+"]"); 295 } 296 else 297 { 298 flowCell = PhysicalBioAssay.getNew(dc); 299 flowCell.setItemSubtype(Subtype.FLOW_CELL.get(dc)); 300 flowCell.setName(FlowCell.getNextNames(dc, 1).get(0)); 301 Pipeline.RNA_SEQ.setAnnotation(dc, flowCell); 302 flowCell.setSize(flowCellInfo.size); 303 Annotationtype.FLOWCELL_ID.setAnnotationValue(dc, flowCell, flowCellId); 304 Annotationtype.SEQUENCING_CYCLES.setAnnotationValue(dc, flowCell, flowCellInfo.sequencingCycles); 305 Annotationtype.FLOWCELL_TYPE.setAnnotationValue(dc, flowCell, seqRunInfo.sequencer.flowCellType); 306 Annotationtype.CLUSTER_OPERATOR.setAnnotationValue(dc, flowCell, flowCellInfo.operator); 307 Annotationtype.PLATE_PROCESS_RESULT.setAnnotationValue(dc, flowCell, ReactionPlate.PROCESS_SUCCESSFUL); 308 dc.saveItem(flowCell); 309 310 BioMaterialEvent createEvent = flowCell.getCreationEvent(); 311 createEvent.setProtocol(null); // To avoid that a 'project default' is used 312 createEvent.setHardware(seqRunInfo.sequencer.sequencer); 313 314 // Link with pool 315 for (int laneNo = 1; laneNo <= flowCell.getSize(); laneNo++) 378 316 { 379 addErrorMessage("Found "+list.size()+" flow cells with FlowCellID="+flowCellId); 380 return null; 317 Extract poolA = Extract.getNew(dc); 318 poolA.setItemSubtype(Subtype.POOLED_LIBRARY_ALIQUOT.get(dc)); 319 poolA.setName(pool.getNextAliquotName(dc)); 320 poolA.getCreationEvent().setSource(pool.getItem()); 321 createEvent.addSource(poolA).setPosition(laneNo); 322 dc.saveItem(poolA); 323 addDebugMessage("Created: "+ poolA.getName()); 381 324 } 382 else if (list.size() == 1) 383 { 384 flowCell = list.get(0); 385 addDebugMessage("Found: "+flowCell.getName()+"[ref="+flowCellId+"]"); 386 // TODO -- it should be linked to pool already -- verify?? 387 } 388 else 389 { 390 flowCell = PhysicalBioAssay.getNew(dc); 391 flowCell.setItemSubtype(Subtype.FLOW_CELL.get(dc)); 392 flowCell.setName(FlowCell.getNextNames(dc, 1).get(0)); 393 Pipeline.RNA_SEQ.setAnnotation(dc, flowCell); 394 flowCell.setSize(flowCellInfo.size); 395 Annotationtype.FLOWCELL_ID.setAnnotationValue(dc, flowCell, flowCellId); 396 Annotationtype.SEQUENCING_CYCLES.setAnnotationValue(dc, flowCell, flowCellInfo.sequencingCycles); 397 Annotationtype.FLOWCELL_TYPE.setAnnotationValue(dc, flowCell, seqRunInfo.sequencer.flowCellType); 398 Annotationtype.CLUSTER_OPERATOR.setAnnotationValue(dc, flowCell, flowCellInfo.operator); 399 Annotationtype.PLATE_PROCESS_RESULT.setAnnotationValue(dc, flowCell, ReactionPlate.PROCESS_SUCCESSFUL); 400 dc.saveItem(flowCell); 401 402 BioMaterialEvent createEvent = flowCell.getCreationEvent(); 403 createEvent.setProtocol(null); // To avoid that a 'project default' is used 404 createEvent.setHardware(seqRunInfo.sequencer.sequencer); 405 406 // Link with pool 407 for (int laneNo = 1; laneNo <= flowCell.getSize(); laneNo++) 408 { 409 Extract poolA = Extract.getNew(dc); 410 poolA.setItemSubtype(Subtype.POOLED_LIBRARY_ALIQUOT.get(dc)); 411 poolA.setName(pool.getNextAliquotName(dc)); 412 poolA.getCreationEvent().setSource(pool.getItem()); 413 createEvent.addSource(poolA).setPosition(laneNo); 414 dc.saveItem(poolA); 415 addDebugMessage("Created: "+ poolA.getName()); 416 } 417 418 addDebugMessage("Created: "+flowCell.getName()+"[ref="+flowCellId+"]"); 419 } 420 flowCellCache.put(flowCellId, flowCell); 421 } 422 else 423 { 424 addDebugMessage("Found: "+flowCell.getName()+"[ref="+flowCellId+"]"); 325 326 addDebugMessage("Created: "+flowCell.getName()+"[ref="+flowCellId+"]"); 425 327 } 426 328 … … 433 335 if (flowCellId == null) return null; 434 336 435 DerivedBioAssay seqRun = seqRunCache.get(flowCellId); 436 if (seqRun == null) 437 { 438 if (flowCell.getItem().isInDatabase()) 439 { 440 ItemQuery<DerivedBioAssay> query = flowCell.getItem().getRootDerivedBioAssays(); 441 query.setIncludes(Reggie.INCLUDE_IN_CURRENT_PROJECT); 442 Subtype.SEQUENCING_RUN.addFilter(dc, query); 443 List<DerivedBioAssay> list = query.list(dc); 444 if (list.size() > 1) 445 { 446 addErrorMessage("Found "+list.size()+" sequencing runs for FlowCellID="+flowCellId); 447 return null; 448 } 449 else if (list.size() == 1) 450 { 451 seqRun = list.get(0); 452 addDebugMessage("Found: "+seqRun.getName()+"[ref="+flowCellId+"]"); 453 } 454 } 455 if (seqRun == null) 456 { 457 seqRun = DerivedBioAssay.getNew(dc, flowCell.getItem(), null); 458 seqRun.setItemSubtype(Subtype.SEQUENCING_RUN.get(dc)); 459 seqRun.setName(SequencingRun.getNextName(dc)); 460 Pipeline.RNA_SEQ.setAnnotation(dc, seqRun); 461 seqRun.setHardware(seqRunInfo.sequencer.sequencer); 462 seqRun.setSoftware(null); 463 seqRun.setProtocol(null); 464 Annotationtype.HISEQ_POSITION.setAnnotationValue(dc, seqRun, seqRunInfo.position); 465 Annotationtype.SEQUENCING_RUN_NUMBER.setAnnotationValue(dc, seqRun, seqRunInfo.runNumber); 466 Annotationtype.SEQUENCING_START.setAnnotationValue(dc, seqRun, seqRunInfo.startDate); 467 Annotationtype.SEQUENCING_END.setAnnotationValue(dc, seqRun, seqRunInfo.endDate); 468 Annotationtype.SEQUENCING_OPERATOR.setAnnotationValue(dc, seqRun, seqRunInfo.operator); 469 Annotationtype.SEQUENCING_CYCLES.setAnnotationValue(dc, seqRun, flowCellInfo.sequencingCycles); 470 Annotationtype.SEQUENCING_CONFIRMED.setAnnotationValue(dc, seqRun, true); 471 Annotationtype.SEQUENCING_RESULT.setAnnotationValue(dc, seqRun, SequencingRun.SEQUENCING_SUCCESSFUL); 472 473 DateFormat df = new SimpleDateFormat("yyyy/yyMMdd"); 474 String dataFilesFolder = df.format(seqRunInfo.startDate)+ 475 "_"+seqRunInfo.sequencer.serialNo+ 476 "_"+MD5.leftPad(Integer.toString(seqRunInfo.runNumber), '0', 4)+ 477 "_"+seqRunInfo.position+flowCellInfo.flowCellId; 478 addDebugMessage(dataFilesFolder); 479 Annotationtype.DATA_FILES_FOLDER.setAnnotationValue(dc, seqRun, dataFilesFolder); 480 dc.saveItem(seqRun); 481 482 addDebugMessage("Created: "+ seqRun.getName()); 483 } 484 seqRunCache.put(flowCellId, seqRun); 485 337 DerivedBioAssay seqRun = seqRunInfo.sequencingRun; 338 if (seqRun != null) 339 { 340 addDebugMessage("Found: "+seqRun.getName()+"[ref="+flowCellId+"]"); 341 } 342 else 343 { 344 seqRun = DerivedBioAssay.getNew(dc, flowCell.getItem(), null); 345 seqRun.setItemSubtype(Subtype.SEQUENCING_RUN.get(dc)); 346 seqRun.setName(SequencingRun.getNextName(dc)); 347 Pipeline.RNA_SEQ.setAnnotation(dc, seqRun); 348 seqRun.setHardware(seqRunInfo.sequencer.sequencer); 349 seqRun.setSoftware(null); 350 seqRun.setProtocol(null); 351 Annotationtype.HISEQ_POSITION.setAnnotationValue(dc, seqRun, seqRunInfo.position); 352 Annotationtype.SEQUENCING_RUN_NUMBER.setAnnotationValue(dc, seqRun, seqRunInfo.runNumber); 353 Annotationtype.SEQUENCING_START.setAnnotationValue(dc, seqRun, seqRunInfo.startDate); 354 Annotationtype.SEQUENCING_END.setAnnotationValue(dc, seqRun, seqRunInfo.endDate); 355 Annotationtype.SEQUENCING_OPERATOR.setAnnotationValue(dc, seqRun, seqRunInfo.operator); 356 Annotationtype.SEQUENCING_CYCLES.setAnnotationValue(dc, seqRun, flowCellInfo.sequencingCycles); 357 Annotationtype.SEQUENCING_CONFIRMED.setAnnotationValue(dc, seqRun, true); 358 Annotationtype.SEQUENCING_RESULT.setAnnotationValue(dc, seqRun, SequencingRun.SEQUENCING_SUCCESSFUL); 359 360 DateFormat df = new SimpleDateFormat("yyyy/yyMMdd"); 361 String dataFilesFolder = df.format(seqRunInfo.startDate)+ 362 "_"+seqRunInfo.sequencer.serialNo+ 363 "_"+MD5.leftPad(Integer.toString(seqRunInfo.runNumber), '0', 4)+ 364 "_"+seqRunInfo.position+flowCellInfo.flowCellId; 365 addDebugMessage(dataFilesFolder); 366 Annotationtype.DATA_FILES_FOLDER.setAnnotationValue(dc, seqRun, dataFilesFolder); 367 dc.saveItem(seqRun); 368 369 addDebugMessage("Created: "+ seqRun.getName()); 486 370 } 487 371 return SequencingRun.get(seqRun); … … 494 378 if (flowCellId == null) return null; 495 379 496 DerivedBioAssay demux = demuxCache.get(flowCellId); 497 if (demux == null) 498 { 499 if (seqRun.getItem().isInDatabase()) 500 { 501 ItemQuery<DerivedBioAssay> query = seqRun.getItem().getChildren(); 502 query.setIncludes(Reggie.INCLUDE_IN_CURRENT_PROJECT); 503 Subtype.DEMUXED_SEQUENCES.addFilter(dc, query); 504 List<DerivedBioAssay> list = query.list(dc); 505 if (list.size() > 1) 506 { 507 addErrorMessage("Found "+list.size()+" demux items for FlowCellID="+flowCellId); 508 return null; 509 } 510 else if (list.size() == 1) 511 { 512 demux = list.get(0); 513 addDebugMessage("Found: "+demux.getName()+"[ref="+flowCellId+"]"); 514 } 515 } 516 if (demux == null) 517 { 518 demux = DerivedBioAssay.getNew(dc, seqRun.getItem(), null); 519 demux.setItemSubtype(Subtype.DEMUXED_SEQUENCES.get(dc)); 520 demux.setName(seqRun.getNextDemuxedSequencesName(dc)); 521 Pipeline.RNA_SEQ.setAnnotation(dc, demux); 522 demux.setHardware(null); 523 demux.setSoftware(demuxInfo.software); 524 demux.setProtocol(null); 525 Annotationtype.READ_STRING.setAnnotationValue(dc, demux, demuxInfo.readString); 526 dc.saveItem(demux); 527 528 addDebugMessage("Created: "+ demux.getName()); 529 } 530 demuxCache.put(flowCellId, demux); 380 DerivedBioAssay demux = demuxInfo.demux; 381 if (demux != null) 382 { 383 addDebugMessage("Found: "+demux.getName()+"[ref="+flowCellId+"]"); 384 } 385 else 386 { 387 demux = DerivedBioAssay.getNew(dc, seqRun.getItem(), null); 388 demux.setItemSubtype(Subtype.DEMUXED_SEQUENCES.get(dc)); 389 demux.setName(seqRun.getNextDemuxedSequencesName(dc)); 390 Pipeline.RNA_SEQ.setAnnotation(dc, demux); 391 demux.setHardware(null); 392 demux.setSoftware(demuxInfo.software); 393 demux.setProtocol(null); 394 Annotationtype.READ_STRING.setAnnotationValue(dc, demux, demuxInfo.readString); 395 dc.saveItem(demux); 396 397 addDebugMessage("Created: "+ demux.getName()); 531 398 } 532 399 return DemuxedSequences.get(demux); -
extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/plugins/cmd/DateValidator.java
r6201 r6205 51 51 catch (Exception ex) 52 52 { 53 section.addErrorMessage("Invalid date in JSON: "+entryKey+"="+value +" (expected format: "+format+")");53 section.addErrorMessage("Invalid date in JSON: "+entryKey+"="+value+" (expected format: "+format+")"); 54 54 } 55 55 return null; -
extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/plugins/cmd/DemuxInfo.java
r6204 r6205 4 4 5 5 import net.sf.basedb.core.DbControl; 6 import net.sf.basedb.core.DerivedBioAssay; 6 7 import net.sf.basedb.core.ItemQuery; 7 8 import net.sf.basedb.core.Software; … … 26 27 { 27 28 29 public DerivedBioAssay demux; 28 30 public Software software; 29 31 public String readString; … … 31 33 public boolean valid; 32 34 33 public DemuxInfo(JsonSection demux)35 public DemuxInfo(JsonSection section, SequencingRunInfo seqRunInfo, FlowCellInfo flowCellInfo) 34 36 { 35 if ( demux!= null)37 if (section != null) 36 38 { 37 software = demux.getRequiredEntry("Software", SoftwareValidator.INSTANCE); 38 readString = demux.getRequiredEntry("ReadString", PatternValidator.READ_STRING); 39 software = section.getRequiredEntry("Software", SoftwareValidator.INSTANCE); 40 readString = section.getRequiredEntry("ReadString", PatternValidator.READ_STRING); 41 if (seqRunInfo.sequencingRun != null) 42 { 43 demux = findExistingDemux(seqRunInfo.sequencingRun, flowCellInfo.flowCellId, section); 44 } 39 45 } 40 valid = demux != null && !demux.hasError(); 46 valid = section != null && !section.hasError(); 47 } 48 49 50 private DerivedBioAssay findExistingDemux(DerivedBioAssay seqRun, String flowCellId, JsonSection section) 51 { 52 DerivedBioAssay demux = null; 53 DbControl dc = section.getFile().dc(); 54 ItemQuery<DerivedBioAssay> query = seqRun.getChildren(); 55 query.setIncludes(Reggie.INCLUDE_IN_CURRENT_PROJECT); 56 Subtype.DEMUXED_SEQUENCES.addFilter(dc, query); 57 List<DerivedBioAssay> list = query.list(dc); 58 if (list.size() > 1) 59 { 60 section.addErrorMessage("Found "+list.size()+" demux items for FlowCellID="+flowCellId); 61 } 62 else if (list.size() == 1) 63 { 64 demux = list.get(0); 65 } 66 return demux; 41 67 } 42 68 -
extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/plugins/cmd/FloatValidator.java
r6201 r6205 12 12 { 13 13 14 /** 15 Allow all values. 16 */ 14 17 public static final FloatValidator INSTANCE = new FloatValidator(); 18 19 /** 20 All positive values >= 0. 21 */ 22 public static final FloatValidator POSITIVE = new FloatValidator(0f, null); 23 24 private Float maxValue; 25 private Float minValue; 15 26 16 27 public FloatValidator() 17 28 {} 18 29 30 /** 31 Allow all values between min and max (inclusive). 32 Null values are allowed and mean no limit. 33 */ 34 public FloatValidator(Float min, Float max) 35 { 36 this.minValue = min; 37 this.maxValue = max; 38 } 39 19 40 @Override 20 41 public Float isValid(DbControl dc, Object value, JsonSection section, String entryKey) 21 42 { 43 Float result = null; 22 44 if (value instanceof Number) 23 45 { 24 re turn((Number)value).floatValue();46 result = ((Number)value).floatValue(); 25 47 } 26 48 else … … 28 50 try 29 51 { 30 re turnFloat.parseFloat(value.toString());52 result = Float.parseFloat(value.toString()); 31 53 } 32 54 catch (Exception ex) … … 35 57 } 36 58 } 37 return null; 59 if (result != null) 60 { 61 if (minValue != null && result < minValue) 62 { 63 section.addErrorMessage("Invalid value in JSON: "+entryKey+"="+value+" (expected >="+minValue+")"); 64 result = null; 65 } 66 if (maxValue != null && result > maxValue) 67 { 68 section.addErrorMessage("Invalid value in JSON: "+entryKey+"="+value+" (expected <="+maxValue+")"); 69 result = null; 70 } 71 } 72 return result; 38 73 } 39 74 -
extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/plugins/cmd/FlowCellInfo.java
r6202 r6205 1 1 package net.sf.basedb.reggie.plugins.cmd; 2 2 3 import java.util.List; 4 5 import net.sf.basedb.core.DbControl; 6 import net.sf.basedb.core.ItemQuery; 7 import net.sf.basedb.core.PhysicalBioAssay; 8 import net.sf.basedb.core.query.Annotations; 9 import net.sf.basedb.core.query.Expressions; 10 import net.sf.basedb.core.query.Hql; 11 import net.sf.basedb.core.query.Restrictions; 12 import net.sf.basedb.reggie.Reggie; 13 import net.sf.basedb.reggie.dao.Annotationtype; 14 import net.sf.basedb.reggie.dao.FlowCell; 15 import net.sf.basedb.reggie.dao.PooledLibrary; 16 import net.sf.basedb.reggie.dao.Subtype; 3 17 4 18 /** … … 20 34 21 35 public String flowCellId; 36 public PhysicalBioAssay flowCell; 22 37 public Integer size; 23 38 public String sequencingCycles; … … 26 41 public boolean valid; 27 42 28 public FlowCellInfo(JsonSection flowCell)43 public FlowCellInfo(JsonSection section, PoolInfo poolInfo) 29 44 { 30 if ( flowCell!= null)45 if (section != null) 31 46 { 32 flowCellId = flowCell.getRequiredEntry("FlowCellID", PatternValidator.FLOWCELL_ID); 33 size = flowCell.getRequiredEntry("Size", IntValidator.FLOWCELL_SIZE_2_OR_4); 34 sequencingCycles = flowCell.getRequiredEntry("SequencingCycles", PatternValidator.CMD_ID); 35 operator = flowCell.getRequiredEntry("Operator"); 47 flowCellId = section.getRequiredEntry("FlowCellID", PatternValidator.FLOWCELL_ID); 48 if (flowCellId != null) flowCell = findExistingFlowCell(flowCellId, section); 49 if (flowCell != null && poolInfo.poolId != null) 50 { 51 verifyPoolIsSequencedOnFlowCell(flowCell, poolInfo, section); 52 } 53 size = section.getRequiredEntry("Size", IntValidator.FLOWCELL_SIZE_2_OR_4); 54 sequencingCycles = section.getRequiredEntry("SequencingCycles", PatternValidator.CMD_ID); 55 operator = section.getRequiredEntry("Operator"); 36 56 } 37 valid = flowCell != null && !flowCell.hasError(); 57 valid = section != null && !section.hasError(); 58 } 59 60 private PhysicalBioAssay findExistingFlowCell(String flowCellId, JsonSection section) 61 { 62 PhysicalBioAssay flowCell = null; 63 DbControl dc = section.getFile().dc(); 64 ItemQuery<PhysicalBioAssay> query = PhysicalBioAssay.getQuery(); 65 query.setIncludes(Reggie.INCLUDE_IN_CURRENT_PROJECT); 66 Subtype.FLOW_CELL.addFilter(dc, query); 67 query.join(Annotations.innerJoin(null, Annotationtype.FLOWCELL_ID.load(dc), "ref")); 68 query.restrict(Restrictions.eq(Hql.alias("ref"), Expressions.string(flowCellId))); 69 List<PhysicalBioAssay> list = query.list(dc); 70 if (list.size() > 1) 71 { 72 section.addErrorMessage("Found "+list.size()+" flow cells with FlowCellID="+flowCellId); 73 } 74 else if (list.size() == 1) 75 { 76 flowCell = list.get(0); 77 } 78 return flowCell; 79 } 80 81 /** 82 Verify that an existing flow cell is linked to an existing pool. Note 83 that is it not possible to add a new pool to an existing flow cell. 84 */ 85 private void verifyPoolIsSequencedOnFlowCell(PhysicalBioAssay flowCell, PoolInfo poolInfo, JsonSection section) 86 { 87 if (poolInfo.pool != null) 88 { 89 DbControl dc = section.getFile().dc(); 90 // Verify that the flow cell is linked to the pool 91 List<PooledLibrary> pools = PooledLibrary.getByFlowCell(dc, FlowCell.get(flowCell)); 92 boolean isLinked = false; 93 for (PooledLibrary p : pools) 94 { 95 if (p.getId() == poolInfo.pool.getId()) isLinked = true; 96 } 97 if (!isLinked) 98 { 99 section.addErrorMessage(poolInfo.pool.getName()+" is not sequenced on "+flowCell.getName()); 100 } 101 } 102 else 103 { 104 // This is a new pool that can't be added to the existing flow cell 105 section.addErrorMessage("Pool[ExternalRef="+poolInfo.poolId+"] is not sequenced on "+flowCell.getName()); 106 } 38 107 } 39 108 -
extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/plugins/cmd/JsonFile.java
r6203 r6205 225 225 if (fastqInfo.valid) fastqInfo.loadFileInfo(session, rootDir); 226 226 227 libInfo = new LibraryInfo(getRequiredSection("Library")); 228 poolInfo = new PoolInfo(getRequiredSection("Pool"), libInfo); 229 flowCellInfo = new FlowCellInfo(getRequiredSection("FlowCell"), poolInfo); 230 seqRunInfo = new SequencingRunInfo(getRequiredSection("SequencingRun"), flowCellInfo); 231 demuxInfo = new DemuxInfo(getRequiredSection("DemuxedSequences"), seqRunInfo, flowCellInfo); 227 232 mergeInfo = new MergeInfo(getRequiredSection("MergedSequences")); 228 demuxInfo = new DemuxInfo(getRequiredSection("DemuxedSequences"));229 seqRunInfo = new SequencingRunInfo(getRequiredSection("SequencingRun"));230 flowCellInfo = new FlowCellInfo(getRequiredSection("FlowCell"));231 poolInfo = new PoolInfo(getRequiredSection("Pool"));232 libInfo = new LibraryInfo(getRequiredSection("Library"));233 233 } 234 234 catch (Exception ex) -
extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/plugins/cmd/LibraryInfo.java
r6201 r6205 2 2 3 3 import java.util.Date; 4 import java.util.List; 5 import java.util.regex.Matcher; 6 import java.util.regex.Pattern; 4 7 8 import net.sf.basedb.core.BioPlate; 9 import net.sf.basedb.core.BioWell; 10 import net.sf.basedb.core.DbControl; 11 import net.sf.basedb.core.ItemQuery; 12 import net.sf.basedb.core.Protocol; 13 import net.sf.basedb.core.Tag; 5 14 import net.sf.basedb.core.data.PlateCoordinate; 15 import net.sf.basedb.core.query.Annotations; 16 import net.sf.basedb.core.query.Expressions; 17 import net.sf.basedb.core.query.Hql; 18 import net.sf.basedb.core.query.Restrictions; 19 import net.sf.basedb.reggie.Reggie; 20 import net.sf.basedb.reggie.dao.Annotationtype; 21 import net.sf.basedb.reggie.dao.BioplateType; 22 import net.sf.basedb.reggie.dao.Pipeline; 23 import net.sf.basedb.reggie.dao.Subtype; 24 import net.sf.basedb.util.Coordinate; 6 25 7 26 /** … … 25 44 public String operator; 26 45 46 public Tag barcode; 47 public Protocol protocol; 48 public BioPlate libPlate; 49 27 50 public boolean valid; 28 51 29 public LibraryInfo(JsonSection lib)52 public LibraryInfo(JsonSection section) 30 53 { 31 if ( lib!= null)54 if (section != null) 32 55 { 33 plateId = lib.getRequiredEntry("Plate name", PatternValidator.CMD_ID);34 well = lib.getRequiredEntry("Plate well", PlateWellValidator.PLATE_8x12);56 plateId = section.getRequiredEntry("Plate name", PatternValidator.CMD_ID); 57 well = section.getRequiredEntry("Plate well", PlateWellValidator.PLATE_8x12); 35 58 36 libDate = lib.getRequiredEntry("Date", DateValidator.YYYY_MM_DD); 37 libSize = lib.getRequiredEntry("Library size", IntValidator.ALL); 38 libMolarity = lib.getRequiredEntry("Library molarity", FloatValidator.INSTANCE); 39 qubitConc = lib.getRequiredEntry("Qubit concentration (ng/ul)", FloatValidator.INSTANCE); 40 operator = lib.getRequiredEntry("Operator"); 59 if (plateId != null) libPlate = findExistingLibPlate(plateId, section); 60 if (libPlate != null && well != null) 61 { 62 verifyEmptyPosition(libPlate, well, section); 63 } 64 65 libDate = section.getRequiredEntry("Date", DateValidator.YYYY_MM_DD); 66 libSize = section.getRequiredEntry("Library size", IntValidator.POSITIVE); 67 libMolarity = section.getRequiredEntry("Library molarity", FloatValidator.POSITIVE); 68 qubitConc = section.getRequiredEntry("Qubit concentration (ng/ul)", FloatValidator.POSITIVE); 69 operator = section.getRequiredEntry("Operator"); 70 71 barcode = section.getRequiredEntry("Barcode", BarcodeValidator.INSTANCE); 72 // TODO -- protocol 41 73 } 42 valid = lib != null && !lib.hasError();74 valid = section != null && !section.hasError(); 43 75 } 44 76 77 private BioPlate findExistingLibPlate(String plateId, JsonSection section) 78 { 79 BioPlate libPlate = null; 80 DbControl dc = section.getFile().dc(); 81 ItemQuery<BioPlate> query = BioPlate.getQuery(); 82 query.setIncludes(Reggie.INCLUDE_IN_CURRENT_PROJECT); 83 BioplateType.EXTERNAL_LIBRARY.addFilter(dc, query, false); 84 query.join(Annotations.innerJoin(null, Annotationtype.EXTERNAL_REF.load(dc), "eref")); 85 query.restrict(Restrictions.eq(Hql.alias("eref"), Expressions.string(plateId))); 86 List<BioPlate> list = query.list(dc); 87 if (list.size() > 1) 88 { 89 section.addErrorMessage("Found "+list.size()+" library plates with ExternalRef="+plateId); 90 } 91 else if (list.size() == 1) 92 { 93 libPlate = list.get(0); 94 } 95 return libPlate; 96 } 97 98 /** 99 Verify that the given position on the libplate is empty. 100 */ 101 private void verifyEmptyPosition(BioPlate libPlate, PlateCoordinate pos, JsonSection section) 102 { 103 String coordinate = Coordinate.numericToAlpha(pos.getRow()+1)+(pos.getColumn()+1); 104 BioWell well = libPlate.getBioWell(pos); 105 if (well == null) 106 { 107 section.addErrorMessage("Well not found: "+libPlate.getName()+"["+ coordinate+"; ref="+plateId+"]"); 108 } 109 else if (!well.isEmpty()) 110 { 111 section.addErrorMessage("Well is not empty: "+libPlate.getName()+"["+ coordinate+"; ref="+plateId+"]"); 112 } 113 } 114 115 116 /** 117 Find a barcode by looking at the UDI part of the value from the JSON file. 118 The entry in the JSON is typically: 04A UDI0025 (ACTAAGAT-AACCGCGG) 119 If a barcode is found we also check the Barcode sequences and issue 120 a warning if they don't match. 121 */ 122 static class BarcodeValidator 123 implements ValueValidator<String, Tag> 124 { 125 126 static final BarcodeValidator INSTANCE = new BarcodeValidator(); 127 128 @Override 129 public Class<String> getExpectedClass() 130 { 131 return String.class; 132 } 133 134 @Override 135 public Tag isValid(DbControl dc, String value, JsonSection section, String entryKey) 136 { 137 Pattern p = Pattern.compile(".*(UDI\\d+).*"); 138 Matcher m = p.matcher(value); 139 if (!m.matches()) 140 { 141 section.addErrorMessage("Invalid barcode in JSON: "+entryKey+"="+value+" (expected to find 'UDI[0-9]+')"); 142 return null; 143 } 144 String name = m.group(1); 145 146 ItemQuery<Tag> query = Tag.getQuery(); 147 query.setIncludes(Reggie.INCLUDE_IN_CURRENT_PROJECT); 148 Subtype.BARCODE.addFilter(dc, query); 149 Pipeline.RNA_SEQ.addFilter(dc, query); 150 query.restrict(Restrictions.eq(Hql.property("name"), Expressions.string(name))); 151 List<Tag> list = query.list(dc); 152 if (list.size() != 1) 153 { 154 if (list.size() > 1) 155 { 156 section.addErrorMessage("Found "+list.size()+" barcodes: name="+name); 157 } 158 else 159 { 160 section.addErrorMessage("Barcode not found: name="+name); 161 } 162 return null; 163 } 164 Tag barcode = list.get(0); 165 String seq1 = (String)Annotationtype.BARCODE_SEQUENCE.getAnnotationValue(dc, barcode); 166 String seq2 = (String)Annotationtype.BARCODE_SEQUENCE_2.getAnnotationValue(dc, barcode); 167 168 if (seq1 != null && seq2 != null) 169 { 170 p = Pattern.compile("([ACGT]+\\-[ACGT]+)"); 171 m = p.matcher(value); 172 if (m.find()) 173 { 174 String seq = m.group(); 175 if (!seq.equals(seq1+"-"+seq2)) 176 { 177 section.addWarningMessage("Barcode sequence mismatch: "+entryKey+"="+value+" (expected "+seq1+"-"+seq2+")"); 178 } 179 } 180 } 181 return barcode; 182 } 183 } 184 45 185 } -
extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/plugins/cmd/PoolInfo.java
r6200 r6205 2 2 3 3 import java.util.Date; 4 import java.util.List; 5 6 import net.sf.basedb.core.DbControl; 7 import net.sf.basedb.core.Extract; 8 import net.sf.basedb.core.ItemQuery; 9 import net.sf.basedb.core.Tag; 10 import net.sf.basedb.core.query.Annotations; 11 import net.sf.basedb.core.query.Expressions; 12 import net.sf.basedb.core.query.Hql; 13 import net.sf.basedb.core.query.Restrictions; 14 import net.sf.basedb.reggie.Reggie; 15 import net.sf.basedb.reggie.dao.Annotationtype; 16 import net.sf.basedb.reggie.dao.Subtype; 17 import net.sf.basedb.util.Values; 18 import net.sf.basedb.util.formatter.NameableFormatter; 4 19 5 20 /** … … 15 30 16 31 public String poolId; 32 public Extract pool; 17 33 public Date poolDate; 18 34 public String operator; … … 20 36 public boolean valid; 21 37 22 public PoolInfo(JsonSection pool)38 public PoolInfo(JsonSection section, LibraryInfo libInfo) 23 39 { 24 if ( pool!= null)40 if (section != null) 25 41 { 26 poolId = pool.getRequiredEntry("Pool ID", PatternValidator.CMD_ID); 27 poolDate = pool.getRequiredEntry("Date", DateValidator.YYYY_MM_DD); 28 operator = pool.getRequiredEntry("Operator"); 42 poolId = section.getRequiredEntry("Pool ID", PatternValidator.CMD_ID); 43 if (poolId != null) pool = findExistingPool(poolId, section); 44 if (pool != null && libInfo.barcode != null) 45 { 46 verifyUnusedBarcode(pool, libInfo.barcode, section); 47 } 48 poolDate = section.getRequiredEntry("Date", DateValidator.YYYY_MM_DD); 49 operator = section.getRequiredEntry("Operator"); 29 50 } 30 valid = pool != null && !pool.hasError();51 valid = section != null && !section.hasError(); 31 52 } 32 53 54 /** 55 Find an existing pool with the given id. 56 */ 57 private Extract findExistingPool(String poolId, JsonSection section) 58 { 59 Extract pool = null; 60 DbControl dc = section.getFile().dc(); 61 ItemQuery<Extract> query = Extract.getQuery(); 62 query.setIncludes(Reggie.INCLUDE_IN_CURRENT_PROJECT); 63 Subtype.POOLED_LIBRARY.addFilter(dc, query); 64 query.join(Annotations.innerJoin(null, Annotationtype.EXTERNAL_REF.load(dc), "eref")); 65 query.restrict(Restrictions.eq(Hql.alias("eref"), Expressions.string(poolId))); 66 List<Extract> list = query.list(dc); 67 if (list.size() > 1) 68 { 69 section.addErrorMessage("Found "+list.size()+" pools with ExternalRef="+poolId); 70 } 71 else if (list.size() == 1) 72 { 73 pool = list.get(0); 74 } 75 return pool; 76 } 77 78 /** 79 Check if there are any other libs in the pool with the same barcode 80 */ 81 private void verifyUnusedBarcode(Extract pool, Tag barcode, JsonSection section) 82 { 83 DbControl dc = section.getFile().dc(); 84 ItemQuery<Extract> query = Extract.getQuery(); 85 query.join(Hql.innerJoin("childCreationEvents", "cce")); 86 query.join(Hql.innerJoin("cce", "event", "pool")); 87 query.restrict(Restrictions.eq(Hql.alias("pool"), Hql.entity(pool.getCreationEvent()))); 88 query.restrict(Restrictions.eq(Hql.property("tag"), Hql.entity(barcode))); 89 List<Extract> libsInPool = query.list(dc); 90 if (libsInPool.size() > 0) 91 { 92 section.addErrorMessage("Found other libraries in "+pool.getName() + 93 " with barcode "+barcode.getName()+": " + Values.getString(libsInPool, ", ", true, new NameableFormatter())); 94 } 95 96 } 33 97 } -
extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/plugins/cmd/SequencingRunInfo.java
r6202 r6205 5 5 6 6 import net.sf.basedb.core.DbControl; 7 import net.sf.basedb.core.DerivedBioAssay; 7 8 import net.sf.basedb.core.Hardware; 8 9 import net.sf.basedb.core.ItemQuery; … … 31 32 { 32 33 34 public DerivedBioAssay sequencingRun; 33 35 public SequencerInfo sequencer; 34 36 public String position; … … 40 42 public boolean valid; 41 43 42 public SequencingRunInfo(JsonSection se qRun)44 public SequencingRunInfo(JsonSection section, FlowCellInfo flowCellInfo) 43 45 { 44 if (se qRun != null)46 if (section != null) 45 47 { 46 sequencer = seqRun.getRequiredEntry("SerialNumber", new SequencerInfo()); 47 position = seqRun.getRequiredEntry("Position", PatternValidator.SEQUENCER_POSITION); 48 runNumber = seqRun.getRequiredEntry("RunNumber", IntValidator.POSITIVE); 49 startDate = seqRun.getRequiredEntry("StartDate", DateValidator.YYMMDD); 50 endDate = seqRun.getRequiredEntry("EndDate", DateValidator.YYMMDD_HH_MM_SS); 51 operator = seqRun.getRequiredEntry("Operator"); 48 sequencer = section.getRequiredEntry("SerialNumber", new SequencerInfo()); 49 position = section.getRequiredEntry("Position", PatternValidator.SEQUENCER_POSITION); 50 runNumber = section.getRequiredEntry("RunNumber", IntValidator.POSITIVE); 51 startDate = section.getRequiredEntry("StartDate", DateValidator.YYMMDD); 52 endDate = section.getRequiredEntry("EndDate", DateValidator.YYMMDD_HH_MM_SS); 53 operator = section.getRequiredEntry("Operator"); 54 if (flowCellInfo.flowCell != null) 55 { 56 sequencingRun = findExistingSeqRun(flowCellInfo, section); 57 } 52 58 } 53 valid = seqRun != null && !seqRun.hasError(); 59 valid = section != null && !section.hasError(); 60 } 61 62 private DerivedBioAssay findExistingSeqRun(FlowCellInfo flowCellInfo, JsonSection section) 63 { 64 DerivedBioAssay seqRun = null; 65 DbControl dc = section.getFile().dc(); 66 ItemQuery<DerivedBioAssay> query = flowCellInfo.flowCell.getRootDerivedBioAssays(); 67 query.setIncludes(Reggie.INCLUDE_IN_CURRENT_PROJECT); 68 Subtype.SEQUENCING_RUN.addFilter(dc, query); 69 List<DerivedBioAssay> list = query.list(dc); 70 if (list.size() > 1) 71 { 72 section.addErrorMessage("Found "+list.size()+" sequencing runs for FlowCellID="+flowCellInfo.flowCellId); 73 } 74 else if (list.size() == 1) 75 { 76 seqRun = list.get(0); 77 } 78 return seqRun; 54 79 } 55 80
Note: See TracChangeset
for help on using the changeset viewer.