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)
127 'local alignment':
'local-aln',
128 'global alignment':
'global-aln'}
133 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 = QGridLayout(self)
171 layout.addWidget(QLabel(
"reference"), grow, 0)
177 layout.addWidget(QLabel(
"reference chain"), grow, 0)
180 layout.addWidget(QLabel(
"chain"), grow, 0)
185 SIGNAL(
'currentIndexChanged(int)'),
189 layout.addWidget(QLabel(
'match residues by'), grow, 0)
197 layout.addWidget(self._atmselectbx, grow, 1)
200 ok_button = QPushButton(
"Superpose")
201 QObject.connect(ok_button, SIGNAL(
'clicked()'), self.accept)
202 cancel_button = QPushButton(
"Cancel")
203 hbox_layout = QHBoxLayout()
204 hbox_layout.addStretch(1)
205 layout.addLayout(hbox_layout, grow, 0, 1, 2)
207 QObject.connect(cancel_button, SIGNAL(
'clicked()'), self.reject)
208 QObject.connect(self, SIGNAL(
'accepted()'), self.
_Superpose)
209 hbox_layout.addWidget(cancel_button, 0)
210 hbox_layout.addWidget(ok_button, 0)
211 ok_button.setDefault(
True)
219 def _Superpose(self):
220 view_one = self._chain_one.selected_chain
221 view_two = self._chain_two.selected_chain
228 def _toggle_atoms(self, checked):
230 self._atoms.setEnabled(
True)
232 self._atoms.setEnabled(
False)
234 def _AtomSelectionBox(self):
235 bt1 = QRadioButton(
'All')
236 bt2 = QRadioButton(
'Backbone')
237 bt3 = QRadioButton(
'CA')
239 custom_rbutton = QRadioButton(self.
cstmbtntxt)
240 group = QButtonGroup()
244 group.addButton(custom_rbutton)
246 vbox_layout = QVBoxLayout()
247 vbox_layout.addWidget(bt1)
248 vbox_layout.addWidget(bt2)
249 vbox_layout.addWidget(bt3)
250 vbox_layout.addWidget(custom_rbutton)
251 vbox_layout.addWidget(self.
_atoms)
252 QObject.connect(custom_rbutton, SIGNAL(
'toggled(bool)'), self.
_toggle_atoms)
253 box = QGroupBox(
"atom selection")
254 box.setLayout(vbox_layout)
257 def _GetAtomSelection(self):
258 checkedbtn = self._atmselectgrp.checkedButton()
260 return str(checkedbtn.text())
261 slctn_model = self._atoms.selectionModel()
262 dt_model = slctn_model.model()
264 for idx
in slctn_model.selectedRows():
265 slctn = dt_model.data(idx, Qt.DisplayRole).toString()
266 atms.append(str(slctn))
269 def _FetchAtoms(self, dim, ent_a, ent_b):
272 for atm
in ent_a.GetAtomList():
273 atm_dict[atm.name] = 0
274 for atm
in ent_b.GetAtomList():
275 if atm.name
in atm_dict:
276 atm_dict[atm.name] = 1
277 atmlst = QStringList()
278 for atm
in sorted(atm_dict.keys()):
281 elems = QStringListModel(atmlst)
282 atoms = QListView(self)
283 dim.setHeight(3*dim.height())
284 atoms.setFixedSize(dim)
285 atoms.setModel(elems)
286 atoms.setSelectionMode(QAbstractItemView.MultiSelection)
287 atoms.setEditTriggers(QAbstractItemView.NoEditTriggers)
288 atoms.setEnabled(
False)
291 def _ReferenceSelection(self, name_a, name_b):
296 cbox.setCurrentIndex(0)
299 def _ChangeChainSelection(self, index):
309 def _MatchMethods(self):
310 methods=QComboBox(self)
312 methods.addItem(method)