Changeset 6217
- Timestamp:
- Apr 19, 2021, 11:35:57 AM (2 years ago)
- Location:
- extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/plugins
- Files:
-
- 2 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/plugins/FutureSpecimenImporter.java
r6215 r6217 39 39 import net.sf.basedb.reggie.plugins.cmd.FlowThroughInfo; 40 40 import net.sf.basedb.reggie.plugins.cmd.JsonFile; 41 import net.sf.basedb.reggie.plugins.cmd.JsonSection;42 41 import net.sf.basedb.reggie.plugins.cmd.LibraryInfo; 43 42 import net.sf.basedb.reggie.plugins.cmd.LysateInfo; … … 45 44 import net.sf.basedb.reggie.plugins.cmd.RnaInfo; 46 45 import net.sf.basedb.reggie.plugins.cmd.SequencingRunInfo; 46 import net.sf.basedb.reggie.plugins.cmd.SpecimenInfo; 47 47 import net.sf.basedb.util.MD5; 48 48 … … 93 93 94 94 JSONObject json = jsonFile.getJSON(); 95 JsonSection jsonSpecimen = jsonFile.getRequiredSection("Specimen");95 SpecimenInfo specimenInfo = jsonFile.getSpecimen(); 96 96 97 97 LysateInfo lysateInfo = jsonFile.getLysate(); … … 106 106 FastqInfo fastqInfo = jsonFile.getFastqInfo(); 107 107 108 if (jsonSpecimen == null) return null;109 110 108 ImportedItems items = new ImportedItems(); 111 112 SpecimenTube specimen = importToSpecimen(dc, sample, jsonSpecimen); 113 114 if (specimen == null || !lysateInfo.valid) return null; 115 items.lysate = createLysate(dc, specimen, lysateInfo); 109 110 if (!specimenInfo.valid) return null; 111 items.specimen = importToSpecimen(dc, sample, specimenInfo); 112 113 if (items.specimen == null || !lysateInfo.valid) return null; 114 items.lysate = createLysate(dc, items.specimen, lysateInfo); 116 115 117 116 if (items.lysate == null || !rnaInfo.valid || !dnaInfo.valid || !ftInfo.valid) return null; … … 147 146 } 148 147 149 private SpecimenTube importToSpecimen(DbControl dc, Sample specimen, JsonSection jsonSpecimen) 150 { 148 /** 149 Import to an existing specimen or FutureSpecimen item. 150 */ 151 private SpecimenTube importToSpecimen(DbControl dc, Sample specimen, SpecimenInfo info) 152 { 153 // TODO -- this need to be changed, since there are actually 3 cases: 154 // 1. A FutureSpecimen exists. Import to this item and change type to Specimen 155 // 2. Re-extraction from existing specimen. Do not change the specimen, start by creating new Lysate 156 // 3. A second specimen tube related to a previous FutureSpecimen. The first Specimen was imported 157 // to the FutureSpecimen, now we need to create a new Specimen item. 158 151 159 if (Subtype.FUTURE_SPECIMEN.get(dc).equals(specimen.getItemSubtype())) 152 160 { 153 161 // Change subtype to Specimen 154 162 specimen.setItemSubtype(Subtype.SPECIMEN.get(dc)); 155 156 163 addDebugMessage("FutureSpecimen changed to Specimen: "+specimen.getName()); 164 165 Annotationtype.ARRIVAL_DATE.setAnnotationValue(dc, specimen, info.arrivalDate); 166 Annotationtype.NOF_DELIVERED_TUBES.setAnnotationValue(dc, specimen, info.numberOfTubes); 167 Annotationtype.NOF_PIECES.setAnnotationValue(dc, specimen, info.numberOfPieces); 168 Annotationtype.SPECIMEN_TYPE.setAnnotationValue(dc, specimen, info.specimenType); 169 Annotationtype.BIOPSY_TYPE.setAnnotationValue(dc, specimen, info.biopsyType); 170 Annotationtype.OPERATOR_DELIVERY_COMMENT.setAnnotationValue(dc, specimen, info.deliveryComment); 171 172 specimen.setOriginalQuantity(info.originalQuantity); 173 // Other properties should be set already 174 /* 175 info.laterality; 176 info.pad; 177 info.pathologyNote; 178 info.samplingDateTime; 179 info.rnaLaterDateTime; 180 */ 157 181 } 158 182 else … … 532 556 public static class ImportedItems 533 557 { 558 public SpecimenTube specimen; 534 559 public Lysate lysate; 535 560 public FlowThrough flowThrough; -
extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/plugins/cmd/DateValidator.java
r6206 r6217 6 6 7 7 import net.sf.basedb.core.DbControl; 8 import net.sf.basedb.reggie.Reggie;9 8 10 9 … … 23 22 public static final DateValidator YYYY_MM_DD = new DateValidator("yyyy-MM-dd"); 24 23 24 /** 25 Date validator for dates in 'yyyy-MM-dd HH:mm' format. 26 */ 27 public static final DateValidator YYYY_MM_DD_HH_MM = new DateValidator("yyyy-MM-dd HH:mm"); 28 25 29 /** 26 30 Date validator for dates in 'yyMMdd' format. … … 46 50 } 47 51 52 @Override 53 protected DateValidator clone() 54 { 55 try 56 { 57 return (DateValidator)super.clone(); 58 } 59 catch (CloneNotSupportedException e) 60 { 61 // Should never happen 62 throw new UnsupportedOperationException("clone()"); 63 } 64 } 65 48 66 /** 49 67 Wrap this date validator with a validator that issue a warning … … 52 70 public DateValidator warnIfFuture() 53 71 { 54 DateValidator wrap; 55 try 56 { 57 wrap = (DateValidator)this.clone(); 58 wrap.notAfter = new Date(); 59 } 60 catch (CloneNotSupportedException e) 61 { 62 throw new UnsupportedOperationException("clone()"); 63 } 72 DateValidator wrap = clone(); 73 wrap.notAfter = new Date(); 64 74 return wrap; 65 75 } … … 109 119 { 110 120 section.addWarningMessage("Old date in JSON: "+entryKey+"="+value+ 111 " (expected after "+ Reggie.CONVERTER_DATE_TO_STRING_WITH_SEPARATOR.format(notBefore)+")");121 " (expected after "+dateFormat.format(notBefore)+")"); 112 122 } 113 123 } -
extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/plugins/cmd/IntValidator.java
r6206 r6217 61 61 } 62 62 63 @Override 64 protected IntValidator clone() 65 { 66 try 67 { 68 return (IntValidator)super.clone(); 69 } 70 catch (CloneNotSupportedException e) 71 { 72 // Should never happen 73 throw new UnsupportedOperationException("clone()"); 74 } 75 } 76 77 63 78 /** 64 79 Wrap this validator with a validator that create warnings … … 67 82 public IntValidator warnIf(Integer softMin, Integer softMax) 68 83 { 69 IntValidator wrap; 70 try 71 { 72 wrap = (IntValidator)this.clone(); 73 wrap.softMax = softMax; 74 wrap.softMin = softMin; 75 } 76 catch (CloneNotSupportedException e) 77 { 78 throw new UnsupportedOperationException("clone()"); 79 } 84 IntValidator wrap = clone(); 85 wrap.softMax = softMax; 86 wrap.softMin = softMin; 80 87 return wrap; 81 88 } -
extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/plugins/cmd/JsonFile.java
r6215 r6217 86 86 87 87 private FastqInfo fastqInfo; 88 private SpecimenInfo specimenInfo; 88 89 private LysateInfo lysateInfo; 89 90 private RnaInfo rnaInfo; … … 251 252 if (fastqInfo.valid) fastqInfo.loadFileInfo(session, directory); 252 253 253 lysateInfo = new LysateInfo(getRequiredSection("Lysate")); 254 specimenInfo = new SpecimenInfo(getRequiredSection("Specimen")); 255 lysateInfo = new LysateInfo(getRequiredSection("Lysate"), specimenInfo); 254 256 dnaInfo = new DnaInfo(getRequiredSection("DNA")); 255 257 rnaInfo = new RnaInfo(getRequiredSection("RNA")); … … 322 324 } 323 325 326 public SpecimenInfo getSpecimen() 327 { 328 return specimenInfo; 329 } 330 324 331 public LysateInfo getLysate() 325 332 { -
extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/plugins/cmd/JsonSection.java
r6212 r6217 133 133 if (val == null) 134 134 { 135 addErrorMessage("Missing entry in JSON: "+section+"."+key); 135 if (json.containsKey(key)) 136 { 137 addErrorMessage("Missing value in JSON: "+section+"."+key+" = null"); 138 } 139 else 140 { 141 addErrorMessage("Missing entry in JSON: "+section+"."+key); 142 } 136 143 } 137 144 else if (!validator.getExpectedClass().isInstance(val)) -
extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/plugins/cmd/LongValidator.java
r6206 r6217 53 53 } 54 54 55 @Override 56 protected LongValidator clone() 57 { 58 try 59 { 60 return (LongValidator)super.clone(); 61 } 62 catch (CloneNotSupportedException e) 63 { 64 // Should never happen 65 throw new UnsupportedOperationException("clone()"); 66 } 67 } 68 69 55 70 /** 56 71 Wrap this validator with a validator that create warnings … … 59 74 public LongValidator warnIf(Long softMin, Long softMax) 60 75 { 61 LongValidator wrap; 62 try 63 { 64 wrap = (LongValidator)this.clone(); 65 wrap.softMax = softMax; 66 wrap.softMin = softMin; 67 } 68 catch (CloneNotSupportedException e) 69 { 70 throw new UnsupportedOperationException("clone()"); 71 } 76 LongValidator wrap = clone(); 77 wrap.softMax = softMax; 78 wrap.softMin = softMin; 72 79 return wrap; 73 80 } 74 75 81 76 82 @Override -
extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/plugins/cmd/LysateInfo.java
r6207 r6217 3 3 import java.util.Date; 4 4 import net.sf.basedb.core.Protocol; 5 import net.sf.basedb.util.Values; 5 6 6 7 /** … … 23 24 public boolean valid; 24 25 25 public LysateInfo(JsonSection section )26 public LysateInfo(JsonSection section, SpecimenInfo specimen) 26 27 { 27 28 if (section != null) … … 31 32 originalVolume = section.getRequiredEntry("Original volume (ul)", FloatValidator.POSITIVE); 32 33 usedFromSpecimen = section.getRequiredEntry("Used quantity (mg)", FloatValidator.POSITIVE); 34 // TODO -- protocol 33 35 34 // TODO -- protocol 36 if (specimen.originalQuantity != null && specimen.remainingQuantity != null && usedFromSpecimen != null) 37 { 38 if (Math.abs(specimen.originalQuantity-usedFromSpecimen-specimen.remainingQuantity) > 0.1) 39 { 40 section.addWarningMessage("Used quantity ("+Values.formatNumber(usedFromSpecimen, 1, "mg")+ 41 ") <> Specimen.originalQuantity ("+Values.formatNumber(specimen.originalQuantity, 1, "mg")+ 42 ") - Specimen.remainingQuantity ("+Values.formatNumber(specimen.remainingQuantity, 1, "mg")+")"); 43 } 44 } 35 45 } 36 46 valid = section != null && !section.hasError(); -
extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/plugins/cmd/PatternValidator.java
r6209 r6217 49 49 public static final PatternValidator SEQUENCING_CYCLES = new PatternValidator("([0-9]+\\-){3}[0-9]+", "sequencing cycles", null, "4 groups of 0-9"); 50 50 51 /** 52 PAD is uppercase letters and numbers or '-'. Typically 5-10 53 characters but we allow between 4 and 20. 54 */ 55 public static final PatternValidator PAD = new PatternValidator("[A-Z0-9-]{4,20}", "PAD", null, "4-20 characters A-Z, 0-9 or '-'"); 56 51 57 private final Pattern pattern; 52 58 private final String subject;
Note: See TracChangeset
for help on using the changeset viewer.