Changeset 6197


Ignore:
Timestamp:
Apr 6, 2021, 8:47:34 AM (14 months ago)
Author:
Nicklas Nordborg
Message:

References #1295: Registration of specimen handled by external lab

Added ExternalRef annotation intended to be used for storing a reference id generated by the external lab on items that we need to use multiple times for different samples. For example: pool, library plate, flow cell, etc.

Location:
extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/dao/Annotationtype.java

    r6098 r6197  
    19271927    new Annotationtype("VariantsPassedFilter", Type.INT, false, Item.RAWBIOASSAY);
    19281928
     1929  /**
     1930    The "ExternalRef" annotation is used to store an ID reference on
     1931    items that have been handled externally.
     1932    @since 4.32
     1933  */
     1934  public static final Annotationtype EXTERNAL_REF =
     1935    new Annotationtype("ExternalRef", Type.STRING, false, Item.SAMPLE, Item.EXTRACT, Item.PHYSICALBIOASSAY, Item.DERIVEDBIOASSAY, Item.BIOPLATE);
    19291936 
    19301937  /**
  • extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/plugins/FutureSpecimenImporter.java

    r6195 r6197  
    33
    44import java.util.HashMap;
     5import java.util.List;
    56import java.util.Map;
    67import java.util.regex.Matcher;
     
    1617import net.sf.basedb.core.DerivedBioAssay;
    1718import net.sf.basedb.core.Extract;
     19import net.sf.basedb.core.ItemQuery;
    1820import net.sf.basedb.core.PhysicalBioAssay;
    1921import net.sf.basedb.core.Sample;
     22import net.sf.basedb.core.query.Annotations;
     23import net.sf.basedb.core.query.Expressions;
     24import net.sf.basedb.core.query.Hql;
     25import net.sf.basedb.core.query.Restrictions;
     26import net.sf.basedb.reggie.Reggie;
    2027import net.sf.basedb.reggie.dao.Annotationtype;
    2128import net.sf.basedb.reggie.dao.BioplateType;
     
    196203        else
    197204        {
     205          jsonMessages.add("Well is not empty: " + pos);
    198206          // ERROR
    199207        }
     
    201209      else
    202210      {
     211        jsonMessages.add("Invalid well: " + pos);
    203212        // ERROR
    204213      }
     
    212221  {
    213222    String plateId = (String)jsonLib.get("plate");
    214     BioPlate plate = findLibPlateById(dc, plateId);
     223    BioPlate plate = findLibPlateByRef(dc, plateId);
    215224    if (plate == null)
    216225    {
     
    218227      plate = BioPlate.getNew(dc, plateType.getPlateGeometry(dc), plateType.get(dc));
    219228      plate.setName(plateType.getNextPlateName(dc, true));
    220       // plate.setTheId(plateId);
     229      Annotationtype.EXTERNAL_REF.setAnnotationValue(dc, plate, plateId);
    221230      dc.saveItem(plate);
    222231      libPlateCache.put(plateId, plate);
    223       jsonMessages.add("Created: "+ plate.getName());
     232      jsonMessages.add("Created: "+ plate.getName() + "[ref="+plateId+"]");
    224233    }
    225234    else
     
    231240  }
    232241 
    233   private BioPlate findLibPlateById(DbControl dc, String plateId)
     242  private BioPlate findLibPlateByRef(DbControl dc, String plateId)
    234243  {
    235244    BioPlate plate = libPlateCache.get(plateId);
    236245    if (plate == null)
    237246    {
    238       // TODO -- query database
     247      ItemQuery<BioPlate> query = BioPlate.getQuery();
     248      query.setIncludes(Reggie.INCLUDE_IN_CURRENT_PROJECT);
     249      BioplateType.EXTERNAL_LIBRARY.addFilter(dc, query, false);
     250      query.join(Annotations.innerJoin(null, Annotationtype.EXTERNAL_REF.load(dc), "eref"));
     251      query.restrict(Restrictions.eq(Hql.alias("eref"), Expressions.string(plateId)));
     252      List<BioPlate> list = query.list(dc);
     253      if (list.size() > 1)
     254      {
     255        // ERROR
     256      }
     257      else if (list.size() == 1)
     258      {
     259        plate = list.get(0);
     260      }
    239261    }
    240262    return plate;
     
    245267  {
    246268    String poolId = (String)jsonPool.get("poolId");
    247     Extract pool = findPoolById(dc, poolId);
     269    Extract pool = findPoolByRef(dc, poolId);
    248270    if (pool == null)
    249271    {
     
    252274      pool.setName(PooledLibrary.getNextNames(dc, 1).get(0));
    253275      Annotationtype.PIPELINE.setAnnotationValue(dc, pool, Pipeline.RNA_SEQ.getName());
    254       // pool.setTheId(poolId);
     276      Annotationtype.EXTERNAL_REF.setAnnotationValue(dc, pool, poolId);
    255277      dc.saveItem(pool);
    256278      poolCache.put(poolId, pool);
    257279     
    258       jsonMessages.add("Created: "+ pool.getName());
     280      jsonMessages.add("Created: "+ pool.getName() + "[ref="+poolId+"]");
    259281    }
    260282    else
     
    268290  }
    269291 
    270   private Extract findPoolById(DbControl dc, String poolId)
     292  private Extract findPoolByRef(DbControl dc, String poolId)
    271293  {
    272294    Extract pool = poolCache.get(poolId);
    273295    if (pool == null)
    274296    {
    275       // TODO -- query database
     297      ItemQuery<Extract> query = Extract.getQuery();
     298      query.setIncludes(Reggie.INCLUDE_IN_CURRENT_PROJECT);
     299      Subtype.POOLED_LIBRARY.addFilter(dc, query);
     300      query.join(Annotations.innerJoin(null, Annotationtype.EXTERNAL_REF.load(dc), "eref"));
     301      query.restrict(Restrictions.eq(Hql.alias("eref"), Expressions.string(poolId)));
     302      List<Extract> list = query.list(dc);
     303      if (list.size() > 1)
     304      {
     305        // ERROR
     306      }
     307      else if (list.size() == 1)
     308      {
     309        pool = list.get(0);
     310      }
    276311    }
    277312    return pool;
     
    281316  {
    282317    String flowCellId = (String)jsonSeq.get("flowCellId");
    283     PhysicalBioAssay flowCell = findFlowCellById(dc, flowCellId);
     318    PhysicalBioAssay flowCell = findFlowCellByRef(dc, flowCellId);
    284319    if (flowCell == null)
    285320    {
     
    288323      flowCell.setName(FlowCell.getNextNames(dc, 1).get(0));
    289324      Annotationtype.PIPELINE.setAnnotationValue(dc, flowCell, Pipeline.RNA_SEQ.getName());
    290       // flowCell.setTheId(poolId);
     325      Annotationtype.EXTERNAL_REF.setAnnotationValue(dc, flowCell, flowCellId);
    291326      flowCell.setSize(2); // Can also be 4
    292327      dc.saveItem(flowCell);
     
    308343      jsonMessages.add("Created: "+ flowCell.getName());
    309344     
    310      
    311       //seqRun = SequencingRun.get(sr);
    312345    }
    313346    else
     
    317350    }
    318351   
    319     DerivedBioAssay seqRun = findSeqRunById(dc, flowCellId);
     352    DerivedBioAssay seqRun = findSeqRunByRef(dc, flowCellId);
    320353    if (seqRun == null)
    321354    {
     
    324357      seqRun.setName(SequencingRun.getNextName(dc));
    325358      Annotationtype.PIPELINE.setAnnotationValue(dc, seqRun, Pipeline.RNA_SEQ.getName());
     359      Annotationtype.EXTERNAL_REF.setAnnotationValue(dc, seqRun, flowCellId);
    326360      dc.saveItem(seqRun);
    327361     
     
    338372  }
    339373 
    340   private PhysicalBioAssay findFlowCellById(DbControl dc, String flowCellId)
     374  private PhysicalBioAssay findFlowCellByRef(DbControl dc, String flowCellId)
    341375  {
    342376    PhysicalBioAssay flowCell = flowCellCache.get(flowCellId);
    343377    if (flowCell == null)
    344378    {
    345       // TODO -- query database
     379      ItemQuery<PhysicalBioAssay> query = PhysicalBioAssay.getQuery();
     380      query.setIncludes(Reggie.INCLUDE_IN_CURRENT_PROJECT);
     381      Subtype.FLOW_CELL.addFilter(dc, query);
     382      query.join(Annotations.innerJoin(null, Annotationtype.EXTERNAL_REF.load(dc), "eref"));
     383      query.restrict(Restrictions.eq(Hql.alias("eref"), Expressions.string(flowCellId)));
     384      List<PhysicalBioAssay> list = query.list(dc);
     385      if (list.size() > 1)
     386      {
     387        // ERROR
     388      }
     389      else if (list.size() == 1)
     390      {
     391        flowCell = list.get(0);
     392      }
    346393    }
    347394    return flowCell;
    348395  }
    349396
    350   private DerivedBioAssay findSeqRunById(DbControl dc, String flowCellId)
     397  private DerivedBioAssay findSeqRunByRef(DbControl dc, String flowCellId)
    351398  {
    352399    DerivedBioAssay seqRun = seqRunCache.get(flowCellId);
    353400    if (seqRun == null)
    354401    {
    355       // TODO -- query database
     402      ItemQuery<DerivedBioAssay> query = DerivedBioAssay.getQuery();
     403      query.setIncludes(Reggie.INCLUDE_IN_CURRENT_PROJECT);
     404      Subtype.SEQUENCING_RUN.addFilter(dc, query);
     405      query.join(Annotations.innerJoin(null, Annotationtype.EXTERNAL_REF.load(dc), "eref"));
     406      query.restrict(Restrictions.eq(Hql.alias("eref"), Expressions.string(flowCellId)));
     407      List<DerivedBioAssay> list = query.list(dc);
     408      if (list.size() > 1)
     409      {
     410        // ERROR
     411      }
     412      else if (list.size() == 1)
     413      {
     414        seqRun = list.get(0);
     415      }
    356416    }
    357417    return seqRun;
  • extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/servlet/InstallServlet.java

    r6187 r6197  
    384384       
    385385        // -- the second batch need only be shared to the active project or to the PatientCurator group
    386 
     386        jsonChecks.add(checkAnnotationType(dc, Annotationtype.EXTERNAL_REF, 1, null, createIfMissing, effectivePermissionsUse));
    387387        jsonChecks.add(checkAnnotationType(dc, Annotationtype.DATE_OF_BIRTH, 1, null, createIfMissing, effectivePermissionsUse));
    388388        jsonChecks.add(checkAnnotationType(dc, Annotationtype.GENDER, 1, new ValueOptions("F", "M"), createIfMissing, effectivePermissionsUse));
     
    985985            Annotationtype.DO_NOT_USE, Annotationtype.DO_NOT_USE_COMMENT,
    986986            Annotationtype.PIPELINE, Annotationtype.EXTERNAL_PLATE_POS,
    987             Annotationtype.EXTERNAL_OPERATOR,
     987            Annotationtype.EXTERNAL_OPERATOR, Annotationtype.EXTERNAL_REF,
    988988            Annotationtype.RNA_TARGET_VOLUME, Annotationtype.RNA_TARGET_AMOUNT,
    989989            Annotationtype.PLATE_PROCESS_RESULT));
     
    997997            Annotationtype.POOL_TARGET_MOLARITY, Annotationtype.POOL_IS_MANUAL,
    998998            Annotationtype.POOL_MIXING_STRATEGY, Annotationtype.POOL_DATE, Annotationtype.POOL_OPERATOR,
    999             Annotationtype.PIPELINE,
     999            Annotationtype.PIPELINE, Annotationtype.EXTERNAL_REF,
    10001000            Annotationtype.FLAG, Annotationtype.AUTO_PROCESSING));
    10011001
     
    10041004            Annotationtype.CLUSTER_START, Annotationtype.CLUSTER_OPERATOR,
    10051005            Annotationtype.SEQUENCING_CYCLES, Annotationtype.FAILED_LANES,
    1006             Annotationtype.PIPELINE,
     1006            Annotationtype.PIPELINE, Annotationtype.EXTERNAL_REF,
    10071007            Annotationtype.PLATE_PROCESS_RESULT, Annotationtype.SEQUENCING_RESULT));
    10081008       
     
    10121012            Annotationtype.HISEQ_POSITION, Annotationtype.DATA_FILES_FOLDER, Annotationtype.SEQUENCING_RESULT,
    10131013            Annotationtype.SEQUENCING_CONFIRMED, Annotationtype.AUTO_PROCESSING,
    1014             Annotationtype.PIPELINE
     1014            Annotationtype.PIPELINE, Annotationtype.EXTERNAL_REF
    10151015          ));
    10161016       
Note: See TracChangeset for help on using the changeset viewer.