コード例 #1
0
 def test_parse_format_line_returns_none(self):
     d = DataHandler()
     assert d.parse_format_line('#NEXUS ') is None
     assert d.parse_format_line('') is None
     assert d.parse_format_line('Begin data;') is None
     assert d.parse_format_line('Dimensions ntax=4 nchar=2;') is None
     assert d.parse_format_line('Matrix') is None
     assert d.parse_format_line('Harry              00') is None
     assert d.parse_format_line('Simon              01') is None
     assert d.parse_format_line('Betty              10') is None
     assert d.parse_format_line('Louise             11') is None
     assert d.parse_format_line('    ;') is None
     assert d.parse_format_line('End;') is None
コード例 #2
0
ファイル: test_reader.py プロジェクト: nishmadahal/PTP
 def test_parse_format_line(self):
     d = DataHandler()
     f = d.parse_format_line('Format datatype=standard symbols="01" gap=-;')
     assert f['datatype'] == 'standard', "Expected 'standard', but got '%s'" % f['datatype']
     assert f['symbols'] == '01', "Expected '01', but got '%s'" % f['symbols']
     assert f['gap'] == '-', "Expected 'gap', but got '%s'" % f['gap']
     
     f = d.parse_format_line('FORMAT datatype=RNA missing=? gap=- symbols="ACGU" labels interleave;')
     assert f['datatype'] == 'rna', "Expected 'rna', but got '%s'" % f['datatype']
     assert f['missing'] == '?', "Expected '?', but got '%s'" % f['missing']
     assert f['gap'] == '-', "Expected '-', but got '%s'" % f['gap']
     assert f['symbols'] == 'acgu', "Expected 'acgu', but got '%s'" % f['symbols']
     assert f['labels'] == True, "Expected <True>, but got '%s'" % f['labels']
     assert f['interleave'] == True, "Expected <True>, but got '%s'" % f['interleave']
コード例 #3
0
    def test_parse_format_line(self):
        d = DataHandler()
        f = d.parse_format_line('Format datatype=standard gap=- symbols="01";')
        assert f['datatype'] == 'standard', \
            "Expected 'standard', but got '%s'" % f['datatype']
        assert f['symbols'] == '01', \
            "Expected '01', but got '%s'" % f['symbols']
        assert f['gap'] == '-', \
            "Expected 'gap', but got '%s'" % f['gap']

        fmt = 'FORMAT datatype=RNA missing=? symbols="ACGU" labels interleave;'
        f = d.parse_format_line(fmt)
        assert f['datatype'] == 'rna', \
            "Expected 'rna', but got '%s'" % f['datatype']
        assert f['missing'] == '?', \
            "Expected '?', but got '%s'" % f['missing']
        assert f['symbols'] == 'acgu', \
            "Expected 'acgu', but got '%s'" % f['symbols']
        assert f['labels'] is True, \
            "Expected <True>, but got '%s'" % f['labels']
        assert f['interleave'] is True, \
            "Expected <True>, but got '%s'" % f['interleave']
コード例 #4
0
 def test_maddison(self):
     assert DataHandler()._parse_sites('TAG;') == ['T', 'A', 'G']
コード例 #5
0
 def test_extra_comma(self):
     assert DataHandler()._parse_sites('(T,A),C,G') == ['T,A', 'C', 'G']
コード例 #6
0
 def test_comma(self):
     assert DataHandler()._parse_sites('123(4,5)56') == \
         ['1', '2', '3', '4,5', '5', '6']
コード例 #7
0
 def test_sequence(self):
     assert DataHandler()._parse_sites("ACGTU?") == \
         ['A', 'C', 'G', 'T', 'U', '?']
コード例 #8
0
 def test_multi(self):
     assert DataHandler()._parse_sites('1(12)') == ['1', '12']
コード例 #9
0
 def test_simple(self):
     assert DataHandler()._parse_sites('123') == ['1', '2', '3']
コード例 #10
0
 def test_parse_format_line_returns_none(self):
     d = DataHandler()
     assert d.parse_format_line('#NEXUS ') is None
     assert d.parse_format_line('') is None
     assert d.parse_format_line('Begin data;') is None
     assert d.parse_format_line('Dimensions ntax=4 nchar=2;') is None
     assert d.parse_format_line('Matrix') is None
     assert d.parse_format_line('Harry              00') is None
     assert d.parse_format_line('Simon              01') is None
     assert d.parse_format_line('Betty              10') is None
     assert d.parse_format_line('Louise             11') is None
     assert d.parse_format_line('    ;') is None
     assert d.parse_format_line('End;') is None
コード例 #11
0
def test_parse_range():
    d = DataHandler()
    assert d.parse_range("1-3") == [1, 2, 3]
    assert d.parse_range("29") == [29]
    assert d.parse_range("1,9") == [1, 9]
コード例 #12
0
def test_DataHandler_parse_sites(input, expected):
    assert DataHandler()._parse_sites(input) == expected