schrodinger.application.msv.gui.viewmodel module¶
-
class
schrodinger.application.msv.gui.viewmodel.
AlignmentInfoProxyModel
(parent=None)¶ Bases:
schrodinger.application.msv.gui.viewmodel.BaseAdjacentAlignmentProxyModel
A proxy model that contains sequence info for an alignment.
-
Column
¶ alias of
AlignmentInfoColumns
-
ROLES_FROM_PROXY
= set([0, 7, 3, 1, <CustomRole.FixedColFontRole: 279>])¶
-
ROLES_FROM_SOURCE
= set([<CustomRole.RowType: 257>, <CustomRole.Seq: 261>, 6, <CustomRole.RowHeightScale: 282>, <CustomRole.ReferenceSequence: 269>, <CustomRole.Included: 270>])¶
-
flags
(index)¶
-
getAlignment
()¶ Return the underlying alignment
Returns: The alignment if the source model exists; else None Return type: schrodinger.protein.alignment.BaseAlignment
-
getTitleColumnWidth
()¶ Return the width of the longest title currently shown, including both sequence titles and annotation names
Return type: int Returns: The length of the longest title currently shown
-
orderChanged
¶
-
-
class
schrodinger.application.msv.gui.viewmodel.
AlignmentMetricsProxyModel
(parent, options_model)¶ Bases:
schrodinger.application.msv.gui.viewmodel.BaseAdjacentAlignmentProxyModel
A proxy model that contains the alignment metrics, such as percentage of identity, similarity, homology and score to the reference sequence. Columns can be enabled or disabled via the options model.
Note: If all columns are disabled, then this model will be completely empty (i.e. zero rows in addition to zero columns). That’s because there’s no way to generate a valid QModelIndex object without any columns, so there would be no way to create a parent index when referring to a nested row. Instead, this model will ignore all row changes until a column is enabled, at which point it will emit modelAboutToBeReset and modelReset to resync the view. -
Column
¶ alias of
AlignmentMetricsColumns
-
columnCount
(parent=None)¶
-
endInsertRows
()¶
-
endRemoveRows
()¶
-
getIncludeGaps
()¶ Returns: Whether to include gaps. Return type: bool
-
rowCount
(parent=None)¶
-
setIncludeGaps
(include_gaps)¶ Parameters: include_gaps (bool) – Whether to include gaps in alignment
-
setOptionsModel
(options_model)¶ Set the options model for the proxy, which are used for row filtering.
Parameters: options_model ( schrodinger.application.msv.gui.preferences. OptionsModel
) – The widget options.
-
-
class
schrodinger.application.msv.gui.viewmodel.
AnnotationProxyModel
(parent=None)¶ Bases:
schrodinger.application.msv.gui.viewmodel.PerRowFlagCacheProxyMixin
,schrodinger.ui.qt.table_speed_up.MultipleRolesRoleProxyMixin
,schrodinger.application.msv.gui.viewmodel.ProxyMixin
,schrodinger.application.msv.gui.viewmodel.NestedProxy
A mixin to cache flags on a per-row basis instead of per-cell (which is what
table_speed_up.FlagCacheProxyMixin
does) since flags are the same across rows here.Note: This mixin assumes that all indices in the same row have the same internal ID. This is true for any NestedProxy subclasses, but is not generally true for Qt tree models.
-
ROLE_MAPPINGS
= {0: (0, <RoleBase.SeqAnnotation: 10256>, <RoleBase.GlobalAnnotation: 11256>), 8: (8, <RoleBase.SeqBackground: 14256>, <RoleBase.GlobalBackground: 15256>), <CustomRole.DataRange: 258>: (None, <RoleBase.SeqAnnotationRange: 12256>, <RoleBase.GlobalAnnotationRange: 13256>), 3: (3, <RoleBase.SeqToolTip: 18256>, <RoleBase.GlobalToolTip: 19256>), 9: (9, <RoleBase.SeqForeground: 16256>, <RoleBase.GlobalForeground: 17256>)}¶
-
ROW_HEIGHT_SCALE_ROLES
= [<ANNOTATION_TYPES.ligand_contacts: 17>, <ANNOTATION_TYPES.disulfide_bonds: 3>, <ANNOTATION_TYPES.antibody_cdr: 18>]¶
-
columnCount
(parent=None)¶
-
data
(proxy_index, role=0, multiple_roles=None)¶
-
endInsertColumns
()¶
-
endRemoveColumns
()¶
-
flags
(index)¶
-
getGroupBy
()¶ Are the rows currently grouped by sequence or by annotation type?
Returns: The current setting Return type: GroupBy
-
getShownRowTypes
()¶ Return a set of allowed annotation types
Returns: A set of annotation types. Note that the returned value is a copy of the attribute variable, so modifying it will not have any effect on this proxy. Return type: set
-
groupByChanged
¶
-
groupExpansionChanged
¶
-
mapFromSource
(source_index)¶
-
mapToSource
(proxy_index)¶
-
reorderRow
(proxy_from_row, proxy_to_row)¶ Pass the reorderRow request down to the next proxy after translating the row numbers. We override
PostReorderingProxyMixin.reorderRow
so we can handle drops on annotation rows appropriately. (Drops on an annotation row are treated as a drop after the sequence.)See
ReorderingProxyModel.reorderRow
for documentation on arguments and the return value.
-
rowCount
(parent=None)¶
-
setData
(proxy_index, value, role=2)¶
-
setGroupBy
(group_by)¶ Should the rows be grouped by sequence or by annotation type?
Parameters: group_by ( GroupBy
) – The setting to apply
-
setShownRowTypes
(row_types)¶ Allow only the specified annotations
Parameters: row_types (iter) – An iterable containing the annotations to allow
-
setSourceModel
(model)¶
-
setVisibilityForRowType
(row_type, show=True)¶ Toggle visibility for the specified annotation
Parameters: - row_type (
enum.Enum
) – The annotation to adjust - show (bool) – Whether the annotation should be shown or hidden
- row_type (
-
setVisibilityForRowTypes
(row_types, show=True)¶ Toggle visibility for the specified annotations
Parameters: - row_types (iter) – An iterable containing the annotations to adjust
- show (bool) – Whether the annotations should be shown or hidden
-
tableWidthChanged
(width)¶ Emit the
tableWidthChangedSignal
with the specified width. TheRowWrapProxyModel
should receive this signal and adjust the wrapping as necessary.Parameters: width (int) – The current number of columns in the table
-
tableWidthChangedSignal
¶
-
-
class
schrodinger.application.msv.gui.viewmodel.
BaseAdjacentAlignmentProxyModel
(parent=None)¶ Bases:
schrodinger.ui.qt.table_speed_up.MultipleRolesRoleProxyMixin
,schrodinger.application.msv.gui.viewmodel.GroupExpansionProxyMixin
,schrodinger.application.msv.gui.viewmodel.NestedProxy
A base proxy model to be subclassed by other proxy models that show data related to and synchronized with an alignment but in separate, adjacent views.
Variables: ROLES_FROM_SOURCE (set) – Set of data roles to query from the source model. -
Column
= None¶
-
FONT_SCALE
= 1.25¶
-
ROLES_FROM_PROXY
= set([0, 3, <CustomRole.FixedColFontRole: 279>, 7])¶
-
ROLES_FROM_SOURCE
= set([<CustomRole.RowType: 257>, <CustomRole.RowHeightScale: 282>, <CustomRole.ReferenceSequence: 269>, 6, <CustomRole.Seq: 261>])¶
-
columnCount
(parent=None)¶
-
data
(proxy_index, role=0, multiple_roles=None)¶
-
isWorkspaceAln
()¶ Returns: Whether this model represents the workspace alignment. Return type: bool
-
mapFromSource
(source_index)¶
-
mapToSource
(proxy_index)¶
-
rowCount
(parent=None)¶
-
rowHeightChanged
¶
-
setSourceModel
(model)¶
-
textSizeChanged
¶
-
updateData
(role, source_row)¶ Update a specified index when data changes.
Parameters: - role (
enum.Enum
) – Role of the data that changed. - source_row (int) – Index of the source model index to update.
- role (
-
-
class
schrodinger.application.msv.gui.viewmodel.
ExportProxyModel
(*args, **kwargs)¶ Bases:
schrodinger.application.msv.gui.viewmodel.PostAnnotationProxyMixin
,PyQt5.QtCore.QIdentityProxyModel
A proxy for use when generating a static image of the table.
-
tableWidthChanged
(*args, **kwargs)¶ Ignore changes in the table size rather than trying to update row wrapping.
-
-
class
schrodinger.application.msv.gui.viewmodel.
FixedColumn
(title, tooltip=None, role=None, fmt=None, all_rows=False, align=132)¶ Bases:
schrodinger.ui.qt.table_helper.Column
A table column that is fixed on the left or right of the scrollable columns. This object is intended to be used in the
table_helper.TableColumns
enum.
-
class
schrodinger.application.msv.gui.viewmodel.
GroupByAnnotationInfo
(ann, seq_numbers)¶ Bases:
future.types.newobject.newobject
Information about a sequence annotation. Used in
AnnotationProxyModel
.
-
class
schrodinger.application.msv.gui.viewmodel.
GroupExpansionProxyMixin
¶ Bases:
future.types.newobject.newobject
A mixin for tree models that transmit group expansion information to their view. Used in both the fixed and scrollable columns.
-
groupByChanged
¶
-
groupExpansionChanged
¶
-
setSourceModel
(model)¶
-
-
class
schrodinger.application.msv.gui.viewmodel.
NestedProxy
¶ Bases:
PyQt5.QtCore.QAbstractProxyModel
A base class for proxy models that contain one level of nesting. The internal ID of indices will be either
TOP_LEVEL
or the row number of the parent row.Variables: TOP_LEVEL (int) – The internal ID to use for indices that are at the top level of the table. (Internal ID is an unsigned 32-bit integer according to Qt’s QModelIndex documentation.) -
TOP_LEVEL
= 4294967295¶
-
buddy
(index)¶
-
hasChildren
(parent)¶
-
index
(row, column, parent=None)¶
-
parent
(index)¶
-
-
class
schrodinger.application.msv.gui.viewmodel.
PerRowFlagCacheProxyMixin
(*args, **kwargs)¶ Bases:
schrodinger.ui.qt.table_speed_up.AbstractFlagCacheProxyMixin
A mixin to cache flags on a per-row basis instead of per-cell (which is what
table_speed_up.FlagCacheProxyMixin
does) since flags are the same across rows here.Note: This mixin assumes that all indices in the same row have the same internal ID. This is true for any NestedProxy subclasses, but is not generally true for Qt tree models.
-
flags
(index)¶
-
-
class
schrodinger.application.msv.gui.viewmodel.
PostAnnotationProxyMixin
(*args, **kwargs)¶ Bases:
schrodinger.application.msv.gui.viewmodel.GroupExpansionProxyMixin
,schrodinger.application.msv.gui.viewmodel.ProxyMixin
A mixin for all proxies that are used after the
AnnotationProxyModel
.-
getShownRowTypes
()¶ See
AnnotationProxyModel.getShownRowTypes
for method documentation.
-
-
class
schrodinger.application.msv.gui.viewmodel.
ProxyMixin
(*args, **kwargs)¶ Bases:
schrodinger.ui.qt.table_speed_up.MultipleRolesRoleProxyPassthroughMixin
A mixin class that provides functionality common to all the proxies.
We also cache the sourceModel to avoid going through the C++ layer.
Note that this mixin should be listed first in the parents for the proxy classes that use it.
Variables: fixedColumnDataChanged ( QtCore.pyqtSignal
emitting a tuple of (enum.Enum
, int)) – Signal emitted when the data in a fixed column is changed. Passes a tuple of the role and row index that are changing.-
clearSelection
()¶
-
fixedColumnDataChanged
¶
-
getAlignment
()¶ Return the underlying alignment
Returns: The alignment if the source model exists; else None Return type: schrodinger.protein.alignment.BaseAlignment
-
getIndexForRes
(res)¶ Get the model index for the given residue.
Parameters: res (schrodinger.protein.residue.Residue) – A residue Returns: The model index of the residue Return type: QModelIndex
-
getResidueDisplayMode
()¶ Return the current residue display mode setting.
Returns: The current residue display mode. Return type: enum.Enum
-
isWorkspaceAln
()¶ Returns: Whether this model represents the workspace alignment. Return type: bool
-
reorderRow
(proxy_from_row, proxy_to_row)¶ Pass the reorderRow request down to the next proxy after translating the row numbers.
See
ReorderingProxyModel.reorderRow
for documentation on arguments and the return value.
-
residueFormatChanged
¶
-
rowHeightChanged
¶
-
setSelectionState
(selection, selected)¶ Mark the residues specified by
selection
as either selected or deselected.Parameters: - selection (QtCore.QItemSelection) – A selection containing the entries to update.
- selected (bool) – Whether the entries should be selected (True) or deselected (False).
-
setSourceModel
(model)¶
-
sourceModel
()¶ We override this and return the cached source model so that we avoid going through the C++ layer
-
textSizeChanged
¶
-
-
class
schrodinger.application.msv.gui.viewmodel.
RowWrapInsertingChildRows
(source_parent_row, source_start, source_end)¶ Bases:
future.types.newobject.newobject
An object to store
RowWrapProxyModel
bookkeeping for the insertion of child rows.Variables: - source_parent_row (int) – The row number of the top-level row that the child rows are being inserted into.
- source_start (int) – The row number of the first row being inserted.
- source_start – The row number of the last row being inserted.
- num_new_rows (int) – The number of rows being inserted.
- wrap (int) – The wrap of
RowWrapProxyModel
that rows were just inserted into - seeRowWrapProxyModel._sourceRowsAboutToBeInserted
.
-
class
schrodinger.application.msv.gui.viewmodel.
RowWrapInsertingRows
(old_source_row_count, new_source_row_count, source_start, source_end)¶ Bases:
future.types.newobject.newobject
An object to store
RowWrapProxyModel
bookkeeping for the insertion of top-level rows.Variables: - old_source_row_count (int) – The number of rows in the source model before the insertion.
- new_source_row_count (int) – The number of rows in the source model after the insertion.
- source_start (int) – The row number of the first row being inserted.
- source_start – The row number of the last row being inserted.
- num_new_rows (int) – The number of rows being inserted.
- wrap (int) – The wrap of
RowWrapProxyModel
that rows were just inserted into - seeRowWrapProxyModel._sourceRowsAboutToBeInserted
. - update_row_num (int) – The row number of
RowWrapProxyModel
that was just updated; i.e., that just had child rows inserted into it - seeRowWrapProxyModel._sourceRowsInserted
.
-
class
schrodinger.application.msv.gui.viewmodel.
RowWrapProxyModel
(parent=None)¶ Bases:
schrodinger.application.msv.gui.viewmodel.PerRowFlagCacheProxyMixin
,schrodinger.application.msv.gui.viewmodel.PostAnnotationProxyMixin
,schrodinger.application.msv.gui.viewmodel.NestedProxy
A mixin to cache flags on a per-row basis instead of per-cell (which is what
table_speed_up.FlagCacheProxyMixin
does) since flags are the same across rows here.Note: This mixin assumes that all indices in the same row have the same internal ID. This is true for any NestedProxy subclasses, but is not generally true for Qt tree models.
-
columnCount
(parent=None)¶
-
data
(index, role=0, multiple_roles=None)¶
-
headerData
(section, orientation, role=0)¶
-
mapFromSource
(source_index)¶
-
mapToSource
(proxy_index)¶
-
rowCount
(parent=None)¶
-
setSourceModel
(model)¶
-
tableWidthChanged
(width)¶ Wrap the table to the specified number of columns.
Parameters: width (int) – The number of columns to wrap to.
-
-
class
schrodinger.application.msv.gui.viewmodel.
RowWrapRemovingChildRows
(source_parent_row, source_start, source_end)¶ Bases:
future.types.newobject.newobject
An object to store
RowWrapProxyModel
bookkeeping for the removal of child rows.Variables: - source_parent_row (int) – The row number of the top-level row that the child rows are being removed from.
- source_start (int) – The row number of the first row being removed.
- source_start – The row number of the last row being removed.
- num_rem_rows – The number of rows being removed.
- wrap (int) – The wrap of
RowWrapProxyModel
that rows were just removed from - seeRowWrapProxyModel._sourceRowsAboutToBeRemoved
.
-
class
schrodinger.application.msv.gui.viewmodel.
RowWrapRemovingRows
(old_source_row_count, new_source_row_count, source_start, source_end)¶ Bases:
future.types.newobject.newobject
An object to store
RowWrapProxyModel
bookkeeping for the removal of top-level rows.Variables: - old_source_row_count (int) – The number of rows in the source model before the removal.
- new_source_row_count (int) – The number of rows in the source model after the removal.
- source_start (int) – The row number of the first row being removed.
- source_start – The row number of the last row being removed.
- num_rem_rows – The number of rows being removed.
- wrap (int) – The wrap of
RowWrapProxyModel
that rows were just removed from - seeRowWrapProxyModel._sourceRowsAboutToBeRemoved
.
-
class
schrodinger.application.msv.gui.viewmodel.
SequenceAlignmentModel
(parent=None, options_model=None, display_mode=<Format.one_letter: 1>, include_gaps=False)¶ Bases:
schrodinger.ui.qt.table_speed_up.MultipleRolesRoleModelMixin
,schrodinger.ui.qt.table_helper.RowBasedTableModel
A QTable model where each row corresponds to a sequence and each column corresponds to a residue position
Note: If the alignment contains only zero-length sequences, then this model creates a dummy column. Otherwise, we wouldn’t be able to generate any valid QModelIndex objects, which means we couldn’t create any parent indices for row insertion signals.
Variables: - fixedColumnDataChanged (
QtCore.pyqtSignal
emitting a tuple of (enum.Enum
, int)) – Signal emitted when the data in a fixed column is changed. Passes a tuple of the role and row index that are changing. - rowHeightChanged (
QtCore.pyqtSignal
) – Signal emitted when the height of a row is changed is changed.
-
annotationTypes
()¶ Get the current annotation types
Returns: A tuple of: - The global annotation enum - The sequence annotation enum Return type: tuple
-
clearSelection
()¶
-
columnCount
(parent=None)¶
-
emitLayoutAboutToBeChanged
()¶ Emit a layoutAboutToBeChanged signal. This helper makes disconnecting from the signal easier.
-
emitLayoutChanged
()¶ Emit a layoutChanged signal. This helper makes disconnecting easier.
-
fixedColumnDataChanged
¶
-
flags
(index)¶ See Qt documentation for method documentation
-
getAlignment
()¶ Return the underlying alignment object
Returns: The alignment Return type: schrodinger.protein.alignment.BaseAlignment
-
getAverageColorInColumn
(col_index, scheme)¶ Return the average color at a specified column and updates the cache if necessary.
Note: This feature works particularly well with the Taylor scheme.
Parameters: - col_index (int) – index of specified column
- scheme (
color.RowColorScheme
) – Row’s color scheme
Returns: average color in the column
Return type: QColor
Raises: IndexError – If the alignment has no residues and the only column present is a dummy column.
-
getColorScheme
()¶ Return type: dict Returns: The color scheme currently in use
-
getCustomResColors
()¶ Return a map of custom residue brushes
Returns: Map of custom residue color brushes Return type: dict
-
getIDDispMode
()¶ Are the identities shown as residues or dots?
Returns: The current setting Return type: IdentityDisplayMode
-
getIndexForRes
(res)¶ Get the model index for the given residue.
Parameters: res (schrodinger.protein.residue.Residue) – A residue Returns: The model index of the residue Return type: QModelIndex
-
getResidueColors
(structured_only=True)¶ Get the color of residues in the sequence rows
Parameters: structured_only (bool) – Whether to only get colors of residues in sequences that have structures Returns: The colors of each residue in the MSV. Each residue is represented by a tuple of (entry_id, chain, resnum, inscode) and each color is represented by a tuple of (r,g,b) values. Return type: dict(tuple(string, string, int, string), tuple((int, int, int))
-
getResidueDisplayMode
()¶ Return type: ResidueFormat Returns: The residue display mode in current use
-
headerData
(section, orientation, role=0)¶
-
isWorkspaceAln
()¶ Returns: Whether this model represents the workspace alignment. Return type: bool
-
onSelectionChanged
(selected, deselected)¶ Update the view appropriately when residue selection has been changed
Parameters: - selected (iterable of
schrodinger.protein.residue.Residue
) – The residues who have been newly selected - deselected (iterable of
schrodinger.protein.residue.Residue
) – The residues who have been newly deselected
- selected (iterable of
-
resetAnnotation
(ann)¶
-
residueFormatChanged
¶
-
rowCount
(parent=None)¶
-
rowHeightChanged
¶
-
sequenceCount
()¶ Return type: int Returns: The number of sequences in the alignment
-
sequencesReordered
¶
-
setAlignment
(aln)¶ Set the alignment model to display data from
Parameters: alignment ( schrodinger.protein.alignment.BaseAlignment
) – The alignment model
-
setFontSize
(size)¶ Set the font size to the specified size
Parameters: size (int) – The new point size for the text
-
setIDDispMode
(id_disp_mode)¶ Should the identities be shown as residues or dots?
Parameters: id_disp_mode ( IdentityDisplayMode
) – The setting to apply
-
setOptionsModel
(options_model)¶ Set the options model for the model, which is used to know what antibody cdr scheme to display
Parameters: options_model ( schrodinger.application.msv.gui.preferences. OptionsModel
) – The widget options.
-
setResidueDisplayMode
(mode)¶ Parameters: mode (ResidueFormat) – The display mode for residue text
-
setSelectionState
(selection, selected)¶ Mark the residues specified by
selection
as either selected or deselected.Parameters: - selection (
QtCore.QItemSelection
) – A selection containing the entries to update. - selected (bool) – Whether the entries should be selected (True) or deselected (False).
- selection (
-
strucTitles
()¶ Get all structure titles
Returns: A list containing all structure titles Return type: list
-
textSizeChanged
¶
-
updateColorScheme
(row_type, scheme)¶ Used to set the color scheme of a specific row type.
-
updateCustomResColors
(color_map)¶ Update the map of custom residue colors.
Parameters: color_map (dict) – Map of custom residue colors to apply
-
updateResidueColors
(key_to_color_map)¶ Update the colors of residues in the sequence rows.
Parameters: key_to_color_map (dict(tuple(string, string, int, string), tuple((int, int, int))) – A map from residues to colors. Each residue is represented by a tuple of (entry_id, chain, resnum, inscode) and each color is represented by a tuple of (r,g,b) values.
- fixedColumnDataChanged (
-
class
schrodinger.application.msv.gui.viewmodel.
SequenceInfo
(has_struc=None, anns=None)¶ Bases:
future.types.newobject.newobject
Information about a single sequence. Used in
AnnotationProxyModel
.
-
class
schrodinger.application.msv.gui.viewmodel.
SequenceNums
(all, structured_only)¶ Bases:
tuple
-
all
¶ Alias for field number 0
-
structured_only
¶ Alias for field number 1
-
-
class
schrodinger.application.msv.gui.viewmodel.
ViewModel
(parent, options_model)¶ Bases:
PyQt5.QtCore.QObject
An abstraction layer for the various table models in this module
Variables: - orderChanged (
QtCore.pyqtSignal
) – A signal emitted when the sorting or row reodering (due to drag-and-drop) has changed. Emitted with the new seq indices. - topModelChanged (
QtCore.pyqtSignal
) – A signal emitted when row wrapping is toggled. The view must change models whenever this signal is emitted. Emitted with the new model that the view should use.
-
orderChanged
¶
-
rowWrap
()¶ Return the current row wrapping setting.
Returns: True if the rows are wrapped. False otherwise. Return type: bool
-
setIncludeGaps
(include_gaps)¶ Enable or disable gap including. Gap inclusion only affects whether gaps are used when calculating metrics.
Parameters: include_gaps (bool) – True if gaps should be included, false otherwise.
-
setRowWrap
(enabled)¶ Enable or disabled row wrapping.
Parameters: enabled (bool) – True if rows should be wrapped. False otherwise.
-
topModelChanged
¶
- orderChanged (