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

make sure ClustalW gets sequences with unique identifiers

parent c0ae1b7f
No related branches found
No related tags found
No related merge requests found
...@@ -92,6 +92,13 @@ def ClustalW(seq1, seq2=None, clustalw=None, keep_files=False, nopgap=False, ...@@ -92,6 +92,13 @@ def ClustalW(seq1, seq2=None, clustalw=None, keep_files=False, nopgap=False,
LogError("WARNING: Specify either two SequenceHandles or one SequenceList") LogError("WARNING: Specify either two SequenceHandles or one SequenceList")
return return
sequence_names = set()
for s in seq_list:
sequence_names.add(s.GetName())
if len(sequence_names) < len(seq_list):
raise ValueError("ClustalW can only process sequences with unique identifiers!")
new_list = seq.CreateSequenceList() new_list = seq.CreateSequenceList()
for s in seq_list: for s in seq_list:
ss = s.Copy() ss = s.Copy()
...@@ -101,6 +108,7 @@ def ClustalW(seq1, seq2=None, clustalw=None, keep_files=False, nopgap=False, ...@@ -101,6 +108,7 @@ def ClustalW(seq1, seq2=None, clustalw=None, keep_files=False, nopgap=False,
new_list.AddSequence(ss) new_list.AddSequence(ss)
seq_list = new_list seq_list = new_list
temp_dir=utils.TempDirWithFiles((seq_list,)) temp_dir=utils.TempDirWithFiles((seq_list,))
out=os.path.join(temp_dir.dirname, 'out.fasta') out=os.path.join(temp_dir.dirname, 'out.fasta')
......
...@@ -62,6 +62,13 @@ class TestClustalWBindings(unittest.TestCase): ...@@ -62,6 +62,13 @@ class TestClustalWBindings(unittest.TestCase):
assert self.seq1_seq2_alignment_options_changed.ToString(80) == aln.ToString(80), \ assert self.seq1_seq2_alignment_options_changed.ToString(80) == aln.ToString(80), \
"Pairwise alignment with modified gap penalties differs from precomputed one" "Pairwise alignment with modified gap penalties differs from precomputed one"
def testUniqueIdentifier(self):
seq1 = seq.CreateSequence('heelloo','AWESOME')
seq2 = seq.CreateSequence('heelloo','AWESOME')
self.assertRaises(ValueError,clustalw.ClustalW,seq1,seq2)
if __name__ == "__main__": if __name__ == "__main__":
# test if clustalw package is available on system, otherwise ignore tests # test if clustalw package is available on system, otherwise ignore tests
try: try:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment