schrodinger.application.msv.test_helpers module¶
- schrodinger.application.msv.test_helpers.make_alignment(AlnClass, aln_info)[source]¶
Given an alignment class and information to populate an instance returns an instance of an alignment
- Parameters
AlnClass (type) – An alignment class
aln_info (AlignmentInfo) – Information to populate the instance
- Returns
A ProteinAlignment instance.
- Return type
- schrodinger.application.msv.test_helpers.make_empty_performance_panel(show_on_screen=False, width=695, height=495)[source]¶
Create an MSV panel to use for measuring performance.
- Parameters
show_on_screen (bool) – Whether to display the panel.
width (int) – The desired width for the alignment view.
height (int) – The desired height for the alignment view.
- schrodinger.application.msv.test_helpers.make_performance_panel(input_path, num_copies, show_on_screen=False, width=695, height=495)[source]¶
Create an MSV panel to use for measuring painting performance and load sequences into it.
- Parameters
input_path (str) – The path to the file to load in
num_copies (int) – The number of copies of
input_path
to loadshow_on_screen (bool) – Whether to display the panel.
width (int) – The desired width for the alignment view.
height (int) – The desired height for the alignment view.
- schrodinger.application.msv.test_helpers.timing_anno(anno, msv_widget)[source]¶
A context manager for timing the painting of a given annotation or row type. All caches are cleared at the start of the context, and a function is yielded that will enable the row type. Runtime for the execution of this function should be counted as part of the initial paint time, since the view will calculate size hints while this function is run. If we’re timing an annotation row type (as opposed to sequence rows), then painting and data-fetching for sequence rows will be disabled during the context, and the annotation will be disabled at the end of the context.
- Parameters
anno (enum.Enum) – The desired annotation or row type to show.
msv_widget (AbstractMSVWidget) – The widget to enable the annotations on.
- Returns
Yields a function for enabling the specified row type. This function will be a no-op if timing sequence rows.
- Return type
function
- schrodinger.application.msv.test_helpers.time_msv_widget_painting(msv_widget, show_anno, global_ann=False, measure_scrolling=True, collect_profile=False, profile_filename=None)[source]¶
Time how long it takes to paint the MSV after clearing all cached data. Painting is broken down into two measurements: 1) initial paint and 2) scrolling. The initial paint will include the time to repopulate the caches.
- Parameters
msv_widget (gui.msv_widget.AbstractMsvWidget) – The widget to paint
show_anno (function) – A function to call to enable the desired annotation. Runtime for this function will be counted as part of the initial paint.
global_ann (bool) – Whether this timing is intended to measure a global annotation. If True, then the alignment will only be scrolled horizontally. Otherwise, it will be scrolled vertically and then horizontally.
measure_scrolling (bool) – Whether to time scrolling. If False, only the initial paint will be measured.
collect_profile (bool) – Whether to collect profiling data while painting. Data will be saved to
profile_filename
. Note that collecting profiling data will affect runtime. Times measured using profiling should not be compared to times measured without profiling.profile_filename (str or None) – The filename to save profiling data to. Only used if
collect_profile
is truthy. The string must have a “{time_type}” field in it, which will be filled in with “init_paint” or “scrolling”.
- Returns
A tuple of: - The time to paint the first frame, measured in seconds - The time to scroll the widget, measured in seconds, or None if measure_scrolling is False.
- Return type
tuple(float, float or None)
- schrodinger.application.msv.test_helpers.get_view_expanded_states(msv_wid)[source]¶
Get expanded states for all rows in all views in the msv widget
- schrodinger.application.msv.test_helpers.assert_view_expansion_is_synced_with_model(msv_wid)[source]¶
- schrodinger.application.msv.test_helpers.process_events_multiple(app)[source]¶
Call processEvents multiple times in case any pending timer slots trigger additional timers. Also explicitly processes deleteLater calls.
- Parameters
app (QtWidgets.QApplication) – The Qt application
- class schrodinger.application.msv.test_helpers.StandaloneStructureModelWithWorkspace(parent, undo_stack)[source]¶
Bases:
schrodinger.application.msv.structure_model.StandaloneStructureModel
A structure model with a fake workspace alignment so we can test how the MSV panel will respond when run inside Maestro. Used in TestMSVPanelWithWorkspaceTab.
- getWorkspaceAlignment()[source]¶
Return an alignment that contains all entries included in the workspace. The structure model will ensure that this alignment is always kept in sync with the workspace. Returns None if the associated program has no concept of a workspace (i.e. StandaloneStructureModel).
- Note
This method will always return a split-chain alignment regardless of the current split-chain view setting.
- Return type
alignment.BaseAlignment
or NoneType
- getWorkspaceColors()[source]¶
Returns a dict mapping residues to their color in the workspace. :rtype: dict
- importStructuresIntoWorkspace(filename)[source]¶
Import all structures from the given file into the workspace and include only the first structure.
- Parameters
filename (str) – The filename to read
- Returns
Sequences from the workspace alignment that correspond to the newly imported structures.
- Return type
list(sequence.Sequence)
- syncSelectionToMaestro(selection)[source]¶
This method should be patched instead of actually called.
- IMPLEMENTS_AUTOLOAD = False¶
- IMPLEMENTS_GET_INCLUDED = False¶
- IMPLEMENTS_GET_SELECTED = False¶
- applyWorkspaceSelectionToSeqs(aln, seqs=None)¶
Select any residues in the given sequences that are selected in the workspace. Sequences without structures or with structures that aren’t currently included in the workspace are ignored.
This method is a no-op for structure models without a workspace.
- Parameters
aln (gui_alignment._ProteinAlignment) – The alignment to select the residues in
seqs (Iterable(sequence.Sequence)) – The sequences to select residues in. If not given, all sequences in
aln
will be used.
- blockSignals(self, bool) bool ¶
- childEvent(self, QChildEvent)¶
- children(self) List[QObject] ¶
- connectNotify(self, QMetaMethod)¶
- customEvent(self, QEvent)¶
- delayedSyncFromMsvToWorkspace(aln)¶
Replace residue selection in the workspace with residue selection in the given alignment. When new entries are included in the workspace, their residue selection is not automatically synchronized until selection is changed in either the workspace (in which case residue selection from the workspace is applied to the MSV) or the MSV (in which case residue selection from the MSV active tab is applied to the workspace and to the other MSV tabs). This method forces selection to be immediately synchronized.
This method will also remove workspace selection for any entries without a linked sequence in the given alignment.
This method is a no-op for structure models without a workspace.
- Parameters
aln (gui_alignment._ProteinAlignment) – The alignment to take residue selection from
- deleteLater(self)¶
- destroyed¶
destroyed(self, object: QObject = None) [signal]
- disconnect(QMetaObject.Connection) bool ¶
- disconnect(self) None
- disconnectNotify(self, QMetaMethod)¶
- dumpObjectInfo(self)¶
- dumpObjectTree(self)¶
- dynamicPropertyNames(self) List[QByteArray] ¶
- event(self, QEvent) bool ¶
- eventFilter(self, QObject, QEvent) bool ¶
- findChild(self, type, name: str = '', options: Union[Qt.FindChildOptions, Qt.FindChildOption] = Qt.FindChildrenRecursively) QObject ¶
- findChild(self, Tuple, name: str = '', options: Union[Qt.FindChildOptions, Qt.FindChildOption] = Qt.FindChildrenRecursively) QObject
- findChildren(self, type, name: str = '', options: Union[Qt.FindChildOptions, Qt.FindChildOption] = Qt.FindChildrenRecursively) List[QObject] ¶
- findChildren(self, Tuple, name: str = '', options: Union[Qt.FindChildOptions, Qt.FindChildOption] = Qt.FindChildrenRecursively) List[QObject]
- findChildren(self, type, QRegExp, options: Union[Qt.FindChildOptions, Qt.FindChildOption] = Qt.FindChildrenRecursively) List[QObject]
- findChildren(self, Tuple, QRegExp, options: Union[Qt.FindChildOptions, Qt.FindChildOption] = Qt.FindChildrenRecursively) List[QObject]
- findChildren(self, type, QRegularExpression, options: Union[Qt.FindChildOptions, Qt.FindChildOption] = Qt.FindChildrenRecursively) List[QObject]
- findChildren(self, Tuple, QRegularExpression, options: Union[Qt.FindChildOptions, Qt.FindChildOption] = Qt.FindChildrenRecursively) List[QObject]
- classmethod generateEntryResidueASL(residues_by_entry)¶
Generate an ASL string for the given entry IDs and residues.
- Parameters
residues_by_entry (dict[str, list(protein.residue.Residue)]) – Mapping of entry id to residues
- classmethod generateMultiEntryResidueASL(residues)¶
Generate an ASL string for the given residues. Residues can be from different entries.
- static generateResidueASL(residues)¶
Generate an ASL string for the given residues. Residues should be from the same entry.
- getIncludedEntries()¶
Returns a list of sequences for all entries that are currently included in the workspace. Raises NotImplementedError if the associated program has no concept of a workspace. :rtype: list
- getLinkedAlnSeqs(seq)¶
Return a set of linked sequences to the specified sequence :type seq: sequence.ProteinSequence :rtype: set
- getSelectedEntries()¶
Returns a list of sequences for all entries that are currently selected in the project table. Raises NotImplementedError if the associated program has no concept of a selected entry. :rtype: list
- getStructSeq(entry_id, chain_name)¶
Return a sequence for the chain structure specified by
entry_id
andchain_name
. This sequence will not be monitored by the structure model in any way and will not be kept up to date with any changes to the structure.This method will always raise a ValueError for structure models without a workspace.
- Parameters
entry_id (int or str) – The entry id of the structure.
chain_name (str) – The name of the chain to create a sequence for.
- Returns
The requested sequence
- Return type
- Raises
ValueError – If the specified entry_id or chain don’t exist.
- importFile(filename)¶
Return sequences for the specified file. If the file contains structural data, then the sequences will have associated structures accessible via
sequence.getStructure()
.- Parameters
filename (str) – The filename to read
- Returns
All sequences. Note that these sequences have not been loaded into any alignment, including the workspace alignment. If
filename
contains structural data and the current structure model backend implements a workspace, seeimportStructuresIntoWorkspace
, which imports a file and returns the corresponding workspace alignment sequences.- Return type
list(sequence.Sequence)
- Raises
IOError – If there was an error importing the file.
- importFiles(filenames)¶
Return sequences for all specified files. If any of the files contain structural data, then those sequences will have associated structures accessible via
sequence.getStructure()
.- Parameters
filenames (iterable) – The filenames to read
- Returns
All imported sequences. Note that these sequences have not been loaded into any alignment, including the workspace alignment.
- Return type
list(sequence.Sequence)
- Raises
IOError – If there was an error importing the files.
- inherits(self, str) bool ¶
- installEventFilter(self, QObject)¶
- isSignalConnected(self, QMetaMethod) bool ¶
- isWidgetType(self) bool ¶
- isWindowType(self) bool ¶
- killTimer(self, int)¶
- linkSequence(seq, entry_id, chain_name)¶
Link a sequence to the structure specified by entry_id and chain name.
This method will always raise a ValueError for structure models without a workspace.
- Parameters
seq (sequence.Sequence) – The sequence to associate with a structure.
entry_id (str or int) – The entry id of the structure to associate
chain_name (str) – The name of chain of the structure to associate with the sequence.
- Raises
ValueError – If the specified entry_id or chain don’t exist.
- loadFileAndLink(filename, seq)¶
- mapResidues(residues)¶
Map residues to all residues represented by the same structure residue. Note that only structures currently included in the workspace are considered. If a residue has no structure, the residue is included unchanged.
- metaObject(self) QMetaObject ¶
- moveToThread(self, QThread)¶
- objectName(self) str ¶
- objectNameChanged¶
objectNameChanged(self, str) [signal]
- onPagesMutated(new_pages, old_pages)¶
Update state in response to gui_model.pages.mutated signal. Note that this method must be connected to using
getSignalsAndSlots
rathermutated.connect
.
- parent(self) QObject ¶
- projectLoadRequested¶
- projectSaveRequested¶
- property(self, str) Any ¶
- pyqtConfigure(...)¶
Each keyword argument is either the name of a Qt property or a Qt signal. For properties the property is set to the given value which should be of an appropriate type. For signals the signal is connected to the given value which should be a callable.
- receivers(self, PYQT_SIGNAL) int ¶
- removeEventFilter(self, QObject)¶
- renameSeq(seq, new_name)¶
Rename the specified sequence
- Parameters
seq (sequence.ProteinSequence) – Sequence to be renamed
new_name (str) – New name for the sequence
- renumberResidues(seq, start, increment, preserve_icode)¶
Renumbers residues for a sequence.
- renumberResiduesByAntibodyCDR(seq, new_res_num_list)¶
Renumber residues in the sequence based on the given new numbers. :param seq: Sequnce to be renumbered :type seq: protein.sequence.ProteinSequence
- Parameters
new_res_num_list (List[str]) – List of residue numbers based on the Antibody CDR numbering scheme.
- renumberResiduesByTemplate(seq, template_seq)¶
Renumber
seq
based on the residue numbers oftemplate_seq
.- Parameters
seq (schrodinger.protein.sequence.ProteinSequence) – input sequence to be renumbered
template_seq (schrodinger.protein.sequence.ProteinSequence) – template sequence
- sender(self) QObject ¶
- senderSignalIndex(self) int ¶
- seqProjectTitlesChanged¶
- setObjectName(self, str)¶
- setParent(self, QObject)¶
- setProperty(self, str, Any) bool ¶
- setWorkspaceColors(color_map, all_atoms=False)¶
Sets the colors in the workspace to the colors given by color_map.
- Parameters
all_atoms (bool) – Whether to color all atoms or just carbons
- signalsBlocked(self) bool ¶
- startTimer(self, int, timerType: Qt.TimerType = Qt.CoarseTimer) int ¶
- staticMetaObject = <PyQt5.QtCore.QMetaObject object>¶
- structureWarningProduced¶
- thread(self) QThread ¶
- timerEvent(self, QTimerEvent)¶
- tr(self, str, disambiguation: str = None, n: int = - 1) str ¶
- workspaceColorsChanged¶
- class schrodinger.application.msv.test_helpers.BaseCheckUndoMixin[source]¶
Bases:
object
Mixin for checking that alignment undo operations are correct.
checkUndo
is a no-op, so this class can be used for testing a non-undoable alignment.
- class schrodinger.application.msv.test_helpers.CheckUndoMixin[source]¶
Bases:
schrodinger.application.msv.test_helpers.BaseCheckUndoMixin
Mixin for checking that GuiAlignment undo operations are correct.
- Variables
DELETE_UNDO_STACK (bool) – Whether checkUndo should set a new undo stack on entry and delete it on exit
- DELETE_UNDO_STACK = False¶
- checkUndo(aln)[source]¶
Check that calling undo on the specified alignment restores it to the state it was in before redo was called; calls redo on exit.
- Note
redo is called on the alignment on exiting the context, so that the alignment can be checked for other properties.
- Note
Because the context manager calls redo and undo, signals must be checked inside the context in tests.
- Note
Only one method that alters the alignment should be called inside the context
- Parameters
aln (schrodinger.application.msv.gui.gui_alignment._ProteinAlignment) – An undoable alignment to check
- schrodinger.application.msv.test_helpers.add_dummy_structure(seq)[source]¶
Add a 1 atom structure to the given sequence. This will make the
getStructure
andhasStructure
methods work for many testing purposes.
- schrodinger.application.msv.test_helpers.get_seqs_for_structure(filename)[source]¶
Create sequences for the structure in the specified file. The sequence’s
getStructure
andhasStructure
methods will work properly. (In the MSV panel, this would be handled by the structure model. Hereseq._get_structure
is set manually, which is typically sufficient for testing purposes.)- Parameters
filename (str) – The file to read the structure from
- Returns
Sequences for each chain in the structure
- Return type
list(sequence.Sequence)
- schrodinger.application.msv.test_helpers.immediate_selection_updates(sel_model)[source]¶
Modify the given selection model so that the selectionChanged signal is emitted immediately whenever the selection changes.
- Parameters
sel_model (gui.gui_alignment.AbstractAlignmentSelectionModel) – The selection model to modify
- schrodinger.application.msv.test_helpers.enable_mock_BlastTask()[source]¶
Replace the
BlastTask
class in theblast
module with a mocked out version that returns the blast results for 1cmy:a. TheBlastTaskTester
does not make a call to the ncbi server.
- schrodinger.application.msv.test_helpers.strings_to_multichain_seqs(strings)[source]¶
Convert a list of strings to a list of split-chain sequences. Each string represents a single combined-chain sequence, with pipes (“|”) used to represent chain breaks.
- Parameters
strings (list[str]) – The strings to convert.
- Returns
The newly constructed split-chain sequences
- Return type
- schrodinger.application.msv.test_helpers.strings_to_combined_aln(strings, split_aln_class=<class 'schrodinger.application.msv.gui.gui_alignment.GuiProteinAlignment'>, combined_aln_class=<class 'schrodinger.application.msv.gui.gui_alignment.GuiCombinedChainProteinAlignment'>)[source]¶
Convert a list of strings to a combined-chain alignment. Each string represents a single combined-chain sequence, with pipes (“|”) used to represent chain breaks.
- Parameters
strings (list[str]) – The strings to convert.
split_aln_class (Type[schrodinger.protein.alignment.BaseAlignment] or Type[gui_alignment.GuiProteinAlignment]) – The class of split-chain alignment to use.
combined_aln_class (Type[schrodinger.protein.alignment.CombinedChainProteinAlignment] or Type[gui_alignment.GuiCombinedChainProteinAlignment]) – The class of combined-chain alignment to use.
- Returns
The newly constructed combined-chain alignment
- Return type
Type[schrodinger.protein.alignment.CombinedChainProteinAlignment] or Type[gui_alignment.GuiCombinedChainProteinAlignment]
- schrodinger.application.msv.test_helpers.combined_aln_to_strings(aln)[source]¶
Convert a combined-chain alignment to a list of strings, with one string per sequence and pipes (“|”) used to represent chain breaks.
- Parameters
aln (schrodinger.protein.alignment.CombinedChainProteinAlignment or gui_alignment.GuiCombinedChainProteinAlignment) – The alignment to convert
- Returns
A list of strings containing the sequences in
aln
.- Return type
list[str]