31 QComboBox.__init__(self, parent)
34 for chain
in self.entity.chains:
35 self.addItem(chain.name)
37 self.setCurrentIndex(0)
41 SIGNAL(
'highlighted (const QString&)'),
48 self.gfx.selection =
None
54 for chain
in self.entity.chains:
55 self.addItem(chain.name)
57 self.setCurrentIndex(0)
61 def _HighlightChain(self, chain):
62 if str(chain) !=
'All':
63 self.gfx.SetSelection(self.entity.Select(
'cname="%s"' % str(chain)))
65 self.gfx.SetSelection(self.entity.Select(
''))
67 def _GetSelectedChain(self):
68 if self.currentIndex() == -1:
72 return self.entity.Select(
'cname="%s"' % str(self.currentText()))
74 def _SetSelectedChain(self, chain):
75 if hasattr(chain,
'name'):
79 for i
in range(self.count()):
80 if self.itemText(i) == name:
81 self.setCurrentIndex(i)
83 selected_chain = property(_GetSelectedChain, _SetSelectedChain)
87 Provides a graphical user interface to structurally superpose two entities.
88 Uses function :func:`~ost.mol.alg.Superpose`. The RMSD of two superposed
89 molecules will be stored in attribute ``rmsd``. An index for the selected
90 reference molecule will be stored in attribute ``reference``.
92 :param ent_one: The first entity
93 :type ent_one: :class:`~ost.mol.EntityView`, :class:`~ost.mol.EntityHandle`
94 or :class:`~ost.gfx.Entity`
95 :param ent_two: The second entity
96 :type ent_two: :class:`~ost.mol.EntityView`, :class:`~ost.mol.EntityHandle`
97 or :class:`~ost.gfx.Entity`
101 .. code-block:: python
103 e1=io.LoadPDB('examples/code_fragments/entity/pdb1ake.ent')
104 e2=io.LoadPDB('examples/code_fragments/entity/pdb4ake.ent')
106 sd = ost.gui.dng.superpositiondialog.SuperpositionDialog(e1, e2)
108 g1=gfx.Entity('G1', e1)
109 g2=gfx.Entity('G2', e2)
113 if sd.reference == 0:
119 LogScript('RMSD: %.3f'%sd.rmsd)
129 'local alignment':
'local-aln',
130 'global alignment':
'global-aln'}
135 QDialog.__init__(self, parent)
136 self.setWindowTitle(
'Superpose structures')
139 n_one = ent_one.GetName()
145 n_one = ent_one.GetName()
147 n_one = ent_one.GetHandle().GetName()
153 n_two = ent_two.GetName()
159 n_two = ent_two.GetName()
161 n_two = ent_two.GetHandle().GetName()
168 layout = QGridLayout(self)
173 layout.addWidget(QLabel(
"reference"), grow, 0)
179 layout.addWidget(QLabel(
"reference chain"), grow, 0)
182 layout.addWidget(QLabel(
"chain"), grow, 0)
187 SIGNAL(
'currentIndexChanged(int)'),
191 layout.addWidget(QLabel(
'match residues by'), grow, 0)
198 layout.addWidget(self._it_box, grow, 0)
204 layout.addWidget(self._atmselectbx, grow, 1)
207 ok_button = QPushButton(
"Superpose")
208 QObject.connect(ok_button, SIGNAL(
'clicked()'), self.accept)
209 cancel_button = QPushButton(
"Cancel")
210 hbox_layout = QHBoxLayout()
211 hbox_layout.addStretch(1)
212 layout.addLayout(hbox_layout, grow, 0, 1, 2)
214 QObject.connect(cancel_button, SIGNAL(
'clicked()'), self.reject)
215 QObject.connect(self, SIGNAL(
'accepted()'), self.
_Superpose)
216 hbox_layout.addWidget(cancel_button, 0)
217 hbox_layout.addWidget(ok_button, 0)
218 ok_button.setDefault(
True)
226 def _Superpose(self):
227 view_one = self._chain_one.selected_chain
228 view_two = self._chain_two.selected_chain
233 max_iterations=self._it_in.value(), distance_threshold=self._dist_in.value())
239 def _toggle_atoms(self, checked):
241 self._atoms.setEnabled(
True)
243 self._atoms.setEnabled(
False)
245 def _AtomSelectionBox(self):
246 bt1 = QRadioButton(
'All')
247 bt2 = QRadioButton(
'Backbone')
248 bt3 = QRadioButton(
'CA')
250 custom_rbutton = QRadioButton(self.
cstmbtntxt)
251 group = QButtonGroup()
255 group.addButton(custom_rbutton)
257 vbox_layout = QVBoxLayout()
258 vbox_layout.addWidget(bt1)
259 vbox_layout.addWidget(bt2)
260 vbox_layout.addWidget(bt3)
261 vbox_layout.addWidget(custom_rbutton)
262 vbox_layout.addWidget(self.
_atoms)
263 QObject.connect(custom_rbutton, SIGNAL(
'toggled(bool)'), self.
_toggle_atoms)
264 box = QGroupBox(
"atom selection")
265 box.setLayout(vbox_layout)
268 def _GetAtomSelection(self):
269 checkedbtn = self._atmselectgrp.checkedButton()
271 return str(checkedbtn.text())
272 slctn_model = self._atoms.selectionModel()
273 dt_model = slctn_model.model()
275 for idx
in slctn_model.selectedRows():
276 slctn = dt_model.data(idx, Qt.DisplayRole).toString()
277 atms.append(str(slctn))
280 def _FetchAtoms(self, dim, ent_a, ent_b):
283 for atm
in ent_a.GetAtomList():
284 atm_dict[atm.name] = 0
285 for atm
in ent_b.GetAtomList():
286 if atm.name
in atm_dict:
287 atm_dict[atm.name] = 1
288 atmlst = QStringList()
289 for atm
in sorted(atm_dict.keys()):
292 elems = QStringListModel(atmlst)
293 atoms = QListView(self)
294 dim.setHeight(3*dim.height())
295 atoms.setFixedSize(dim)
296 atoms.setModel(elems)
297 atoms.setSelectionMode(QAbstractItemView.MultiSelection)
298 atoms.setEditTriggers(QAbstractItemView.NoEditTriggers)
299 atoms.setEnabled(
False)
302 def _ReferenceSelection(self, name_a, name_b):
307 cbox.setCurrentIndex(0)
310 def _toggle_iterative(self, checked):
312 self._it_in.setEnabled(
True)
313 self._dist_in.setEnabled(
True)
316 self._it_in.setEnabled(
False)
317 self._dist_in.setEnabled(
False)
321 bt1 = QRadioButton(
"On")
322 iteration_label=QLabel(
"Max Iterations: ")
323 distance_label=QLabel(
"Dist Thresh: ")
324 iteration_in=QSpinBox()
325 iteration_in.setRange(1,30)
326 iteration_in.setValue(8)
327 distance_in=QDoubleSpinBox()
328 distance_in.setRange(1.0,10.0)
329 distance_in.setValue(3.0)
330 distance_in.setDecimals(1)
331 distance_in.setSingleStep(0.5)
332 iteration_in.setEnabled(
False)
333 distance_in.setEnabled(
False)
334 bt1.setChecked(
False)
336 vbox_layout = QVBoxLayout()
337 vbox_layout.addWidget(bt1)
338 vbox_layout.addWidget(iteration_label)
339 vbox_layout.addWidget(iteration_in)
340 vbox_layout.addWidget(distance_label)
341 vbox_layout.addWidget(distance_in)
342 vbox_layout.addSpacing(50)
344 box = QGroupBox(
"Iterative")
345 box.setLayout(vbox_layout)
346 return box,iteration_in, distance_in
348 def _ChangeChainSelection(self, index):
358 def _MatchMethods(self):
359 methods=QComboBox(self)
361 methods.addItem(method)
def _ChangeChainSelection