comparison test/test_match_library.py @ 0:9d5f4f5f764b

Initial commit to toolshed
author pieter.lukasse@wur.nl
date Thu, 16 Jan 2014 13:10:00 +0100
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:9d5f4f5f764b
1 '''
2 Created on Mar 6, 2012
3
4 @author: marcelk
5 '''
6 from GCMS import match_library
7 import unittest
8 from pkg_resources import resource_filename # @UnresolvedImport # pylint: disable=E0611
9
10
11 class Test(unittest.TestCase):
12 '''
13 Tests the 'match_library' Galaxy tool
14 '''
15 nist_db = resource_filename(__name__, "data/RIDB_subset.txt")
16
17 def test_get_column_type(self):
18 '''
19 Tests the 'get_column_type' function that returns tuples of unique elements
20 for column types in the RI database
21 '''
22 galaxy_output = match_library.get_column_type(self.nist_db)
23 self.assertEqual([('Capillary(9999)', 'Capillary', False)], galaxy_output)
24
25 def test_filter_column(self):
26 '''
27 Tests the 'filter_column' function showing the column phase for all 'Capillary' columns
28 '''
29 galaxy_output = match_library.filter_column(self.nist_db, 'Capillary')
30 self.assertEqual([('Semi-standard non-polar(9999)', 'Semi-standard non-polar', False)], galaxy_output)
31
32 def test_filter_column2(self):
33 '''
34 Tests the 'filter_column' function showing all possibilities for columns having both the
35 'Capillary' and 'Semi-standard non-polar' properties
36 '''
37 galaxy_output = match_library.filter_column2(self.nist_db, 'Capillary', 'Semi-standard non-polar')
38 self.failUnless(('Apiezon M(6)', 'Apiezon M', False) in galaxy_output)
39
40 def test_count_occurrence(self):
41 '''
42 Tests the 'count_occurrence' function
43 '''
44 test_list = [2, 0, 0, 2, 1, 3, 4, 5, 3, 2, 3, 4, 5, 5, 4, 2, 5, 3, 4, 3, 5, 4, 2, 0, 4]
45 counts = match_library.count_occurrence(test_list)
46 self.assertEqual({0: 3, 1: 1, 2: 5, 3: 5, 4: 6, 5: 5}, counts)
47
48
49 if __name__ == "__main__":
50 #import sys;sys.argv = ['', 'Test.testName']
51 unittest.main()