schrodinger.infra.table module

A pythonic wrapper to an mmlibs mmtable object.

Note that column and row indices start at 1.

Copyright Schrodinger, LLC. All rights reserved.

class schrodinger.infra.table.TableRow(table, row)

Bases: object

This class represents a table row–what you get by indexing a Table.

Note that a TableRow should not outlive its corresponding Table.

__init__(table, row)

Construct a Table Row for the given table handle and row number

__repr__()

Return representation suitable for use as a Python expression

__getitem__(prop)

Return Table Row cell value or None if the cell doesn’t have a value

prop is the name of the property (column). This can either be a data name or a user name.

prop can also be the index of a column

__setitem__(prop, value)

Set Table Row cell value

prop is the name of the property (column), i.e. the key. This can either be the data name or the user name

prop can also be the index of a column

__class__

alias of builtins.type

__delattr__

Implement delattr(self, name).

__dict__ = mappingproxy({'__module__': 'schrodinger.infra.table', '__doc__': '\n This class represents a table row--what you get by indexing a Table.\n\n Note that a TableRow should not outlive its corresponding Table.\n ', '__init__': <function TableRow.__init__>, '__repr__': <function TableRow.__repr__>, '__getitem__': <function TableRow.__getitem__>, '__setitem__': <function TableRow.__setitem__>, '_setValue': <function TableRow._setValue>, '__dict__': <attribute '__dict__' of 'TableRow' objects>, '__weakref__': <attribute '__weakref__' of 'TableRow' objects>})
__dir__() → list

default dir() implementation

__eq__

Return self==value.

__format__()

default object formatter

__ge__

Return self>=value.

__getattribute__

Return getattr(self, name).

__gt__

Return self>value.

__hash__

Return hash(self).

__init_subclass__()

This method is called when a class is subclassed.

The default implementation does nothing. It may be overridden to extend subclasses.

__le__

Return self<=value.

__lt__

Return self<value.

__module__ = 'schrodinger.infra.table'
__ne__

Return self!=value.

__new__()

Create and return a new object. See help(type) for accurate signature.

__reduce__()

helper for pickle

__reduce_ex__()

helper for pickle

__setattr__

Implement setattr(self, name, value).

__sizeof__() → int

size of object in memory, in bytes

__str__

Return str(self).

__subclasshook__()

Abstract classes can override this to customize issubclass().

This is invoked early on by abc.ABCMeta.__subclasscheck__(). It should return True, False or NotImplemented. If it returns NotImplemented, the normal algorithm is used. Otherwise, it overrides the normal algorithm (and the outcome is cached).

__weakref__

list of weak references to the object (if defined)

class schrodinger.infra.table.Table(table_file='', table_handle=None, manage=True)

Bases: schrodinger.infra.mmobject.MmObject

Class to handle mmtables. This is largely a wrapper to the underlying C library which stores all the state information.

static setDebug(state)

Enable or disable debug output. Use False or True. Sets this for the class, i.e. affects all instances, current and future.

static initialize(error_handler=None)

Initialize necessary mmlibs (which will also implicitly initialize all the dependent mmlibs)

static terminate()

Terminate various mmlibs (which also implicitly terminates all the libraries they are dependent upon)

__init__(table_file='', table_handle=None, manage=True)

Construct a Table class object either by reading a table file or using a handle to an existing mmtable.

If a table file is given via table_file, then we read the given mmtable file. If a table handle for an existing table is passed in (via the table_handle argument), then we use that. If neither are given, then we create a new table object owned by this table. Specifying both is an error.

Passing in a table file causes manage=True. When a managed instance goes out of scope or is deleted, garbage collection is performed. One side effect is that the table is deleted.

Passing in a table handle causes manage=False. When a non-managed instance goes out of scope or is deleted the table is left around.

__repr__()

Return representation suitable for use as a Python expression

__str__()

Return string representation

__int__()

Return mmtable handle. Can be used with mmtable functions.

__len__()

Return the number of rows in the table

__getitem__(item)

Returns Table Row (if item is an integer) or table property (if item is a string)

__setitem__(item, value)

This function sets a table-level property

__iter__()

Return an iterator object

