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)
127 'local alignment':
'local-aln',
128 'global alignment':
'global-aln'}
133 QtWidgets.QDialog.__init__(self, parent)
134 self.setWindowTitle(
'Superpose Structures')
137 n_one = ent_one.GetName()
143 n_one = ent_one.GetName()
145 n_one = ent_one.GetHandle().GetName()
151 n_two = ent_two.GetName()
157 n_two = ent_two.GetName()
159 n_two = ent_two.GetHandle().GetName()
166 layout = QtWidgets.QGridLayout(self)
171 layout.addWidget(QtWidgets.QLabel(
"reference"), grow, 0)
177 layout.addWidget(QtWidgets.QLabel(
"reference chain"), grow, 0)
180 layout.addWidget(QtWidgets.QLabel(
"chain"), grow, 0)
187 layout.addWidget(QtWidgets.QLabel(
'match residues by'), grow, 0)
194 layout.addWidget(self._it_box, grow, 0)
200 layout.addWidget(self._atmselectbx, grow, 1)
203 ok_button = QtWidgets.QPushButton(
"Superpose")
204 ok_button.clicked.connect(self.accept)
205 cancel_button = QtWidgets.QPushButton(
"Cancel")
206 hbox_layout = QtWidgets.QHBoxLayout()
207 hbox_layout.addStretch(1)
208 layout.addLayout(hbox_layout, grow, 0, 1, 2)
210 cancel_button.clicked.connect(self.reject)
212 hbox_layout.addWidget(cancel_button, 0)
213 hbox_layout.addWidget(ok_button, 0)
214 ok_button.setDefault(
True)
222 def _Superpose(self):
223 view_one = self._chain_one.selected_chain
224 view_two = self._chain_two.selected_chain
229 max_iterations=self._it_in.value(),
230 distance_threshold=self._dist_in.value())
236 def _toggle_atoms(self, checked):
238 self._atoms.setEnabled(
True)
240 self._atoms.setEnabled(
False)
242 def _AtomSelectionBox(self):
243 bt1 = QtWidgets.QRadioButton(
'All')
244 bt2 = QtWidgets.QRadioButton(
'Backbone')
245 bt3 = QtWidgets.QRadioButton(
'CA')
247 custom_rbutton = QtWidgets.QRadioButton(self.
cstmbtntxt)
248 group = QtWidgets.QButtonGroup()
252 group.addButton(custom_rbutton)
254 vbox_layout = QtWidgets.QVBoxLayout()
255 vbox_layout.addWidget(bt1)
256 vbox_layout.addWidget(bt2)
257 vbox_layout.addWidget(bt3)
258 vbox_layout.addWidget(custom_rbutton)
259 vbox_layout.addWidget(self.
_atoms)
261 box = QtWidgets.QGroupBox(
"atom selection")
262 box.setLayout(vbox_layout)
265 def _GetAtomSelection(self):
266 checkedbtn = self._atmselectgrp.checkedButton()
268 return str(checkedbtn.text())
269 slctn_model = self._atoms.selectionModel()
270 dt_model = slctn_model.model()
272 for idx
in slctn_model.selectedRows():
273 slctn = dt_model.data(idx, Qt.DisplayRole).toString()
274 atms.append(str(slctn))
277 def _FetchAtoms(self, dim, ent_a, ent_b):
280 for atm
in ent_a.GetAtomList():
281 atm_dict[atm.name] = 0
282 for atm
in ent_b.GetAtomList():
283 if atm.name
in atm_dict:
284 atm_dict[atm.name] = 1
286 for atm
in sorted(atm_dict.keys()):
289 elems = QtCore.QStringListModel(atmlst)
290 atoms = QtWidgets.QListView(self)
291 dim.setHeight(3*dim.height())
292 atoms.setFixedSize(dim)
293 atoms.setModel(elems)
294 atoms.setSelectionMode(QtWidgets.QAbstractItemView.MultiSelection)
295 atoms.setEditTriggers(QtWidgets.QAbstractItemView.NoEditTriggers)
296 atoms.setEnabled(
False)
299 def _ReferenceSelection(self, name_a, name_b):
300 cbox = QtWidgets.QComboBox()
304 cbox.setCurrentIndex(0)
307 def _toggle_iterative(self, checked):
309 self._it_in.setEnabled(
True)
310 self._dist_in.setEnabled(
True)
313 self._it_in.setEnabled(
False)
314 self._dist_in.setEnabled(
False)
318 bt1 = QtWidgets.QRadioButton(
"On")
319 iteration_label=QtWidgets.QLabel(
"Max Iterations: ")
320 distance_label=QtWidgets.QLabel(
"Dist Thresh: ")
321 iteration_in=QtWidgets.QSpinBox()
322 iteration_in.setRange(1,30)
323 iteration_in.setValue(8)
324 distance_in=QtWidgets.QDoubleSpinBox()
325 distance_in.setRange(1.0,10.0)
326 distance_in.setValue(3.0)
327 distance_in.setDecimals(1)
328 distance_in.setSingleStep(0.5)
329 iteration_in.setEnabled(
False)
330 distance_in.setEnabled(
False)
331 bt1.setChecked(
False)
333 vbox_layout = QtWidgets.QVBoxLayout()
334 vbox_layout.addWidget(bt1)
335 vbox_layout.addWidget(iteration_label)
336 vbox_layout.addWidget(iteration_in)
337 vbox_layout.addWidget(distance_label)
338 vbox_layout.addWidget(distance_in)
339 vbox_layout.addSpacing(50)
341 box = QtWidgets.QGroupBox(
"Iterative")
342 box.setLayout(vbox_layout)
343 return box,iteration_in, distance_in
345 def _ChangeChainSelection(self, index):
355 def _MatchMethods(self):
356 methods=QtWidgets.QComboBox(self)
358 methods.addItem(method)
def _ChangeChainSelection