allpy
changeset 1081:43b5207a70d7
Bugfixed the previous commit (decency verification), (see #98)
* Removed the decency verification function itself, it does not seem to be
necessary YET
* Moved the check on alignment quality within processors.FixOrdering, which is
the one that actually fails and is hard to debug if sequences have the same
identification.
* Added a specific testcase for this situation.
author | Daniil Alexeyevsky <dendik@kodomo.fbb.msu.ru> |
---|---|
date | Wed, 30 May 2012 13:35:04 +0400 |
parents | fdc2d3594a3e |
children | 4b1a6a7bbeea 56b6a55ce463 |
files | allpy/base.py allpy/processors.py test/test_realign.py |
diffstat | 3 files changed, 19 insertions(+), 15 deletions(-) [+] |
line diff
1.1 --- a/allpy/base.py Wed May 30 12:43:09 2012 +0400 1.2 +++ b/allpy/base.py Wed May 30 13:35:04 2012 +0400 1.3 @@ -494,24 +494,9 @@ 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
2.1 --- a/allpy/processors.py Wed May 30 12:43:09 2012 +0400 2.2 +++ b/allpy/processors.py Wed May 30 13:35:04 2012 +0400 2.3 @@ -185,6 +185,8 @@ 2.4 (self.id(sequence), sequence) 2.5 for sequence in out_block.sequences 2.6 )) 2.7 + assert len(sequences) == len(block.sequences), \ 2.8 + "Sequence identificators must be unique!" 2.9 out_block.sequences = [ 2.10 sequences[self.id(old_sequence)] 2.11 for old_sequence in block.sequences
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 3.2 +++ b/test/test_realign.py Wed May 30 13:35:04 2012 +0400 3.3 @@ -0,0 +1,17 @@ 3.4 +from nose.tools import raises 3.5 +from allpy import protein, processors 3.6 + 3.7 +example1 = protein.Alignment().\ 3.8 + append_sequence(protein.Sequence.from_string("mkstf", name="abc")).\ 3.9 + append_sequence(protein.Sequence.from_string("mstkfff", description="Longer sequence")) 3.10 + 3.11 +def test_muscle(): 3.12 + example1.realign(processors.Muscle()) 3.13 + 3.14 +example2 = protein.Alignment().\ 3.15 + append_sequence(protein.Sequence.from_string("mkstf", name="a")).\ 3.16 + append_sequence(protein.Sequence.from_string("mstkfff", name="a")) 3.17 + 3.18 +@raises(AssertionError) 3.19 +def test_muscle_failure(): 3.20 + example2.realign(processors.Muscle())