Allows iteration over the selected rows.

To iterate over all rows use: ‘for row in range(1, len(table)+1)’

cellClearData(row, column)

Clears any data in the given cell

cellHasData(row, column)

Indicates whether or not the given cell has data

columnGetDataName(column)

Returns the data name for the given column

columnGetDataType(column)

Returns the data type for the given column

Possibilities are: mm.M2IO_BOOLEAN_TYPE, mm.M2IO_INT_TYPE, mm.M2IO_REAL_TYPE, or mm.M2IO_STRING_TYPE

columnGetName(column)

Returns the user name for the given column

columnGetPersistent(column)

Returns whether or not the given column is persistent. Only persistent columns will be written to disk.

columnGetProperty(column, prop)

Returns the value of the given property for the column

columnGetVisible(column)

Returns the visible property for the given column

columnGetWidth(column)

Returns the width in characters of the given column

columnSetName(column, name)

Sets the user name for the given column

columnSetPersistent(column, persistent)

Sets whether or not the given row is persistent. Only persistent columns will be written to disk.

columnSetProperty(column, prop, value)

Sets the value of the given property for the column

columnSetVisible(column, visible)

Sets the visible property for the given column

columnSetWidth(column, width)

Sets the width in characters for the given column

deleteAllRows()

Deletes all rows from the table

deleteColumn(column)

Delets the given column

deleteRow(row)

Deletes the given row

getColumnIndex(name)

Returns the column index for the given user or data name

getColumnNames()

Return a list of the column data names in this table

getColumnTotal()

Returns the number of columns in the table

getFirstSelectedRow()

Returns the first selected row–throws an error if no rows are selected.

getOrAddColumn(name, visible)

Finds or adds the given column via data name.

visible indicates whether or not the column should be visible if it is added.

getSelectedRows()

Returns a bitset containing the selected rows

getSelectedRowTotal()

Return the total number of selected rows

getVisibleColumnTotal()

Returns the number of visible columns

getVisibleColumnIndex(column)

Converts an index from the visible columns into the full set of columns

getVisibleRowIndex(row)

Converts an index from the visible rows into the full set of rows

getVisibleRowTotal()

Returns the number of visible rows

insertColumn(column, name)

Adds the given column before the specified column. Specify column 1 to insert at the far left of the table (first column) Specify mm.MMTABLE_END to add to the right of the table

insertRow(row, file_index)

Adds a row.

Set row to 1 to insert at the top of the table or mm.MMTABLE_END to add to the bottom of the table.

If the table has an M2IO_DATA_FILE_INDEX column, the cell’s value will be set to file_index (if file_index != 0), or to a unique value if file_index == 0.

isRowSelected(row)

Returns True if the given row is selected, or False otherwise

keys()

Returns the column data names

makeNestedRowVisible(row)

Expands and makes visible all parents of the given row. Also makes the given row visible, but does not expand it.

moveColumn(from_column, to_column)

Moves the given column to the destination column

moveRows(from_rows, to_row)

Moves the given rows to the destination row

rowGetExpanded(row)

Indicates whether or not the given row is expanded

rowGetVisible(row)

Returns the visible property for the given row

rowSetExpanded(row, expanded)

Sets the expanded property for the given row. The row can also be set to mm.MMTABLE_ALL_ROWS.

rowSetVisible(row, visible)

Sets the visible property for the given row. The row can also be set to mm.MMTABLE_ALL_ROWS.

__class__

alias of builtins.type

__del__()

Decrement the reference count. If the handle is being actively managed, call _delete when it the count hits zero.

__delattr__

Implement delattr(self, name).

__dict__ = mappingproxy({'__module__': 'schrodinger.infra.table', '__doc__': '\n Class to handle mmtables. This is largely a wrapper to\n the underlying C library which stores all the state information.\n\n ', '_instances': {}, '_debug': False, 'setDebug': <staticmethod object>, '_printDebug': <staticmethod object>, 'initialize': <staticmethod object>, 'terminate': <staticmethod object>, '__init__': <function Table.__init__>, '_delete': <function Table._delete>, '__repr__': <function Table.__repr__>, '__str__': <function Table.__str__>, '__int__': <function Table.__int__>, '__len__': <function Table.__len__>, '__getitem__': <function Table.__getitem__>, '__setitem__': <function Table.__setitem__>, '__iter__': <function Table.__iter__>, 'cellClearData': <function Table.cellClearData>, 'cellHasData': <function Table.cellHasData>, 'columnGetDataName': <function Table.columnGetDataName>, 'columnGetDataType': <function Table.columnGetDataType>, 'columnGetName': <function Table.columnGetName>, 'columnGetPersistent': <function Table.columnGetPersistent>, 'columnGetProperty': <function Table.columnGetProperty>, 'columnGetVisible': <function Table.columnGetVisible>, 'columnGetWidth': <function Table.columnGetWidth>, 'columnSetName': <function Table.columnSetName>, 'columnSetPersistent': <function Table.columnSetPersistent>, 'columnSetProperty': <function Table.columnSetProperty>, 'columnSetVisible': <function Table.columnSetVisible>, 'columnSetWidth': <function Table.columnSetWidth>, 'deleteAllRows': <function Table.deleteAllRows>, 'deleteColumn': <function Table.deleteColumn>, 'deleteRow': <function Table.deleteRow>, 'getColumnIndex': <function Table.getColumnIndex>, 'getColumnNames': <function Table.getColumnNames>, 'getColumnTotal': <function Table.getColumnTotal>, 'getFirstSelectedRow': <function Table.getFirstSelectedRow>, 'getOrAddColumn': <function Table.getOrAddColumn>, 'getSelectedRows': <function Table.getSelectedRows>, 'getSelectedRowTotal': <function Table.getSelectedRowTotal>, 'getVisibleColumnTotal': <function Table.getVisibleColumnTotal>, 'getVisibleColumnIndex': <function Table.getVisibleColumnIndex>, 'getVisibleRowIndex': <function Table.getVisibleRowIndex>, 'getVisibleRowTotal': <function Table.getVisibleRowTotal>, 'insertColumn': <function Table.insertColumn>, 'insertRow': <function Table.insertRow>, 'isRowSelected': <function Table.isRowSelected>, 'keys': <function Table.keys>, 'makeNestedRowVisible': <function Table.makeNestedRowVisible>, 'moveColumn': <function Table.moveColumn>, 'moveRows': <function Table.moveRows>, 'rowGetExpanded': <function Table.rowGetExpanded>, 'rowGetVisible': <function Table.rowGetVisible>, 'rowSetExpanded': <function Table.rowSetExpanded>, 'rowSetVisible': <function Table.rowSetVisible>, 'selectAddRows': <function Table.selectAddRows>, 'selectRows': <function Table.selectRows>, 'sortRows': <function Table.sortRows>, 'unselectRows': <function Table.unselectRows>})
__dir__() → list

default dir() implementation

__eq__

Return self==value.

__format__()

default object formatter

__ge__

Return self>=value.

__getattribute__

Return getattr(self, name).

__gt__

Return self>value.

__hash__

Return hash(self).

__init_subclass__()

This method is called when a class is subclassed.

The default implementation does nothing. It may be overridden to extend subclasses.

__le__

Return self<=value.

__lt__

Return self<value.

__module__ = 'schrodinger.infra.table'
__ne__

Return self!=value.

__new__()

Create and return a new object. See help(type) for accurate signature.

__reduce__()

helper for pickle

__reduce_ex__()

helper for pickle

__setattr__

Implement setattr(self, name, value).

__sizeof__() → int

size of object in memory, in bytes

__subclasshook__()

Abstract classes can override this to customize issubclass().

This is invoked early on by abc.ABCMeta.__subclasscheck__(). It should return True, False or NotImplemented. If it returns NotImplemented, the normal algorithm is used. Otherwise, it overrides the normal algorithm (and the outcome is cached).

__weakref__

list of weak references to the object (if defined)

selectAddRows(rows)

This function selects the given rows without deselecting any other rows.

selectRows(rows)

This function selects only the given rows.

sortRows(column, ascending)

Sorts the rows by the given column in either ascending or descending order

unselectRows(rows)

This function unselects the given rows