Mercurial > repos > pieterlukasse > prims_metabolomics
view test/test_query_metexp.py @ 29:0d534bce8e84
small fix
author | pieter.lukasse@wur.nl |
---|---|
date | Fri, 09 May 2014 17:11:11 +0200 |
parents | 19d8fd10248e |
children |
line wrap: on
line source
'''Integration tests for the GCMS project''' from pkg_resources import resource_filename # @UnresolvedImport # pylint: disable=E0611 from GCMS import query_metexp import os.path import sys import unittest class IntegrationTest(unittest.TestCase): # def test_MM_calculations(self): # ''' # test the implemented method for MM calculations for # given chemical formulas # ''' # export_to_metexp_tabular.init_elements_and_masses_map() # # formula = "C8H18O3" # # should be = 12.01*8 + 1.01*18 + 16*3 = 162.26 # result = export_to_metexp_tabular.get_molecular_mass(formula) # self.assertEqual(162.26, result) # # formula = "CH2O3Fe2Ni" # # should be = 12.01*1 + 1.01*2 + 16*3 + 55.85*2 + 58.71 = 232.44 # result = export_to_metexp_tabular.get_molecular_mass(formula) # self.assertAlmostEqual(232.44, result, 2) # # # def test_simple(self): ''' Simple initial test ''' # Create out folder outdir = "output/metexp_query/" if not os.path.exists(outdir): os.makedirs(outdir) #Build up arguments and run # input_file = sys.argv[1] # molecular_mass_col = sys.argv[2] # formula_col = sys.argv[3] # metexp_dblink_file = sys.argv[4] # output_result = sys.argv[5] input_file = resource_filename(__name__, "data/metexp_query_tabular.txt") casid_col = "CAS" formula_col = "FORMULA" molecular_mass_col = "MM" metexp_dblink_file = resource_filename(__name__, "data/METEXP Test DB.txt") output_result = resource_filename(__name__, outdir + "metexp_query_results_added.txt") sys.argv = ['test', input_file, casid_col, formula_col, molecular_mass_col, metexp_dblink_file, 'GC', output_result] # Execute main function with arguments provided through sys.argv query_metexp.main() # TODO - asserts (base them on DB being filled with test data form metexp unit test for upload method) # PA def _read_file(filename): ''' Helper method to quickly read a file @param filename: ''' with open(filename) as handle: return handle.read()