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)[source]

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)[source]

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

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

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)[source]

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)[source]

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

static terminate()[source]

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

__init__(table_file='', table_handle=None, manage=True)[source]

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.

__len__()[source]

Return the number of rows in the table

cellClearData(row, column)[source]

Clears any data in the given cell

cellHasData(row, column)[source]

Indicates whether or not the given cell has data

columnGetDataName(column)[source]

Returns the data name for the given column

columnGetDataType(column)[source]

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)[source]

Returns the user name for the given column

columnGetPersistent(column)[source]

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

columnGetProperty(column, prop)[source]

Returns the value of the given property for the column

columnGetVisible(column)[source]

Returns the visible property for the given column

columnGetWidth(column)[source]

Returns the width in characters of the given column

columnSetName(column, name)[source]

Sets the user name for the given column

columnSetPersistent(column, persistent)[source]

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

columnSetProperty(column, prop, value)[source]

Sets the value of the given property for the column

columnSetVisible(column, visible)[source]

Sets the visible property for the given column

columnSetWidth(column, width)[source]

Sets the width in characters for the given column

deleteAllRows()[source]

Deletes all rows from the table

deleteColumn(column)[source]

Delets the given column

deleteRow(row)[source]

Deletes the given row

getColumnIndex(name)[source]

Returns the column index for the given user or data name

getColumnNames()[source]

Return a list of the column data names in this table

getColumnTotal()[source]

Returns the number of columns in the table

getFirstSelectedRow()[source]

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

getOrAddColumn(name, visible)[source]

Finds or adds the given column via data name.

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

getSelectedRows()[source]

Returns a bitset containing the selected rows

getSelectedRowTotal()[source]

Return the total number of selected rows

getVisibleColumnTotal()[source]

Returns the number of visible columns

getVisibleColumnIndex(column)[source]

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

getVisibleRowIndex(row)[source]

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

getVisibleRowTotal()[source]

Returns the number of visible rows

insertColumn(column, name)[source]

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)[source]

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)[source]

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

keys()[source]

Returns the column data names

makeNestedRowVisible(row)[source]

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)[source]

Moves the given column to the destination column

moveRows(from_rows, to_row)[source]

Moves the given rows to the destination row

rowGetExpanded(row)[source]

Indicates whether or not the given row is expanded

rowGetVisible(row)[source]

Returns the visible property for the given row

rowSetExpanded(row, expanded)[source]

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

rowSetVisible(row, visible)[source]

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

selectAddRows(rows)[source]

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

selectRows(rows)[source]

This function selects only the given rows.

sortRows(column, ascending)[source]

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

unselectRows(rows)[source]

This function unselects the given rows