Difference between revisions of "Omero-pychrm"
Jump to navigation
Jump to search
(Created page with "==General== * [https://github.com/manics/omero-pychrm repository] ==OmeroPychrm scripts== ===__init__.py=== * empty ===TableConnection.py=== <pre class="brush:python"> clas...") |
|||
Line 1: | Line 1: | ||
==General== | ==General== | ||
* [https://github.com/manics/omero-pychrm repository] | * [https://github.com/manics/omero-pychrm repository] | ||
+ | |||
+ | ==BlitzGateway== | ||
+ | * blitz_gateway - python bindings and wrappers to access an OMERO blitz server | ||
+ | * script location in $OMERO_HOME/lib/python/omero/gateway/ | ||
+ | ===__init__.py=== | ||
+ | * where all the magic happens | ||
+ | * <code>BlitzGateway = _BlitzGateway</code> | ||
==OmeroPychrm scripts== | ==OmeroPychrm scripts== | ||
Line 38: | Line 45: | ||
def openTable(self, tableId): | def openTable(self, tableId): | ||
"""Opens an existing table by ID""" | """Opens an existing table by ID""" | ||
− | + | ofile = self.conn.getObject("OriginalFile", attributes = {'id': long(tableId)}) | |
+ | if not ofile: | ||
+ | raise TableConnectionError('No table found with id:%s' % tableId) | ||
+ | def findByName(self): | ||
+ | """Searches for OriginalFile objects by name, does not check whether file is a table""" | ||
+ | return self.conn.getObjects("OriginalFile", attributes = {'name': self.tableName} ) | ||
+ | def deleteAllTables(self): | ||
+ | """Delete all tables with tableName. Will fail if there are any annotation links.""" | ||
+ | ofiles = self.conn.getObjects("OriginalFile", attributes = {'name': self.tableName}) | ||
+ | ids = [f.getId() for f in ofiles] | ||
+ | elf.conn.deleteObjects('OriginalFile', ids) | ||
</pre> | </pre> | ||
Revision as of 20:24, 18 June 2013
Contents
General
BlitzGateway
- blitz_gateway - python bindings and wrappers to access an OMERO blitz server
- script location in $OMERO_HOME/lib/python/omero/gateway/
__init__.py
- where all the magic happens
BlitzGateway = _BlitzGateway
OmeroPychrm scripts
__init__.py
- empty
TableConnection.py
class PychrmStorageError(Exception): pass class Connection(object): def __init__(self, user = None, passwd = None, host = None, client = None): """A wrapper for omero.client.""" self.log = logging.getLogger(__name__) self.conn = BlitzGateway(client_obj = client) self.res = omero.client.getSession().sharedResources() def __enter__(self): return self.log.debug('Entering Connection') def __exit__(self): self.log.debug('Exiting Connection') self.conn._closeSession() class TableConnection(Connection): """A basic client-side wrapper for OMERO.tables which handles opening and closing tables.""" def __init__(self, user = None, passwd = None, host = None, client = None, tableName = None): """Create a new table handler, either by specifying user and passwd or by providing a client object (for scripts).""" # call base class constructor self.rid = self.res.repositories().descriptions[0].id.val self.tableName = tableName self.tableId = None self.table = None def close(self, parent=True): """standard cleanup stuff""" pass def openTable(self, tableId): """Opens an existing table by ID""" ofile = self.conn.getObject("OriginalFile", attributes = {'id': long(tableId)}) if not ofile: raise TableConnectionError('No table found with id:%s' % tableId) def findByName(self): """Searches for OriginalFile objects by name, does not check whether file is a table""" return self.conn.getObjects("OriginalFile", attributes = {'name': self.tableName} ) def deleteAllTables(self): """Delete all tables with tableName. Will fail if there are any annotation links.""" ofiles = self.conn.getObjects("OriginalFile", attributes = {'name': self.tableName}) ids = [f.getId() for f in ofiles] elf.conn.deleteObjects('OriginalFile', ids)
PychrmStorage.py
class PychrmStorageError(Exception): pass def parseFeatureName( name ): """Separate bin number and feature group name""" pass def createFeatureName(ft, idx): """Concatenate feature group name and feature bin number""" pass def featureSizes(names): """Return a dictionary of feature groups and corresponding numbers of features in them""" pass