22 from PyQt5
import QtCore, QtGui, QtWidgets
30 QtWidgets.QComboBox.__init__(self, parent)
33 for chain
in self.entity.chains:
34 self.addItem(chain.name)
36 self.setCurrentIndex(0)
45 self.gfx.selection =
None
51 for chain
in self.entity.chains:
52 self.addItem(chain.name)
54 self.setCurrentIndex(0)
58 def _HighlightChain(self, chain_idx):
59 chain = self.itemText(chain_idx)
61 self.gfx.SetSelection(self.entity.Select(
'cname="%s"' % str(chain)))
63 self.gfx.SetSelection(self.entity.Select(
''))
65 def _GetSelectedChain(self):
66 if self.currentIndex() == -1:
70 return self.entity.Select(
'cname="%s"' % str(self.currentText()))
72 def _SetSelectedChain(self, chain):
73 if hasattr(chain,
'name'):
77 for i
in range(self.count()):
78 if self.itemText(i) == name:
79 self.setCurrentIndex(i)
81 selected_chain = property(_GetSelectedChain, _SetSelectedChain)
85 Provides a graphical user interface to structurally superpose two entities.
86 Uses function :func:`~ost.mol.alg.Superpose`. The RMSD of two superposed
87 molecules will be stored in attribute ``rmsd``. An index for the selected
88 reference molecule will be stored in attribute ``reference``.
90 :param ent_one: The first entity
91 :type ent_one: :class:`~ost.mol.EntityView`, :class:`~ost.mol.EntityHandle`
92 or :class:`~ost.gfx.Entity`
93 :param ent_two: The second entity
94 :type ent_two: :class:`~ost.mol.EntityView`, :class:`~ost.mol.EntityHandle`
95 or :class:`~ost.gfx.Entity`
99 .. code-block:: python
101 e1=io.LoadPDB('examples/code_fragments/entity/pdb1ake.ent')
102 e2=io.LoadPDB('examples/code_fragments/entity/pdb4ake.ent')
104 sd = ost.gui.dng.superpositiondialog.SuperpositionDialog(e1, e2)
106 g1=gfx.Entity('G1', e1)
107 g2=gfx.Entity('G2', e2)
111 if sd.reference == 0:
117 LogScript('RMSD: %.3f'%sd.rmsd)
128 'local alignment':
'local-aln',
129 'global alignment':
'global-aln'}
134 QtWidgets.QDialog.__init__(self, parent)
135 self.setWindowTitle(
'Superpose Structures')
138 n_one = ent_one.GetName()
144 n_one = ent_one.GetName()
146 n_one = ent_one.GetHandle().GetName()
152 n_two = ent_two.GetName()
158 n_two = ent_two.GetName()
160 n_two = ent_two.GetHandle().GetName()
167 layout = QtWidgets.QGridLayout(self)
172 layout.addWidget(QtWidgets.QLabel(
"reference"), grow, 0)
178 layout.addWidget(QtWidgets.QLabel(
"reference chain"), grow, 0)
181 layout.addWidget(QtWidgets.QLabel(
"chain"), grow, 0)
188 layout.addWidget(QtWidgets.QLabel(
'match residues by'), grow, 0)
195 layout.addWidget(self._it_box, grow, 0)
201 layout.addWidget(self._atmselectbx, grow, 1)
204 ok_button = QtWidgets.QPushButton(
"Superpose")
205 ok_button.clicked.connect(self.accept)
206 cancel_button = QtWidgets.QPushButton(
"Cancel")
207 hbox_layout = QtWidgets.QHBoxLayout()
208 hbox_layout.addStretch(1)
209 layout.addLayout(hbox_layout, grow, 0, 1, 2)
211 cancel_button.clicked.connect(self.reject)
213 hbox_layout.addWidget(cancel_button, 0)
214 hbox_layout.addWidget(ok_button, 0)
215 ok_button.setDefault(
True)
223 def _Superpose(self):
224 view_one = self._chain_one.selected_chain
225 view_two = self._chain_two.selected_chain
231 max_iterations=self._it_in.value(),
232 distance_threshold=self._dist_in.value())
233 except Exception
as e:
242 def _toggle_atoms(self, checked):
244 self._atoms.setEnabled(
True)
246 self._atoms.setEnabled(
False)
248 def _AtomSelectionBox(self):
249 bt1 = QtWidgets.QRadioButton(
'All')
250 bt2 = QtWidgets.QRadioButton(
'Backbone')
251 bt3 = QtWidgets.QRadioButton(
'CA')
253 custom_rbutton = QtWidgets.QRadioButton(self.
cstmbtntxt)
254 group = QtWidgets.QButtonGroup()
258 group.addButton(custom_rbutton)
260 vbox_layout = QtWidgets.QVBoxLayout()
261 vbox_layout.addWidget(bt1)
262 vbox_layout.addWidget(bt2)
263 vbox_layout.addWidget(bt3)
264 vbox_layout.addWidget(custom_rbutton)
265 vbox_layout.addWidget(self.
_atoms)
267 box = QtWidgets.QGroupBox(
"atom selection")
268 box.setLayout(vbox_layout)
271 def _GetAtomSelection(self):
272 checkedbtn = self._atmselectgrp.checkedButton()
274 return str(checkedbtn.text())
275 slctn_model = self._atoms.selectionModel()
276 dt_model = slctn_model.model()
278 for idx
in slctn_model.selectedRows():
279 slctn = dt_model.data(idx, Qt.DisplayRole).toString()
280 atms.append(str(slctn))
283 def _FetchAtoms(self, dim, ent_a, ent_b):
286 for atm
in ent_a.GetAtomList():
287 atm_dict[atm.name] = 0
288 for atm
in ent_b.GetAtomList():
289 if atm.name
in atm_dict:
290 atm_dict[atm.name] = 1
292 for atm
in sorted(atm_dict.keys()):
295 elems = QtCore.QStringListModel(atmlst)
296 atoms = QtWidgets.QListView(self)
297 dim.setHeight(3*dim.height())
298 atoms.setFixedSize(dim)
299 atoms.setModel(elems)
300 atoms.setSelectionMode(QtWidgets.QAbstractItemView.MultiSelection)
301 atoms.setEditTriggers(QtWidgets.QAbstractItemView.NoEditTriggers)
302 atoms.setEnabled(
False)
305 def _ReferenceSelection(self, name_a, name_b):
306 cbox = QtWidgets.QComboBox()
310 cbox.setCurrentIndex(0)
313 def _toggle_iterative(self, checked):
315 self._it_in.setEnabled(
True)
316 self._dist_in.setEnabled(
True)
319 self._it_in.setEnabled(
False)
320 self._dist_in.setEnabled(
False)
324 bt1 = QtWidgets.QRadioButton(
"On")
325 iteration_label=QtWidgets.QLabel(
"Max Iterations: ")
326 distance_label=QtWidgets.QLabel(
"Dist Thresh: ")
327 iteration_in=QtWidgets.QSpinBox()
328 iteration_in.setRange(1,30)
329 iteration_in.setValue(8)
330 distance_in=QtWidgets.QDoubleSpinBox()
331 distance_in.setRange(1.0,10.0)
332 distance_in.setValue(3.0)
333 distance_in.setDecimals(1)
334 distance_in.setSingleStep(0.5)
335 iteration_in.setEnabled(
False)
336 distance_in.setEnabled(
False)
337 bt1.setChecked(
False)
339 vbox_layout = QtWidgets.QVBoxLayout()
340 vbox_layout.addWidget(bt1)
341 vbox_layout.addWidget(iteration_label)
342 vbox_layout.addWidget(iteration_in)
343 vbox_layout.addWidget(distance_label)
344 vbox_layout.addWidget(distance_in)
345 vbox_layout.addSpacing(50)
347 box = QtWidgets.QGroupBox(
"Iterative")
348 box.setLayout(vbox_layout)
349 return box,iteration_in, distance_in
351 def _ChangeChainSelection(self, index):
361 def _MatchMethods(self):
362 methods=QtWidgets.QComboBox(self)
364 methods.addItem(method)
def _ChangeChainSelection