Skip to content
Snippets Groups Projects
Commit e12c868d authored by Studer Gabriel's avatar Studer Gabriel
Browse files

make Align functionality in dng independent of tmtools

Use the WrappedTMAlign instead
parent bc3fb329
No related branches found
No related tags found
No related merge requests found
...@@ -7,7 +7,7 @@ import sip ...@@ -7,7 +7,7 @@ import sip
from ost import geom, gfx, gui, seq from ost import geom, gfx, gui, seq
from ost import settings from ost import settings
from ost import LogError, mol from ost import LogError, mol
from ost.bindings import tmtools from ost.bindings import WrappedTMAlign
from ost.bindings import msms from ost.bindings import msms
from ost.seq import alg from ost.seq import alg
import ost import ost
...@@ -236,26 +236,12 @@ class SurfaceContextMenu(QtCore.QObject): ...@@ -236,26 +236,12 @@ class SurfaceContextMenu(QtCore.QObject):
class AlignmentContextMenu(QtCore.QObject): class AlignmentContextMenu(QtCore.QObject):
def __init__(self, context_menu): def __init__(self, context_menu):
try:
try: # workaround for interrupted system call bug on OSX QtCore.QObject.__init__(self, context_menu.qobject)
if platform.system() == "Windows": self.action = QtWidgets.QAction("Align", self)
settings_name="tmalign.exe" self.action.triggered.connect(self.Align)
else: context_menu.AddAction(self.action, gui.ContextActionType.ENTITY | gui.ContextActionType.MULTI)
settings_name="tmalign" self.seq_viewer = None
except IOError:
# if platform.system() fails with an IOError we are most likely on a buggy mac an therefore
# use "tmalign"
settings_name="tmalign"
settings.Locate(settings_name)
QtCore.QObject.__init__(self, context_menu.qobject)
self.action = QtWidgets.QAction("Align", self)
self.action.triggered.connect(self.Align)
context_menu.AddAction(self.action, gui.ContextActionType.ENTITY | gui.ContextActionType.MULTI)
self.seq_viewer = None
except settings.FileNotFound:
return
def Align(self): def Align(self):
scene_selection = gui.SceneSelection.Instance() scene_selection = gui.SceneSelection.Instance()
...@@ -270,11 +256,11 @@ class AlignmentContextMenu(QtCore.QObject): ...@@ -270,11 +256,11 @@ class AlignmentContextMenu(QtCore.QObject):
node = ent_list[0] node = ent_list[0]
res_list = list() res_list = list()
if isinstance(node, gfx.Entity): if isinstance(node, gfx.Entity):
ref = node.view.handle ref = node.view.chains[0]
for i in range(1,len(ent_list)): for i in range(1,len(ent_list)):
node = ent_list[i] node = ent_list[i]
if isinstance(node, gfx.Entity): if isinstance(node, gfx.Entity):
res_list.append(tmtools.TMAlign(node.view.handle, ref)) res_list.append(WrappedTMAlign(node.view.chains[0], ref))
node.UpdatePositions() node.UpdatePositions()
if show_scores: if show_scores:
self.__ShowScore(ent_list, res_list) self.__ShowScore(ent_list, res_list)
...@@ -291,12 +277,18 @@ class AlignmentContextMenu(QtCore.QObject): ...@@ -291,12 +277,18 @@ class AlignmentContextMenu(QtCore.QObject):
def __DisplayAlignment(self, ent_list, res_list): def __DisplayAlignment(self, ent_list, res_list):
if(len(res_list)>0): if(len(res_list)>0):
ref_seq = seq.CreateSequence("%s (ref)"%ent_list[0].GetName(),res_list[0].ref_sequence.GetGaplessString()) ref_seq = seq.CreateSequence("%s (ref)"%ent_list[0].GetName(),
res_list[0].alignment.GetSequence(1).GetGaplessString())
aln_list = seq.AlignmentList() aln_list = seq.AlignmentList()
if(ref_seq.IsValid()): if(ref_seq.IsValid()):
for i in range(0, len(res_list)): for i in range(0, len(res_list)):
res_list[i].alignment.SetSequenceName(1,ent_list[i+1].GetName()) # WrappedTMAlign returns an alignment with second sequence
aln_list.append(res_list[i].alignment) # being reference... let's swap...
new_aln = seq.CreateAlignment()
new_aln.AddSequence(res_list[i].alignment.GetSequence(1))
new_aln.AddSequence(res_list[i].alignment.GetSequence(0))
new_aln.SetSequenceName(1, ent_list[i+1].GetName())
aln_list.append(new_aln)
alignment = alg.MergePairwiseAlignments(aln_list, ref_seq) alignment = alg.MergePairwiseAlignments(aln_list, ref_seq)
gosty = gui.GostyApp.Instance() gosty = gui.GostyApp.Instance()
main_area = gosty.perspective.GetMainArea() main_area = gosty.perspective.GetMainArea()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment