allpy
changeset 826:18119191a4c8
Bug: alignment IO recorded incorrect value to sequence's source attribute -- fixed
| author | Daniil Alexeyevsky <dendik@kodomo.fbb.msu.ru> |
|---|---|
| date | Fri, 15 Jul 2011 18:38:01 +0400 |
| parents | 4f896db3531d |
| children | 672f228c949e |
| files | allpy/fileio.py test/test_base.py |
| diffstat | 2 files changed, 8 insertions(+), 1 deletions(-) [+] |
line diff
1.1 --- a/allpy/fileio.py Fri Jul 15 18:01:31 2011 +0400 1.2 +++ b/allpy/fileio.py Fri Jul 15 18:38:01 2011 +0400 1.3 @@ -40,8 +40,9 @@ 1.4 def read_alignment(self, alignment): 1.5 """Read alignment from the file.""" 1.6 append_row = alignment.append_row_from_string 1.7 + source = getattr(self.file, 'name', '') 1.8 for name, description, body in self.read_strings(): 1.9 - append_row(body, name, description, file.name, self.gaps) 1.10 + append_row(body, name, description, source, self.gaps) 1.11 1.12 class FastaFile(AlignmentFile): 1.13 """Fasta parser & writer."""
2.1 --- a/test/test_base.py Fri Jul 15 18:01:31 2011 +0400 2.2 +++ b/test/test_base.py Fri Jul 15 18:38:01 2011 +0400 2.3 @@ -116,4 +116,10 @@ 2.4 expect = re.sub('(stdout MSF: 5 Type: N) .*', r'\1', expect) 2.5 assert expect == got, "Expected:\n%r\nGot:\n%r" % (expect, got) 2.6 2.7 + o.name = 'whoopie.msf' 2.8 + o.seek(0) 2.9 + b = p.Alignment().append_file(o, format='msf') 2.10 + assert b.rows_as_strings() == ["A-C-D", "TGCGA"] 2.11 + assert b.sequences[0].source == o.name 2.12 + 2.13 # vim: set et ts=4 sts=4 sw=4:
