schrodinger.application.matsci.reordergui module¶
This module contains classes to enable use of the reorder module in a GUI.
Copyright Schrodinger, LLC. All rights reserved.
-
class
schrodinger.application.matsci.reordergui.
StructureListWidget
(master, atomic_constraints=None)¶ Bases:
schrodinger.ui.qt.swidgets.SListWidget
A QListWidget that interacts with a structure picture to select atoms. Clicking on a row will send a signal that an atom has been clicked on. Atoms (rows) can be marked as Mapped or Unmapped, which will result in changing the background color of the row.
There is 1 row in in the ListWidget for each atom in the structure, in the same order as atoms are in the structure. Note that row indexes start at 0 but atom indexes start at 1, so we often have to add/subtract 1 to translate between the two.
-
atom_clicked
¶
-
setStructure
(struct)¶ Set the structure object for this widget and fill the widget
Parameters: struct ( schrodinger.structure.Structure
) – The structure object containing the data for this ListWidget
-
fill
()¶ Fill the items in the ListWidget using the current structure
-
selectAtom
(index)¶ Select the item that corresponds to the atom index
Parameters: index (int) – The index of atom whose item should be selected
-
itemSelected
(row)¶ React to the user selecting an item in the ListWidget
Parameters: row (int) – The row of the item selected
-
parseAtomText
(text)¶ Parse the given text into an element and atom index
Parameters: text (str) – String describing the atom such as C 13, H 1, etc. Also accepts strings for mapped atoms such as “C 13 - C 12” Return type: (str, int) Returns: The element and atom index specified by text
-
markAtomMapped
(index, guess=False)¶ Mark the row for the given atom index as mapped
Parameters: - index (int) – Atom to mark
- guess (bool) – True if this mark results from a guess, False if not. The background color used depends on this parameter.
Return type: QListWidgetItem
Returns: The list widget item for the affected atom
-
markAtomUnmapped
(index)¶ Mark the row for the given atom index as unmapped
Parameters: index (int) – Atom to mark Return type: QListWidgetItem Returns: The list widget item for the affected atom
-
-
class
schrodinger.application.matsci.reordergui.
ComparisonListWidget
(master, atomic_constraints=None)¶ Bases:
schrodinger.application.matsci.reordergui.StructureListWidget
The list widget for the Comparison structure.
-
getAtomText
(atom)¶ Get the text to display in a row of the ListWidget
The atom text for an item is just the atom element plus index
Parameters: atom (int or _StructureAtom) – A reference to the atom to create text for Return type: str Returns: The text to display for this atom
-
markAtomMapped
(index, guess=False)¶ Mark the row for the given atom index as mapped
Adds to the parent method by deselecting the row
Parameters: - index (int) – Atom to mark
- guess (bool) – True if this mark results from a guess, False if not. The background color used depends on this parameter.
Return type: QListWidgetItem
Returns: The list widget item for the affected atom
-
-
class
schrodinger.application.matsci.reordergui.
ReferenceListWidget
(master, atomic_constraints=None)¶ Bases:
schrodinger.application.matsci.reordergui.StructureListWidget
The ListWidget for the reference structure.
-
markAtomMapped
(index, guess=False)¶ Mark the row for the given atom index as mapped and update the text
Adds to the parent method by changing the text of the marked item to reflect the mapping.
Parameters: - index (int) – Atom to mark
- guess (bool) – True if this mark results from a guess, False if not. The background color used depends on this parameter.
Return type: QListWidgetItem
Returns: The list widget item for the affected atom
-
markAtomUnmapped
(index)¶ Remove the mapping for atom index
Adds to the parent method by changing the text of the marked item to reflect the unmapping.
Parameters: index (int) – The atom index to unmap Return type: QListWidgetItem Returns: The list widget item for the affected atom
-
getAtomText
(atom)¶ Get the text to display in a row of the ListWidget
The atom text for an item is the atom element plus index for the Reference atom, plus the atom index of any Comparison atom mapped to this atom.
Parameters: atom (int or _StructureAtom) – A reference to the atom to create text for Return type: str Returns: The text to display for this atom
-
-
class
schrodinger.application.matsci.reordergui.
StructureView
(scene)¶ Bases:
schrodinger.ui.qt.structure2d.structure_view
View which holds a structure_item object
-
atom_highlighted
¶
-
-
class
schrodinger.application.matsci.reordergui.
StructurePic
(scene)¶ Bases:
schrodinger.ui.qt.structure2d.structure_item
The QGraphicsItem that holds a 2D image of a structure
-
reset
()¶ Clear all the annotators and remove the picture
-
hoverMoveEvent
(event)¶ Track when the mouse is over an atom - emit a signal when it enters a new atom or leaves an atom. An index of 0 is emitted when the mouse is not over any atom.
-
setStructure
(struct)¶ Set the structure - create a new image of it
Parameters: struct ( schrodinger.structure.Structure
) – The structure object for this picture
-
selectAtom
(index)¶ Select an atom in the image and regenerate the picture
Parameters: index (int) – The atom index to select
-
markAtomMapped
(index, guess=False)¶ Mark an atom as mapped (either by guess or manually) and regenerate the picture.
Parameters: - index (int) – The atom index to mark
- guess (bool) – True if this mark results from a guess, False if not. The background color used depends on this parameter.
-
markAtomUnmapped
(index)¶ Mark an atom as unmapped and regenerate the picture.
Parameters: index (int) – The atom index to mark
-
highlightAtom
(index, guess=False)¶ Highlight an atom
Parameters: - index (int) – The atom index to highlight
- guess (bool) – True if this atom is marked by a guess, False if it was marked by the user. The background color used depends on this parameter.
-
-
class
schrodinger.application.matsci.reordergui.
StructureFrame
(master, structure_layout, list_layout, struct=None, mytype='Comparison', atomic_constraints=None)¶ Bases:
PyQt5.QtWidgets.QFrame
A QFrame that contains a 2D image of a structure. This also creates a QListWidget that is coordinated with the 2D image. This is the base class for both the Reference and Comparison structures.
-
setLabel
(guessing=False)¶ Set the label that describes what the user should do
Parameters: guessing (bool) – True if there is currently a guess in place, False if not.
-
setStructure
(struct)¶ Set the structure for this frame. Updates the image and the list widget
Parameters: struct ( schrodinger.structure.Structure
) – The structure for this frame
-
highlightAtom
(index, guess=False)¶ Highlight the given atom
Parameters: - index (int) – The atom index to highlight
- guess (bool) – True if this atom is marked by a guess, False if it was marked by the user. The background color used depends on this parameter.
-
unmapAtom
(index)¶ Mark an atom as unmapped
Parameters: index (int) – The atom index to mark
-
reset
(reset_structure=True)¶ Reset to a blank frame, or remove any mapping but keep the structure
Parameters: reset_structure – True if the structure should be reset, False if it should be kept
-
isValidAtomIndex
(index)¶ Check if this index is a valid atom index for the loaded structure
Parameters: index (int) – The atom index to check Return type: bool Returns: True 0 < index <= atom_total, False otherwise
-
-
class
schrodinger.application.matsci.reordergui.
ComparisonFrame
(master, structure_layout, list_layout, struct=None, mytype='Comparison', atomic_constraints=None)¶ Bases:
schrodinger.application.matsci.reordergui.StructureFrame
The StructureFrame for the Comparison structure
-
mapAtom
(index, guess=False)¶ Mark an atom as mapped
Parameters: - index (int) – The atom index to mark
- guess (bool) – True if this atom is marked by a guess, False if it was marked by the user. The background color used depends on this parameter.
-
selectAtom
(index)¶ Select an atom in both the image and listwidget
Parameters: index (int) – The atom index to select
-
-
class
schrodinger.application.matsci.reordergui.
ReferenceFrame
(*args, **kwargs)¶ Bases:
schrodinger.application.matsci.reordergui.StructureFrame
The StructureFrame for the Reference structure
-
setStructure
(struct)¶ Set the structure for this frame. Updates the image and the list widget
Parameters: struct ( schrodinger.structure.Structure
) – The structure for this frame
-
mapAtom
(ref_index, advance=True, guess=False)¶ Map the given atom index in the comparison structure to the given atom index in the reference structure.
Parameters: - ref_index (int) – The atom index of the reference molecule
- advance (bool) – Whether to advance the selected atom or not. The selection will automatically be advanced if ref_index is the currently selected atom regardless of this setting.
-
advanceSelection
(index)¶ Move the selection to the next unmapped atom with a higher index. If none exist, start checking again at atom 1.
Parameters: index (int) – Start search for unmapped atoms with indexes higher than this number
-
selectedIndex
()¶ Get the index of the currently selected atom
Return type: int Returns: The index of the selected Reference atom
-
-
class
schrodinger.application.matsci.reordergui.
ReorderAtomFrame
(parent=None, by_element=True, by_smiles=True, by_smarts=True, by_superposition=True, layout=None, reference_structure=None, comparison_structure=None, reference_structure_constraints=None)¶ Bases:
schrodinger.ui.qt.swidgets.SFrame
A frame which allows the user to reorder the atoms of a comparison structure based on the atom order of a reference structure. The widgets provide the ability to guess at atom order based on multiple algorithms and also manually specify order using 2D images of the structures.
-
setStructures
(reference, comparison)¶ Set the reference and comparison structures
Parameters: - reference (
schrodinger.structure.Structure
) – The structure to use as the reference - comparison (
schrodinger.structure.Structure
) – The structure to use as the comparison
- reference (
-
guessMode
(guessmode)¶ Set the current guess mode - affects label texts and enabling/disabling widgets and user interaction signals.
Parameters: guessmode (bool) – True if a guess is currently taking place and has not yet been Accepted/Rejected, False if any other situation
-
selectRefAtom
(index)¶ Select the current atom in the reference structure
Parameters: index (int) – The index of the atom to select
-
mapPair
(ref_index, comp_index, advance=True, guess=False)¶ Create a mapping between an atom in the Comparison structure to an atom in the Reference structure.
Parameters: - ref_index (int) – The atom index of the reference atom to map
- comp_index (int) – The atom index of the comparison atom to map
- advance (bool) – True if the Reference atom selection should be advanced, False if not
- guess (bool) – True if this mark results from a guess, False if not. The background color used depends on this parameter.
-
unmapPair
(ref_index, comp_index)¶ Create a mapping between an atom in the Comparison structure to an atom in the Reference structure.
Parameters: - ref_index (int) – The atom index of the reference atom to map
- comp_index (int) – The atom index of the comparison atom to map
-
mapCompAtom
(comp_index, ref_index=None, auto=True, advance=True)¶ Map an atom in the Comparison structure to an atom in the Reference structure
Parameters: - comp_index (int) – The atom index of the comparison atom to map
- ref_index (int or None) – If an int, the index of the reference atom to map to. If not given, the selected reference atom will be used
- auto (bool) – Whether to Auto guess additional atoms based on this mapping. Default is True - but autoguessing will only occur if the user has checked the Auto guess box.
- advance (bool) – True if the Reference atom selection should be advanced, False if not
-
autoMap
()¶ Automatically map no-brainer atoms based on the current mapping. No-brainer atoms are atoms that are the only atoms remaining of a given element, or hydrogens bound to mapped atoms that can be uniquely identified.
-
compAtomFromRefAtom
(index)¶ Get the atom in the Comparison structure that is mapped to the given index in the Reference structure
Parameters: index (int) – The index of the Reference atom to check Return type: int Returns: The index of the Comparison atom mapped to the given Reference atom
-
refAtomFromCompAtom
(index)¶ Get the atom in the Reference structure that is mapped to the given index in the Comparison structure
Parameters: index (int) – The index of the Comparison atom to check Return type: int Returns: The index of the Reference atom mapped to the given Comparison atom
-
highlightCompAtom
(comp_index)¶ Highlight an atom in the Comparision structure
Parameters: comp_index (int) – The index of the comparison atom to highlight
-
highlightRefAtom
(ref_index)¶ Highlight an atom in the Reference structure
Parameters: ref_index (int) – The index of the reference atom to highlight
-
highlightMapPair
(ref_index, comp_index)¶ Highlight the mapped pair of atoms
Parameters: - ref_index (int) – The index of the reference atom to highlight
- comp_index (int) – The index of the comparison atom to highlight
-
guessOrder
()¶ Make a guess at the new order of the Comparison atoms
-
guessAccepted
()¶ User has accpeted the guess, make the atoms truly mapped
-
guessRejected
()¶ User has rejected the guess remove it
-
isInGuessMode
()¶ Is the panel currently in guess mode?
Return type: bool Returns: True if the panel is in guess mode, False if not
-
finishGuess
()¶ Finish guess mode after the user has accepted or rejected the guess.
Note - this method should be callable even if not currently in a guess.
-
doneReordering
()¶ Check if the reordering process is done
Return type: bool Returns: True if all the atoms in one of the structures are mapped
-
getReorderedStructure
()¶ Get a reordered version of the comparison structure
Return type: schrodinger.structure.Structure
, list or (None, None)Returns: The comparison structure with the atoms reordered as specified in the mapping, and the list used to reorder the structure. The first element of the list is the original index of the atom that is first in the reordered structure, the second is the original index of the atom that is second in the reordered structure, etc. (None, None) is returned if the structure is not ready for reordering.
-
resetMap
()¶ Reset only the map, keeping the structures
-
reset
(reset_structures=True)¶ Reset the frame
Parameters: reset_structures (bool) – True if structures should be reset, False if they should be kept
-
-
class
schrodinger.application.matsci.reordergui.
ReorderAtomPanel
(**kwargs)¶ Bases:
schrodinger.ui.qt.appframework2.af2.JobApp
A simple panel that takes two selected entries and allows one of them to be reordered - this is mainly for testing and example purposes.
-
setPanelOptions
()¶ Override the generic parent class to set panel options
-
layOut
()¶ Lay out the widgets for this panel
-
loadStructures
()¶ Load in the two structures. The first selected entry will be the reference.
-
createReorderedEntry
()¶ Create a new, reordered version of the second selected entry. If run from maestro, this will be created as a new project entry and included in the workspace.
-
-
class
schrodinger.application.matsci.reordergui.
ReorderAtomsDialog
(master, struct1, struct2, modality=0, struct1_atomic_constraints=None, **kwargs)¶ Bases:
schrodinger.ui.qt.swidgets.SDialog
A Window-Modal dialog that allows the user to reorder atoms in a comparison structure based on a reference structure.
-
layOut
()¶ Lay out the custom widgets in this dialog.
-
accept
()¶ User has clicked accept, get the reordered structure, call the accept_command with it and close the dialog.
Return type: int or None Returns: QDialog.Accepted if a structure has been reordered, or None if the reordering was incomplete and the dialog not closed
-
reject
()¶ User has clicked reject - do nothing but call custom reject method
Return type: int Returns: QDialog.Reject
-
-
schrodinger.application.matsci.reordergui.
panel
()¶ Top-level function for bringing up the panel.
-
schrodinger.application.matsci.reordergui.
main
(*args)¶