Package schrodinger :: Package application :: Package msv :: Package gui :: Module viewmodel :: Class AnnotationProxyModel
[hide private]
[frames] | no frames]

Class AnnotationProxyModel

                                                 object --+            
                                                          |            
                ui.qt.table_helper.DataMethodDecoratorMixin --+        
                                                              |        
               ui.qt.table_speed_up.MultipleRolesRoleModelMixin --+    
                                                                  |    
                   ui.qt.table_speed_up.MultipleRolesRoleProxyMixin --+
                                                                      |
                                                 object --+           |
                                                          |           |
ui.qt.table_speed_up.MultipleRolesRoleProxyPassthroughMixin --+       |
                                                              |       |
                                                     ProxyMixin --+   |
                                                                  |   |
                                           PostReorderingProxyMixin --+
                                                                      |
                                     object --+                       |
                                              |                       |
                              sip.simplewrapper --+                   |
                                                  |                   |
                                        sip.wrapper --+               |
                                                      |               |
                                   PyQt5.QtCore.QObject --+           |
                                                          |           |
                            PyQt5.QtCore.QAbstractItemModel --+       |
                                                              |       |
                               PyQt5.QtCore.QAbstractProxyModel --+   |
                                                                  |   |
                                                        NestedProxy --+
                                                                      |
                                                                     AnnotationProxyModel

A proxy model that creates children rows for currently displayed annotations and adds a spacer row in between sequences. This proxy can be toggled between grouping rows by sequence and grouping rows by annotation.

Nested Classes [hide private]

Inherited from ProxyMixin: __metaclass__

Inherited from PyQt5.QtCore.QAbstractItemModel: LayoutChangeHint

Instance Methods [hide private]
 
groupExpansionChanged(...)
A signal emitted when group expansion is changed.
 
groupByChanged(...)
A signal emitted when the model is toggled between group-by-sequence and group-by-annotation.
 
__init__(self, parent=None)
x.__init__(...) initializes x; see help(type(x)) for signature
 
setSourceModel(self, model)
 
_sourceModelReset(self)
 
_fetchAnnotationTypes(self)
When we get a new model or the model is reset, fetch the enums for annotation types
 
_initializeBookkeeping(self)
Clear and re-populate all of the bookkeeping data needed for this proxy.
 
_initializeGroupBySeqData(self)
Populate the bookkeeping data needed when we're grouping rows by sequence.
tuple
_getSeqAnnotationLists(self)
Generate lists of currently shown sequence annotations for structured and structureless sequences.
 
_initializeGroupByAnnData(self)
Populate the bookkeeping data needed when we're grouping rows by annotation.
SequenceNums
_genSeqNums(self)
Return lists of sequence numbers that should be shown for annotations that don't require a structure and annotations that do require a structure.
 
rowCount(self, parent=None)
 
columnCount(self, parent=None)
tuple
_getMappedIndex(self, proxy_index)
Determine what source index and annotation the specified index maps to
 
mapFromSource(self, source_index)
 
mapToSource(self, proxy_index)
 
setData(self, proxy_index, value, role=2)
object
data(self, proxy_index, role=0, multiple_roles=None)
Provide data for the specified index and role.
dict
_multipleRolesData(self, proxy_index, source_index, source_model, ann_type, ann, multiple_roles)
Provide data for all requested roles.
 
_rowTypeData(self, proxy_index, source_index, source_model, ann_type, ann)
Return the type of data contained in the specified row.
 
_spacerTypeData(self, proxy_index, source_index, source_model, ann_type, ann)
Return the annotation type for spacer rows that contain labels.
 
_dataRangeData(self, proxy_index, source_index, source_model, ann_type, ann, multiple_role_data)
Return the range of values contained in the specified row.
int or NoneType
_dataRangeRole(self, ann_type, ann)
Determine the appropriate role to use for fetching annotation data range for a given row.
 
_displayData(self, proxy_index, source_index, source_model, ann_type, ann)
int or NoneType
_displayRole(self, ann_type, ann)
Determine the appropriate role to use for fetching display data range for a given row.
 
_seqRowEntryIDData(self, proxy_index, source_index, source_model, ann_type, ann)
 
_residueData(self, proxy_index, source_index, source_model, ann_type, ann, multiple_roles_data)
 
_rowTitleData(self, proxy_index, source_index, source_model, ann_type, ann, multiple_roles_data)
 
_chainColData(self, proxy_index, source_index, source_model, ann_type, ann, multiple_roles_data)
 
flags(self, index)
See Qt documentation for additional method documentation
 
reorderRow(self, proxy_from_row, proxy_to_row)
Pass the reorderRow request down to the next proxy after translating the row numbers.
 
_sourceRowsAboutToBeInserted(self, parent, source_start, source_end)
Respond to the rowsAboutToBeInserted signal from the source model.
 
_sourceRowsInserted(self, parent, source_start, source_end)
Respond to the rowsInserted signal from the source model.
 
_sourceRowsAboutToBeRemoved(self, parent, source_start, source_end)
Respond to the rowsAboutToBeRemoved signal from the source model.
 
_sourceRowsRemoved(self)
Respond to the rowsRemoved signal from the source model.
 
_modelDataChanged(self, source_topleft, source_bottomright)
Respond to the dataChanged signal from the source model.
 
setGroupBy(self, group_by)
Should the rows be grouped by sequence or by annotation type?
GroupBy
getGroupBy(self)
Are the rows currently grouped by sequence or by annotation type?
 
setShownRowTypes(self, row_types)
Allow only the specified annotations
set
getShownRowTypes(self)
Return a set of allowed annotation types
 
setVisibilityForRowType(self, row_type, show=True)
Toggle visibility for the specified annotation
 
setVisibilityForRowTypes(self, row_types, show=True)
Toggle visibility for the specified annotations
 
_invalidateFilter(self)
Update which annotations are shown and hidden.
 
_updateAnnotationList(self, shown_ann, all_ann, parent, account_for_spacer=False)
Update the given list of shown annotations to reflect the current contents of self._shown_row_types.
 
_updateSeqAnnForGroupBySeq(self)
Update which sequence annotations are shown when rows are grouped by sequence.
 
_updateSeqAnnForGroupByAnn(self)
Update which sequence annotations are shown when rows are grouped by annotation.
 
endInsertColumns(self)
 
endRemoveColumns(self)

Inherited from ui.qt.table_speed_up.MultipleRolesRoleProxyMixin (private): _genDataArgs

Inherited from ui.qt.table_speed_up.MultipleRolesRoleModelMixin (private): _fetchMultipleRoles

Inherited from ui.qt.table_helper.DataMethodDecoratorMixin (private): _callDataMethod, _collectDataMethods

Inherited from PostReorderingProxyMixin (private): _mapRowToSource

Inherited from ProxyMixin: emitResidueSelection, getResidueDisplayMode, residueFormatChanged, residuesSelected, sourceModel

Inherited from NestedProxy: buddy, hasChildren, index, parent

Inherited from PyQt5.QtCore.QAbstractProxyModel: canDropMimeData, canFetchMore, dropMimeData, fetchMore, headerData, itemData, mapSelectionFromSource, mapSelectionToSource, mimeData, mimeTypes, resetInternalData, revert, setHeaderData, setItemData, sibling, sort, sourceModelChanged, span, submit, supportedDragActions, supportedDropActions

Inherited from PyQt5.QtCore.QAbstractItemModel: beginInsertColumns, beginInsertRows, beginMoveColumns, beginMoveRows, beginRemoveColumns, beginRemoveRows, beginResetModel, changePersistentIndex, changePersistentIndexList, columnsAboutToBeInserted, columnsAboutToBeMoved, columnsAboutToBeRemoved, columnsInserted, columnsMoved, columnsRemoved, createIndex, dataChanged, decodeData, encodeData, endInsertRows, endMoveColumns, endMoveRows, endRemoveRows, endResetModel, hasIndex, headerDataChanged, insertColumn, insertColumns, insertRow, insertRows, layoutAboutToBeChanged, layoutChanged, match, modelAboutToBeReset, modelReset, moveColumn, moveColumns, moveRow, moveRows, persistentIndexList, removeColumn, removeColumns, removeRow, removeRows, roleNames, rowsAboutToBeInserted, rowsAboutToBeMoved, rowsAboutToBeRemoved, rowsInserted, rowsMoved, rowsRemoved

Inherited from PyQt5.QtCore.QObject: __getattr__, blockSignals, childEvent, children, connectNotify, customEvent, deleteLater, destroyed, disconnect, disconnectNotify, dumpObjectInfo, dumpObjectTree, dynamicPropertyNames, event, eventFilter, findChild, findChildren, inherits, installEventFilter, isSignalConnected, isWidgetType, isWindowType, killTimer, metaObject, moveToThread, objectName, objectNameChanged, property, pyqtConfigure, receivers, removeEventFilter, sender, senderSignalIndex, setObjectName, setParent, setProperty, signalsBlocked, startTimer, thread, timerEvent, tr

Inherited from sip.simplewrapper: __new__

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Class Variables [hide private]

Inherited from NestedProxy: TOP_LEVEL

Inherited from PyQt5.QtCore.QAbstractItemModel: HorizontalSortHint, NoLayoutChangeHint, VerticalSortHint

Inherited from PyQt5.QtCore.QObject: staticMetaObject

Instance Variables [hide private]
enum.Enum or list _all_global_ann
An enum containing all global annotations present in the alignment.
enum.Enum or list _all_seq_ann
An enum containing all sequence annotations present in the alignment.
list _all_structureless_seq_ann
All sequence annotations present in the alignment that don't require a structure.
GroupBy _group_by
Whether the table is currently grouped by sequence or by annotation.
list _group_by_ann_info
A list of annotations currently displayed in the table.
  _group_by_ann_seq_nums
A SequenceInfo object containing sequence numbers for the annotations that do and do not require a structure.
list _seq_info
A list of sequences in the table.
list _shown_global_ann
A list of all global annotations that are currently displayed.
set _shown_row_types
A set of all global and sequence annotations that are currently displayed.
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

groupExpansionChanged(...)

 
A signal emitted when group expansion is changed. Emitted with:
  • A list of all indices to be expanded or collapsed.
  • True if the indices should be expanded. False if they should be collapsed.

groupByChanged(...)

 
A signal emitted when the model is toggled between group-by-sequence and group-by-annotation. Emitted with the new group-by setting (GroupBy).

__init__(self, parent=None)
(Constructor)

 

x.__init__(...) initializes x; see help(type(x)) for signature

Overrides: object.__init__
(inherited documentation)

setSourceModel(self, model)

 
Decorators:
  • @table_helper.model_reset_method
Overrides: PyQt5.QtCore.QAbstractProxyModel.setSourceModel

_getSeqAnnotationLists(self)

 

Generate lists of currently shown sequence annotations for structured and structureless sequences.

Returns: tuple
A tuple of:
  • A list of sequence annotations for sequence with an associated structure.
  • A list of sequence annotations for sequence without an associated structure.

rowCount(self, parent=None)

 
Overrides: PyQt5.QtCore.QAbstractItemModel.rowCount

columnCount(self, parent=None)

 
Overrides: PyQt5.QtCore.QAbstractItemModel.columnCount

_getMappedIndex(self, proxy_index)

 

Determine what source index and annotation the specified index maps to

Parameters:
  • proxy_index (QtCore.QModelIndex) - The index to map. Must be a valid index.
Returns: tuple
A tuple of
  • The source index that proxy_index maps to (QtCore.QModelIndex)
  • If the proxy_index row represents an annotation, returns an AnnotationType enum representing the annotation type. If the proxy_index row represents a sequence or a spacer, returns a RowType enum representing the row type.
  • If the proxy_index row represents an annotation, returns an annotation enum.

mapFromSource(self, source_index)

 
Overrides: PyQt5.QtCore.QAbstractProxyModel.mapFromSource

mapToSource(self, proxy_index)

 
Overrides: PyQt5.QtCore.QAbstractProxyModel.mapToSource

setData(self, proxy_index, value, role=2)

 
Overrides: PyQt5.QtCore.QAbstractItemModel.setData

data(self, proxy_index, role=0, multiple_roles=None)

 

Provide data for the specified index and role. Subclasses normally do not need to redefine this method. Instead, new methods should be created and decorated with table_helper.data_method.

Parameters:
  • index - The index to return data for.
  • role - The role to request data for.
  • multiple_roles - If role equals {MultipleRolesUserRolesEnum.MultipleRoles}, a set of roles to retrieve data for. Ignored otherwise.
Returns: object
The requested data. If role equals {MultipleRolesUserRolesEnum.MultipleRoles}, will be a dictionary of {role: value}. The dictionary not contain roles that are not provided by this model and may contain additional roles that were not explicitly requested.
Overrides: PyQt5.QtCore.QAbstractItemModel.data

_multipleRolesData(self, proxy_index, source_index, source_model, ann_type, ann, multiple_roles)

 

Provide data for all requested roles. The last argument must be an iterable of roles to fetch data for. All additional arguments will be passed to the data methods.

Returns: dict
A {role: value} dictionary of data for all requested roles.
Decorators:
  • @table_helper.data_method(CustomRole.MultipleRoles)
Overrides: ui.qt.table_speed_up.MultipleRolesRoleModelMixin._multipleRolesData
(inherited documentation)

_rowTypeData(self, proxy_index, source_index, source_model, ann_type, ann)

 

Return the type of data contained in the specified row. The return value will be either a RowType enum or an annotation enum.

Decorators:
  • @table_helper.data_method(CustomRole.RowType)

_spacerTypeData(self, proxy_index, source_index, source_model, ann_type, ann)

 

Return the annotation type for spacer rows that contain labels. When grouping by annotation, the spacer row in between two annotation types is used to label the following annotation type. This method will return RowType.Spacer for unlabeled spacers.

Decorators:
  • @table_helper.data_method(CustomRole.SpacerType)

_dataRangeData(self, proxy_index, source_index, source_model, ann_type, ann, multiple_role_data)

 

Return the range of values contained in the specified row.

Decorators:
  • @table_helper.data_method(CustomRole.DataRange)

_dataRangeRole(self, ann_type, ann)

 

Determine the appropriate role to use for fetching annotation data range for a given row.

Parameters:
Returns: int or NoneType
If the row represents an annotation, the data range role. None otherwise.

_displayData(self, proxy_index, source_index, source_model, ann_type, ann)

 
Decorators:
  • @table_helper.data_method(Qt.DisplayRole)

_displayRole(self, ann_type, ann)

 

Determine the appropriate role to use for fetching display data range for a given row.

Parameters:
Returns: int or NoneType
If the row represents an annotation or a sequence, the display role. None otherwise.

_seqRowEntryIDData(self, proxy_index, source_index, source_model, ann_type, ann)

 
Decorators:
  • @table_helper.data_method(CustomRole.SeqRowEntryID)

_residueData(self, proxy_index, source_index, source_model, ann_type, ann, multiple_roles_data)

 
Decorators:
  • @table_helper.data_method(CustomRole.Residue)

_rowTitleData(self, proxy_index, source_index, source_model, ann_type, ann, multiple_roles_data)

 
Decorators:
  • @table_helper.data_method(CustomRole.RowTitle)

_chainColData(self, proxy_index, source_index, source_model, ann_type, ann, multiple_roles_data)

 
Decorators:
  • @table_helper.data_method(CustomRole.ChainCol)

flags(self, index)

 

See Qt documentation for additional method documentation

Everything is selectable except for spacers

Overrides: PyQt5.QtCore.QAbstractItemModel.flags

