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.
labellabel = QtWidgets.QLabel(
"Please Select the Reference Object")
22 self.
listlist = QtWidgets.QTableWidget(self)
23 self.
listlist.horizontalHeader().setStretchLastSection(
True)
24 self.
listlist.setColumnCount(2)
25 self.
listlist.verticalHeader().setVisible(
False)
26 self.
listlist.horizontalHeader().setVisible(
False)
27 self.
listlist.setSelectionBehavior(QtWidgets.QAbstractItemView.SelectRows)
28 self.
listlist.setSelectionMode(QtWidgets.QAbstractItemView.SingleSelection)
29 vb.addWidget(self.
labellabel)
30 vb.addWidget(self.
listlist)
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.
SelectSelect)
49 cancel_btn.clicked.connect(self.reject)
53 variant = QtCore.QVariant(ent)
54 self.
listlist.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.
listlist.setItem(row, 0, new_item)
59 new_item = QtWidgets.QTableWidgetItem(ent.GetName())
60 new_item.setFlags(QtCore.Qt.ItemIsSelectable|QtCore.Qt.ItemIsEnabled)
61 self.
listlist.setItem(row, 1, new_item)
64 self.
listlist.resizeColumnsToContents()
67 items = self.
listlist.selectedItems()
70 ent = item.data(QtCore.Qt.UserRole)
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.
labellabel = QtWidgets.QLabel(
"Alignment results with %s as reference"%ent_list[0].GetName())
92 self.
listlist = QtWidgets.QTableWidget(self)
93 self.
listlist.horizontalHeader().setStretchLastSection(
True)
94 self.
listlist.setColumnCount(4)
95 self.
listlist.verticalHeader().setVisible(
False)
96 self.
listlist.setHorizontalHeaderLabels ([
"Name",
"RMSD",
"TMScore",
""])
97 self.
listlist.setSelectionBehavior(QtWidgets.QAbstractItemView.SelectRows)
98 vb.addWidget(self.
labellabel)
99 vb.addWidget(self.
listlist)
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.
listlist.insertRow(i)
111 new_item = QtWidgets.QTableWidgetItem(ent_list[i+1].GetName())
112 new_item.setFlags(QtCore.Qt.ItemIsEnabled)
113 self.
listlist.setItem(i, 0, new_item)
114 new_item = QtWidgets.QTableWidgetItem(
"%.2f"%res_list[i].rmsd)
115 new_item.setFlags(QtCore.Qt.ItemIsEnabled)
116 self.
listlist.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.
listlist.setItem(i, 2, new_item)
120 new_item = QtWidgets.QTableWidgetItem()
121 new_item.setFlags(QtCore.Qt.ItemIsEnabled)
122 self.
listlist.setItem(i, 3, new_item)
124 self.
listlist.resizeColumnsToContents()
128 QtWidgets.QDialog.__init__(self, parent)
129 vb = QtWidgets.QGridLayout()
131 self.setWindowTitle(
"MSMS Surface Settings")
132 msmsexe_label=QtWidgets.QLabel(
"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")
142 vb.addWidget(surfname_label, 1, 0)
144 density_label=QtWidgets.QLabel(
"density")
148 vb.addWidget(density_label, 2, 0)
150 probe_label=QtWidgets.QLabel(
"probe radius")
156 vb.addWidget(probe_label, 3, 0)
158 selection_label=QtWidgets.QLabel(
"selection")
161 vb.addWidget(selection_label, 4, 0)
163 self.
noh_boxnoh_box=QtWidgets.QCheckBox(
"no hydrogens")
164 vb.addWidget(self.
noh_boxnoh_box, 5, 0)
165 self.
nohet_boxnohet_box=QtWidgets.QCheckBox(
"no hetatoms")
166 vb.addWidget(self.
nohet_boxnohet_box, 5, 1)
167 self.
nowat_boxnowat_box=QtWidgets.QCheckBox(
"no waters")
168 vb.addWidget(self.
nowat_boxnowat_box, 5, 2)
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.
GetPathGetPath)
176 ok_btn.clicked.connect(self.accept)
177 cancel_btn.clicked.connect(self.reject)
180 path, _ =QtWidgets.QFileDialog.getOpenFileName(self,
"Choose MSMS Executable")
191 QtCore.QObject.__init__(self, context_menu.qobject)
192 self.
actionaction = QtWidgets.QAction(
"Calculate Surface", self)
194 context_menu.AddAction(self.
actionaction, 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.
actionaction = QtWidgets.QAction(
"Assign Secondary Structure", self)
240 context_menu.AddAction(self.
actionaction, 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.
actionaction = QtWidgets.QAction(
"Align", self)
257 self.
actionaction.triggered.connect(self.
AlignAlign)
258 context_menu.AddAction(self.
actionaction, 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__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()
315 self.
seq_viewerseq_viewer.AddAlignment(alignment)
316 self.
seq_viewerseq_viewer.ChangeDisplayMode(
"Highlight conservation 1")
321 QtCore.QObject.__init__(self, context_menu.qobject)
322 action=QtWidgets.QAction(
"Select...", self)
323 action.triggered.connect(self.
_Select_Select)
324 context_menu.AddAction(action, gui.ENTITY)
325 action=QtWidgets.QAction(
"Copy Selection...", self)
326 action.triggered.connect(self.
_CopyViews_CopyViews)
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()
graphical rendering of mol::EntityHandle entites
main class for organization and root for the graphical display
QTableView with first column not moving.
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)