3 from PyQt5
import QtCore, QtWidgets
5 from ost
import geom, gfx, gui, seq
6 from ost
import settings
7 from ost
import LogError, mol
16 QtWidgets.QDialog.__init__(self, parent)
18 vb = QtWidgets.QVBoxLayout()
20 self.setWindowTitle(
"Select Reference Object")
21 self.
label = QtWidgets.QLabel(
"Please Select the Reference Object")
22 self.
list = QtWidgets.QTableWidget(self)
23 self.list.horizontalHeader().setStretchLastSection(
True)
24 self.list.setColumnCount(2)
25 self.list.verticalHeader().setVisible(
False)
26 self.list.horizontalHeader().setVisible(
False)
27 self.list.setSelectionBehavior(QtWidgets.QAbstractItemView.SelectRows)
28 self.list.setSelectionMode(QtWidgets.QAbstractItemView.SingleSelection)
29 vb.addWidget(self.
label)
30 vb.addWidget(self.
list)
32 self.show_scores.setText(
"Show Scores")
33 self.show_scores.setChecked(
True)
36 self.show_alignment.setText(
"Display Alignment")
37 self.show_alignment.setChecked(
False)
39 hb = QtWidgets.QHBoxLayout()
40 hb.setDirection(QtWidgets.QBoxLayout.LeftToRight)
41 cancel_btn = QtWidgets.QPushButton(
"Cancel", self)
42 load_btn = QtWidgets.QPushButton(
"Select", self)
44 hb.addWidget(cancel_btn)
45 hb.addWidget(load_btn)
47 load_btn.setDefault(
True)
48 load_btn.clicked.connect(self.
Select)
49 cancel_btn.clicked.connect(self.reject)
53 variant = QtCore.QVariant(ent)
54 self.list.insertRow(row)
55 new_item = QtWidgets.QTableWidgetItem(
"%i"%(row+1))
56 new_item.setFlags(QtCore.Qt.ItemIsSelectable|QtCore.Qt.ItemIsEnabled)
57 new_item.setData(QtCore.Qt.UserRole,variant)
58 self.list.setItem(row, 0, new_item)
59 new_item = QtWidgets.QTableWidgetItem(ent.GetName())
60 new_item.setFlags(QtCore.Qt.ItemIsSelectable|QtCore.Qt.ItemIsEnabled)
61 self.list.setItem(row, 1, new_item)
64 self.list.resizeColumnsToContents()
67 items = self.list.selectedItems()
70 ent = item.data(QtCore.Qt.UserRole)
71 self.ent_list_.remove(ent)
72 self.ent_list_.insert(0,ent)
76 return self.show_scores.isChecked()
79 return self.show_alignment.isChecked()
85 def __init__(self, ent_list, res_list, parent=None):
86 QtWidgets.QDialog.__init__(self, parent)
88 vb = QtWidgets.QVBoxLayout()
90 self.setWindowTitle(
"Alignment result")
91 self.
label = QtWidgets.QLabel(
"Alignment results with %s as reference"%ent_list[0].GetName())
92 self.
list = QtWidgets.QTableWidget(self)
93 self.list.horizontalHeader().setStretchLastSection(
True)
94 self.list.setColumnCount(4)
95 self.list.verticalHeader().setVisible(
False)
96 self.list.setHorizontalHeaderLabels ([
"Name",
"RMSD",
"TMScore",
""])
97 self.list.setSelectionBehavior(QtWidgets.QAbstractItemView.SelectRows)
98 vb.addWidget(self.
label)
99 vb.addWidget(self.
list)
100 hb = QtWidgets.QHBoxLayout()
101 hb.setDirection(QtWidgets.QBoxLayout.LeftToRight)
102 ok_btn = QtWidgets.QPushButton(
"OK", self)
106 ok_btn.setDefault(
True)
107 ok_btn.clicked.connect(self.accept)
109 for i
in range(0, len(res_list)):
110 self.list.insertRow(i)
111 new_item = QtWidgets.QTableWidgetItem(ent_list[i+1].GetName())
112 new_item.setFlags(QtCore.Qt.ItemIsEnabled)
113 self.list.setItem(i, 0, new_item)
114 new_item = QtWidgets.QTableWidgetItem(
"%.2f"%res_list[i].rmsd)
115 new_item.setFlags(QtCore.Qt.ItemIsEnabled)
116 self.list.setItem(i, 1, new_item)
117 new_item = QtWidgets.QTableWidgetItem(
"%.2f"%res_list[i].tm_score)
118 new_item.setFlags(QtCore.Qt.ItemIsEnabled)
119 self.list.setItem(i, 2, new_item)
120 new_item = QtWidgets.QTableWidgetItem()
121 new_item.setFlags(QtCore.Qt.ItemIsEnabled)
122 self.list.setItem(i, 3, new_item)
124 self.list.resizeColumnsToContents()
128 QtWidgets.QDialog.__init__(self, parent)
129 vb = QtWidgets.QGridLayout()
131 self.setWindowTitle(
"MSMS Surface Settings")
132 msmsexe_label=QtWidgets.QLabel(
"executable")
134 self.msmsexe_field.setText(executable)
135 msmsexe_browsebutton=QtWidgets.QPushButton(
"Browse")
136 vb.addWidget(msmsexe_label, 0, 0)
138 vb.addWidget(msmsexe_browsebutton, 0, 2)
139 surfname_label=QtWidgets.QLabel(
"surface name")
141 self.surfname_field.setText(
"surface")
142 vb.addWidget(surfname_label, 1, 0)
144 density_label=QtWidgets.QLabel(
"density")
146 self.density_spinbox.setRange(1, 10)
147 self.density_spinbox.setValue(4)
148 vb.addWidget(density_label, 2, 0)
150 probe_label=QtWidgets.QLabel(
"probe radius")
152 self.probe_spinbox.setDecimals(1)
153 self.probe_spinbox.setSingleStep(0.1)
154 self.probe_spinbox.setRange(0.3, 5.0)
155 self.probe_spinbox.setValue(1.4)
156 vb.addWidget(probe_label, 3, 0)
158 selection_label=QtWidgets.QLabel(
"selection")
160 self.selection_field.setText(
"")
161 vb.addWidget(selection_label, 4, 0)
163 self.
noh_box=QtWidgets.QCheckBox(
"no hydrogens")
164 vb.addWidget(self.
noh_box, 5, 0)
170 cancel_btn = QtWidgets.QPushButton(
"Cancel", self)
171 ok_btn = QtWidgets.QPushButton(
"OK", self)
172 vb.addWidget(cancel_btn, 6, 1)
173 vb.addWidget(ok_btn, 6, 2)
175 msmsexe_browsebutton.clicked.connect(self.
GetPath)
176 ok_btn.clicked.connect(self.accept)
177 cancel_btn.clicked.connect(self.reject)
180 path, _ =QtWidgets.QFileDialog.getOpenFileName(self,
"Choose MSMS Executable")
182 self.msmsexe_field.setText(path)
191 QtCore.QObject.__init__(self, context_menu.qobject)
192 self.
action = QtWidgets.QAction(
"Calculate Surface", self)
194 context_menu.AddAction(self.
action, gui.ContextActionType.ENTITY)
197 scene_selection = gui.SceneSelection.Instance()
199 for i
in range(0,scene_selection.GetActiveNodeCount()):
200 ent_list.append(scene_selection.GetActiveNode(i))
204 str(cssd.surfname_field.text()),
205 str(cssd.msmsexe_field.text()),
206 cssd.density_spinbox.value(),
207 cssd.probe_spinbox.value(),
208 str(cssd.selection_field.text()),
209 cssd.noh_box.isChecked(),
210 cssd.nohet_box.isChecked(),
211 cssd.nowat_box.isChecked())
213 def __CalculateSurface(self,ent_list,name,msms_exe,density,
214 radius,selection,noh,nohet,nowat):
215 for entity
in ent_list:
218 s=msms.CalculateSurface(entity.view,
227 except (RuntimeError, msms.MsmsProcessError):
228 LogError(
"WARNING: Surface could not be calculated")
231 LogError(
"WARNING: Entry with the same name already present in scene")
237 QtCore.QObject.__init__(self, context_menu.qobject)
238 self.
action = QtWidgets.QAction(
"Assign Secondary Structure", self)
240 context_menu.AddAction(self.
action, gui.ContextActionType.ENTITY)
243 scene_selection = gui.SceneSelection.Instance()
245 for i
in range(0,scene_selection.GetActiveNodeCount()):
246 node = scene_selection.GetActiveNode(i)
247 mol.alg.AssignSecStruct(node.view)
255 QtCore.QObject.__init__(self, context_menu.qobject)
256 self.
action = QtWidgets.QAction(
"Align", self)
257 self.action.triggered.connect(self.
Align)
258 context_menu.AddAction(self.
action, gui.ContextActionType.ENTITY | gui.ContextActionType.MULTI)
262 scene_selection = gui.SceneSelection.Instance()
264 for i
in range(0,scene_selection.GetActiveNodeCount()):
265 ent_list.append(scene_selection.GetActiveNode(i))
268 self.
__Align(sd.GetEntities(),sd.GetShowScores(), sd.GetDisplayAlignment())
270 def __Align(self, ent_list, show_scores=True, display_alignment=False):
274 ref = node.view.chains[0]
275 for i
in range(1,len(ent_list)):
279 res_list.append(tm_result)
280 node.view.handle.EditXCS().ApplyTransform(tm_result.transform)
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, bool rna=false)
QTableView with first column not moving.