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
Branches
Tags
No related merge requests found
......@@ -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")
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()
for s in seq_list:
ss = s.Copy()
......@@ -101,6 +108,7 @@ def ClustalW(seq1, seq2=None, clustalw=None, keep_files=False, nopgap=False,
new_list.AddSequence(ss)
seq_list = new_list
temp_dir=utils.TempDirWithFiles((seq_list,))
out=os.path.join(temp_dir.dirname, 'out.fasta')
......
......@@ -62,6 +62,13 @@ class TestClustalWBindings(unittest.TestCase):
assert self.seq1_seq2_alignment_options_changed.ToString(80) == aln.ToString(80), \
"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__":
# test if clustalw package is available on system, otherwise ignore tests
try:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment