3 from PyQt4
import QtCore, QtGui
7 from ost
import geom, gfx, gui, seq
8 from ost
import settings
9 from ost
import LogError, mol
18 QtGui.QDialog.__init__(self, parent)
20 vb = QtGui.QVBoxLayout()
22 self.setWindowTitle(
"Select Reference Object")
23 self.
label = QtGui.QLabel(
"Please Select the Reference Object")
24 self.
list = QtGui.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(QtGui.QAbstractItemView.SelectRows)
30 self.list.setSelectionMode(QtGui.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 = QtGui.QHBoxLayout()
42 hb.setDirection(QtGui.QBoxLayout.LeftToRight)
43 cancel_btn = QtGui.QPushButton(
"Cancel", self)
44 load_btn = QtGui.QPushButton(
"Select", self)
46 hb.addWidget(cancel_btn)
47 hb.addWidget(load_btn)
49 load_btn.setDefault(
True)
50 QtCore.QObject.connect(load_btn, QtCore.SIGNAL(
"clicked()"), self.
Select)
51 QtCore.QObject.connect(cancel_btn, QtCore.SIGNAL(
"clicked()"), self.reject)
55 variant = QtCore.QVariant(ent)
56 self.list.insertRow(row)
57 new_item = QtGui.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 = QtGui.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).toPyObject()
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 QtGui.QDialog.__init__(self, parent)
90 vb = QtGui.QVBoxLayout()
92 self.setWindowTitle(
"Alignment result")
93 self.
label = QtGui.QLabel(
"Alignment results with %s as reference"%ent_list[0].GetName())
94 self.
list = QtGui.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(QtGui.QAbstractItemView.SelectRows)
100 vb.addWidget(self.
label)
101 vb.addWidget(self.
list)
102 hb = QtGui.QHBoxLayout()
103 hb.setDirection(QtGui.QBoxLayout.LeftToRight)
104 ok_btn = QtGui.QPushButton(
"OK", self)
108 ok_btn.setDefault(
True)
109 QtCore.QObject.connect(ok_btn, QtCore.SIGNAL(
"clicked()"), self.accept)
111 for i
in range(0, len(res_list)):
112 self.list.insertRow(i)
113 new_item = QtGui.QTableWidgetItem(ent_list[i+1].GetName())
114 new_item.setFlags(QtCore.Qt.ItemIsEnabled)
115 self.list.setItem(i, 0, new_item)
116 new_item = QtGui.QTableWidgetItem(
"%.2f"%res_list[i].rmsd)
117 new_item.setFlags(QtCore.Qt.ItemIsEnabled)
118 self.list.setItem(i, 1, new_item)
119 new_item = QtGui.QTableWidgetItem(
"%i"%res_list[i].tm_score)
120 new_item.setFlags(QtCore.Qt.ItemIsEnabled)
121 self.list.setItem(i, 2, new_item)
122 new_item = QtGui.QTableWidgetItem()
123 new_item.setFlags(QtCore.Qt.ItemIsEnabled)
124 self.list.setItem(i, 3, new_item)
126 self.list.resizeColumnsToContents()
130 QtGui.QDialog.__init__(self, parent)
131 vb = QtGui.QGridLayout()
133 self.setWindowTitle(
"MSMS Surface Settings")
134 msmsexe_label=QtGui.QLabel(
"executable")
136 self.msmsexe_field.setText(executable)
137 msmsexe_browsebutton=QtGui.QPushButton(
"Browse")
138 vb.addWidget(msmsexe_label, 0, 0)
140 vb.addWidget(msmsexe_browsebutton, 0, 2)
141 surfname_label=QtGui.QLabel(
"surface name")
143 self.surfname_field.setText(
"surface")
144 vb.addWidget(surfname_label, 1, 0)
146 density_label=QtGui.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=QtGui.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=QtGui.QLabel(
"selection")
162 self.selection_field.setText(
"")
163 vb.addWidget(selection_label, 4, 0)
166 vb.addWidget(self.
noh_box, 5, 0)
172 cancel_btn = QtGui.QPushButton(
"Cancel", self)
173 ok_btn = QtGui.QPushButton(
"OK", self)
174 vb.addWidget(cancel_btn, 6, 1)
175 vb.addWidget(ok_btn, 6, 2)
177 QtCore.QObject.connect(msmsexe_browsebutton, QtCore.SIGNAL(
"clicked()"), self.
GetPath)
178 QtCore.QObject.connect(ok_btn, QtCore.SIGNAL(
"clicked()"), self.accept)
179 QtCore.QObject.connect(cancel_btn, QtCore.SIGNAL(
"clicked()"), self.reject)
182 path=QtGui.QFileDialog().getOpenFileName(self,
"Choose MSMS Executable")
184 self.msmsexe_field.setText(path)
193 QtCore.QObject.__init__(self, context_menu.qobject)
194 self.
action = QtGui.QAction(
"Calculate Surface", self)
195 QtCore.QObject.connect(self.
action, QtCore.SIGNAL(
"triggered()"),
197 context_menu.AddAction(self.
action, gui.ContextActionType.ENTITY)
200 scene_selection = gui.SceneSelection.Instance()
202 for i
in range(0,scene_selection.GetActiveNodeCount()):
203 ent_list.append(scene_selection.GetActiveNode(i))
207 str(cssd.surfname_field.text()),
208 str(cssd.msmsexe_field.text()),
209 cssd.density_spinbox.value(),
210 cssd.probe_spinbox.value(),
211 str(cssd.selection_field.text()),
212 cssd.noh_box.isChecked(),
213 cssd.nohet_box.isChecked(),
214 cssd.nowat_box.isChecked())
216 def __CalculateSurface(self,ent_list,name,msms_exe,density,
217 radius,selection,noh,nohet,nowat):
218 for entity
in ent_list:
221 s=msms.CalculateSurface(entity.view,
230 except (RuntimeError, msms.MsmsProcessError):
231 LogError(
"WARNING: Surface could not be calculated")
234 LogError(
"WARNING: Entry with the same name already present in scene")
242 if platform.system() ==
"Windows":
243 settings_name=
"tmalign.exe"
245 settings_name=
"tmalign"
249 settings_name=
"tmalign"
251 settings.Locate(settings_name)
252 QtCore.QObject.__init__(self, context_menu.qobject)
254 self.
action = QtGui.QAction(
"Align", self)
255 QtCore.QObject.connect(self.
action,QtCore.SIGNAL(
"triggered()"), self.
Align)
256 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.handle
275 for i
in range(1,len(ent_list)):
278 res_list.append(tmtools.TMAlign(node.view.handle, ref))
279 node.UpdatePositions()
282 if display_alignment:
285 def __ShowScore(self, ent_list, res_list):
286 if(len(res_list)==1):
288 string =
"RMSD: %.2f, TMScore: %i"%(res.rmsd, res.tm_score)
289 gui.GostyApp.Instance().perspective.StatusMessage(string)
290 elif(len(res_list)>1):
293 def __DisplayAlignment(self, ent_list, res_list):
295 ref_seq = seq.CreateSequence(
"%s (ref)"%ent_list[0].GetName(),res_list[0].ref_sequence.GetGaplessString())
296 aln_list = seq.AlignmentList()
297 if(ref_seq.IsValid()):
298 for i
in range(0, len(res_list)):
299 res_list[i].alignment.SetSequenceName(1,ent_list[i+1].GetName())
300 aln_list.append(res_list[i].alignment)
301 alignment = alg.MergePairwiseAlignments(aln_list, ref_seq)
302 gosty = gui.GostyApp.Instance()
303 main_area = gosty.perspective.GetMainArea()
305 self.seq_viewer.qobject.close()
307 self.seq_viewer.AddAlignment(alignment)
308 self.seq_viewer.ChangeDisplayMode(
"Highlight conservation 1")
309 self.seq_viewer.Show()
313 QtCore.QObject.__init__(self, context_menu.qobject)
314 action=QtGui.QAction(
"Select...", self)
315 QtCore.QObject.connect(action, QtCore.SIGNAL(
'triggered()'),
317 context_menu.AddAction(action, gui.ENTITY)
318 action=QtGui.QAction(
"Copy Selection...", self)
319 QtCore.QObject.connect(action, QtCore.SIGNAL(
'triggered()'),
321 context_menu.AddAction(action, gui.ENTITY)
322 action=QtGui.QAction(
'Select...', self)
323 QtCore.QObject.connect(action, QtCore.SIGNAL(
'triggered()'),
325 context_menu.AddAction(action, gui.ENTITY_VIEW|gui.VIEWS_SAME_OBJECT)
327 scene_selection=gui.SceneSelection.Instance()
328 ent=scene_selection.GetActiveNode(0)
333 ent.selection=ent.view.Select(dialog.query, dialog.query_flags)
335 ost.LogError(
"invalid query: %s" % q.error)
337 def _UniqueName(self, ent):
339 Returns a name based on ent that is unique within the scene
341 ent_name=ent.GetName()
344 candidate_name=
'%s-%d' % (ent_name, num)
345 if not gfx.Scene().HasNode(candidate_name):
346 return candidate_name
349 def _SelectViewsSameEntity(self):
351 union=gui.SceneSelection.Instance().GetViewUnion()
356 ve=gui.SceneSelection.Instance().GetViewEntity()
357 ve.selection=union.Select(q, dialog.query_flags)
359 ost.LogError(
"invalid query: %s" % q.error)
361 def _CopyViews(self):
363 scene_selection=gui.SceneSelection.Instance()
364 ent=scene_selection.GetActiveNode(0)
369 for i
in range(scene_selection.GetActiveNodeCount()):
370 ent=scene_selection.GetActiveNode(i)
371 selected=ent.view.Select(q, dialog.query_flags)
375 ost.LogError(
"invalid query: %s" % q.error)
377 def _InitContextMenu(app):
378 _InitContextMenu.cm=app.scene_win.GetContextMenu()