Source code for schrodinger.application.matsci.rdpattern_gui
"""
GUI elements to generate and evaluate Smiles/SMARTS pattern for both CG and all
atomic structure using RDKIT
Copyright Schrodinger, LLC. All rights reserved.
"""
from schrodinger.application.matsci import rdpattern
from schrodinger.ui.qt.widgetmixins import basicmixins
[docs]class GuiPattern(rdpattern.Pattern, basicmixins.MessageBoxMixin):
"""
This class describes a pattern that can be used by graphical user interface.
"""
[docs] def evaluateSmarts(self, smarts, **kwargs):
"""
Overwrite parent class to reload rdmol to obey stereochemistry in case
smarts has stereo and current rdmol does not.
"""
# Evaluate if already contains stereo
if self.include_stereo:
super().evaluateSmarts(smarts, **kwargs)
if rdpattern.has_stereo_smarts(smarts):
msg = (f'{smarts} contains stereochemistry information. Evaluating '
'a SMARTS pattern with stereochemistry might take may take '
'a long time.')
result = self.question(text=msg,
yes_text='Continue',
title='Stereochemical SMARTS')
if result:
# Clear smarts related cache since rdmol has changed
self._smarts = {}
# Load pattern with stereo
self.include_stereo = True
self.loadMol()
return super().evaluateSmarts(smarts, **kwargs)