Changeset 6217


Ignore:
Timestamp:
Apr 19, 2021, 11:35:57 AM (13 months ago)
Author:
Nicklas Nordborg
Message:

References #1295: Registration of specimen handled by external lab

Started to implement the specimen-specific details.

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  
    3939import net.sf.basedb.reggie.plugins.cmd.FlowThroughInfo;
    4040import net.sf.basedb.reggie.plugins.cmd.JsonFile;
    41 import net.sf.basedb.reggie.plugins.cmd.JsonSection;
    4241import net.sf.basedb.reggie.plugins.cmd.LibraryInfo;
    4342import net.sf.basedb.reggie.plugins.cmd.LysateInfo;
     
    4544import net.sf.basedb.reggie.plugins.cmd.RnaInfo;
    4645import net.sf.basedb.reggie.plugins.cmd.SequencingRunInfo;
     46import net.sf.basedb.reggie.plugins.cmd.SpecimenInfo;
    4747import net.sf.basedb.util.MD5;
    4848
     
    9393   
    9494    JSONObject json = jsonFile.getJSON();
    95     JsonSection jsonSpecimen = jsonFile.getRequiredSection("Specimen");
     95    SpecimenInfo specimenInfo = jsonFile.getSpecimen();
    9696   
    9797    LysateInfo lysateInfo = jsonFile.getLysate();
     
    106106    FastqInfo fastqInfo = jsonFile.getFastqInfo();
    107107
    108     if (jsonSpecimen == null) return null;
    109 
    110108    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);
    116115   
    117116    if (items.lysate == null || !rnaInfo.valid || !dnaInfo.valid || !ftInfo.valid) return null;
     
    147146  }
    148147 
    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
    151159    if (Subtype.FUTURE_SPECIMEN.get(dc).equals(specimen.getItemSubtype()))
    152160    {
    153161      // Change subtype to Specimen
    154162      specimen.setItemSubtype(Subtype.SPECIMEN.get(dc));
    155    
    156163      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      */
    157181    }
    158182    else
     
    532556  public static class ImportedItems
    533557  {
     558    public SpecimenTube specimen;
    534559    public Lysate lysate;
    535560    public FlowThrough flowThrough;
  • extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/plugins/cmd/DateValidator.java

    r6206 r6217  
    66
    77import net.sf.basedb.core.DbControl;
    8 import net.sf.basedb.reggie.Reggie;
    98
    109
     
    2322  public static final DateValidator YYYY_MM_DD = new DateValidator("yyyy-MM-dd");
    2423
     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 
    2529  /**
    2630    Date validator for dates in 'yyMMdd' format.
     
    4650  }
    4751 
     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
    4866  /**
    4967    Wrap this date validator with a validator that issue a warning
     
    5270  public DateValidator warnIfFuture()
    5371  {
    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();
    6474    return wrap;
    6575  }
     
    109119      {
    110120        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)+")");
    112122      }
    113123    }
  • extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/plugins/cmd/IntValidator.java

    r6206 r6217  
    6161  }
    6262 
     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 
    6378  /**
    6479    Wrap this validator with a validator that create warnings
     
    6782  public IntValidator warnIf(Integer softMin, Integer softMax)
    6883  {
    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;
    8087    return wrap;
    8188  }
  • extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/plugins/cmd/JsonFile.java

    r6215 r6217  
    8686
    8787  private FastqInfo fastqInfo;
     88  private SpecimenInfo specimenInfo;
    8889  private LysateInfo lysateInfo;
    8990  private RnaInfo rnaInfo;
     
    251252      if (fastqInfo.valid) fastqInfo.loadFileInfo(session, directory);
    252253
    253       lysateInfo = new LysateInfo(getRequiredSection("Lysate"));
     254      specimenInfo = new SpecimenInfo(getRequiredSection("Specimen"));
     255      lysateInfo = new LysateInfo(getRequiredSection("Lysate"), specimenInfo);
    254256      dnaInfo = new DnaInfo(getRequiredSection("DNA"));
    255257      rnaInfo = new RnaInfo(getRequiredSection("RNA"));
     
    322324  }
    323325 
     326  public SpecimenInfo getSpecimen()
     327  {
     328    return specimenInfo;
     329  }
     330 
    324331  public LysateInfo getLysate()
    325332  {
  • extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/plugins/cmd/JsonSection.java

    r6212 r6217  
    133133    if (val == null)
    134134    {
    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      }
    136143    }
    137144    else if (!validator.getExpectedClass().isInstance(val))
  • extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/plugins/cmd/LongValidator.java

    r6206 r6217  
    5353  }
    5454 
     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 
    5570  /**
    5671    Wrap this validator with a validator that create warnings
     
    5974  public LongValidator warnIf(Long softMin, Long softMax)
    6075  {
    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;
    7279    return wrap;
    7380  }
    74 
    7581 
    7682  @Override
  • extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/plugins/cmd/LysateInfo.java

    r6207 r6217  
    33import java.util.Date;
    44import net.sf.basedb.core.Protocol;
     5import net.sf.basedb.util.Values;
    56
    67/**
     
    2324  public boolean valid;
    2425 
    25   public LysateInfo(JsonSection section)
     26  public LysateInfo(JsonSection section, SpecimenInfo specimen)
    2627  {
    2728    if (section != null)
     
    3132      originalVolume = section.getRequiredEntry("Original volume (ul)", FloatValidator.POSITIVE);
    3233      usedFromSpecimen = section.getRequiredEntry("Used quantity (mg)", FloatValidator.POSITIVE);
     34      // TODO -- protocol
    3335     
    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      }
    3545    }
    3646    valid = section != null && !section.hasError();
  • extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/plugins/cmd/PatternValidator.java

    r6209 r6217  
    4949  public static final PatternValidator SEQUENCING_CYCLES = new PatternValidator("([0-9]+\\-){3}[0-9]+", "sequencing cycles", null, "4 groups of 0-9");
    5050 
     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 
    5157  private final Pattern pattern;
    5258  private final String subject;
Note: See TracChangeset for help on using the changeset viewer.