Документ взят из кэша поисковой машины. Адрес оригинального документа : http://kodomo.fbb.msu.ru/hg/allpy/rev/e90119f01df8
Дата изменения: Unknown
Дата индексирования: Tue Oct 2 01:01:38 2012
Кодировка:
allpy: e90119f01df8

allpy

changeset 641:e90119f01df8

Added some tests for allpy.fileio with format conversions and StringIO
author Daniil Alexeyevsky <dendik@kodomo.fbb.msu.ru>
date Fri, 03 Jun 2011 15:30:48 +0400
parents 69079d72d207
children a1307c0bb030
files test/test_base.py
diffstat 1 files changed, 34 insertions(+), 0 deletions(-) [+]
line diff
     1.1 --- a/test/test_base.py	Fri Jun 03 15:29:47 2011 +0400
     1.2 +++ b/test/test_base.py	Fri Jun 03 15:30:48 2011 +0400
     1.3 @@ -2,6 +2,7 @@
     1.4  import allpy.protein as p
     1.5  from allpy import processors
     1.6  from StringIO import StringIO
     1.7 +import re
     1.8  
     1.9  # XXX Totally missed:
    1.10  # XXX - monomer representation (should we test it at all?)
    1.11 @@ -76,4 +77,37 @@
    1.12          "-------------RST",
    1.13      )
    1.14  
    1.15 +def test_stringio_conversions():
    1.16 +    a = (p.Alignment().
    1.17 +        append_row_from_string("a-c-d", name="Seq1").
    1.18 +        append_row_from_string("tgcga", name="Seq2"))
    1.19 +
    1.20 +    o = StringIO()
    1.21 +    a.to_file(o, "fasta")
    1.22 +    got = o.getvalue()
    1.23 +    expect = ">Seq1\nA-C-D\n>Seq2\nTGCGA\n"
    1.24 +    assert expect == got, "Expected:\n%r\nGot:\n%r" % (expect, got)
    1.25 +
    1.26 +    o = StringIO()
    1.27 +    a.to_file(o, "msf")
    1.28 +    got = o.getvalue()
    1.29 +    got = re.sub('(stdout MSF: 5 Type: N) .*', r'\1', got)
    1.30 +    expect = (
    1.31 +        "!!NA_MULTIPLE_ALIGNMENT 1.0\n"
    1.32 +        "\n"
    1.33 +        "  stdout MSF: 5 Type: N 03/06/11 CompCheck: 1918 ..\n"
    1.34 +        "\n"
    1.35 +        "  Name: Seq1       Len: 5  Check:  882 Weight: 1.00\n"
    1.36 +        "  Name: Seq2       Len: 5  Check: 1036 Weight: 1.00\n"
    1.37 +        "\n"
    1.38 +        "//\n"
    1.39 +        "\n"
    1.40 +        "           1   5\n"
    1.41 +        "Seq1       A.C.D\n"
    1.42 +        "Seq2       TGCGA\n"
    1.43 +        "\n"
    1.44 +    )
    1.45 +    expect = re.sub('(stdout MSF: 5 Type: N) .*', r'\1', expect)
    1.46 +    assert expect == got, "Expected:\n%r\nGot:\n%r" % (expect, got)
    1.47 +
    1.48  # vim: set et ts=4 sts=4 sw=4: