Skip to content

Commit

Permalink
Flake8 remaining examples Python files
Browse files Browse the repository at this point in the history
  • Loading branch information
sbesson committed Dec 15, 2014
1 parent bc386dd commit 54abbb5
Show file tree
Hide file tree
Showing 14 changed files with 87 additions and 72 deletions.
2 changes: 1 addition & 1 deletion examples/Delete/Callback.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
print "ERROR: Failed to cancel"

reports = deleteHandlePrx.report()
r = reports[0] # We only sent one command
r = reports[0] # We only sent one command
print "Report:error=%s,warning=%s,deleted=%s" % \
(r.error, r.warning, r.actualDeletes)

Expand Down
5 changes: 3 additions & 2 deletions examples/Delete/FileAnnotationDelete.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@
c = omero.client()
ice_config = c.getProperty("Ice.Config")

from omero.rtypes import *
from omero.model import *
from omero.rtypes import rstring
from omero.model import DatasetI, FileAnnotationI, OriginalFileI
from omero.model import DatasetAnnotationLinkI

try:
s = c.createSession()
Expand Down
2 changes: 1 addition & 1 deletion examples/Delete/Options.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
print "ERROR: Failed to cancel"

reports = deleteHandlePrx.report()
r = reports[0] # We only sent one command
r = reports[0] # We only sent one command
print "Report:error=%s,warning=%s,deleted=%s" % \
(r.error, r.warning, r.actualDeletes)

Expand Down
5 changes: 3 additions & 2 deletions examples/Delete/Subclass.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
c = omero.client()
s = c.createSession()


class Subclass(omero.callbacks.DeleteCallbackI):

def finished(self, errors):
Expand All @@ -19,8 +20,8 @@ def finished(self, errors):
try:
reports = self.handle.report()
for r in reports:
print "Report:error=%s,warning=%s,deleted=%s" % \
(r.error, r.warning, r.actualDeletes)
print "Report:error=%s,warning=%s,deleted=%s" % (
r.error, r.warning, r.actualDeletes)

except omero.ServerError:
print "Something happened to the handle?!?"
Expand Down
10 changes: 4 additions & 6 deletions examples/OmeroTables/first.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import omero
import omero_Tables_ice
import omero_SharedResources_ice

c = omero.client()
s = c.createSession()
r = s.sharedResources()
m = r.repositories()
i = m.descriptions[0].id.val
t = r.newTable(i, "/example.h5")
l = omero.grid.LongColumn('name','desc',None)
l = omero.grid.LongColumn('name', 'desc', None)
t.initialize([l])
l.values = [1,2,3,4]
l.values = [1, 2, 3, 4]
t.addData([l])
ids = t.getWhereList('(name==1)',{},0,0,0)
ids = t.getWhereList('(name==1)', {}, 0, 0, 0)
data = t.readCoordinates(ids)
print data.columns[0].values[0]
data = t.slice([0],[0])
data = t.slice([0], [0])
print data.columns[0].values[0]
17 changes: 6 additions & 11 deletions examples/OmeroTables/iroi.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,18 @@
# -*- coding: utf-8 -*-
import omero
import omero.clients
import omero_Tables_ice
import omero_api_IRoi_ice
import omero_SharedResources_ice

from omero.rtypes import *
from omero.rtypes import rstring, rtime

c = omero.client()
s = c.createSession()

# Create a table
table = s.sharedResources().newTable(1,"iroi.h5")
table = s.sharedResources().newTable(1, "iroi.h5")
cols = []
cols.append( omero.grid.RoiColumn('roi_id','Roi ID', None) )
cols.append( omero.grid.DoubleColumn('area','Area of ROI', None) )
cols.append( omero.grid.LongColumn('intensity','Intensity of ROI', None) )
cols.append(omero.grid.RoiColumn('roi_id', 'Roi ID', None))
cols.append(omero.grid.DoubleColumn('area', 'Area of ROI', None))
cols.append(omero.grid.LongColumn('intensity', 'Intensity of ROI', None))
table.initialize(cols)
file = table.getOriginalFile()

Expand All @@ -39,12 +36,10 @@
plate = s.getUpdateService().saveAndReturnObject(plate)
image_id = plate.copyWells()[0].copyWellSamples()[0].image.id.val

# http://hudson.openmicroscopy.org.uk/job/OMERO/javadoc/slice2html/omero/api/IRoi.html#IRoi
roi_svc = s.getRoiService()
roi_meas = roi_svc.getRoiMeasurements(image_id, None)

if len(roi_meas) > 0:
roi_result = roi_svc.getMeasuredRois(image_id, roi_meas[0].id.val, None)
table = roi_svc.getTable(roi_meas[0].id.val)
print table.slice([0],None) # All of column 1

print table.slice([0], None) # All of column 1
2 changes: 1 addition & 1 deletion examples/RegionsOfInterest/Main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# -*- coding: utf-8 -*-
import omero
import omero.clients
from omero.rtypes import *
from omero.rtypes import rdouble

roi = omero.model.RoiI()
ellipse = omero.model.EllipseI()
Expand Down
27 changes: 15 additions & 12 deletions examples/ScreenPlateWell/imagesperwell.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,18 @@
# -*- coding: utf-8 -*-
import sys
import omero
from omero.rtypes import *
from omero_sys_ParametersI import ParametersI # Temporary
from omero.rtypes import rint
from omero_sys_ParametersI import ParametersI # Temporary

c = omero.client();
s = c.createSession();
q = s.getQueryService();
c = omero.client()
s = c.createSession()
q = s.getQueryService()

LOAD_WELLS = """select w from Well w join fetch w.wellSamples ws
join fetch ws.image i join fetch i.pixels p where w.plate.id = :id"""
LOAD_WELLS = (
"select w from Well w join fetch w.wellSamples ws"
" join fetch ws.image i join fetch i.pixels p where w.plate.id = :id")

filter = omero.sys.Filter();
filter = omero.sys.Filter()
filter.limit = rint(10)
filter.offset = rint(0)

Expand All @@ -24,7 +25,8 @@
else:
import random
example_plate = random.choice(plates)
print "Loading wells for Plate %s (%s)" % (example_plate.getId().getValue(), example_plate.getName().getValue())
print "Loading wells for Plate %s (%s)" % (
example_plate.getId().getValue(), example_plate.getName().getValue())

# An example of true paging
filter.limit = rint(12)
Expand All @@ -40,7 +42,7 @@
break
else:
offset += len(wells)
params.theFilter.offset = rint( offset )
params.theFilter.offset = rint(offset)

for well in wells:
id = well.getId().getValue()
Expand All @@ -54,6 +56,7 @@
sizeC = pix.sizeC.val
sizeT = pix.sizeT.val
sizeZ = pix.sizeZ.val
images.append( img.getId().getValue() )
images.append(img.getId().getValue())
planes += sizeZ*sizeT*sizeC
print "Well %s (%2sx%2s) contains the images: %s with %s planes" % (id, row, col, images, planes)
print ("Well %s (%2sx%2s) contains the images: %s with %s planes"
% (id, row, col, images, planes))
38 changes: 20 additions & 18 deletions examples/ScreenPlateWell/listplates.py
Original file line number Diff line number Diff line change
@@ -1,44 +1,46 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import omero
from omero_sys_ParametersI import ParametersI # Temporary
from omero_sys_ParametersI import ParametersI # Temporary

c = omero.client();
s = c.createSession();
q = s.getQueryService();
c = omero.client()
s = c.createSession()
q = s.getQueryService()

QUERY = 'select p from Plate p left outer join fetch p.wells w left outer join fetch w.wellSamples s left outer join fetch s.image where p.id = :id';
QUERY = ("select p from Plate p left outer join fetch p.wells w"
" left outer join fetch w.wellSamples s"
" left outer join fetch s.image where p.id = :id")

filter = omero.sys.Filter();
plates = q.findAll('Plate', filter);
filter = omero.sys.Filter()
plates = q.findAll('Plate', filter)


print 'Plate:'
for i in range(len(plates)):
params = ParametersI();
params.addId(plates[i].getId().getValue());
plate = q.findByQuery(QUERY, params);
print ' %d %s ' % ( i, plate.getName().getValue() )
params = ParametersI()
params.addId(plates[i].getId().getValue())
plate = q.findByQuery(QUERY, params)
print ' %d %s ' % (i, plate.getName().getValue())
wells = {}

for well in plate.copyWells():
row = well.getRow() and well.getRow().getValue() or -1
col = well.getColumn() and well.getColumn().getValue() or -1
if row in wells:
row_list = wells[row];
row_list = wells[row]
else:
row_list = []
wells[row] = row_list;
row_list.append(col);
wells[row] = row_list
row_list.append(col)
row_list.sort()

rows = list(wells.keys());
rows = list(wells.keys())
rows.sort()

for row in rows:
msg = ' ';
col_list = list(wells[row]);
msg = ' '
col_list = list(wells[row])
col_list.sort()
for col in col_list:
msg += '%2dx%2d ' % (row, col);
msg += '%2dx%2d ' % (row, col)
print msg
31 changes: 19 additions & 12 deletions examples/ScreenPlateWell/platecodebyimage.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import omero
from omero.rtypes import *
from omero_sys_ParametersI import ParametersI # Temporary
from omero.rtypes import rint
from omero_sys_ParametersI import ParametersI # Temporary

c = omero.client();
s = c.createSession();
q = s.getQueryService();
c = omero.client()
s = c.createSession()
q = s.getQueryService()

GET_IMAGES_WITH_PLATES = 'select i from Image i join i.wellSamples ws join ws.well w join w.plate p' # Inner joins
GET_PLATE_FROM_IMAGE_ID = 'select p from Plate p join p.wells w join w.wellSamples ws join ws.image i where i.id = :id'
GET_IMAGES_WITH_PLATES = (
"select i from Image i join i.wellSamples ws join ws.well w"
" join w.plate p") # Inner joins
GET_PLATE_FROM_IMAGE_ID = (
"select p from Plate p join p.wells w join w.wellSamples ws"
" join ws.image i where i.id = :id")

filter = omero.sys.Filter();
filter = omero.sys.Filter()
filter.limit = rint(100)
filter.offset = rint(0)
params = ParametersI()
Expand All @@ -22,7 +26,10 @@

for image in images:

params = ParametersI();
params.addId(image.getId().getValue());
plate = q.findByQuery(GET_PLATE_FROM_IMAGE_ID, params); # Multiple plates per image will through an exception
print 'Image %s belongs to Plate %s (%s)' % ( image.getId().getValue(), plate.getId().getValue(), plate.getName().getValue() )
params = ParametersI()
params.addId(image.getId().getValue())
# Multiple plates per image will through an exception
plate = q.findByQuery(GET_PLATE_FROM_IMAGE_ID, params)
print 'Image %s belongs to Plate %s (%s)' % (
image.getId().getValue(), plate.getId().getValue(),
plate.getName().getValue())
12 changes: 8 additions & 4 deletions examples/TreeList/AllProjects.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import omero
from omero.rtypes import *

from omero.rtypes import rstring
from omero_sys_ParametersI import ParametersI


def getProjects(query_prx, username):
return query_prx.findAllByQuery(
"select p from Project p join fetch p.datasetLinks dil join fetch dil.child where p.details.owner.omeName = :name",
ParametersI().add("name", rstring(username)))
"select p from Project p"
" join fetch p.datasetLinks dil"
" join fetch dil.child"
" where p.details.owner.omeName = :name",
ParametersI().add("name", rstring(username)))
5 changes: 3 additions & 2 deletions examples/TreeList/Main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
# -*- coding: utf-8 -*-
import sys
import omero
import Usage, AllProjects, PrintProjects
import Usage
import AllProjects
import PrintProjects

if __name__ == "__main__":
try:
Expand All @@ -20,4 +22,3 @@
PrintProjects.print_(projects)
finally:
client.closeSession()

2 changes: 2 additions & 0 deletions examples/TreeList/PrintProjects.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-


def print_(projects):
for project in projects:
print project.getName().val
Expand Down
1 change: 1 addition & 0 deletions examples/TreeList/Usage.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# -*- coding: utf-8 -*-
import sys


def usage():
print"TreeList.Main host port username password"
sys.exit(-2)

0 comments on commit 54abbb5

Please sign in to comment.