Changeset 4736


Ignore:
Timestamp:
Jan 23, 2009, 4:00:00 PM (13 years ago)
Author:
Martin Svensson
Message:

Fixes #1171 Add BioLIMS support to batch importers. Also updated the user-role test to place the biomaterials on a bioplate.

Location:
trunk/src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/plugins/core/net/sf/basedb/plugins/batchimport/AbstractItemImporter.java

    r4597 r4736  
    3939import net.sf.basedb.core.BaseException;
    4040import net.sf.basedb.core.BasicItem;
     41import net.sf.basedb.core.BioPlate;
    4142import net.sf.basedb.core.BioSource;
     43import net.sf.basedb.core.BioWell;
    4244import net.sf.basedb.core.BooleanParameterType;
    4345import net.sf.basedb.core.DataFileType;
     
    14021404    return findReferencedItem(dc, idMethod, labeledExtractQuery, identifier, false);
    14031405  }
    1404 
     1406 
     1407  private ItemQuery<BioPlate> bioPlateQuery;
     1408  /**
     1409    Find a bioplate with a given identifier. This is a utility method that
     1410    subclasses can use when creating or updating items.
     1411    <p>
     1412    NOTE! The first time this method is called a query object is initialised
     1413    using the {@link IdMethod#prepareQuery(DbControl, ItemQuery)} method.
     1414    Subsequent calls uses the same query. Thus, this method should always be
     1415    called with the same id method object, otherwise the result is undefined.
     1416   
     1417    @param dc The DbControl to use for database access
     1418    @param identifier The identifier protocol
     1419    @return A bioplate, or null if no item could be found
     1420   */
     1421  protected BioPlate findBioPlate(DbControl dc, IdMethod idMethod, String identifier)
     1422  {
     1423    if (identifier == null) return null;
     1424    if (bioPlateQuery == null)
     1425    {
     1426      bioPlateQuery = initReferenceQuery(dc, idMethod, BioPlate.getQuery());
     1427    }
     1428    return findReferencedItem(dc, idMethod, bioPlateQuery, identifier, false);
     1429  }
     1430 
    14051431  private ItemQuery<ArraySlide> arraySlideQuery;
    14061432  /**
  • trunk/src/plugins/core/net/sf/basedb/plugins/batchimport/ExtractImporter.java

    r4551 r4736  
    2727
    2828import net.sf.basedb.core.BioMaterialEvent;
     29import net.sf.basedb.core.BioPlate;
     30import net.sf.basedb.core.BioWell;
    2931import net.sf.basedb.core.DbControl;
    3032import net.sf.basedb.core.Extract;
     
    112114  private Mapper parentMapper;
    113115  private Mapper usedQuantityMapper;
     116  private Mapper bioPlateMapper;
     117  private Mapper bioWellRowMapper;
     118  private Mapper bioWellColMapper;
    114119 
    115120  /**
     
    148153    parameters.add(SampleImporter.parentColumnMapping);
    149154    parameters.add(SampleImporter.usedQuantityColumnMapping);
     155    parameters.add(SampleImporter.bioPlateColumnMapping);
     156    parameters.add(SampleImporter.bioWellRowColumnMapping);
     157    parameters.add(SampleImporter.bioWellColColumnMapping);
    150158  }
    151159 
     
    174182    parentMapper = getMapper(ffp, (String)job.getValue("parentColumnMapping"), null, null);
    175183    usedQuantityMapper = getMapper(ffp, (String)job.getValue("usedQuantityColumnMapping"), null, null);
     184    bioPlateMapper = getMapper(ffp, (String)job.getValue("bioPlateColumnMapping"), null, null);
     185    bioWellRowMapper = getMapper(ffp, (String)job.getValue("bioWellRowColumnMapping"), null, null);
     186    bioWellColMapper = getMapper(ffp, (String)job.getValue("bioWellColColumnMapping"), null, null);
    176187  }
    177188 
     
    204215      Protocol protocol = findProtocol(dc, FallbackIdMethod.NAME_OR_ID, nameOrId, type);
    205216      if (nameOrId == null || protocol != null) creationEvent.setProtocol(protocol);
     217    }
     218    if (bioPlateMapper != null && bioWellRowMapper != null && bioWellColMapper != null)
     219    {
     220      String plateNameOrId = bioPlateMapper.getValue(data);
     221      BioPlate plate = findBioPlate(dc, FallbackIdMethod.NAME_OR_ID, plateNameOrId);
     222      BioWell well = null;
     223      if (plate != null)
     224      {
     225        Integer row = bioWellRowMapper.getInt(data);
     226        Integer column = bioWellColMapper.getInt(data);       
     227        if (column != null && row != null)
     228        {
     229          well = plate.getBioWell(row, column);;
     230        }
     231      }
     232      extract.setBioWell(well);
     233     
    206234    }
    207235    if (!extract.isPooled())
  • trunk/src/plugins/core/net/sf/basedb/plugins/batchimport/LabeledExtractImporter.java

    r4551 r4736  
    2727
    2828import net.sf.basedb.core.BioMaterialEvent;
     29import net.sf.basedb.core.BioPlate;
     30import net.sf.basedb.core.BioWell;
    2931import net.sf.basedb.core.DbControl;
    3032import net.sf.basedb.core.Extract;
     
    124126  private Mapper parentMapper;
    125127  private Mapper usedQuantityMapper;
     128  private Mapper bioPlateMapper;
     129  private Mapper bioWellRowMapper;
     130  private Mapper bioWellColMapper;
    126131 
    127132  /**
     
    161166    parameters.add(SampleImporter.parentColumnMapping);
    162167    parameters.add(SampleImporter.usedQuantityColumnMapping);
     168    parameters.add(SampleImporter.bioPlateColumnMapping);
     169    parameters.add(SampleImporter.bioWellRowColumnMapping);
     170    parameters.add(SampleImporter.bioWellColColumnMapping);
    163171  }
    164172 
     
    188196    parentMapper = getMapper(ffp, (String)job.getValue("parentColumnMapping"), null, null);
    189197    usedQuantityMapper = getMapper(ffp, (String)job.getValue("usedQuantityColumnMapping"), null, null);
     198    bioPlateMapper = getMapper(ffp, (String)job.getValue("bioPlateColumnMapping"), null, null);
     199    bioWellRowMapper = getMapper(ffp, (String)job.getValue("bioWellRowColumnMapping"), null, null);   
     200    bioWellColMapper = getMapper(ffp, (String)job.getValue("bioWellColColumnMapping"), null, null);
    190201  }
    191202 
     
    243254      }
    244255    }
     256    if (bioPlateMapper != null && bioWellRowMapper != null && bioWellColMapper != null)
     257    {
     258      String plateNameOrId = bioPlateMapper.getValue(data);
     259      BioPlate plate = findBioPlate(dc, FallbackIdMethod.NAME_OR_ID, plateNameOrId);
     260      BioWell well = null;
     261      if (plate != null)
     262      {
     263        Integer row = bioWellRowMapper.getInt(data);
     264        Integer column = bioWellColMapper.getInt(data);       
     265        if (column != null && row != null)
     266        {
     267          well = plate.getBioWell(row, column);;
     268        }
     269      }
     270      extract.setBioWell(well);   
     271    }
    245272    if (!extract.isPooled())
    246273    {
  • trunk/src/plugins/core/net/sf/basedb/plugins/batchimport/SampleImporter.java

    r4551 r4736  
    2727
    2828import net.sf.basedb.core.BioMaterialEvent;
     29import net.sf.basedb.core.BioPlate;
    2930import net.sf.basedb.core.BioSource;
     31import net.sf.basedb.core.BioWell;
    3032import net.sf.basedb.core.DbControl;
    3133import net.sf.basedb.core.Item;
     
    123125    );
    124126
     127  /**
     128    Column mapping parameter for the bioplate
     129   */
     130  protected static final PluginParameter<String> bioPlateColumnMapping =
     131    new PluginParameter<String>(
     132        "bioPlateColumnMapping",
     133        "Bioplate",
     134        "Mapping that picks the name or id of the bioplate in the data columns. "+
     135        "Example: \\Bioplate\\",
     136        optionalColumnMapping
     137    );
     138 
     139
     140  /**
     141    Column mapping parameter for the biowell's row
     142   */
     143  protected static final PluginParameter<String> bioWellRowColumnMapping =
     144    new PluginParameter<String>(
     145        "bioWellRowColumnMapping",
     146        "Biowell row",
     147        "Mapping that picks the row of the biowell in the data columns. "+
     148        "Example: \\Biowell row\\",
     149        optionalColumnMapping
     150    );
     151 
     152  /**
     153    Column mapping parameter for the biowell's column
     154   */
     155  protected static final PluginParameter<String> bioWellColColumnMapping =
     156    new PluginParameter<String>(
     157        "bioWellColColumnMapping",
     158        "Biowell column",
     159        "Mapping that picks the column of the biowell in the data columns. "+
     160        "Example: \\Biowell column\\",
     161        optionalColumnMapping
     162    );
    125163 
    126164  private static final About about =
     
    176214  private Mapper parentMapper;
    177215  private Mapper usedQuantityMapper;
     216  private Mapper bioPlateMapper;
     217  private Mapper bioWellRowMapper;
     218  private Mapper bioWellColMapper;
    178219 
    179220  /**
     
    212253    parameters.add(parentColumnMapping);
    213254    parameters.add(usedQuantityColumnMapping);
     255    parameters.add(bioPlateColumnMapping);
     256    parameters.add(bioWellRowColumnMapping);
     257    parameters.add(bioWellColColumnMapping);
    214258  }
    215259 
     
    238282    parentMapper = getMapper(ffp, (String)job.getValue("parentColumnMapping"), null, null);
    239283    usedQuantityMapper = getMapper(ffp, (String)job.getValue("usedQuantityColumnMapping"), null, null);
     284    bioPlateMapper = getMapper(ffp, (String)job.getValue("bioPlateColumnMapping"), null, null);
     285    bioWellRowMapper = getMapper(ffp, (String)job.getValue("bioWellRowColumnMapping"), null, null);
     286    bioWellColMapper = getMapper(ffp, (String)job.getValue("bioWellColColumnMapping"), null, null);
    240287  }
    241288 
     
    264311      Protocol protocol = findProtocol(dc, FallbackIdMethod.NAME_OR_ID, nameOrId, type);
    265312      if (nameOrId == null || protocol != null) creationEvent.setProtocol(protocol);
     313    }
     314    if (bioPlateMapper != null && bioWellColMapper != null && bioWellRowMapper != null)
     315    {
     316      String plateNameOrId = bioPlateMapper.getValue(data);
     317      BioPlate plate = findBioPlate(dc, FallbackIdMethod.NAME_OR_ID, plateNameOrId);
     318      BioWell well = null;
     319      if (plate != null)
     320      {
     321        Integer row = bioWellRowMapper.getInt(data);
     322        Integer column = bioWellColMapper.getInt(data);       
     323        if (column != null && row != null)
     324        {
     325          well = plate.getBioWell(row, column);;
     326        }
     327      }
     328      sample.setBioWell(well);     
    266329    }
    267330    if (pooledMapper != null)
  • trunk/src/test/net/sf/basedb/test/roles/UserTest.java

    r4640 r4736  
    2828import net.sf.basedb.core.ArrayDesign;
    2929import net.sf.basedb.core.BioMaterialEvent;
     30import net.sf.basedb.core.BioPlate;
    3031import net.sf.basedb.core.BioSource;
    3132import net.sf.basedb.core.DataFileType;
     
    4445import net.sf.basedb.core.Label;
    4546import net.sf.basedb.core.LabeledExtract;
     47import net.sf.basedb.core.PlateGeometry;
    4648import net.sf.basedb.core.Platform;
    4749import net.sf.basedb.core.PluginConfiguration;
     
    145147      Platform genericPlatform = Platform.getByExternalId(dc, Platform.GENERIC);
    146148      Platform affymetrixPlatform = Platform.getByExternalId(dc, Platform.AFFYMETRIX);
     149      BioPlate bioplate = createBioPlate(dc, "Bioplate A", Util.findGeometry(dc, 16, 24));
    147150     
    148151     
     
    174177      {
    175178        dc = TestUtil.getDbControl();
     179               
    176180        bioSource =  createBioSource(dc, "Biosource A", "medium");
    177181        s1 = createSample(dc, "Sample A.00h", bioSource, 0, hoursUnit);
     182        s1.setBioWell(bioplate.getBioWell(0, 0));       
    178183        s2 = createSample(dc, "Sample A.24h", bioSource, 24, hoursUnit);
     184        s2.setBioWell(bioplate.getBioWell(0, 1));       
    179185        sRef = createSample(dc, "Sample A.ref", null, null, null);
     186        sRef.setBioWell(bioplate.getBioWell(0, 2));
    180187       
    181188        Extract e1 = createExtract(dc, "Extract A.00h", s1);
     189        e1.setBioWell(bioplate.getBioWell(1, 0));
    182190        Extract e2 = createExtract(dc, "Extract A.24h", s2);
     191        e2.setBioWell(bioplate.getBioWell(1, 1));       
    183192        Extract eRef = createExtract(dc, "Extract A.ref", sRef);
     193        eRef.setBioWell(bioplate.getBioWell(1, 2));
    184194       
    185195        Label cy3 = Util.findLabel(dc, "cy3");     
    186196        Label cy5 = Util.findLabel(dc, "cy5");     
    187197        LabeledExtract le1 = createLabeledExtract(dc, "Labeled extract A.00h", e1, cy3);
     198        le1.setBioWell(bioplate.getBioWell(2, 0));
     199        LabeledExtract le1DyeSwap = createLabeledExtract(dc, "Labeled extract A.00h (dye-swap)", e1, cy5);
     200        le1DyeSwap.setBioWell(bioplate.getBioWell(2, 1));
    188201        LabeledExtract le2 = createLabeledExtract(dc, "Labeled extract A.24h", e2, cy3);
     202        le2.setBioWell(bioplate.getBioWell(2, 2));
     203        LabeledExtract le2DyeSwap = createLabeledExtract(dc, "Labeled extract A.24h (dye-swap)", e2, cy5);
     204        le2DyeSwap.setBioWell(bioplate.getBioWell(2, 3));
    189205        LabeledExtract leRef = createLabeledExtract(dc, "Labeled extract A.ref", eRef, cy5);
    190         LabeledExtract le1DyeSwap = createLabeledExtract(dc, "Labeled extract A.00h (dye-swap)", e1, cy5);
    191         LabeledExtract le2DyeSwap = createLabeledExtract(dc, "Labeled extract A.24h (dye-swap)", e2, cy5);
     206        leRef.setBioWell(bioplate.getBioWell(2, 4));
    192207        LabeledExtract leRefDyeSwap = createLabeledExtract(dc, "Labeled extract A.ref (dye-swap)", eRef, cy3);
     208        leRefDyeSwap.setBioWell(bioplate.getBioWell(2, 5));
    193209//        dc.commit();
    194210       
     
    391407 
    392408  /**
     409    Create a bioplate
     410   */
     411  public static BioPlate createBioPlate(DbControl dc, String name, PlateGeometry geometry)
     412  {
     413    TestUtil.write("--Creating bioplate: " + name + "\n");
     414   
     415    BioPlate plate = BioPlate.getNew(dc, geometry);
     416    plate.setName(name);
     417    dc.saveItem(plate);
     418    return plate;
     419  }
     420 
     421  /**
    393422    Create a hybridization.
    394423  */
     
    636665      job.setParameterValue("dataSplitterRegexp", new StringParameterType(), "\\t");
    637666      job.setParameterValue("dataHeaderRegexp", new StringParameterType(),
    638           "Name\\tLabel\\tOriginal quantity\\tDescription\\tExternal id\\tProtocol\\tCreated\\tPooled\\tParent\\tParent used quantity");
     667          "Name\\tLabel\\tOriginal quantity\\tDescription\\tExternal id\\tProtocol\\tCreated\\tPooled\\tParent\\tParent used quantity\\tBioplate\\tBiowell row\\tBiowell column");
    639668     
    640669      job.setParameterValue("nameColumnMapping", new StringParameterType(), "\\Name\\");
     
    648677      job.setParameterValue("protocolColumnMapping", new StringParameterType(), "\\Protocol\\");
    649678      job.setParameterValue("labelColumnMapping", new StringParameterType(), "\\Label\\");
     679      job.setParameterValue("bioPlateColumnMapping", new StringParameterType(), "\\Bioplate\\");
     680      job.setParameterValue("bioWellRowColumnMapping", new StringParameterType(), "\\Biowell row\\");
     681      job.setParameterValue("bioWellColColumnMapping", new StringParameterType(), "\\Biowell column\\");
    650682     
    651683      dc.saveItem(job);
     
    673705      job.setParameterValue("dataSplitterRegexp", new StringParameterType(), "\\t");
    674706      job.setParameterValue("dataHeaderRegexp", new StringParameterType(),
    675           "Name\\tOriginal quantity\\tDescription\\tExternal id\\tProtocol\\tCreated\\tPooled\\tParent\\tParent used quantity");
     707          "Name\\tOriginal quantity\\tDescription\\tExternal id\\tProtocol\\tCreated\\tPooled\\tParent\\tParent used quantity\\tBioplate\\tBiowell row\\tBiowell column");
    676708     
    677709      job.setParameterValue("nameColumnMapping", new StringParameterType(), "\\Name\\");
     
    684716      job.setParameterValue("usedQuantityColumnMapping", new StringParameterType(), "\\Parent used quantity\\");
    685717      job.setParameterValue("protocolColumnMapping", new StringParameterType(), "\\Protocol\\");
     718      job.setParameterValue("bioPlateColumnMapping", new StringParameterType(), "\\Bioplate\\");
     719      job.setParameterValue("bioWellRowColumnMapping", new StringParameterType(), "\\Biowell row\\");
     720      job.setParameterValue("bioWellColColumnMapping", new StringParameterType(), "\\Biowell column\\");
    686721     
    687722      dc.saveItem(job);
     
    709744      job.setParameterValue("dataSplitterRegexp", new StringParameterType(), "\\t");
    710745      job.setParameterValue("dataHeaderRegexp", new StringParameterType(),
    711           "Name\\tOriginal quantity\\tDescription\\tExternal id\\tCreated\\tPooled\\tBiosource\\tProtocol\\tTime");
     746          "Name\\tOriginal quantity\\tDescription\\tExternal id\\tCreated\\tPooled\\tBiosource\\tProtocol\\tBioplate\\tBiowell row\\tBiowell column\\tTime");
    712747     
    713748      job.setParameterValue("nameColumnMapping", new StringParameterType(), "\\Name\\");
     
    719754      job.setParameterValue("parentColumnMapping", new StringParameterType(), "\\Biosource\\");
    720755      job.setParameterValue("protocolColumnMapping", new StringParameterType(), "\\Protocol\\");
     756      job.setParameterValue("bioPlateColumnMapping", new StringParameterType(), "\\Bioplate\\");
     757      job.setParameterValue("bioWellRowColumnMapping", new StringParameterType(), "\\Biowell row\\");
     758      job.setParameterValue("bioWellColColumnMapping", new StringParameterType(), "\\Biowell column\\");
    721759     
    722760      dc.saveItem(job);
     
    819857  private static String[] getSampleColumnHeaders()
    820858  {
    821     return new String[] {"Name", "Original quantity", "Description", "External id", "Created", "Pooled", "Biosource", "Protocol", "Time"};
     859    return new String[] {"Name", "Original quantity", "Description", "External id", "Created", "Pooled", "Biosource", "Protocol", "Bioplate", "Biowell row", "Biowell column", "Time"};
    822860  }
    823861}
Note: See TracChangeset for help on using the changeset viewer.