diff --git a/sanofi/dist/etc/sanofi-dropbox/plateinitializer.py b/sanofi/dist/etc/sanofi-dropbox/plateinitializer.py index bc54e4dda6556e8e6da48d6503619d23993ae635..613af1d08bf1fdf8ef93d41c96dbf9397cd3ccea 100644 --- a/sanofi/dist/etc/sanofi-dropbox/plateinitializer.py +++ b/sanofi/dist/etc/sanofi-dropbox/plateinitializer.py @@ -18,11 +18,10 @@ class SanofiMaterial: """ A data structure class holding compound materials as they exist in the Abase (Sanofi) database. """ - def __init__(self, wellCode, materialCode, sanofiId, sanofiBatchId): + def __init__(self, wellCode, compoundBatchId, compoundId): self.wellCode = self.normalizeWellCode(wellCode) - self.materialCode = materialCode - self.sanofiId = sanofiId - self.sanofiBatchId = sanofiBatchId + self.compoundBatchId = compoundBatchId + self.compoundId = compoundId def normalizeWellCode(self, wellCode): """ normalizes Sanofi wellCodes to openBIS wellCodes e.g. AB007 to AB7 """ @@ -30,10 +29,17 @@ class SanofiMaterial: class PlateInitializer: ABASE_DATA_SOURCE = "abase-datasource" +# ABASE_PRODUCTION_QUERY = """select +# ptodwellreference WELL_CODE, +# translate(objdbatchref,'{/:()+','{_____') MATERIAL_CODE, +# translate(objdid,'{/:()+','{_____') ABASE_COMPOUND_ID, +# olptid ABASE_PLATE_CODE +# from sysadmin.plteobjd +# where olptid = ?{1}""" + ABASE_PRODUCTION_QUERY = """select ptodwellreference WELL_CODE, - translate(objdbatchref,'{/:()+','{_____') MATERIAL_CODE, - objdbatchref ABASE_COMPOUND_BATCH_ID, + objdbatchref MATERIAL_CODE, objdid ABASE_COMPOUND_ID, olptid ABASE_PLATE_CODE from sysadmin.plteobjd @@ -42,7 +48,7 @@ class PlateInitializer: # used for integration testing from openBIS team members ABASE_TEST_MODE_QUERY = """select WELL_CODE, MATERIAL_CODE, ABASE_COMPOUND_ID, - ABASE_COMPOUND_BATCH_ID, ABASE_PLATE_CODE + ABASE_PLATE_CODE from plates where ABASE_PLATE_CODE = ?{1}""" @@ -53,12 +59,12 @@ class PlateInitializer: COMPOUND_WELL_TYPE = "COMPOUND_WELL" COMPOUND_WELL_CONCENTRATION_PROPNAME = "CONCENTRATION_M" - COMPOUND_WELL_MATERIAL_PROPNAME = "COMPOUND" + COMPOUND_WELL_MATERIAL_PROPNAME = "COMPOUND_BATCH" - MATERIAL_TYPE = "COMPOUND" - MATERIAL_ID_PROPNAME = "COMPOUND_ID" - MATERIAL_BATCH_ID_PROPNAME = "COMPOUND_BATCH_ID" - + MATERIAL_BATCH_TYPE = "COMPOUND_BATCH" + MATERIAL_COMPOUND_TYPE = "COMPOUND" + MATERIAL_ID_PROPNAME = "COMPOUND" + def __init__(self, transaction, state, plate, experiment, testMode): self.transaction = transaction self.state = state @@ -151,7 +157,7 @@ class PlateInitializer: raise RuntimeException("No column '%s' in the query results from the ABASE Database" % (code)) material = SanofiMaterial(val('WELL_CODE'), val('MATERIAL_CODE'), \ - val('ABASE_COMPOUND_ID'), val('ABASE_COMPOUND_BATCH_ID')) + val('ABASE_COMPOUND_ID')) sanofiMaterials.append(material) @@ -159,34 +165,53 @@ class PlateInitializer: return sanofiMaterials - def createMaterial(self, sanofiMaterial): - material = self.transaction.createNewMaterial(sanofiMaterial.materialCode, self.MATERIAL_TYPE) - material.setPropertyValue(self.MATERIAL_ID_PROPNAME, sanofiMaterial.sanofiId) - material.setPropertyValue(self.MATERIAL_BATCH_ID_PROPNAME, sanofiMaterial.sanofiBatchId) + def createCompoundBatchMaterial(self, sanofiMaterial): + material = self.transaction.createNewMaterial(sanofiMaterial.compoundBatchId, self.MATERIAL_BATCH_TYPE) + material.setPropertyValue(self.MATERIAL_ID_PROPNAME, sanofiMaterial.compoundId) return material - def getOrCreateMaterials(self, template, sanofiMaterials): - materialsByCode = {} - for sanofiMaterial in sanofiMaterials: - materialsByCode[ sanofiMaterial.materialCode ] = sanofiMaterial + def createCompoundMaterial(self, sanofiMaterial): + material = self.transaction.createNewMaterial(sanofiMaterial.compoundId, self.MATERIAL_COMPOUND_TYPE) + return material + def findExistingMaterials(self, materialType, materialCodes): materialIdentifiers = MaterialIdentifierCollection() - for materialCode in materialsByCode: - materialIdentifiers.addIdentifier(self.MATERIAL_TYPE, materialCode) + for materialCode in materialCodes: + materialIdentifiers.addIdentifier(materialType, materialCode) searchService = self.transaction.getSearchService() - existingMaterials = list(searchService.listMaterials(materialIdentifiers)) - - existingMaterialsByCode = {} + return list(searchService.listMaterials(materialIdentifiers)) + + def createNonExistingMaterials(self, sanofiMaterialsByCode, existingMaterials, createFunction): + materialsByCode = {} for material in existingMaterials: - existingMaterialsByCode[ material.getCode() ] = material - - for materialCode in materialsByCode: - if not materialCode in existingMaterialsByCode: - sanofiMaterial = materialsByCode[materialCode] - openbisMaterial = self.createMaterial(sanofiMaterial) - existingMaterialsByCode[materialCode] = openbisMaterial + materialsByCode[ material.getCode() ] = material + + for materialCode in sanofiMaterialsByCode: + if not materialCode in materialsByCode: + sanofiMaterial = sanofiMaterialsByCode[materialCode] + materialsByCode[materialCode] = createFunction(sanofiMaterial) + + return materialsByCode + + + def getOrCreateMaterials(self, template, sanofiMaterials): + materialsByBatchId = {} + materialsByCompoundId = {} + + for sanofiMaterial in sanofiMaterials: + materialsByBatchId[ sanofiMaterial.compoundBatchId ] = sanofiMaterial + materialsByCompoundId[ sanofiMaterial.compoundId ] = sanofiMaterial + + existingCompoundMaterials = self.findExistingMaterials(self.MATERIAL_COMPOUND_TYPE, materialsByCompoundId) + allCompoundMaterialsByCode = self.createNonExistingMaterials(materialsByCompoundId, existingCompoundMaterials, self.createCompoundMaterial) + + existingBatchMaterials = self.findExistingMaterials(self.MATERIAL_BATCH_TYPE, materialsByBatchId) + allBatchMaterialsByCode = self.createNonExistingMaterials(materialsByBatchId, existingBatchMaterials, self.createCompoundBatchMaterial) - return existingMaterialsByCode + # returns a dict UNION + allMaterialsByCode = dict(allCompoundMaterialsByCode) + allMaterialsByCode.update(allBatchMaterialsByCode) + return allMaterialsByCode def getByWellCode(self, wellCode, sanofiMaterials): @@ -233,7 +258,7 @@ class PlateInitializer: well.setContainer(self.plate) concentration = self.parseConcentration(templateValue) well.setPropertyValue(self.COMPOUND_WELL_CONCENTRATION_PROPNAME, concentration) - materialCode = sanofiMaterial.materialCode + materialCode = sanofiMaterial.compoundBatchId material = openbisMaterials[materialCode] well.setPropertyValue(self.COMPOUND_WELL_MATERIAL_PROPNAME, material.getMaterialIdentifier()) diff --git a/sanofi/resource/master-data/sanofi-master-data.py b/sanofi/resource/master-data/sanofi-master-data.py new file mode 100644 index 0000000000000000000000000000000000000000..507b981b4862ca7c95215ff57552920aa23d753d --- /dev/null +++ b/sanofi/resource/master-data/sanofi-master-data.py @@ -0,0 +1,72 @@ +import ch.systemsx.cisd.openbis.generic.server.jython.api.v1.DataType as DataType + +tr = service.transaction() +# +# Materials +# +material_type_COMPOUND = tr.getMaterialType('COMPOUND') +if not material_type_COMPOUND: + material_type_COMPOUND = tr.createNewMaterialType('COMPOUND') + material_type_COMPOUND.setDescription('Compound material') + +material_type_COMPOUND_BATCH = tr.createNewMaterialType('COMPOUND_BATCH') +material_type_COMPOUND_BATCH.setDescription('Compound batch material') + +prop_type_COMPOUND = tr.createNewPropertyType('COMPOUND', DataType.MATERIAL) +prop_type_COMPOUND.setLabel('Compound material') +tr.assignPropertyType(material_type_COMPOUND_BATCH, prop_type_COMPOUND) + + +# +# Experiment + Properties +# + +experiment_type_COMPOUND_HCS = tr.getExperimentType('COMPOUND_HCS') + +prop_type_OBSERVER_EMAILS = tr.createNewPropertyType('OBSERVER_EMAILS', DataType.VARCHAR) +prop_type_OBSERVER_EMAILS.setLabel('Observer e-mails') +tr.assignPropertyType(experiment_type_COMPOUND_HCS, prop_type_OBSERVER_EMAILS) + +prop_type_LIBRARY_TEMPLATE = tr.createNewPropertyType('LIBRARY_TEMPLATE', DataType.MULTILINE_VARCHAR) +prop_type_LIBRARY_TEMPLATE.setLabel('Library Template') +tr.assignPropertyType(experiment_type_COMPOUND_HCS, prop_type_LIBRARY_TEMPLATE) + +# +# Samples +# + +samp_type_POSITIVE_CONTROL = tr.createNewSampleType('POSITIVE_CONTROL') +samp_type_POSITIVE_CONTROL.setListable(False) +samp_type_POSITIVE_CONTROL.setGeneratedCodePrefix('P') + + +samp_type_NEGATIVE_CONTROL = tr.createNewSampleType('NEGATIVE_CONTROL') +samp_type_NEGATIVE_CONTROL.setListable(False) +samp_type_NEGATIVE_CONTROL.setGeneratedCodePrefix('N') + + +samp_type_COMPOUND_WELL = tr.createNewSampleType('COMPOUND_WELL') +samp_type_COMPOUND_WELL.setListable(False) +samp_type_COMPOUND_WELL.setGeneratedCodePrefix('C') + + + +prop_type_COMPOUND_BATCH = tr.createNewPropertyType('COMPOUND_BATCH', DataType.MATERIAL) +prop_type_COMPOUND_BATCH.setLabel('Compound batch material') +tr.assignPropertyType(samp_type_COMPOUND_WELL, prop_type_COMPOUND_BATCH) + +tr.assignPropertyType(samp_type_COMPOUND_WELL, prop_type_COMPOUND) + +prop_type_CONCENTRATION_M = tr.createNewPropertyType('CONCENTRATION_M', DataType.REAL) +prop_type_CONCENTRATION_M.setLabel('Concentration (M)') +tr.assignPropertyType(samp_type_COMPOUND_WELL, prop_type_CONCENTRATION_M) + +# +# Data Sets +# +data_set_type_HCS_IMAGE_RAW = tr.getDataSetType('HCS_IMAGE_RAW') + +prop_type_ACQUISITION_BATCH = tr.createNewPropertyType('ACQUISITION_BATCH', DataType.VARCHAR) +prop_type_ACQUISITION_BATCH.setLabel('Acquisition Batch') +tr.assignPropertyType(data_set_type_HCS_IMAGE_RAW, prop_type_ACQUISITION_BATCH) + diff --git a/sanofi/resource/mock-abase-db/mock-abase-db.sql b/sanofi/resource/mock-abase-db/mock-abase-db.sql index ae34c8ae1c23fcc5d7084f18c188f4917d90b950..c3d8e6b9dde1e62141be9532f6d231f7282eae64 100644 --- a/sanofi/resource/mock-abase-db/mock-abase-db.sql +++ b/sanofi/resource/mock-abase-db/mock-abase-db.sql @@ -1,50 +1,50 @@ -CREATE TABLE plates (WELL_CODE VARCHAR NOT NULL, MATERIAL_CODE VARCHAR NOT NULL, ABASE_COMPOUND_ID VARCHAR NOT NULL, ABASE_COMPOUND_BATCH_ID VARCHAR NOT NULL, ABASE_PLATE_CODE VARCHAR NOT NULL); -INSERT INTO plates (well_code, material_code, abase_compound_id, abase_compound_batch_id, abase_plate_code) values ('A001', 'COMPOUND-1', 'ABASE Compound (1)', 'ABASE Batch Compound (1)', 'PLATE1'); -INSERT INTO plates (well_code, material_code, abase_compound_id, abase_compound_batch_id, abase_plate_code) values ('A002', 'COMPOUND-2', 'ABASE Compound (1)', 'ABASE Batch Compound (1)', 'PLATE1'); -INSERT INTO plates (well_code, material_code, abase_compound_id, abase_compound_batch_id, abase_plate_code) values ('A003', 'COMPOUND-3', 'ABASE Compound (1)', 'ABASE Batch Compound (1)', 'PLATE1'); -INSERT INTO plates (well_code, material_code, abase_compound_id, abase_compound_batch_id, abase_plate_code) values ('A004', 'COMPOUND-4', 'ABASE Compound (1)', 'ABASE Batch Compound (1)', 'PLATE1'); -INSERT INTO plates (well_code, material_code, abase_compound_id, abase_compound_batch_id, abase_plate_code) values ('A005', 'COMPOUND-5', 'ABASE Compound (1)', 'ABASE Batch Compound (1)', 'PLATE1'); -INSERT INTO plates (well_code, material_code, abase_compound_id, abase_compound_batch_id, abase_plate_code) values ('A006', 'COMPOUND-6', 'ABASE Compound (1)', 'ABASE Batch Compound (1)', 'PLATE1'); -INSERT INTO plates (well_code, material_code, abase_compound_id, abase_compound_batch_id, abase_plate_code) values ('A007', 'COMPOUND-7', 'ABASE Compound (1)', 'ABASE Batch Compound (1)', 'PLATE1'); -INSERT INTO plates (well_code, material_code, abase_compound_id, abase_compound_batch_id, abase_plate_code) values ('A008', 'COMPOUND-8', 'ABASE Compound (1)', 'ABASE Batch Compound (1)', 'PLATE1'); -INSERT INTO plates (well_code, material_code, abase_compound_id, abase_compound_batch_id, abase_plate_code) values ('A009', 'COMPOUND-9', 'ABASE Compound (1)', 'ABASE Batch Compound (1)', 'PLATE1'); -INSERT INTO plates (well_code, material_code, abase_compound_id, abase_compound_batch_id, abase_plate_code) values ('A010', 'COMPOUND-10', 'ABASE Compound (1)', 'ABASE Batch Compound (1)', 'PLATE1'); -INSERT INTO plates (well_code, material_code, abase_compound_id, abase_compound_batch_id, abase_plate_code) values ('A011', 'COMPOUND-11', 'ABASE Compound (1)', 'ABASE Batch Compound (1)', 'PLATE1'); -INSERT INTO plates (well_code, material_code, abase_compound_id, abase_compound_batch_id, abase_plate_code) values ('A012', 'COMPOUND-12', 'ABASE Compound (1)', 'ABASE Batch Compound (1)', 'PLATE1'); -INSERT INTO plates (well_code, material_code, abase_compound_id, abase_compound_batch_id, abase_plate_code) values ('A013', 'COMPOUND-13', 'ABASE Compound (1)', 'ABASE Batch Compound (1)', 'PLATE1'); -INSERT INTO plates (well_code, material_code, abase_compound_id, abase_compound_batch_id, abase_plate_code) values ('A014', 'COMPOUND-14', 'ABASE Compound (1)', 'ABASE Batch Compound (1)', 'PLATE1'); -INSERT INTO plates (well_code, material_code, abase_compound_id, abase_compound_batch_id, abase_plate_code) values ('A015', 'COMPOUND-15', 'ABASE Compound (1)', 'ABASE Batch Compound (1)', 'PLATE1'); -INSERT INTO plates (well_code, material_code, abase_compound_id, abase_compound_batch_id, abase_plate_code) values ('A016', 'COMPOUND-16', 'ABASE Compound (1)', 'ABASE Batch Compound (1)', 'PLATE1'); -INSERT INTO plates (well_code, material_code, abase_compound_id, abase_compound_batch_id, abase_plate_code) values ('A017', 'COMPOUND-17', 'ABASE Compound (1)', 'ABASE Batch Compound (1)', 'PLATE1'); -INSERT INTO plates (well_code, material_code, abase_compound_id, abase_compound_batch_id, abase_plate_code) values ('A018', 'COMPOUND-18', 'ABASE Compound (1)', 'ABASE Batch Compound (1)', 'PLATE1'); -INSERT INTO plates (well_code, material_code, abase_compound_id, abase_compound_batch_id, abase_plate_code) values ('A019', 'COMPOUND-19', 'ABASE Compound (1)', 'ABASE Batch Compound (1)', 'PLATE1'); -INSERT INTO plates (well_code, material_code, abase_compound_id, abase_compound_batch_id, abase_plate_code) values ('A020', 'COMPOUND-20', 'ABASE Compound (1)', 'ABASE Batch Compound (1)', 'PLATE1'); -INSERT INTO plates (well_code, material_code, abase_compound_id, abase_compound_batch_id, abase_plate_code) values ('A021', 'COMPOUND-21', 'ABASE Compound (1)', 'ABASE Batch Compound (1)', 'PLATE1'); -INSERT INTO plates (well_code, material_code, abase_compound_id, abase_compound_batch_id, abase_plate_code) values ('A022', 'COMPOUND-22', 'ABASE Compound (1)', 'ABASE Batch Compound (1)', 'PLATE1'); -INSERT INTO plates (well_code, material_code, abase_compound_id, abase_compound_batch_id, abase_plate_code) values ('A023', 'COMPOUND-23', 'ABASE Compound (1)', 'ABASE Batch Compound (1)', 'PLATE1'); -INSERT INTO plates (well_code, material_code, abase_compound_id, abase_compound_batch_id, abase_plate_code) values ('A024', 'COMPOUND-24', 'ABASE Compound (1)', 'ABASE Batch Compound (1)', 'PLATE1'); +CREATE TABLE plates (WELL_CODE VARCHAR NOT NULL, MATERIAL_CODE VARCHAR NOT NULL, ABASE_COMPOUND_ID VARCHAR NOT NULL, ABASE_PLATE_CODE VARCHAR NOT NULL); +INSERT INTO plates (well_code, material_code, abase_compound_id, abase_plate_code) values ('A001', 'COMPOUND-BATCH-1', 'COMPOUND-1', 'PLATE1'); +INSERT INTO plates (well_code, material_code, abase_compound_id, abase_plate_code) values ('A002', 'COMPOUND-BATCH-2', 'COMPOUND-2', 'PLATE1'); +INSERT INTO plates (well_code, material_code, abase_compound_id, abase_plate_code) values ('A003', 'COMPOUND-BATCH-3', 'COMPOUND-3', 'PLATE1'); +INSERT INTO plates (well_code, material_code, abase_compound_id, abase_plate_code) values ('A004', 'COMPOUND-BATCH-4', 'COMPOUND-4', 'PLATE1'); +INSERT INTO plates (well_code, material_code, abase_compound_id, abase_plate_code) values ('A005', 'COMPOUND-BATCH-5', 'COMPOUND-5', 'PLATE1'); +INSERT INTO plates (well_code, material_code, abase_compound_id, abase_plate_code) values ('A006', 'COMPOUND-BATCH-6', 'COMPOUND-6', 'PLATE1'); +INSERT INTO plates (well_code, material_code, abase_compound_id, abase_plate_code) values ('A007', 'COMPOUND-BATCH-7', 'COMPOUND-7', 'PLATE1'); +INSERT INTO plates (well_code, material_code, abase_compound_id, abase_plate_code) values ('A008', 'COMPOUND-BATCH-8', 'COMPOUND-8', 'PLATE1'); +INSERT INTO plates (well_code, material_code, abase_compound_id, abase_plate_code) values ('A009', 'COMPOUND-BATCH-9', 'COMPOUND-9', 'PLATE1'); +INSERT INTO plates (well_code, material_code, abase_compound_id, abase_plate_code) values ('A010', 'COMPOUND-BATCH-10', 'COMPOUND-10', 'PLATE1'); +INSERT INTO plates (well_code, material_code, abase_compound_id, abase_plate_code) values ('A011', 'COMPOUND-BATCH-11', 'COMPOUND-11', 'PLATE1'); +INSERT INTO plates (well_code, material_code, abase_compound_id, abase_plate_code) values ('A012', 'COMPOUND-BATCH-12', 'COMPOUND-12', 'PLATE1'); +INSERT INTO plates (well_code, material_code, abase_compound_id, abase_plate_code) values ('A013', 'COMPOUND-BATCH-13', 'COMPOUND-13', 'PLATE1'); +INSERT INTO plates (well_code, material_code, abase_compound_id, abase_plate_code) values ('A014', 'COMPOUND-BATCH-14', 'COMPOUND-14', 'PLATE1'); +INSERT INTO plates (well_code, material_code, abase_compound_id, abase_plate_code) values ('A015', 'COMPOUND-BATCH-15', 'COMPOUND-15', 'PLATE1'); +INSERT INTO plates (well_code, material_code, abase_compound_id, abase_plate_code) values ('A016', 'COMPOUND-BATCH-16', 'COMPOUND-16', 'PLATE1'); +INSERT INTO plates (well_code, material_code, abase_compound_id, abase_plate_code) values ('A017', 'COMPOUND-BATCH-17', 'COMPOUND-17', 'PLATE1'); +INSERT INTO plates (well_code, material_code, abase_compound_id, abase_plate_code) values ('A018', 'COMPOUND-BATCH-18', 'COMPOUND-18', 'PLATE1'); +INSERT INTO plates (well_code, material_code, abase_compound_id, abase_plate_code) values ('A019', 'COMPOUND-BATCH-19', 'COMPOUND-19', 'PLATE1'); +INSERT INTO plates (well_code, material_code, abase_compound_id, abase_plate_code) values ('A020', 'COMPOUND-BATCH-20', 'COMPOUND-20', 'PLATE1'); +INSERT INTO plates (well_code, material_code, abase_compound_id, abase_plate_code) values ('A021', 'COMPOUND-BATCH-21', 'COMPOUND-21', 'PLATE1'); +INSERT INTO plates (well_code, material_code, abase_compound_id, abase_plate_code) values ('A022', 'COMPOUND-BATCH-22', 'COMPOUND-22', 'PLATE1'); +INSERT INTO plates (well_code, material_code, abase_compound_id, abase_plate_code) values ('A023', 'COMPOUND-BATCH-23', 'COMPOUND-23', 'PLATE1'); +INSERT INTO plates (well_code, material_code, abase_compound_id, abase_plate_code) values ('A024', 'COMPOUND-BATCH-24', 'COMPOUND-24', 'PLATE1'); -INSERT INTO plates (well_code, material_code, abase_compound_id, abase_compound_batch_id, abase_plate_code) values ('P001', 'COMPOUND-1', 'ABASE Compound (1)', 'ABASE Batch Compound (1)', 'PLATE1'); -INSERT INTO plates (well_code, material_code, abase_compound_id, abase_compound_batch_id, abase_plate_code) values ('P002', 'COMPOUND-2', 'ABASE Compound (1)', 'ABASE Batch Compound (1)', 'PLATE1'); -INSERT INTO plates (well_code, material_code, abase_compound_id, abase_compound_batch_id, abase_plate_code) values ('P003', 'COMPOUND-3', 'ABASE Compound (1)', 'ABASE Batch Compound (1)', 'PLATE1'); -INSERT INTO plates (well_code, material_code, abase_compound_id, abase_compound_batch_id, abase_plate_code) values ('P004', 'COMPOUND-4', 'ABASE Compound (1)', 'ABASE Batch Compound (1)', 'PLATE1'); -INSERT INTO plates (well_code, material_code, abase_compound_id, abase_compound_batch_id, abase_plate_code) values ('P005', 'COMPOUND-5', 'ABASE Compound (1)', 'ABASE Batch Compound (1)', 'PLATE1'); -INSERT INTO plates (well_code, material_code, abase_compound_id, abase_compound_batch_id, abase_plate_code) values ('P006', 'COMPOUND-6', 'ABASE Compound (1)', 'ABASE Batch Compound (1)', 'PLATE1'); -INSERT INTO plates (well_code, material_code, abase_compound_id, abase_compound_batch_id, abase_plate_code) values ('P007', 'COMPOUND-7', 'ABASE Compound (1)', 'ABASE Batch Compound (1)', 'PLATE1'); -INSERT INTO plates (well_code, material_code, abase_compound_id, abase_compound_batch_id, abase_plate_code) values ('P008', 'COMPOUND-8', 'ABASE Compound (1)', 'ABASE Batch Compound (1)', 'PLATE1'); -INSERT INTO plates (well_code, material_code, abase_compound_id, abase_compound_batch_id, abase_plate_code) values ('P009', 'COMPOUND-9', 'ABASE Compound (1)', 'ABASE Batch Compound (1)', 'PLATE1'); -INSERT INTO plates (well_code, material_code, abase_compound_id, abase_compound_batch_id, abase_plate_code) values ('P010', 'COMPOUND-10', 'ABASE Compound (1)', 'ABASE Batch Compound (1)', 'PLATE1'); -INSERT INTO plates (well_code, material_code, abase_compound_id, abase_compound_batch_id, abase_plate_code) values ('P011', 'COMPOUND-11', 'ABASE Compound (1)', 'ABASE Batch Compound (1)', 'PLATE1'); -INSERT INTO plates (well_code, material_code, abase_compound_id, abase_compound_batch_id, abase_plate_code) values ('P012', 'COMPOUND-12', 'ABASE Compound (1)', 'ABASE Batch Compound (1)', 'PLATE1'); -INSERT INTO plates (well_code, material_code, abase_compound_id, abase_compound_batch_id, abase_plate_code) values ('P013', 'COMPOUND-13', 'ABASE Compound (1)', 'ABASE Batch Compound (1)', 'PLATE1'); -INSERT INTO plates (well_code, material_code, abase_compound_id, abase_compound_batch_id, abase_plate_code) values ('P014', 'COMPOUND-14', 'ABASE Compound (1)', 'ABASE Batch Compound (1)', 'PLATE1'); -INSERT INTO plates (well_code, material_code, abase_compound_id, abase_compound_batch_id, abase_plate_code) values ('P015', 'COMPOUND-15', 'ABASE Compound (1)', 'ABASE Batch Compound (1)', 'PLATE1'); -INSERT INTO plates (well_code, material_code, abase_compound_id, abase_compound_batch_id, abase_plate_code) values ('P016', 'COMPOUND-16', 'ABASE Compound (1)', 'ABASE Batch Compound (1)', 'PLATE1'); -INSERT INTO plates (well_code, material_code, abase_compound_id, abase_compound_batch_id, abase_plate_code) values ('P017', 'COMPOUND-17', 'ABASE Compound (1)', 'ABASE Batch Compound (1)', 'PLATE1'); -INSERT INTO plates (well_code, material_code, abase_compound_id, abase_compound_batch_id, abase_plate_code) values ('P018', 'COMPOUND-18', 'ABASE Compound (1)', 'ABASE Batch Compound (1)', 'PLATE1'); -INSERT INTO plates (well_code, material_code, abase_compound_id, abase_compound_batch_id, abase_plate_code) values ('P019', 'COMPOUND-19', 'ABASE Compound (1)', 'ABASE Batch Compound (1)', 'PLATE1'); -INSERT INTO plates (well_code, material_code, abase_compound_id, abase_compound_batch_id, abase_plate_code) values ('P020', 'COMPOUND-20', 'ABASE Compound (1)', 'ABASE Batch Compound (1)', 'PLATE1'); -INSERT INTO plates (well_code, material_code, abase_compound_id, abase_compound_batch_id, abase_plate_code) values ('P021', 'COMPOUND-21', 'ABASE Compound (1)', 'ABASE Batch Compound (1)', 'PLATE1'); -INSERT INTO plates (well_code, material_code, abase_compound_id, abase_compound_batch_id, abase_plate_code) values ('P022', 'COMPOUND-22', 'ABASE Compound (1)', 'ABASE Batch Compound (1)', 'PLATE1'); -INSERT INTO plates (well_code, material_code, abase_compound_id, abase_compound_batch_id, abase_plate_code) values ('P023', 'COMPOUND-23', 'ABASE Compound (1)', 'ABASE Batch Compound (1)', 'PLATE1'); -INSERT INTO plates (well_code, material_code, abase_compound_id, abase_compound_batch_id, abase_plate_code) values ('P024', 'COMPOUND-24', 'ABASE Compound (1)', 'ABASE Batch Compound (1)', 'PLATE1'); \ No newline at end of file +INSERT INTO plates (well_code, material_code, abase_compound_id, abase_plate_code) values ('P001', 'COMPOUND-BATCH-1', 'COMPOUND-1', 'PLATE1'); +INSERT INTO plates (well_code, material_code, abase_compound_id, abase_plate_code) values ('P002', 'COMPOUND-BATCH-2', 'COMPOUND-2', 'PLATE1'); +INSERT INTO plates (well_code, material_code, abase_compound_id, abase_plate_code) values ('P003', 'COMPOUND-BATCH-3', 'COMPOUND-3', 'PLATE1'); +INSERT INTO plates (well_code, material_code, abase_compound_id, abase_plate_code) values ('P004', 'COMPOUND-BATCH-4', 'COMPOUND-4', 'PLATE1'); +INSERT INTO plates (well_code, material_code, abase_compound_id, abase_plate_code) values ('P005', 'COMPOUND-BATCH-5', 'COMPOUND-5', 'PLATE1'); +INSERT INTO plates (well_code, material_code, abase_compound_id, abase_plate_code) values ('P006', 'COMPOUND-BATCH-6', 'COMPOUND-6', 'PLATE1'); +INSERT INTO plates (well_code, material_code, abase_compound_id, abase_plate_code) values ('P007', 'COMPOUND-BATCH-7', 'COMPOUND-7', 'PLATE1'); +INSERT INTO plates (well_code, material_code, abase_compound_id, abase_plate_code) values ('P008', 'COMPOUND-BATCH-8', 'COMPOUND-8', 'PLATE1'); +INSERT INTO plates (well_code, material_code, abase_compound_id, abase_plate_code) values ('P009', 'COMPOUND-BATCH-9', 'COMPOUND-9', 'PLATE1'); +INSERT INTO plates (well_code, material_code, abase_compound_id, abase_plate_code) values ('P010', 'COMPOUND-BATCH-10', 'COMPOUND-10', 'PLATE1'); +INSERT INTO plates (well_code, material_code, abase_compound_id, abase_plate_code) values ('P011', 'COMPOUND-BATCH-11', 'COMPOUND-11', 'PLATE1'); +INSERT INTO plates (well_code, material_code, abase_compound_id, abase_plate_code) values ('P012', 'COMPOUND-BATCH-12', 'COMPOUND-12', 'PLATE1'); +INSERT INTO plates (well_code, material_code, abase_compound_id, abase_plate_code) values ('P013', 'COMPOUND-BATCH-13', 'COMPOUND-13', 'PLATE1'); +INSERT INTO plates (well_code, material_code, abase_compound_id, abase_plate_code) values ('P014', 'COMPOUND-BATCH-14', 'COMPOUND-14', 'PLATE1'); +INSERT INTO plates (well_code, material_code, abase_compound_id, abase_plate_code) values ('P015', 'COMPOUND-BATCH-15', 'COMPOUND-15', 'PLATE1'); +INSERT INTO plates (well_code, material_code, abase_compound_id, abase_plate_code) values ('P016', 'COMPOUND-BATCH-16', 'COMPOUND-16', 'PLATE1'); +INSERT INTO plates (well_code, material_code, abase_compound_id, abase_plate_code) values ('P017', 'COMPOUND-BATCH-17', 'COMPOUND-17', 'PLATE1'); +INSERT INTO plates (well_code, material_code, abase_compound_id, abase_plate_code) values ('P018', 'COMPOUND-BATCH-18', 'COMPOUND-18', 'PLATE1'); +INSERT INTO plates (well_code, material_code, abase_compound_id, abase_plate_code) values ('P019', 'COMPOUND-BATCH-19', 'COMPOUND-19', 'PLATE1'); +INSERT INTO plates (well_code, material_code, abase_compound_id, abase_plate_code) values ('P020', 'COMPOUND-BATCH-20', 'COMPOUND-20', 'PLATE1'); +INSERT INTO plates (well_code, material_code, abase_compound_id, abase_plate_code) values ('P021', 'COMPOUND-BATCH-21', 'COMPOUND-21', 'PLATE1'); +INSERT INTO plates (well_code, material_code, abase_compound_id, abase_plate_code) values ('P022', 'COMPOUND-BATCH-22', 'COMPOUND-22', 'PLATE1'); +INSERT INTO plates (well_code, material_code, abase_compound_id, abase_plate_code) values ('P023', 'COMPOUND-BATCH-23', 'COMPOUND-23', 'PLATE1'); +INSERT INTO plates (well_code, material_code, abase_compound_id, abase_plate_code) values ('P024', 'COMPOUND-BATCH-24', 'COMPOUND-24', 'PLATE1'); \ No newline at end of file diff --git a/sanofi/sourceTest/java/ch/systemsx/cisd/sanofi/dss/test/SanofiDropboxJythonRollbackTest.java b/sanofi/sourceTest/java/ch/systemsx/cisd/sanofi/dss/test/SanofiDropboxJythonRollbackTest.java index 18f477c24f03751de3692a223bcc1b4fc2490a5d..f80f05b15a3fc891096989fc8ff76ad80f6f06fe 100644 --- a/sanofi/sourceTest/java/ch/systemsx/cisd/sanofi/dss/test/SanofiDropboxJythonRollbackTest.java +++ b/sanofi/sourceTest/java/ch/systemsx/cisd/sanofi/dss/test/SanofiDropboxJythonRollbackTest.java @@ -158,7 +158,8 @@ public class SanofiDropboxJythonRollbackTest extends AbstractJythonDataSetHandle with(any(String.class)), with(anything())); will(returnValue(queryResult)); - one(openBisService).listMaterials(with(materialCriteria), with(equal(true))); + exactly(2).of(openBisService).listMaterials(with(materialCriteria), + with(equal(true))); will(returnValue(Collections.emptyList())); exactly(4).of(openBisService).createPermId(); 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 3c5cf2edf3a6fb6baab3957780ff52a01bb21f57..cb19f009f36dd9af9d2882a3e139f1e302a32c72 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 @@ -17,6 +17,7 @@ package ch.systemsx.cisd.sanofi.dss.test; + import static ch.systemsx.cisd.common.Constants.IS_FINISHED_PREFIX; import static ch.systemsx.cisd.common.test.AssertionUtil.assertContains; @@ -76,12 +77,6 @@ import ch.systemsx.cisd.openbis.generic.shared.util.EntityHelper; import ch.systemsx.cisd.openbis.plugin.screening.shared.basic.dto.ScreeningConstants; /** - * <pre> - * Things not tested - * - skip well creation when plate library already exists - * - skip material creation for preexisting materials - * </pre> - * * @author Kaloyan Enimanev */ public class SanofiDropboxJythonTest extends AbstractJythonDataSetHandlerTest @@ -101,7 +96,9 @@ public class SanofiDropboxJythonTest extends AbstractJythonDataSetHandlerTest final String[] ALL_EMAILS = new String[] { "admin@sanofi.com", "admin@openbis.org", "donald@duck.com", "mickey@mouse.org" }; - private static final String MATERIAL_TYPE = "COMPOUND"; + private static final String COMPOUND_MATERIAL_TYPE = "COMPOUND"; + + private static final String BATCH_MATERIAL_TYPE = "COMPOUND_BATCH"; private static final String POSITIVE_CONTROL_TYPE = "POSITIVE_CONTROL"; @@ -111,7 +108,10 @@ public class SanofiDropboxJythonTest extends AbstractJythonDataSetHandlerTest private static final String COMPOUND_WELL_CONCENTRATION_PROPNAME = "CONCENTRATION_M"; - private static final String COMPOUND_WELL_MATERIAL_PROPNAME = "COMPOUND"; + // TODO KE: Use this constant after the feedback from Matt + //private static final String COMPOUND_WELL_MATERIAL_PROPNAME = "COMPOUND"; + + private static final String COMPOUND_WELL_BATCH_PROPNAME = "COMPOUND_BATCH"; private static final String IMAGE_DATA_SET_DIR_NAME = "batchNr_plateCode.variant_2011.07.05"; @@ -348,7 +348,8 @@ public class SanofiDropboxJythonTest extends AbstractJythonDataSetHandlerTest with(any(String.class)), with(anything())); will(returnValue(queryResult)); - one(openBisService).listMaterials(with(materialCriteria), with(equal(true))); + exactly(2).of(openBisService).listMaterials(with(materialCriteria), + with(equal(true))); will(returnValue(Collections.emptyList())); exactly(5).of(openBisService).createPermId(); @@ -374,8 +375,10 @@ public class SanofiDropboxJythonTest extends AbstractJythonDataSetHandlerTest handler.handle(markerFile); - assertEquals(MATERIAL_TYPE, materialCriteria.recordedObject().tryGetMaterialType() - .getCode()); + assertEquals(COMPOUND_MATERIAL_TYPE, materialCriteria.getRecordedObjects().get(0) + .tryGetMaterialType().getCode()); + assertEquals(BATCH_MATERIAL_TYPE, materialCriteria.getRecordedObjects().get(1) + .tryGetMaterialType().getCode()); assertEquals(true, queryResult.hasCloseBeenInvoked()); List<NewSample> registeredSamples = @@ -494,7 +497,8 @@ public class SanofiDropboxJythonTest extends AbstractJythonDataSetHandlerTest with(any(String.class)), with(anything())); will(returnValue(queryResult)); - one(openBisService).listMaterials(with(materialCriteria), with(equal(true))); + exactly(2).of(openBisService).listMaterials(with(materialCriteria), + with(equal(true))); will(returnValue(Collections.emptyList())); exactly(3).of(openBisService).createPermId(); @@ -520,8 +524,10 @@ public class SanofiDropboxJythonTest extends AbstractJythonDataSetHandlerTest handler.handle(markerFile); - assertEquals(MATERIAL_TYPE, materialCriteria.recordedObject().tryGetMaterialType() - .getCode()); + assertEquals(COMPOUND_MATERIAL_TYPE, materialCriteria.getRecordedObjects().get(0) + .tryGetMaterialType().getCode()); + assertEquals(BATCH_MATERIAL_TYPE, materialCriteria.getRecordedObjects().get(1) + .tryGetMaterialType().getCode()); assertEquals(true, queryResult.hasCloseBeenInvoked()); List<NewSample> registeredSamples = @@ -566,8 +572,8 @@ public class SanofiDropboxJythonTest extends AbstractJythonDataSetHandlerTest final Sample plate = plateWithLibTemplateAndGeometry("0.75\tH\n54.12\tL", "8_WELLS_2X4"); final MockDataSet<Map<String, Object>> queryResult = new MockDataSet<Map<String, Object>>(); - queryResult.add(createQueryResult("A1", "material-1")); - queryResult.add(createQueryResult("B1", "material-1")); + queryResult.add(createQueryResult("A1", "batch_material", "compound_material")); + queryResult.add(createQueryResult("B1", "batch_material", "compound_material")); setDataSetExpectations(); setUpListAdministratorExpectations(); @@ -579,7 +585,8 @@ public class SanofiDropboxJythonTest extends AbstractJythonDataSetHandlerTest with(any(String.class)), with(anything())); will(returnValue(queryResult)); - one(openBisService).listMaterials(with(materialCriteria), with(equal(true))); + exactly(2).of(openBisService).listMaterials(with(materialCriteria), + with(equal(true))); will(returnValue(Collections.emptyList())); exactly(4).of(openBisService).createPermId(); @@ -605,8 +612,10 @@ public class SanofiDropboxJythonTest extends AbstractJythonDataSetHandlerTest handler.handle(markerFile); - assertEquals(MATERIAL_TYPE, materialCriteria.recordedObject().tryGetMaterialType() - .getCode()); + assertEquals(COMPOUND_MATERIAL_TYPE, materialCriteria.getRecordedObjects().get(0) + .tryGetMaterialType().getCode()); + assertEquals(BATCH_MATERIAL_TYPE, materialCriteria.getRecordedObjects().get(1) + .tryGetMaterialType().getCode()); assertEquals(true, queryResult.hasCloseBeenInvoked()); List<NewSample> registeredSamples = @@ -614,9 +623,9 @@ public class SanofiDropboxJythonTest extends AbstractJythonDataSetHandlerTest assertEquals(4, registeredSamples.size()); assertAllSamplesHaveContainer(registeredSamples, plate.getIdentifier()); - assertCompoundWell(registeredSamples, "A1", "0.75", "material-1"); + assertCompoundWell(registeredSamples, "A1", "0.75", "batch_material", "compound_material"); assertPositiveControl(registeredSamples, "A2"); - assertCompoundWell(registeredSamples, "B1", "54.12", "material-1"); + assertCompoundWell(registeredSamples, "B1", "54.12", "batch_material", "compound_material"); List<? extends NewExternalData> dataSetsRegistered = atomicatOperationDetails.recordedObject().getDataSetRegistrations(); @@ -637,8 +646,17 @@ public class SanofiDropboxJythonTest extends AbstractJythonDataSetHandlerTest Map<String, List<NewMaterial>> materialsRegistered = atomicatOperationDetails.recordedObject().getMaterialRegistrations(); - assertEquals(1, materialsRegistered.size()); - assertEquals("material-1", materialsRegistered.get(MATERIAL_TYPE).get(0).getCode()); + assertEquals(2, materialsRegistered.size()); + + final List<NewMaterial> compoundMaterialsRegistered = + materialsRegistered.get(COMPOUND_MATERIAL_TYPE); + assertEquals(1, compoundMaterialsRegistered.size()); + assertEquals("compound_material", compoundMaterialsRegistered.get(0).getCode()); + + final List<NewMaterial> batchMaterialsRegistered = + materialsRegistered.get(BATCH_MATERIAL_TYPE); + assertEquals(1, batchMaterialsRegistered.size()); + assertEquals("batch_material", batchMaterialsRegistered.get(0).getCode()); AssertionUtil .assertContains( @@ -702,12 +720,14 @@ public class SanofiDropboxJythonTest extends AbstractJythonDataSetHandlerTest private void assertCompoundWell(List<NewSample> newSamples, String wellCode, String concentration) { - String materialCode = getMaterialCodeByWellCode(wellCode); - assertCompoundWell(newSamples, wellCode, concentration, materialCode); + String batchMaterialCode = getBatchMaterialCodeByWellCode(wellCode); + String compoundMaterialCode = getCompoundMaterialCodeByWellCode(wellCode); + assertCompoundWell(newSamples, wellCode, concentration, batchMaterialCode, + compoundMaterialCode); } private void assertCompoundWell(List<NewSample> newSamples, String wellCode, - String concentration, String materialCode) + String concentration, String batchMaterialCode, String compoundMaterialCode) { NewSample newSample = findByWellCode(newSamples, wellCode); assertEquals(COMPOUND_WELL_TYPE, newSample.getSampleType().getCode()); @@ -719,15 +739,24 @@ public class SanofiDropboxJythonTest extends AbstractJythonDataSetHandlerTest assertEquals("Invalid concentration value for well '" + wellCode + "': ", concentration, concentrationProp.tryGetAsString()); - MaterialIdentifier materialIdentifier = new MaterialIdentifier(materialCode, MATERIAL_TYPE); - - IEntityProperty wellMaterialProp = + MaterialIdentifier batchMaterialIdentifier = + new MaterialIdentifier(batchMaterialCode, BATCH_MATERIAL_TYPE); + IEntityProperty batchMaterialProp = EntityHelper.tryFindProperty(newSample.getProperties(), - COMPOUND_WELL_MATERIAL_PROPNAME); - assertNotNull(wellMaterialProp); - assertEquals("Invalid material found in well '" + wellCode + "': ", - materialIdentifier.print(), wellMaterialProp.tryGetAsString()); - + COMPOUND_WELL_BATCH_PROPNAME); + assertNotNull(batchMaterialProp); + assertEquals("Invalid batch material found in well '" + wellCode + "': ", + batchMaterialIdentifier.print(), batchMaterialProp.tryGetAsString()); + // TODO KE: check created BATCH MATERIAL properties (we need to have a "COMPOUND" property !) + // + // MaterialIdentifier compoundMaterialIdentifier = + // new MaterialIdentifier(compoundMaterialCode, COMPOUND_MATERIAL_TYPE); + // IEntityProperty compoundMaterialProp = + // EntityHelper.tryFindProperty(newSample.getProperties(), + // COMPOUND_WELL_MATERIAL_PROPNAME); + // assertNotNull(compoundMaterialProp); + // assertEquals("Invalid compound material found in well '" + wellCode + "': ", + // compoundMaterialIdentifier.print(), compoundMaterialProp.tryGetAsString()); } public Sample plateWithLibTemplateAndGeometry(String libraryTemplate, String plateGeometry) @@ -865,22 +894,28 @@ public class SanofiDropboxJythonTest extends AbstractJythonDataSetHandlerTest private Map<String, Object> createQueryResult(String wellCode) { - return createQueryResult(wellCode, getMaterialCodeByWellCode(wellCode)); + return createQueryResult(wellCode, getBatchMaterialCodeByWellCode(wellCode), + getCompoundMaterialCodeByWellCode(wellCode)); } - private Map<String, Object> createQueryResult(String wellCode, String materialCode) + private Map<String, Object> createQueryResult(String wellCode, String batchMaterialCode, + String compoundMaterialCode) { Map<String, Object> result = new HashMap<String, Object>(); result.put("WELL_CODE", wellCode); - result.put("MATERIAL_CODE", materialCode); - result.put("ABASE_COMPOUND_ID", wellCode + "_compound_id"); - result.put("ABASE_COMPOUND_BATCH_ID", wellCode + "_compound_batch_id"); + result.put("MATERIAL_CODE", batchMaterialCode); + result.put("ABASE_COMPOUND_ID", compoundMaterialCode); return result; } - private String getMaterialCodeByWellCode(String wellCode) + private String getBatchMaterialCodeByWellCode(String wellCode) + { + return wellCode + "_batch_material"; + } + + private String getCompoundMaterialCodeByWellCode(String wellCode) { - return wellCode + "_material_code"; + return wellCode + "_compound_material"; } @Override