def test_distance_matrix(self): """distance_matrix should obey RowOrder of alignment""" #RowOrder=None aln1_exp = array([[0,2,2],[2,0,1],[2,1,0]]) self.assertEqual(distance_matrix(self.aln1),aln1_exp) a = Alignment(self.aln1.copy()) a.RowOrder=[1,2,0] a_exp = array([[0,1,2],[1,0,2],[2,2,0]]) self.assertEqual(distance_matrix(a),a_exp)
def ClustalParser(record, seq_constructor=Sequence, strict=True): """Returns contents of record as Alignment object.""" seqs, label_order = MinimalClustalParser(record, strict) result = Alignment() for label, seq in seqs.items(): new_seq = seq_constructor(''.join(map(strip, seq))) try: new_seq.Label = label except AttributeError: pass result[label] = new_seq result.RowOrder = label_order return result