annotate test/test_query_mass_repos.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 '''Integration tests for the GCMS project'''
dffc38727496 initial commit
pieter.lukasse@wur.nl
parents:
diff changeset
2
dffc38727496 initial commit
pieter.lukasse@wur.nl
parents:
diff changeset
3 from pkg_resources import resource_filename # @UnresolvedImport # pylint: disable=E0611
dffc38727496 initial commit
pieter.lukasse@wur.nl
parents:
diff changeset
4 from MS import query_mass_repos
dffc38727496 initial commit
pieter.lukasse@wur.nl
parents:
diff changeset
5 import os.path
dffc38727496 initial commit
pieter.lukasse@wur.nl
parents:
diff changeset
6 import sys
dffc38727496 initial commit
pieter.lukasse@wur.nl
parents:
diff changeset
7 import unittest
dffc38727496 initial commit
pieter.lukasse@wur.nl
parents:
diff changeset
8
dffc38727496 initial commit
pieter.lukasse@wur.nl
parents:
diff changeset
9
dffc38727496 initial commit
pieter.lukasse@wur.nl
parents:
diff changeset
10 class IntegrationTest(unittest.TestCase):
dffc38727496 initial commit
pieter.lukasse@wur.nl
parents:
diff changeset
11
dffc38727496 initial commit
pieter.lukasse@wur.nl
parents:
diff changeset
12
dffc38727496 initial commit
pieter.lukasse@wur.nl
parents:
diff changeset
13
dffc38727496 initial commit
pieter.lukasse@wur.nl
parents:
diff changeset
14
dffc38727496 initial commit
pieter.lukasse@wur.nl
parents:
diff changeset
15 def test_simple(self):
dffc38727496 initial commit
pieter.lukasse@wur.nl
parents:
diff changeset
16 '''
dffc38727496 initial commit
pieter.lukasse@wur.nl
parents:
diff changeset
17 Simple initial test
dffc38727496 initial commit
pieter.lukasse@wur.nl
parents:
diff changeset
18 '''
dffc38727496 initial commit
pieter.lukasse@wur.nl
parents:
diff changeset
19 # Create out folder
dffc38727496 initial commit
pieter.lukasse@wur.nl
parents:
diff changeset
20 outdir = "output/query_mass_repos/"
dffc38727496 initial commit
pieter.lukasse@wur.nl
parents:
diff changeset
21 if not os.path.exists(outdir):
dffc38727496 initial commit
pieter.lukasse@wur.nl
parents:
diff changeset
22 os.makedirs(outdir)
dffc38727496 initial commit
pieter.lukasse@wur.nl
parents:
diff changeset
23
dffc38727496 initial commit
pieter.lukasse@wur.nl
parents:
diff changeset
24 #Build up arguments and run
dffc38727496 initial commit
pieter.lukasse@wur.nl
parents:
diff changeset
25
dffc38727496 initial commit
pieter.lukasse@wur.nl
parents:
diff changeset
26 # input_file = sys.argv[1]
dffc38727496 initial commit
pieter.lukasse@wur.nl
parents:
diff changeset
27 # molecular_mass_col = sys.argv[2]
dffc38727496 initial commit
pieter.lukasse@wur.nl
parents:
diff changeset
28 # repository_file = sys.argv[3]
dffc38727496 initial commit
pieter.lukasse@wur.nl
parents:
diff changeset
29 # mass_tolerance = float(sys.argv[4])
dffc38727496 initial commit
pieter.lukasse@wur.nl
parents:
diff changeset
30 # output_result = sys.argv[5]
dffc38727496 initial commit
pieter.lukasse@wur.nl
parents:
diff changeset
31
dffc38727496 initial commit
pieter.lukasse@wur.nl
parents:
diff changeset
32 input_file = resource_filename(__name__, "data/service_query_tabular.txt")
dffc38727496 initial commit
pieter.lukasse@wur.nl
parents:
diff changeset
33
dffc38727496 initial commit
pieter.lukasse@wur.nl
parents:
diff changeset
34 molecular_mass_col = "mass (Da)"
dffc38727496 initial commit
pieter.lukasse@wur.nl
parents:
diff changeset
35 dblink_file = resource_filename(__name__, "data/MFSearcher ExactMassDB service.txt")
dffc38727496 initial commit
pieter.lukasse@wur.nl
parents:
diff changeset
36 output_result = resource_filename(__name__, outdir + "metexp_query_results_added.txt")
dffc38727496 initial commit
pieter.lukasse@wur.nl
parents:
diff changeset
37
dffc38727496 initial commit
pieter.lukasse@wur.nl
parents:
diff changeset
38
dffc38727496 initial commit
pieter.lukasse@wur.nl
parents:
diff changeset
39
dffc38727496 initial commit
pieter.lukasse@wur.nl
parents:
diff changeset
40
dffc38727496 initial commit
pieter.lukasse@wur.nl
parents:
diff changeset
41 sys.argv = ['test',
dffc38727496 initial commit
pieter.lukasse@wur.nl
parents:
diff changeset
42 input_file,
dffc38727496 initial commit
pieter.lukasse@wur.nl
parents:
diff changeset
43 molecular_mass_col,
dffc38727496 initial commit
pieter.lukasse@wur.nl
parents:
diff changeset
44 dblink_file,
dffc38727496 initial commit
pieter.lukasse@wur.nl
parents:
diff changeset
45 '0.001',
dffc38727496 initial commit
pieter.lukasse@wur.nl
parents:
diff changeset
46 'ms',
dffc38727496 initial commit
pieter.lukasse@wur.nl
parents:
diff changeset
47 output_result]
dffc38727496 initial commit
pieter.lukasse@wur.nl
parents:
diff changeset
48
dffc38727496 initial commit
pieter.lukasse@wur.nl
parents:
diff changeset
49 # Execute main function with arguments provided through sys.argv
dffc38727496 initial commit
pieter.lukasse@wur.nl
parents:
diff changeset
50 query_mass_repos.main()
dffc38727496 initial commit
pieter.lukasse@wur.nl
parents:
diff changeset
51
dffc38727496 initial commit
pieter.lukasse@wur.nl
parents:
diff changeset
52
dffc38727496 initial commit
pieter.lukasse@wur.nl
parents:
diff changeset
53
dffc38727496 initial commit
pieter.lukasse@wur.nl
parents:
diff changeset
54
dffc38727496 initial commit
pieter.lukasse@wur.nl
parents:
diff changeset
55
dffc38727496 initial commit
pieter.lukasse@wur.nl
parents:
diff changeset
56 def _read_file(filename):
dffc38727496 initial commit
pieter.lukasse@wur.nl
parents:
diff changeset
57 '''
dffc38727496 initial commit
pieter.lukasse@wur.nl
parents:
diff changeset
58 Helper method to quickly read a file
dffc38727496 initial commit
pieter.lukasse@wur.nl
parents:
diff changeset
59 @param filename:
dffc38727496 initial commit
pieter.lukasse@wur.nl
parents:
diff changeset
60 '''
dffc38727496 initial commit
pieter.lukasse@wur.nl
parents:
diff changeset
61 with open(filename) as handle:
dffc38727496 initial commit
pieter.lukasse@wur.nl
parents:
diff changeset
62 return handle.read()