Example #1
0
 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 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)
Example #3
0
    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 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
Example #5
0
 def make_well_sample(x_pos=None, y_pos=None):
     ws = WellSampleI()
     image = itest.new_image(name=itest.uuid())
     ws.image = image
     if x_pos is not None:
         ws.posX = LengthI(x_pos, UnitsLength.REFERENCEFRAME)
     if y_pos is not None:
         ws.posY = LengthI(y_pos, UnitsLength.REFERENCEFRAME)
     return ws
 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
Example #7
0
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)
Example #8
0
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 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)
Example #11
0
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 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 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 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
Example #15
0
    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
Example #16
0
 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)
Example #17
0
    def image_well_plate(self):
        """
        Returns a new OMERO Project, linked Dataset and linked Image populated
        by an L{test.integration.library.ITest} instance with required fields
        set.
        """
        plate = PlateI()
        plate.name = rstring(self.uuid())
        plate = self.update.saveAndReturnObject(plate)

        well = WellI()
        well.plate = plate
        well = self.update.saveAndReturnObject(well)

        image = self.new_image(name=self.uuid())

        ws = WellSampleI()
        ws.image = image
        ws.well = well
        well.addWellSample(ws)
        ws = self.update.saveAndReturnObject(ws)
        return plate, well, ws.image
Example #18
0
    def image_well_plate(self):
        """
        Returns a new OMERO Project, linked Dataset and linked Image populated
        by an L{test.integration.library.ITest} instance with required fields
        set.
        """
        plate = PlateI()
        plate.name = rstring(self.uuid())
        plate = self.update.saveAndReturnObject(plate)

        well = WellI()
        well.plate = plate
        well = self.update.saveAndReturnObject(well)

        image = self.new_image(name=self.uuid())

        ws = WellSampleI()
        ws.image = image
        ws.well = well
        well.addWellSample(ws)
        ws = self.update.saveAndReturnObject(ws)
        return plate, well, ws.image
Example #19
0
def project_structure(conn, timestamp, image_fixture):
    """
    Project              Dataset           Image
    -------              -------           -----
    proj   ---->    ds    ---->            im0

    Screen        Plate         Well          Image
    ------        -----         ----          -----
    screen ---->  plate ---->   well   ----->  im1
    """

    proj_name = "proj_" + timestamp
    proj_id = ezomero.post_project(conn, proj_name)

    ds_name = "ds_" + timestamp
    ds_id = ezomero.post_dataset(conn, ds_name, project_id=proj_id)

    im_name = 'im_' + timestamp
    im_id = ezomero.post_image(conn, image_fixture, im_name, dataset_id=ds_id)

    update_service = conn.getUpdateService()

    # Create Screen
    screen_name = "screen_" + timestamp
    screen = ScreenWrapper(conn, ScreenI())
    screen.setName(screen_name)
    screen.save()
    screen_id = screen.getId()

    # Create Plate
    plate_name = "plate_" + timestamp
    plate = PlateWrapper(conn, PlateI())
    plate.setName(plate_name)
    plate.save()
    plate_id = plate.getId()
    link = ScreenPlateLinkI()
    link.setParent(ScreenI(screen_id, False))
    link.setChild(PlateI(plate_id, False))
    update_service.saveObject(link)

    # Create Well
    well = WellI()
    well.setPlate(PlateI(plate_id, False))
    well.setColumn(rint(1))
    well.setRow(rint(1))
    well.setPlate(PlateI(plate_id, False))

    # Create Well Sample with Image
    ws = WellSampleI()
    im_id1 = ezomero.post_image(conn, image_fixture, "well image")
    ws.setImage(ImageI(im_id1, False))
    well.addWellSample(ws)
    well_obj = update_service.saveAndReturnObject(well)
    well_id = well_obj.getId().getValue()

    return ({
        'proj': proj_id,
        'ds': ds_id,
        'im': im_id,
        'screen': screen_id,
        'plate': plate_id,
        'well': well_id,
        'im1': im_id1
    })
 def make_well_sample():
     ws = WellSampleI()
     image = itest.new_image(name=itest.uuid())
     ws.image = image
     return ws
 def make_well_sample():
     ws = WellSampleI()
     image = itest.new_image(name=itest.uuid())
     ws.image = image
     return ws