00001 from ost.bindings import utils
00002 from ost import settings, io, seq
00003 import os
00004 import subprocess
00005
00006 def ClustalW(seq1, seq2, clustalw=None):
00007 clustalw_path=settings.Locate(('clustalw', 'clustalw2'),
00008 explicit_file_name=clustalw)
00009 seq_list=seq.CreateSequenceList()
00010 seq_list.AddSequence(seq1)
00011 seq_list.AddSequence(seq2)
00012 temp_dir=utils.TempDirWithFiles((seq_list,))
00013 out=os.path.join(temp_dir.dirname, 'out.fasta')
00014 command='%s -infile="%s" -output=fasta -outfile="%s"' % (clustalw_path,
00015 temp_dir.files[0],
00016 out)
00017 ps=subprocess.Popen(command, shell=True, stdout=subprocess.PIPE)
00018 ps.stdout.readlines()
00019 aln=io.LoadAlignment(out)
00020 aln.SetSequenceOffset(0,seq1.GetSequenceOffset())
00021 aln.SetSequenceOffset(1,seq2.GetSequenceOffset())
00022 if seq1.HasAttachedView():
00023 aln.AttachView(0,seq1.GetAttachedView().Copy())
00024 if seq2.HasAttachedView():
00025 aln.AttachView(1,seq2.GetAttachedView().Copy())
00026
00027
00028
00029
00030 return aln
00031