Пример #1
0
    def _test_bulk_to_map_annotation_context(self):
        # self._testPopulateMetadataPlate()
        assert len(self.get_well_annotations()) == 0

        cfg = os.path.join(
            os.path.dirname(__file__), 'bulk_to_map_annotation_context.yml')

        fileid = self.get_plate_annotations()[0].file.id.val
        ctx = BulkToMapAnnotationContext(
            self.client, self.plate, fileid=fileid, cfg=cfg)
        ctx.parse()
        assert len(self.get_well_annotations()) == 0

        ctx.write_to_omero()
        was = self.get_well_annotations()
        assert len(was) == 2

        for ma, wid, wr, wc in was:
            assert isinstance(ma, MapAnnotationI)
            assert unwrap(ma.getNs()) == NSBULKANNOTATIONS
            mv = ma.getMapValueAsMap()
            assert mv['Well'] == str(wid)
            assert coord2offset(mv['Well Name']) == (wr, wc)
            if (wr, wc) == (0, 0):
                assert mv['Well Type'] == 'Control'
                assert mv['Concentration'] == '0'
            else:
                assert mv['Well Type'] == 'Treatment'
                assert mv['Concentration'] == '10'
Пример #2
0
    def _test_bulk_to_map_annotation_context(self):
        # self._testPopulateMetadataPlate()
        assert len(self.get_well_annotations()) == 0

        cfg = os.path.join(os.path.dirname(__file__),
                           'bulk_to_map_annotation_context.yml')

        fileid = self.get_plate_annotations()[0].file.id.val
        ctx = BulkToMapAnnotationContext(self.client,
                                         self.plate,
                                         fileid=fileid,
                                         cfg=cfg)
        ctx.parse()
        assert len(self.get_well_annotations()) == 0

        ctx.write_to_omero()
        was = self.get_well_annotations()
        assert len(was) == 2

        for ma, wid, wr, wc in was:
            assert isinstance(ma, MapAnnotationI)
            assert unwrap(ma.getNs()) == NSBULKANNOTATIONS
            mv = ma.getMapValueAsMap()
            assert mv['Well'] == str(wid)
            assert coord2offset(mv['Well Name']) == (wr, wc)
            if (wr, wc) == (0, 0):
                assert mv['Well Type'] == 'Control'
                assert mv['Concentration'] == '0'
            else:
                assert mv['Well Type'] == 'Treatment'
                assert mv['Concentration'] == '10'
Пример #3
0
    def populate_data(self, csv, cfg):
        row_count = 1
        col_count = 6
        self.screen, self.plate = self.create_screen(row_count, col_count)

        ctx = ParsingContext(self.client, self.screen.proxy(), file=csv)
        ctx.parse()
        ctx.write_to_omero()

        # Get file annotations
        anns = self.get_screen_annotations()
        # Only expect a single annotation which is a 'bulk annotation'
        assert len(anns) == 1
        table_file_ann = anns[0]
        assert unwrap(table_file_ann.getNs()) == NSBULKANNOTATIONS
        fileid = table_file_ann.file.id.val

        ctx = BulkToMapAnnotationContext(
         self.client, self.screen.proxy(), fileid=fileid, cfg=cfg)
        ctx.parse()
        ctx.write_to_omero()
Пример #4
0
class PlateInfo:
    def __init__(self, i, platename):
        self.i = i
        self.name, u, v = re.match("([\w_-]+)_chamber--(U\d\d)--(V\d\d)", r[1]).groups()
        self.well = "%s%s" % (u, v)


plateinfos = [PlateInfo(r[0], r[1]) for r in rs]

names_csv = set(df["Plate"])
names_run = set(pm.name for pm in plateinfos)
# Check all plates have an entry in the CSV
missing = names_run.difference(names_csv)
if missing:
    msg = "No matching annotations found for:%s\n" % ("\n".join(missing))
    if ignore_missing:
        warnings.warn(msg)
    else:
        raise Exception(msg)

links = []
for pm in plateinfos:
    r = df.loc[(df["Plate"] == pm.name) & (df["Well"] == pm.well), :]
    target = omero.model.PlateI(pm.i, False)
    rowkvs = zip(r.columns, r.values.squeeze())
    link = BulkToMapAnnotationContext.create_map_annotation([target], rowkvs, ns)
    links.extend(link)

ids = us.saveAndReturnIds(links)
print "Created MapAnnotation links: %s" % ids
        self.i = i
        self.name, u, v = re.match('([\w_-]+)_chamber--(U\d\d)--(V\d\d)',
                                   r[1]).groups()
        self.well = "%s%s" % (u, v)


plateinfos = [PlateInfo(r[0], r[1]) for r in rs]

names_csv = set(df['Plate'])
names_run = set(pm.name for pm in plateinfos)
# Check all plates have an entry in the CSV
missing = names_run.difference(names_csv)
if missing:
    msg = 'No matching annotations found for:%s\n' % ('\n'.join(missing))
    if ignore_missing:
        warnings.warn(msg)
    else:
        raise Exception(msg)

links = []
for pm in plateinfos:
    r = df.loc[(df['Plate'] == pm.name) & (df['Well'] == pm.well), :]
    target = omero.model.PlateI(pm.i, False)
    rowkvs = zip(r.columns, r.values.squeeze())
    link = BulkToMapAnnotationContext.create_map_annotation([target], rowkvs,
                                                            ns)
    links.extend(link)

ids = us.saveAndReturnIds(links)
print 'Created MapAnnotation links: %s' % ids