From a0a5cfbe437e8b8de225a1fb57d397a39800f3cd Mon Sep 17 00:00:00 2001
From: Gabriel Studer <gabriel.studer@unibas.ch>
Date: Tue, 25 Oct 2022 13:40:36 +0200
Subject: [PATCH] make ClustalW unit test independent of sequence order

Andrius Merkys reported architecture dependent behaviour regarding
ordering of aligned sequences. We want to keep the order as given
by the used ClustalW executable which is potentially different as
in the unit test reference file.
---
 modules/bindings/tests/test_clustalw.py | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/modules/bindings/tests/test_clustalw.py b/modules/bindings/tests/test_clustalw.py
index 222effed8..657fed20b 100644
--- a/modules/bindings/tests/test_clustalw.py
+++ b/modules/bindings/tests/test_clustalw.py
@@ -42,8 +42,16 @@ class TestClustalWBindings(unittest.TestCase):
     
   def testMultipleClustalW(self):
     aln=clustalw.ClustalW(self.multseq)
-    assert self.mult_alignment.ToString(80) == aln.ToString(80), \
-           "Multiple alignment differs from precomputed one"
+    # order of sequences in aln may differ (reported by Andrius Merkys who
+    # found architecture dependent behaviour)
+    # We therefore check for matching sequence names and respective sequences
+    # but not for order.
+    ref_sequences = {s.GetName(): str(s) for s in self.mult_alignment.sequences}
+    sequences = {s.GetName(): str(s) for s in aln.sequences}
+    self.assertEqual(sorted(ref_sequences.keys()), sorted(sequences.keys()))
+    for sname, s in ref_sequences.items():
+      self.assertEqual(s, sequences[sname])
+
 
   def testStringClustalW(self):
     aln=clustalw.ClustalW(self.strseq1, self.strseq2)
-- 
GitLab