Mercurial > repos > pieterlukasse > prims_metabolomics2
comparison test/test_query_metexp_LARGE.py @ 0:dffc38727496
initial commit
author | pieter.lukasse@wur.nl |
---|---|
date | Sat, 07 Feb 2015 22:02:00 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:dffc38727496 |
---|---|
1 '''Integration tests for the GCMS project''' | |
2 | |
3 from pkg_resources import resource_filename # @UnresolvedImport # pylint: disable=E0611 | |
4 from GCMS import query_metexp | |
5 import os.path | |
6 import sys | |
7 import unittest | |
8 | |
9 | |
10 class IntegrationTest(unittest.TestCase): | |
11 | |
12 | |
13 # def test_MM_calculations(self): | |
14 # ''' | |
15 # test the implemented method for MM calculations for | |
16 # given chemical formulas | |
17 # ''' | |
18 # export_to_metexp_tabular.init_elements_and_masses_map() | |
19 # | |
20 # formula = "C8H18O3" | |
21 # # should be = 12.01*8 + 1.01*18 + 16*3 = 162.26 | |
22 # result = export_to_metexp_tabular.get_molecular_mass(formula) | |
23 # self.assertEqual(162.26, result) | |
24 # | |
25 # formula = "CH2O3Fe2Ni" | |
26 # # should be = 12.01*1 + 1.01*2 + 16*3 + 55.85*2 + 58.71 = 232.44 | |
27 # result = export_to_metexp_tabular.get_molecular_mass(formula) | |
28 # self.assertAlmostEqual(232.44, result, 2) | |
29 # | |
30 # | |
31 # | |
32 | |
33 | |
34 def test_large(self): | |
35 ''' | |
36 Simple test, but on larger set, last test executed in 28s | |
37 ''' | |
38 # Create out folder | |
39 outdir = "output/metexp_query/" | |
40 if not os.path.exists(outdir): | |
41 os.makedirs(outdir) | |
42 | |
43 #Build up arguments and run | |
44 | |
45 # input_file = sys.argv[1] | |
46 # molecular_mass_col = sys.argv[2] | |
47 # formula_col = sys.argv[3] | |
48 # metexp_dblink_file = sys.argv[4] | |
49 # output_result = sys.argv[5] | |
50 | |
51 input_file = resource_filename(__name__, "data/metexp_query_tabular_large.txt") | |
52 casid_col = "CAS" | |
53 formula_col = "FORMULA" | |
54 molecular_mass_col = "MM" | |
55 metexp_dblink_file = resource_filename(__name__, "data/METEXP Test DB.txt") | |
56 output_result = resource_filename(__name__, outdir + "metexp_query_results_added_LARGE.txt") | |
57 | |
58 sys.argv = ['test', | |
59 input_file, | |
60 casid_col, | |
61 formula_col, | |
62 molecular_mass_col, | |
63 metexp_dblink_file, | |
64 'GC', | |
65 output_result] | |
66 | |
67 # Execute main function with arguments provided through sys.argv | |
68 query_metexp.main() | |
69 | |
70 | |
71 | |
72 | |
73 def _read_file(filename): | |
74 ''' | |
75 Helper method to quickly read a file | |
76 @param filename: | |
77 ''' | |
78 with open(filename) as handle: | |
79 return handle.read() |