Created
June 28, 2012 10:25
-
-
Save will-moore/3010533 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
""" | |
Script for switching rows / columns of wells in plate. See https://www.openmicroscopy.org/community/posting.php?mode=reply&f=4&t=1211 | |
""" | |
import omero | |
import omero.clients | |
from omero.gateway import BlitzGateway | |
from omero.rtypes import rint | |
user = 'root' | |
pw = 'ome' | |
host = 'localhost' | |
conn = BlitzGateway(user, pw, host=host, port=4064) | |
conn.connect() | |
pId = 55 | |
plate = conn.getObject("Plate", pId) | |
wells = [] | |
new_plate = omero.model.PlateI() | |
new_plate.name = omero.rtypes.rstring("Temporary plate") | |
# we're switching row & col AND moving to new plate to avoid ValidationExceptions | |
for well in plate.listChildren(): | |
c = well.column | |
r = well.row | |
well._obj.column = rint(r) | |
well._obj.row = rint(c) | |
well._obj.setPlate(new_plate) | |
wells.append(well._obj) | |
wells = conn.getUpdateService().saveAndReturnArray(wells) # Saves new Plate | |
# Now we can move wells back to the original Plate | |
for well in wells: | |
new_plate = well.getPlate() # get a ref to new Plate, so we can delete | |
well.setPlate(omero.model.PlateI(pId, False)) # Using unloaded Plate | |
conn.getUpdateService().saveAndReturnArray(wells) # Save Wells onto original Plate | |
# Finally, we can clean up by deleting our temporary plate | |
conn.getUpdateService().deleteObject(new_plate) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment