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:
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¶
A
pyqtSignal
emitted by instances of the class.
- __init__(master, atomic_constraints=None)¶
Create a StructureListWidget instance
- Parameters:
master (ReorderAtomFrame) – The mapping property of the master is used by some subclasses
atomic_constraints (list or None) – list of atomic constraints for each atom or None
- 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
- getMarkedAtoms(guess=False)¶
Get atom indexes of marked atoms.
- Parameters:
guess (bool) – True if this mark results from a guess, False if not. The background color used depends on this parameter.
- Return type:
list(int)
- Returns:
Indexes of marked atoms
- class schrodinger.application.matsci.reordergui.ComparisonListWidget(*args, **kwargs)¶
Bases:
StructureListWidget
The list widget for the Comparison structure.
- __init__(*args, **kwargs)¶
See parent method for the documentation. Here defaults are set.
- 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
- markSuggestedAtom(index)¶
Mark foreground of the suggested atom item with SUGGEST_COLOR, previously suggested atom with BLACK.
- Parameters:
index (int) – Atom to mark
- class schrodinger.application.matsci.reordergui.ReferenceListWidget(master, atomic_constraints=None)¶
Bases:
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:
structure_view
View which holds a structure_item object
- atom_highlighted¶
A
pyqtSignal
emitted by instances of the class.
- class schrodinger.application.matsci.reordergui.StructurePic(scene)¶
Bases:
structure_item
The QGraphicsItem that holds a 2D image of a structure
- __init__(scene)¶
Create a StructurePic instance
- Parameters:
scene (QGraphicsScene) – The Scene this image is placed in
- 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, generate=True)¶
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.
generate (bool) – Whether to regenerate the 2D picture
- 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.
- highlightSuggestedAtom(index)¶
Highlight suggested atom
- Parameters:
index (int) – The atom index to highlight
- class schrodinger.application.matsci.reordergui.StructureFrame(master, label_layout, structure_layout, list_layout, struct=None, mytype='Comparison', atomic_constraints=None, enable_2d_structure=True)¶
Bases:
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.
- __init__(master, label_layout, structure_layout, list_layout, struct=None, mytype='Comparison', atomic_constraints=None, enable_2d_structure=True)¶
Create a StructureFrame instance
- Parameters:
master (ReorderAtomFrame) – The master Frame for this widget
label_layout (QBoxLayout) – The layout to add the label.
structure_layout (QBoxLayout) – The layout to add this widget to.
list_layout (QBoxLayout) – The layout to add the associated ListWidget to.
struct (
schrodinger.structure.Structure
) – The structure for this framemytype (str) – Either REFERENCE or COMPARISON, the type of structure this Frame applies to.
atomic_constraints (list or None) – list of atomic constraints for each atom or None
enable_2d_structure (bool) – If True, enable/show 2D structure. Can be slow for inorganic materials
- generatePicture()¶
Regenerate the 2D picture to show any changes
- 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
- selectAtom(index)¶
Select an atom in both the image and listwidget
- Parameters:
index (int) – The atom index to select
- Return type:
structure._StructureAtom
- Returns:
selected atom
- mapAtom(index, guess=False, generate=True)¶
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.
generate (bool) – Whether to regenerate the 2D picture
- class schrodinger.application.matsci.reordergui.ComparisonFrame(master, label_layout, structure_layout, list_layout, struct=None, mytype='Comparison', atomic_constraints=None, enable_2d_structure=True)¶
Bases:
StructureFrame
The StructureFrame for the Comparison structure
- suggestCloseAtom(xyz)¶
Highlight and return index of the closest atom from the XYZ location taking into account PBCs.
- Param:
Coordinates
- Return type:
int
- Returns:
Closest atom index
- suggestedIndex()¶
Get last suggested index.
- Return type:
int or None
- Returns:
last suggested index
- class schrodinger.application.matsci.reordergui.ReferenceFrame(*args, **kwargs)¶
Bases:
StructureFrame
The StructureFrame for the Reference structure
- __init__(*args, **kwargs)¶
Create a ReferenceFrame object. Parameters are described in the StructureFrame class
- mapAtom(ref_index, advance=True, **kwargs)¶
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.PickPairToggleIntermediate(checkbox, pick_function, pick_text='Pick 2 atoms to define a pair', allow_locked_entries=False)¶
Bases:
PickPairToggle
Class that allows: to call pick function in the intermediate picking state (only one atom is picked out of two); to prevent calling pick function at all if desired.
- setStructures(reference, comparison)¶
Set the reference and comparison structures
- Parameters:
reference (
schrodinger.structure.Structure
) – The structure to use as the referencecomparison (
schrodinger.structure.Structure
) – The structure to use as the comparison
- class schrodinger.application.matsci.reordergui.ReorderAtomFrame(parent=None, by_element=True, by_smiles=True, by_smarts=True, by_superposition=True, default_method='SMARTS patterns of whole molecule or unique atoms', layout=None, reference_structure=None, comparison_structure=None, reference_structure_constraints=None, enable_2d_structure=True)¶
Bases:
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.
- MAP_COUNTER_LABEL = '{num_mapped_atoms} of {atom_total}\natoms mapped'¶
- __init__(parent=None, by_element=True, by_smiles=True, by_smarts=True, by_superposition=True, default_method='SMARTS patterns of whole molecule or unique atoms', layout=None, reference_structure=None, comparison_structure=None, reference_structure_constraints=None, enable_2d_structure=True)¶
Create a ReorderAtomFrame widget
- Parameters:
parent (QWidget) – The parent widget with a .warning(str) method
by_element (bool) – Provide widgets to allow a guess based on lone elements
by_smiles (bool) – Provide widgets to allow a guess based on unique SMILES order
by_smarts (bool) – Provide widgets to allow a guess based on SMARTS patterns
by_superposition (bool) – Provide widgets to allow a guess based on 3D superposition of the structures
default_method (str) – Default guess method
layout (QBoxLayout) – The layout to place this frame into
reference_structure (
schrodinger.structure.Structure
) – The structure to use as the referencecomparison_structure (
schrodinger.structure.Structure
) – The structure to use as the comparisonenable_2d_structure (bool) – If True, enable/show 2D structure. Can be slow for inorganic materials
- updateMapCounter()¶
Updates the label indicating the number of atoms mapped
- Return type:
None
- show2DStructures(state)¶
Show or hide 2D structure pictures
- Parameters:
state (bool) – If True, show 2D structure picture, otherwise hide
- setStructures(reference, comparison)¶
Set the reference and comparison structures
- Parameters:
reference (
schrodinger.structure.Structure
) – The structure to use as the referencecomparison (
schrodinger.structure.Structure
) – The structure to use as the comparison
- 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, generate=True)¶
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.
generate (bool) – Whether to regenerate the 2D picture
- 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
- markAtomsInWS()¶
Mark selected atoms for guess in the WS.
- markSuggestedAtomsInWS(ref_idx, comp_idx)¶
Pick reference atom in the WS and mark suggested comparison atom.
- Parameters:
ref_idx (int) – Index of the atom to pick in the reference WS
comp_idx (int or None) – If int, mark atom in the comparison WS structure
- 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 accepted 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:
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=WindowModality.NonModal, struct1_atomic_constraints=None, default_guess_method='SMARTS patterns of whole molecule or unique atoms', enable_2d_structure=True, **kwargs)¶
Bases:
SDialog
A Window-Modal dialog that allows the user to reorder atoms in a comparison structure based on a reference structure.
- __init__(master, struct1, struct2, modality=WindowModality.NonModal, struct1_atomic_constraints=None, default_guess_method='SMARTS patterns of whole molecule or unique atoms', enable_2d_structure=True, **kwargs)¶
Create a ReorderAtomDialog instance. See parent for
**kwargs
docs.- Parameters:
master (QWidget) – The parent widget
struct1 (
schrodinger.structure.Structure
) – The reference structure. This structure will not be reordered.struct2 (
schrodinger.structure.Structure
) – The comparison structure. A copy of this structure will be reordered when the user clicks OKmodality (int) – The modality of the dialog. Default is Qt.NonModal, other options may be Qt.WindowModal or Qt.ApplicationModal.
struct1_atomic_constraints (list) – List of constraints in text format
default_guess_method (str) – Default guess method
- 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)¶