3 from PyQt5
import QtCore, QtWidgets
7 from ost
import geom, gfx, gui, seq
8 from ost
import settings
9 from ost
import LogError, mol
18 QtWidgets.QDialog.__init__(self, parent)
20 vb = QtWidgets.QVBoxLayout()
22 self.setWindowTitle(
"Select Reference Object")
23 self.
label = QtWidgets.QLabel(
"Please Select the Reference Object")
24 self.
list = QtWidgets.QTableWidget(self)
25 self.list.horizontalHeader().setStretchLastSection(
True)
26 self.list.setColumnCount(2)
27 self.list.verticalHeader().setVisible(
False)
28 self.list.horizontalHeader().setVisible(
False)
29 self.list.setSelectionBehavior(QtWidgets.QAbstractItemView.SelectRows)
30 self.list.setSelectionMode(QtWidgets.QAbstractItemView.SingleSelection)
31 vb.addWidget(self.
label)
32 vb.addWidget(self.
list)
34 self.show_scores.setText(
"Show Scores")
35 self.show_scores.setChecked(
True)
38 self.show_alignment.setText(
"Display Alignment")
39 self.show_alignment.setChecked(
False)
41 hb = QtWidgets.QHBoxLayout()
42 hb.setDirection(QtWidgets.QBoxLayout.LeftToRight)
43 cancel_btn = QtWidgets.QPushButton(
"Cancel", self)
44 load_btn = QtWidgets.QPushButton(
"Select", self)
46 hb.addWidget(cancel_btn)
47 hb.addWidget(load_btn)
49 load_btn.setDefault(
True)
50 load_btn.clicked.connect(self.
Select)
51 cancel_btn.clicked.connect(self.reject)
55 variant = QtCore.QVariant(ent)
56 self.list.insertRow(row)
57 new_item = QtWidgets.QTableWidgetItem(
"%i"%(row+1))
58 new_item.setFlags(QtCore.Qt.ItemIsSelectable|QtCore.Qt.ItemIsEnabled)
59 new_item.setData(QtCore.Qt.UserRole,variant)
60 self.list.setItem(row, 0, new_item)
61 new_item = QtWidgets.QTableWidgetItem(ent.GetName())
62 new_item.setFlags(QtCore.Qt.ItemIsSelectable|QtCore.Qt.ItemIsEnabled)
63 self.list.setItem(row, 1, new_item)
66 self.list.resizeColumnsToContents()
69 items = self.list.selectedItems()
72 ent = item.data(QtCore.Qt.UserRole)
73 self.ent_list_.remove(ent)
74 self.ent_list_.insert(0,ent)
78 return self.show_scores.isChecked()
81 return self.show_alignment.isChecked()
87 def __init__(self, ent_list, res_list, parent=None):
88 QtWidgets.QDialog.__init__(self, parent)
90 vb = QtWidgets.QVBoxLayout()
92 self.setWindowTitle(
"Alignment result")
93 self.
label = QtWidgets.QLabel(
"Alignment results with %s as reference"%ent_list[0].GetName())
94 self.
list = QtWidgets.QTableWidget(self)
95 self.list.horizontalHeader().setStretchLastSection(
True)
96 self.list.setColumnCount(4)
97 self.list.verticalHeader().setVisible(
False)
98 self.list.setHorizontalHeaderLabels ([
"Name",
"RMSD",
"TMScore",
""])
99 self.list.setSelectionBehavior(QtWidgets.QAbstractItemView.SelectRows)
100 vb.addWidget(self.
label)
101 vb.addWidget(self.
list)
102 hb = QtWidgets.QHBoxLayout()
103 hb.setDirection(QtWidgets.QBoxLayout.LeftToRight)
104 ok_btn = QtWidgets.QPushButton(
"OK", self)
108 ok_btn.setDefault(
True)
109 ok_btn.clicked.connect(self.accept)
111 for i
in range(0, len(res_list)):
112 self.list.insertRow(i)
113 new_item = QtWidgets.QTableWidgetItem(ent_list[i+1].GetName())
114 new_item.setFlags(QtCore.Qt.ItemIsEnabled)
115 self.list.setItem(i, 0, new_item)
116 new_item = QtWidgets.QTableWidgetItem(
"%.2f"%res_list[i].rmsd)
117 new_item.setFlags(QtCore.Qt.ItemIsEnabled)
118 self.list.setItem(i, 1, new_item)
119 new_item = QtWidgets.QTableWidgetItem(
"%.2f"%res_list[i].tm_score)
120 new_item.setFlags(QtCore.Qt.ItemIsEnabled)
121 self.list.setItem(i, 2, new_item)
122 new_item = QtWidgets.QTableWidgetItem()
123 new_item.setFlags(QtCore.Qt.ItemIsEnabled)
124 self.list.setItem(i, 3, new_item)
126 self.list.resizeColumnsToContents()
130 QtWidgets.QDialog.__init__(self, parent)
131 vb = QtWidgets.QGridLayout()
133 self.setWindowTitle(
"MSMS Surface Settings")
134 msmsexe_label=QtWidgets.QLabel(
"executable")
136 self.msmsexe_field.setText(executable)
137 msmsexe_browsebutton=QtWidgets.QPushButton(
"Browse")
138 vb.addWidget(msmsexe_label, 0, 0)
140 vb.addWidget(msmsexe_browsebutton, 0, 2)
141 surfname_label=QtWidgets.QLabel(
"surface name")
143 self.surfname_field.setText(
"surface")
144 vb.addWidget(surfname_label, 1, 0)
146 density_label=QtWidgets.QLabel(
"density")
148 self.density_spinbox.setRange(1, 10)
149 self.density_spinbox.setValue(4)
150 vb.addWidget(density_label, 2, 0)
152 probe_label=QtWidgets.QLabel(
"probe radius")
154 self.probe_spinbox.setDecimals(1)
155 self.probe_spinbox.setSingleStep(0.1)
156 self.probe_spinbox.setRange(0.3, 5.0)
157 self.probe_spinbox.setValue(1.4)
158 vb.addWidget(probe_label, 3, 0)
160 selection_label=QtWidgets.QLabel(
"selection")
162 self.selection_field.setText(
"")
163 vb.addWidget(selection_label, 4, 0)
165 self.
noh_box=QtWidgets.QCheckBox(
"no hydrogens")
166 vb.addWidget(self.
noh_box, 5, 0)
172 cancel_btn = QtWidgets.QPushButton(
"Cancel", self)
173 ok_btn = QtWidgets.QPushButton(
"OK", self)
174 vb.addWidget(cancel_btn, 6, 1)
175 vb.addWidget(ok_btn, 6, 2)
177 msmsexe_browsebutton.clicked.connect(self.
GetPath)
178 ok_btn.clicked.connect(self.accept)
179 cancel_btn.clicked.connect(self.reject)
182 path, _ =QtWidgets.QFileDialog.getOpenFileName(self,
"Choose MSMS Executable")
184 self.msmsexe_field.setText(path)
193 QtCore.QObject.__init__(self, context_menu.qobject)
194 self.
action = QtWidgets.QAction(
"Calculate Surface", self)
196 context_menu.AddAction(self.
action, gui.ContextActionType.ENTITY)
199 scene_selection = gui.SceneSelection.Instance()
201 for i
in range(0,scene_selection.GetActiveNodeCount()):
202 ent_list.append(scene_selection.GetActiveNode(i))
206 str(cssd.surfname_field.text()),
207 str(cssd.msmsexe_field.text()),
208 cssd.density_spinbox.value(),
209 cssd.probe_spinbox.value(),
210 str(cssd.selection_field.text()),
211 cssd.noh_box.isChecked(),
212 cssd.nohet_box.isChecked(),
213 cssd.nowat_box.isChecked())
215 def __CalculateSurface(self,ent_list,name,msms_exe,density,
216 radius,selection,noh,nohet,nowat):
217 for entity
in ent_list:
220 s=msms.CalculateSurface(entity.view,
229 except (RuntimeError, msms.MsmsProcessError):
230 LogError(
"WARNING: Surface could not be calculated")
233 LogError(
"WARNING: Entry with the same name already present in scene")
239 QtCore.QObject.__init__(self, context_menu.qobject)
240 self.
action = QtWidgets.QAction(
"Assign Secondary Structure", self)
242 context_menu.AddAction(self.
action, gui.ContextActionType.ENTITY)
245 scene_selection = gui.SceneSelection.Instance()
247 for i
in range(0,scene_selection.GetActiveNodeCount()):
248 node = scene_selection.GetActiveNode(i)
249 mol.alg.AssignSecStruct(node.view)
257 QtCore.QObject.__init__(self, context_menu.qobject)
258 self.
action = QtWidgets.QAction(
"Align", self)
259 self.action.triggered.connect(self.
Align)
260 context_menu.AddAction(self.
action, gui.ContextActionType.ENTITY | gui.ContextActionType.MULTI)
264 scene_selection = gui.SceneSelection.Instance()
266 for i
in range(0,scene_selection.GetActiveNodeCount()):
267 ent_list.append(scene_selection.GetActiveNode(i))
270 self.
__Align(sd.GetEntities(),sd.GetShowScores(), sd.GetDisplayAlignment())
272 def __Align(self, ent_list,show_scores=True, display_alignment=False):
276 ref = node.view.chains[0]
277 for i
in range(1,len(ent_list)):
281 node.UpdatePositions()
284 if display_alignment:
287 def __ShowScore(self, ent_list, res_list):
288 if(len(res_list)==1):
290 string =
"RMSD: %.2f, TMScore: %.2f"%(res.rmsd, res.tm_score)
291 gui.GostyApp.Instance().perspective.StatusMessage(string)
292 elif(len(res_list)>1):
295 def __DisplayAlignment(self, ent_list, res_list):
297 ref_seq = seq.CreateSequence(
"%s (ref)"%ent_list[0].GetName(),
298 res_list[0].alignment.GetSequence(1).GetGaplessString())
299 aln_list = seq.AlignmentList()
300 if(ref_seq.IsValid()):
301 for i
in range(0, len(res_list)):
304 new_aln = seq.CreateAlignment()
305 new_aln.AddSequence(res_list[i].alignment.GetSequence(1))
306 new_aln.AddSequence(res_list[i].alignment.GetSequence(0))
307 new_aln.SetSequenceName(1, ent_list[i+1].GetName())
308 aln_list.append(new_aln)
309 alignment = alg.MergePairwiseAlignments(aln_list, ref_seq)
310 gosty = gui.GostyApp.Instance()
311 main_area = gosty.perspective.GetMainArea()
313 self.seq_viewer.qobject.close()
315 self.seq_viewer.AddAlignment(alignment)
316 self.seq_viewer.ChangeDisplayMode(
"Highlight conservation 1")
317 self.seq_viewer.Show()
321 QtCore.QObject.__init__(self, context_menu.qobject)
322 action=QtWidgets.QAction(
"Select...", self)
323 action.triggered.connect(self.
_Select)
324 context_menu.AddAction(action, gui.ENTITY)
325 action=QtWidgets.QAction(
"Copy Selection...", self)
327 context_menu.AddAction(action, gui.ENTITY)
328 action=QtWidgets.QAction(
'Select...', self)
330 context_menu.AddAction(action, gui.ENTITY_VIEW|gui.VIEWS_SAME_OBJECT)
332 scene_selection=gui.SceneSelection.Instance()
333 ent=scene_selection.GetActiveNode(0)
338 ent.selection=ent.view.Select(dialog.query, dialog.query_flags)
340 ost.LogError(
"invalid query: %s" % q.error)
342 def _UniqueName(self, ent):
344 Returns a name based on ent that is unique within the scene
346 ent_name=ent.GetName()
349 candidate_name=
'%s-%d' % (ent_name, num)
350 if not gfx.Scene().HasNode(candidate_name):
351 return candidate_name
354 def _SelectViewsSameEntity(self):
356 union=gui.SceneSelection.Instance().GetViewUnion()
361 ve=gui.SceneSelection.Instance().GetViewEntity()
362 ve.selection=union.Select(q, dialog.query_flags)
364 ost.LogError(
"invalid query: %s" % q.error)
366 def _CopyViews(self):
368 scene_selection=gui.SceneSelection.Instance()
369 ent=scene_selection.GetActiveNode(0)
374 for i
in range(scene_selection.GetActiveNodeCount()):
375 ent=scene_selection.GetActiveNode(i)
376 selected=ent.view.Select(q, dialog.query_flags)
380 ost.LogError(
"invalid query: %s" % q.error)
382 def _InitContextMenu(app):
383 _InitContextMenu.cm=app.scene_win.GetContextMenu()
main class for organization and root for the graphical display
graphical rendering of mol::EntityHandle entites
TMAlignResult WrappedTMAlign(const geom::Vec3List &pos_one, const geom::Vec3List &pos_two, const ost::seq::SequenceHandle &seq1, const ost::seq::SequenceHandle &seq2, bool fast=false)
QTableView with first column not moving.