From 32f09db895878805477a896ab6c8b81fd6716a91 Mon Sep 17 00:00:00 2001 From: kaloyane <kaloyane> Date: Wed, 29 Jun 2011 15:34:12 +0000 Subject: [PATCH] [LMS-2332] added support for parsing geometry from plate property SVN: 21912 --- .../dist/etc/sanofi-dropbox/sanofi-dropbox.py | 16 +++-- .../dss/test/SanofiDropboxJythonTest.java | 60 +++++++++++++------ 2 files changed, 53 insertions(+), 23 deletions(-) diff --git a/sanofi/dist/etc/sanofi-dropbox/sanofi-dropbox.py b/sanofi/dist/etc/sanofi-dropbox/sanofi-dropbox.py index a264b81b6ae..ee09bf9ca99 100644 --- a/sanofi/dist/etc/sanofi-dropbox/sanofi-dropbox.py +++ b/sanofi/dist/etc/sanofi-dropbox/sanofi-dropbox.py @@ -2,6 +2,7 @@ import ch.systemsx.cisd.etlserver.registrator.api.v1.MaterialIdentifierCollectio import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.SearchCriteria as SearchCriteria import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.SearchCriteria.MatchClause as MatchClause import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.SearchCriteria.MatchClauseAttribute as MatchClauseAttribute +import ch.systemsx.cisd.openbis.plugin.screening.shared.basic.dto.ScreeningConstants as ScreeningConstants PLATE_TYPE = "PLATE" @@ -76,11 +77,17 @@ class PlateInitializer: return chr(ord('A') + x) + str(y) def getPlateDimensions(self): - # TODO KE: implement me - return (2, 2) + """ + parses the plate geometry property from the form "384_WELLS_16X24" + to a tuple of integers (plateHeight, plateWidth) + """ + plateGeometryString = plate.getPropertyValue(ScreeningConstants.PLATE_GEOMETRY) + widthByHeight = plateGeometryString.split("_")[-1] + dimensions = map(int, widthByHeight.split("X")) + return (dimensions[0], dimensions[1]) def validateLibraryDimensions(self, csvLists): - (plateWidth, plateHeight) = self.getPlateDimensions() + (plateHeight, plateWidth) = self.getPlateDimensions() assert plateHeight == len(csvLists), \ "Plate geometry (height=%i) does not agree with LIBRARY_TEMPLATE (height=%i)." % (plateHeight, len(csvLists)) @@ -198,8 +205,7 @@ class PlateInitializer: well.setPropertyValue(self.COMPOUND_WELL_CONCENTRATION_PROPNAME, concentration) materialCode = self.getByWellCode(wellCode, sanofiMaterials).materialCode material = openbisMaterials[materialCode] - # TODO KE: make material property creation possible - #well.setPropertyValue(self.COMPOUND_WELL_MATERIAL_PROPNAME, material) + well.setPropertyValue(self.COMPOUND_WELL_MATERIAL_PROPNAME, material.getMaterialIdentifier()) def createWellsAndMaterials(self): diff --git a/sanofi/sourceTest/java/ch/systemsx/cisd/sanofi/dss/test/SanofiDropboxJythonTest.java b/sanofi/sourceTest/java/ch/systemsx/cisd/sanofi/dss/test/SanofiDropboxJythonTest.java index bf96eb7e040..983660ce870 100644 --- a/sanofi/sourceTest/java/ch/systemsx/cisd/sanofi/dss/test/SanofiDropboxJythonTest.java +++ b/sanofi/sourceTest/java/ch/systemsx/cisd/sanofi/dss/test/SanofiDropboxJythonTest.java @@ -43,6 +43,7 @@ import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.SearchCriteria.MatchCl import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DataSetType; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.IEntityProperty; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.ListMaterialCriteria; +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.MaterialIdentifier; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.NewSample; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.Sample; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.builders.ExperimentBuilder; @@ -54,6 +55,7 @@ import ch.systemsx.cisd.openbis.generic.shared.dto.identifier.ExperimentIdentifi import ch.systemsx.cisd.openbis.generic.shared.dto.identifier.SampleIdentifier; import ch.systemsx.cisd.openbis.generic.shared.dto.identifier.SampleIdentifierFactory; import ch.systemsx.cisd.openbis.generic.shared.util.EntityHelper; +import ch.systemsx.cisd.openbis.plugin.screening.shared.basic.dto.ScreeningConstants; /** * <pre> @@ -81,8 +83,7 @@ public class SanofiDropboxJythonTest extends AbstractJythonDataSetHandlerTest private static final String COMPOUND_WELL_CONCENTRATION_PROPNAME = "CONCENTRATION"; - // TODO KE: implement me - // private static final String COMPOUND_WELL_MATERIAL_PROPNAME = "COMPOUND_BATCH"; + private static final String COMPOUND_WELL_MATERIAL_PROPNAME = "COMPOUND_BATCH"; private static final String DATASET_DIR_NAME = "batchNr_plateCode.variant_2011.06.28"; @@ -111,14 +112,16 @@ public class SanofiDropboxJythonTest extends AbstractJythonDataSetHandlerTest createHandler(properties, false, true, queryService); createData(); - final String libraryTemplate = "1.45, H\n0.12, L"; - final Sample plate = createPlate(libraryTemplate); + final String libraryTemplate = "1.45, 20.701, H\n0.12, 0.002, L"; + final Sample plate = createPlate(libraryTemplate, "6_WELLS_2X3"); setUpPlateSearchExpectations(plate); setUpLibraryTemplateExpectations(plate); final MockDataSet<Map<String, Object>> queryResult = new MockDataSet<Map<String, Object>>(); queryResult.add(createQueryResult("A0")); + queryResult.add(createQueryResult("A1")); queryResult.add(createQueryResult("B0")); + queryResult.add(createQueryResult("B1")); final RecordingMatcher<ch.systemsx.cisd.openbis.generic.shared.dto.AtomicEntityOperationDetails> atomicatOperationDetails = new RecordingMatcher<ch.systemsx.cisd.openbis.generic.shared.dto.AtomicEntityOperationDetails>(); @@ -134,7 +137,7 @@ public class SanofiDropboxJythonTest extends AbstractJythonDataSetHandlerTest one(openBisService).listMaterials(with(materialCriteria), with(equal(true))); will(returnValue(Collections.emptyList())); - exactly(4).of(openBisService).createPermId(); + exactly(6).of(openBisService).createPermId(); will(returnValue("well-permId")); one(openBisService).createDataSetCode(); @@ -164,12 +167,15 @@ public class SanofiDropboxJythonTest extends AbstractJythonDataSetHandlerTest List<NewSample> registeredSamples = atomicatOperationDetails.recordedObject().getSampleRegistrations(); - + + assertEquals(6, registeredSamples.size()); assertAllSamplesHaveContainer(registeredSamples, plate.getIdentifier()); assertCompoundWell(registeredSamples, "A0", "1.45"); - assertPositiveControl(registeredSamples, "A1"); + assertCompoundWell(registeredSamples, "A1", "20.701"); + assertPositiveControl(registeredSamples, "A2"); assertCompoundWell(registeredSamples, "B0", "0.12"); - assertNegativeControl(registeredSamples, "B1"); + assertCompoundWell(registeredSamples, "B1", "0.002"); + assertNegativeControl(registeredSamples, "B2"); List<? extends NewExternalData> dataSetsRegistered = atomicatOperationDetails.recordedObject().getDataSetRegistrations(); @@ -222,12 +228,24 @@ public class SanofiDropboxJythonTest extends AbstractJythonDataSetHandlerTest { NewSample newSample = findByWellCode(newSamples, wellCode); assertEquals(COMPOUND_WELL_TYPE, newSample.getSampleType().getCode()); + IEntityProperty concentrationProp = EntityHelper.tryFindProperty(newSample.getProperties(), COMPOUND_WELL_CONCENTRATION_PROPNAME); assertNotNull(concentrationProp); assertEquals("Invalid concentration value for well '" + wellCode + "': ", concentration, concentrationProp.tryGetAsString()); + + String materialCode = getMaterialCodeByWellCode(wellCode); + MaterialIdentifier materialIdentifier = new MaterialIdentifier(materialCode, MATERIAL_TYPE); + + IEntityProperty wellMaterialProp = + EntityHelper.tryFindProperty(newSample.getProperties(), + COMPOUND_WELL_MATERIAL_PROPNAME); + assertNotNull(wellMaterialProp); + assertEquals("Invalid material found in well '" + wellCode + "': ", + materialIdentifier.print(), wellMaterialProp.tryGetAsString()); + } private void setUpPlateSearchExpectations(final Sample plate) @@ -271,16 +289,17 @@ public class SanofiDropboxJythonTest extends AbstractJythonDataSetHandlerTest FileUtilities.writeToFile(markerFile, ""); } - private Sample createPlate(String libraryTemplate) + private Sample createPlate(String libraryTemplate, String plateGeometry) { - ExperimentBuilder experimentBuilder = - new ExperimentBuilder().identifier(EXPERIMENT_IDENTIFIER).property( - LIBRARY_TEMPLATE_PROPNAME, - libraryTemplate); - - SampleBuilder sampleBuilder = - new SampleBuilder().identifier(PLATE_IDENTIFIER).experiment( - experimentBuilder.getExperiment()); + ExperimentBuilder experimentBuilder = new ExperimentBuilder(); + experimentBuilder.identifier(EXPERIMENT_IDENTIFIER); + experimentBuilder.property(LIBRARY_TEMPLATE_PROPNAME, libraryTemplate); + + SampleBuilder sampleBuilder = new SampleBuilder(); + sampleBuilder.experiment(experimentBuilder.getExperiment()); + sampleBuilder.identifier(PLATE_IDENTIFIER); + sampleBuilder.property(ScreeningConstants.PLATE_GEOMETRY, plateGeometry); + final Sample plate = sampleBuilder.getSample(); return plate; } @@ -289,12 +308,17 @@ public class SanofiDropboxJythonTest extends AbstractJythonDataSetHandlerTest { Map<String, Object> result = new HashMap<String, Object>(); result.put("WELL_CODE", wellCode); - result.put("MATERIAL_CODE", wellCode + "_material_code"); + result.put("MATERIAL_CODE", getMaterialCodeByWellCode(wellCode)); result.put("ABASE_COMPOUND_ID", wellCode + "_compound_id"); result.put("ABASE_COMPOUND_BATCH_ID", wellCode + "_compound_batch_id"); return result; } + private String getMaterialCodeByWellCode(String wellCode) + { + return wellCode + "_material_code"; + } + @Override protected String getRegistrationScriptsFolderPath() { -- GitLab