allpy
changeset 1080:fdc2d3594a3e
allpy.base: Added decency verification function to alignments (closes #98)
Currently, the verification function asserts that no two sequences in an
alignment have the same identifier.
author | Daniil Alexeyevsky <dendik@kodomo.fbb.msu.ru> |
---|---|
date | Wed, 30 May 2012 12:43:09 +0400 |
parents | 9d4f28e3903a |
children | 43b5207a70d7 |
files | allpy/base.py |
diffstat | 1 files changed, 15 insertions(+), 0 deletions(-) [+] |
line diff
1.1 --- a/allpy/base.py Wed May 30 12:33:22 2012 +0400 1.2 +++ b/allpy/base.py Wed May 30 12:43:09 2012 +0400 1.3 @@ -494,9 +494,24 @@ 1.4 1.5 This is the same as process(function, False, False) 1.6 """ 1.7 + self.verify() 1.8 new = function(self) 1.9 self._replace_column_contents(new) 1.10 1.11 + # Helpers 1.12 + # ================================= 1.13 + 1.14 + def verify(self): 1.15 + """Make sure the alignment is decent. Raise an exception otherwise. 1.16 + 1.17 + I.e.: 1.18 + 1.19 + * it has no sequences with the same seq.name 1.20 + """ 1.21 + seq_names = set(seq.names for seq in self.sequences) 1.22 + assert len(seq_names) == len(self.sequences), \ 1.23 + "Alignment has sequences with the same identifier" 1.24 + 1.25 class Column(dict): 1.26 """Column of alignment. 1.27