def screen_plate_run_well(request, itest, update_service): """ Returns a new OMERO Screen, linked Plate, linked Well, linked WellSample, linked Image populate by an L{test.integration.library.ITest} instance and linked PlateAcquisition with all required fields set. """ screen = ScreenI() screen.name = rstring(itest.uuid()) plate = PlateI() plate.name = rstring(itest.uuid()) # Well A10 (will have two WellSamples) well_a = WellI() well_a.row = rint(0) well_a.column = rint(9) # Well A11 (will not have a WellSample) well_b = WellI() well_b.row = rint(0) well_b.column = rint(10) ws_a = WellSampleI() image_a = itest.new_image(name=itest.uuid()) ws_a.image = image_a ws_b = WellSampleI() image_b = itest.new_image(name=itest.uuid()) ws_b.image = image_b plate_acquisition = PlateAcquisitionI() plate_acquisition.plate = plate ws_a.plateAcquisition = plate_acquisition ws_b.plateAcquisition = plate_acquisition well_a.addWellSample(ws_a) well_a.addWellSample(ws_b) plate.addWell(well_a) plate.addWell(well_b) screen.linkPlate(plate) return update_service.saveAndReturnObject(screen)
def screen_plate_run_well(self): """ Returns a new OMERO Screen, linked Plate, linked Well, linked WellSample, linked Image populate by an L{test.integration.library.ITest} instance and linked PlateAcquisition with all required fields set. """ screen = ScreenI() screen.name = rstring(self.uuid()) plate = PlateI() plate.name = rstring(self.uuid()) # Well A10 (will have two WellSamples) well_a = WellI() well_a.row = rint(0) well_a.column = rint(9) # Well A11 (will not have a WellSample) well_b = WellI() well_b.row = rint(0) well_b.column = rint(10) ws_a = WellSampleI() image_a = self.new_image(name=self.uuid()) ws_a.image = image_a ws_b = WellSampleI() image_b = self.new_image(name=self.uuid()) ws_b.image = image_b plate_acquisition = PlateAcquisitionI() plate_acquisition.plate = plate ws_a.plateAcquisition = plate_acquisition ws_b.plateAcquisition = plate_acquisition well_a.addWellSample(ws_a) well_a.addWellSample(ws_b) plate.addWell(well_a) plate.addWell(well_b) screen.linkPlate(plate) return self.update.saveAndReturnObject(screen)
def screen_plates(self, user1): """Return Screen with Plates and an orphaned Plate.""" # Create and name all the objects screen = ScreenI() screen.name = rstring('screen') for i in range(5): plate1 = PlateI() plate1.name = rstring('Plate%s' % i) screen.linkPlate(plate1) # Create single orphaned Plate plate = PlateI() plate.name = rstring('plate') screen = get_update_service(user1).saveAndReturnObject(screen) plate = get_update_service(user1).saveAndReturnObject(plate) # Add well to first plate plates = screen.linkedPlateList() plates.sort(cmp_name_insensitive) plate_id = plates[0].id.val well = WellI() well.column = rint(0) well.row = rint(0) well.plate = PlateI(plate_id, False) image = self.create_test_image(size_x=5, size_y=5, session=user1[0].getSession()) ws = WellSampleI() ws.image = ImageI(image.id, False) ws.well = well well.addWellSample(ws) well = get_update_service(user1).saveAndReturnObject(well) return screen, plate
def setUp(self): AbstractPlateAnalysisCtx.DEFAULT_ORIGINAL_FILE_PROVIDER = \ FromFileOriginalFileProvider original_files = list() # Create our container images and an original file image map images = list() n_images = 0 for row in range(16): for column in range(24): well = WellI(n_images, True) well.column = rint(column) well.row = rint(row) well_sample = WellSampleI(n_images, True) well_sample.well = well image = ImageI(n_images, True) image.addWellSample(well_sample) images.append(image) original_file_image_map = dict() # Our required original file format format = rstring('Companion/InCell') # Create original file representing the result file o = OriginalFileI(1L, True) o.name = rstring(self.RESULT_FILE) o.path = rstring(os.path.join(self.ROOT, self.RESULT_FILE)) o.mimetype = format original_files.append(o) #[1L] = o original_file_image_map[1L] = image sf = TestingServiceFactory() self.analysis_ctx = InCellPlateAnalysisCtx( images, original_files, original_file_image_map, 1L, sf)
def well(): """Basic Well for testing Color. Full test of Well below.""" well = WellI() well.id = rlong(1) well.column = rint(0) well.row = rint(0) return well
def setUp(self): AbstractPlateAnalysisCtx.DEFAULT_ORIGINAL_FILE_PROVIDER = \ FromFileOriginalFileProvider original_files = list() # Create our container images and an original file image map images = list() n_images = 0 for row in range(16): for column in range(24): well = WellI(n_images, True) well.column = rint(column) well.row = rint(row) well_sample = WellSampleI(n_images, True) well_sample.well = well image = ImageI(n_images, True) image.addWellSample(well_sample) images.append(image) original_file_image_map = dict() # Our required original file format format = rstring('Companion/InCell') # Create original file representing the result file o = OriginalFileI(1, True) o.name = rstring(self.RESULT_FILE) o.path = rstring(os.path.join(self.ROOT, self.RESULT_FILE)) o.mimetype = format original_files.append(o) # [1] = o original_file_image_map[1] = image sf = TestingServiceFactory() self.analysis_ctx = InCellPlateAnalysisCtx(images, original_files, original_file_image_map, 1, sf)
def createWell(row, column): well = WellI() well.row = rint(row) well.column = rint(column) ws = WellSampleI() image = self.new_image(name=uuid) ws.image = image well.addWellSample(ws) return well
def screen_with_plates(screen): for plate_id in range(5, 7): o = PlateI() o.id = rlong(plate_id) o.name = rstring('plate_name_%d' % plate_id) o.description = rstring('plate_description_%d' % plate_id) o.columnNamingConvention = rstring('number') o.rowNamingConvention = rstring('letter') o.columns = rint(12) o.rows = rint(8) o.defaultSample = rint(0) o.externalIdentifier = rstring('external_identifier_%d' % plate_id) o.status = rstring('status_%d' % plate_id) o.wellOriginX = LengthI(0.1, UnitsLength.REFERENCEFRAME) o.wellOriginY = LengthI(1.1, UnitsLength.REFERENCEFRAME) screen.linkPlate(o) for well_id in range(7, 9): well = WellI() well.id = rlong(well_id) well.column = rint(2) well.row = rint(1) well.externalDescription = \ rstring('external_description_%d' % well_id) well.externalIdentifier = \ rstring('external_identifier_%d' % well_id) well.type = rstring('the_type') well.alpha = rint(0) well.red = rint(255) well.green = rint(0) well.blue = rint(0) well.status = rstring('the_status') o.addWell(well) plateacquisition = PlateAcquisitionI() plateacquisition.id = rlong(well_id) plateacquisition.name = rstring( 'plateacquisition_name_%d' % well_id) plateacquisition.description = rstring( 'plateacquisition_description_%d' % well_id) plateacquisition.maximumFieldCount = rint(1) plateacquisition.startTime = rtime(1L) plateacquisition.endTime = rtime(2L) for wellsample_id in range(9, 11): wellsample = WellSampleI() wellsample.setPlateAcquisition(plateacquisition) wellsample.id = rlong(wellsample_id) wellsample.posX = LengthI(1.0, UnitsLength.REFERENCEFRAME) wellsample.posY = LengthI(2.0, UnitsLength.REFERENCEFRAME) wellsample.timepoint = rtime(1L) wellsample.image = create_image(1L) well.addWellSample(wellsample) return screen
def create_plate_wells(self, user1, rows, cols, plateacquisitions=1): """Return Plate with Wells.""" updateService = get_update_service(user1) plate = PlateI() plate.name = rstring('plate') plate = updateService.saveAndReturnObject(plate) # PlateAcquisitions for plate plate_acqs = [] for p in range(plateacquisitions): plate_acq = PlateAcquisitionI() plate_acq.name = rstring('plateacquisition_%s' % p) plate_acq.description = rstring('plateacquisition_description') plate_acq.maximumFieldCount = rint(3) plate_acq.startTime = rtime(1) plate_acq.endTime = rtime(2) plate_acq.plate = PlateI(plate.id.val, False) plate_acq = updateService.saveAndReturnObject(plate_acq) plate_acqs.append(plate_acq) # Create Wells for plate ref_frame = UnitsLength.REFERENCEFRAME for row in range(rows): for col in range(cols): # create Well well = WellI() well.column = rint(col) well.row = rint(row) well.plate = PlateI(plate.id.val, False) # Only wells in first Column have well-samples etc. if col == 0: # Have 3 images/well-samples per plateacquisition # (if no plateacquisitions, create 3 well-samples without) for p in range(max(1, plateacquisitions)): for i in range(3): image = self.create_test_image( size_x=5, size_y=5, session=user1[0].getSession()) ws = WellSampleI() ws.image = ImageI(image.id, False) ws.well = well ws.posX = LengthI(i * 10, ref_frame) ws.posY = LengthI(i, ref_frame) if p < len(plate_acqs): ws.setPlateAcquisition( PlateAcquisitionI(plate_acqs[p].id.val, False)) well.addWellSample(ws) updateService.saveObject(well) return plate
def screen_plate_well(self): """ Returns a new OMERO Screen, linked Plate and linked Well with required fields set. """ screen = ScreenI() screen.name = rstring(self.uuid()) plate = PlateI() plate.name = rstring(self.uuid()) # Well A10 well = WellI() well.row = rint(0) well.column = rint(9) plate.addWell(well) screen.linkPlate(plate) return self.update.saveAndReturnObject(screen)
def screen_plate_well(request, itest, update_service): """ Returns a new OMERO Screen, linked Plate and linked Well with required fields set. """ screen = ScreenI() screen.name = rstring(itest.uuid()) plate = PlateI() plate.name = rstring(itest.uuid()) # Well A10 well = WellI() well.row = rint(0) well.column = rint(9) plate.addWell(well) screen.linkPlate(plate) return update_service.saveAndReturnObject(screen)
def full_plate_wells(itest, update_service): """ Returns a full OMERO Plate, linked Wells, linked WellSamples, and linked Images populated by an L{weblibrary.IWebTest} instance. """ lett = map(chr, range(ord('A'), ord('Z')+1)) plate = PlateI() plate.name = rstring(itest.uuid()) for row in range(8): for column in range(12): well = WellI() well.row = rint(row) well.column = rint(column) ws = WellSampleI() image = itest.new_image(name=lett[row]+str(column)) ws.image = image well.addWellSample(ws) plate.addWell(well) return update_service.saveAndReturnObject(plate)
def full_plate_wells(itest, update_service): """ Returns a full OMERO Plate, linked Wells, linked WellSamples, and linked Images populated by an L{weblibrary.IWebTest} instance. """ lett = map(chr, range(ord('A'), ord('Z') + 1)) plate = PlateI() plate.name = rstring(itest.uuid()) for row in range(8): for column in range(12): well = WellI() well.row = rint(row) well.column = rint(column) ws = WellSampleI() image = itest.new_image(name=lett[row] + str(column)) ws.image = image well.addWellSample(ws) plate.addWell(well) return update_service.saveAndReturnObject(plate)
def plate(request, gatewaywrapper): """Creates a Plate.""" gatewaywrapper.loginAsAuthor() gw = gatewaywrapper.gateway update_service = gw.getUpdateService() plate = PlateI() plate.name = rstring(uuid()) for well_index in range(3): well = WellI() well.row = rint(well_index**2) well.column = rint(well_index**3) for well_sample_index in range(2): well_sample = WellSampleI() image = ImageI() image.name = rstring('%s_%d' % (uuid(), well_sample_index)) image.acquisitionDate = rtime(0) well_sample.image = image well.addWellSample(well_sample) plate.addWell(well) plate_id, = update_service.saveAndReturnIds([plate]) return gw.getObject('Plate', plate_id)
def testListParentsSPW(self): """Test listParents() for Image in WellSample""" client, exp = self.new_client_and_user() conn = BlitzGateway(client_obj=client) # setup SPW-WS-Img... s = ScreenI() s.name = wrap('ScreenA') p = PlateI() p.name = wrap('PlateA') s.linkPlate(p) w = WellI() w.column = wrap(0) w.row = wrap(0) p.addWell(w) s = client.sf.getUpdateService().saveAndReturnObject(s) p = s.linkedPlateList()[0] w = p.copyWells()[0] i = self.make_image(name="SPW listParents", client=client) ws = WellSampleI() ws.image = i ws.well = WellI(w.id.val, False) w.addWellSample(ws) ws = client.sf.getUpdateService().saveAndReturnObject(ws) # Traverse from Image -> Screen image = conn.getObject("Image", i.id.val) wellSample = image.listParents()[0] well = wellSample.listParents()[0] assert well.id == w.id.val plate = well.listParents()[0] assert plate.id == p.id.val screen = plate.listParents()[0] assert screen.id == s.id.val # Screen has no parent assert len(screen.listParents()) == 0
def test_plate(self): """Tests label methods for Plate and Well.""" name = u'plate_∞' cols = 4 rows = 3 obj = PlateI() obj.name = rstring(name) plate = MockConnection(obj).getObject("Plate", 1) assert plate.getName() == name.encode('utf8') plate._gridSize = {'rows': rows, 'columns': cols} assert plate.getColumnLabels() == [c for c in range(1, cols + 1)] assert plate.getRowLabels() == ['A', 'B', 'C'] well_obj = WellI() well_obj.column = rint(1) well_obj.row = rint(2) class MockWell(WellWrapper): def getParent(self): return plate well = MockWell(None, well_obj) assert well.getWellPos() == "C2"