annotate test/test_match_library.py @ 0:dffc38727496

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