reorderRow(self, 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.

Overrides: PostReorderingProxyMixin.reorderRow

_sourceRowsAboutToBeInserted(self, parent, source_start, source_end)

 

Respond to the rowsAboutToBeInserted signal from the source model. See Qt documentation for rowsAboutToBeInserted for argument documentation.

_sourceRowsInserted(self, parent, source_start, source_end)

 

Respond to the rowsInserted signal from the source model. See Qt documentation for rowsInserted for argument documentation.

_sourceRowsAboutToBeRemoved(self, parent, source_start, source_end)

 

Respond to the rowsAboutToBeRemoved signal from the source model. If in group by annotation mode, note that this method removes all annotation rows for the deleted sequences. Also note that self._group_by_ann_info and self._group_by_ann_seq_nums will be out of sync until _sourceRowsRemoved is run.

See Qt documentation for rowsAboutToBeRemoved for argument documentation.

_sourceRowsRemoved(self)

 

Respond to the rowsRemoved signal from the source model. See Qt documentation for rowsRemoved for argument documentation.

_modelDataChanged(self, source_topleft, source_bottomright)

 

Respond to the dataChanged signal from the source model. See Qt documentation for dataChanged for argument documentation.

setGroupBy(self, group_by)

 

Should the rows be grouped by sequence or by annotation type?

Parameters:
  • group_by (GroupBy) - The setting to apply

getGroupBy(self)

 

Are the rows currently grouped by sequence or by annotation type?

Returns: GroupBy
The current setting

setShownRowTypes(self, row_types)

 

Allow only the specified annotations

Parameters:
  • row_types (iter) - An iterable containing the annotations to allow

getShownRowTypes(self)

 

Return a set of allowed annotation types

Returns: set
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.

setVisibilityForRowType(self, row_type, show=True)

 

Toggle visibility for the specified annotation

Parameters:
  • row_types (enum.Enum) - The annotations to adjust
  • show (bool) - Whether the annotation should be shown or hidden

setVisibilityForRowTypes(self, 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

_invalidateFilter(self)

 

Update which annotations are shown and hidden. Update self._shown_row_types before calling this method.

_updateAnnotationList(self, shown_ann, all_ann, parent, account_for_spacer=False)

 

Update the given list of shown annotations to reflect the current contents of self._shown_row_types. Row insertion and removal signals will be emitted for all changes.

Parameters:
  • shown_ann (list) - The list of shown annotations to update
  • all_ann (iterable) - All annotations that can be shown for the current row type (i.e. global annotations, sequence annotations, or structureless sequence annotations).
  • parent (QtCore.QModelIndex) - The parent index to emit with the row insertion and removal signals.
  • account_for_spacer (bool) - Whether the parent group can have a spacer as the last row. If True, this spacer row will be removed when the last annotation is removed and added when adding an annotation to an empty group.

endInsertColumns(self)

 
Overrides: PyQt5.QtCore.QAbstractItemModel.endInsertColumns

endRemoveColumns(self)

 
Overrides: PyQt5.QtCore.QAbstractItemModel.endRemoveColumns

Instance Variable Details [hide private]

_all_global_ann

An enum containing all global annotations present in the alignment. If no source model has been set, is an empty list.
Type:
enum.Enum or list

_all_seq_ann

An enum containing all sequence annotations present in the alignment. If no source model has been set, is an empty list.
Type:
enum.Enum or list

_group_by_ann_info

A list of annotations currently displayed in the table. Each annotation is represented by a GroupByAnnotationInfo object. This value is only populated when the table is grouped by annotation. It is None when the table is grouped by sequence.
Type:
list

_group_by_ann_seq_nums

A SequenceInfo object containing sequence numbers for the annotations that do and do not require a structure. Note that the GroupByAnnotationInfo.seqs values in _group_by_ann_info point to the sequence number lists in this object. As such, sequence numbers for all annotations can be updated by updating this object. This value is only populated when the table is grouped by annotation. It is None when the table is grouped by sequence.

_seq_info

A list of sequences in the table. Each sequence is represented by a SequenceInfo object. The SequenceInfo.has_struc values are always populated for each sequence. The SequenceInfo.ann values are only populated when the table is grouped by sequence. They are None when the table is grouped by annotation.
Type:
list

_shown_global_ann

A list of all global annotations that are currently displayed. Annotations are listed in the order that they are displayed.
Type:
list