/
format_test.py
78 lines (65 loc) · 2.5 KB
/
format_test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
'''
Tests segmentation format utility functions.
.. moduleauthor:: Chris Fournier <chris.m.fournier@gmail.com>
'''
import unittest
from format import (convert_positions_to_masses, convert_masses_to_positions,
boundary_string_from_masses)
class TestSegeval(unittest.TestCase):
'''
Segmentation-format-related function tests.
'''
def test_convert_positions_to_masses(self):
'''
Test segment position sequence conversion to masses.
'''
self.assertEqual((5,3,5),
convert_positions_to_masses([1,1,1,1,1,2,2,2,3,3,3,3,3]))
def test_convert_positions_to_masses_none(self):
'''
Test segment position sequence conversion from masses.
'''
self.assertEqual((11,),
convert_positions_to_masses([1,1,1,1,1,1,1,1,1,1,1]))
def test_convert_positions_to_masses_all(self):
'''
Test segment position sequence conversion from masses.
'''
self.assertEqual((1,1,1,1,1,1,1,1,1,1,1),
convert_positions_to_masses([1,2,3,4,5,6,7,8,9,10,11]))
def test_convert_masses_to_positions(self):
'''
Test segment position sequence conversion from masses.
'''
self.assertEqual((1,1,1,1,1,2,2,2,3,3,3,3,3),
convert_masses_to_positions([5,3,5]))
def test_convert_masses_to_positions_none(self):
'''
Test segment position sequence conversion from masses.
'''
self.assertEqual(convert_masses_to_positions([11]),
(1,1,1,1,1,1,1,1,1,1,1))
def test_convert_masses_to_positions_all(self):
'''
Test segment position sequence conversion from masses.
'''
self.assertEqual(convert_masses_to_positions([1,1,1,1,1,1,1,1,1,1,1]),
(1,2,3,4,5,6,7,8,9,10,11))
def test_boundary_string_from_masses_none(self):
'''
No boundaries.
'''
string = boundary_string_from_masses([3])
self.assertEqual(string, (set(), set()))
def test_boundary_string_from_masses_full(self):
'''
Few boundaries.
'''
string = boundary_string_from_masses([1,1,1,1])
self.assertEqual(string, (set([1]), set([1]), set([1])))
def test_boundary_string_from_masses_one(self):
'''
Few boundaries.
'''
string = boundary_string_from_masses([2,3])
self.assertEqual(string, (set(), set([1]), set(), set()))