Source code for schrodinger.application.canvas.fingerprintgui
"""
Higher-level wrappers to the Canvas Fingerprint generation and manipulation
classes with GUI components.
Copyright Schrodinger, LLC. All rights reserved.
"""
# Contributors: Quentin McDonald
import schrodinger.ui.qt.swidgets as swidgets
from schrodinger.application.canvas import fingerprint
from schrodinger.Qt import QtWidgets
#################### GUI Classes start here ###########################
[docs]class CanvasFingerprintGeneratorGUI(fingerprint.CanvasFingerprintGenerator):
"""
A subclass of the canvas fingerprint generator which is to be
used from a program with a TKInter interface. This class has methods
for creating a component which displays all the fingerprint generation
options and takes care of managing the internal state
"""
[docs] def __init__(self, logger, default_type='Linear'):
fingerprint.CanvasFingerprintGenerator.__init__(self, logger,
default_type)
[docs] def getGUI(self):
"""
Returns a GUI component which displays the fingerprint
generation options
"""
self.base_group = swidgets.SGroupBox('Fingerprint Settings')
# Precision
rb_layout = swidgets.SHBoxLayout()
rb_layout.addWidget(QtWidgets.QLabel('Precision:'))
labels = ["%d-bit" % int(x) for x in self.PRECISION]
self.bits_radio = swidgets.SRadioButtonGroup(command=self.bitCB,
labels=labels,
layout=rb_layout,
nocall=True)
self.bitCB(True)
rb_layout.addStretch()
self.base_group.layout.addLayout(rb_layout)
# Fingerprint type
combo_layout = swidgets.SHBoxLayout()
combo_layout.addWidget(QtWidgets.QLabel('Fingerprint type:'))
combo = swidgets.SComboBox(items=self.FINGERPRINT_TYPES,
nocall=True,
command=self.FPTypeCB,
layout=combo_layout)
combo_layout.addStretch()
self.base_group.layout.addLayout(combo_layout)
# Scheme
self.base_group.layout.addWidget(
QtWidgets.QLabel('Atom Typing Scheme:'))
self.listw = swidgets.SListWidget(items=self.ATOM_TYPING_SCHEMES,
command=self.atomTypingCB,
layout=self.base_group.layout)
# Note that "7" is the default atom typing scheme for linear
# fingerprints, but this is index 6 in the list of names:
self.listw.setCurrentRow(6)
self.FPTypeCB(self.FINGERPRINT_TYPES[0])
return self.base_group
[docs] def bitCB(self, value):
"""
A callback function for the Bitsize radio buttons
:type value: unused
:param value: unused
"""
precision = self.bits_radio.checkedText()
bits = precision.replace('-bit', "")
self.setPrecision(int(bits))
[docs] def atomTypingCB(self, row):
"""
Called when the atom typing selection changes
:type row: int
:param row: the row of the listwidget that was selected
"""
self.setAtomBondTyping(row + 1)
[docs] def FPTypeCB(self, fp_type):
"""
A callback for the fingerprint type. Sets the default option
in the list of atom typing schemes based on the fingerprint type
:type fp_type: str
:param fp_type: the text selected in the combobox
"""
self.setType(fp_type)
def_ab_scheme = self.getDefaultAtomTypingScheme()
self.setAtomBondTyping(def_ab_scheme)
self.listw.setCurrentRow(def_ab_scheme - 1)
[docs] def resetfp(self):
"""
Allow reset of the fingerprint generator between cluster calculations.
See EV:91489 and 101763
"""
if self._fingerprinter is not None:
del self._fingerprinter
self._fingerprinter = None