Mercurial > repos > pieterlukasse > prims_metabolomics
annotate test/test_query_mass_repos.py @ 54:10f3cb998c4e
small fix
author | pieter.lukasse@wur.nl |
---|---|
date | Thu, 11 Dec 2014 14:32:19 +0100 |
parents | 637830ac8bcd |
children |
rev | line source |
---|---|
23
85fd05d0d16c
New tool to Query multiple public repositories for elemental compositions
pieter.lukasse@wur.nl
parents:
diff
changeset
|
1 '''Integration tests for the GCMS project''' |
85fd05d0d16c
New tool to Query multiple public repositories for elemental compositions
pieter.lukasse@wur.nl
parents:
diff
changeset
|
2 |
85fd05d0d16c
New tool to Query multiple public repositories for elemental compositions
pieter.lukasse@wur.nl
parents:
diff
changeset
|
3 from pkg_resources import resource_filename # @UnresolvedImport # pylint: disable=E0611 |
85fd05d0d16c
New tool to Query multiple public repositories for elemental compositions
pieter.lukasse@wur.nl
parents:
diff
changeset
|
4 from MS import query_mass_repos |
85fd05d0d16c
New tool to Query multiple public repositories for elemental compositions
pieter.lukasse@wur.nl
parents:
diff
changeset
|
5 import os.path |
85fd05d0d16c
New tool to Query multiple public repositories for elemental compositions
pieter.lukasse@wur.nl
parents:
diff
changeset
|
6 import sys |
85fd05d0d16c
New tool to Query multiple public repositories for elemental compositions
pieter.lukasse@wur.nl
parents:
diff
changeset
|
7 import unittest |
85fd05d0d16c
New tool to Query multiple public repositories for elemental compositions
pieter.lukasse@wur.nl
parents:
diff
changeset
|
8 |
85fd05d0d16c
New tool to Query multiple public repositories for elemental compositions
pieter.lukasse@wur.nl
parents:
diff
changeset
|
9 |
85fd05d0d16c
New tool to Query multiple public repositories for elemental compositions
pieter.lukasse@wur.nl
parents:
diff
changeset
|
10 class IntegrationTest(unittest.TestCase): |
85fd05d0d16c
New tool to Query multiple public repositories for elemental compositions
pieter.lukasse@wur.nl
parents:
diff
changeset
|
11 |
85fd05d0d16c
New tool to Query multiple public repositories for elemental compositions
pieter.lukasse@wur.nl
parents:
diff
changeset
|
12 |
85fd05d0d16c
New tool to Query multiple public repositories for elemental compositions
pieter.lukasse@wur.nl
parents:
diff
changeset
|
13 |
85fd05d0d16c
New tool to Query multiple public repositories for elemental compositions
pieter.lukasse@wur.nl
parents:
diff
changeset
|
14 |
85fd05d0d16c
New tool to Query multiple public repositories for elemental compositions
pieter.lukasse@wur.nl
parents:
diff
changeset
|
15 def test_simple(self): |
85fd05d0d16c
New tool to Query multiple public repositories for elemental compositions
pieter.lukasse@wur.nl
parents:
diff
changeset
|
16 ''' |
85fd05d0d16c
New tool to Query multiple public repositories for elemental compositions
pieter.lukasse@wur.nl
parents:
diff
changeset
|
17 Simple initial test |
85fd05d0d16c
New tool to Query multiple public repositories for elemental compositions
pieter.lukasse@wur.nl
parents:
diff
changeset
|
18 ''' |
85fd05d0d16c
New tool to Query multiple public repositories for elemental compositions
pieter.lukasse@wur.nl
parents:
diff
changeset
|
19 # Create out folder |
85fd05d0d16c
New tool to Query multiple public repositories for elemental compositions
pieter.lukasse@wur.nl
parents:
diff
changeset
|
20 outdir = "output/query_mass_repos/" |
85fd05d0d16c
New tool to Query multiple public repositories for elemental compositions
pieter.lukasse@wur.nl
parents:
diff
changeset
|
21 if not os.path.exists(outdir): |
85fd05d0d16c
New tool to Query multiple public repositories for elemental compositions
pieter.lukasse@wur.nl
parents:
diff
changeset
|
22 os.makedirs(outdir) |
85fd05d0d16c
New tool to Query multiple public repositories for elemental compositions
pieter.lukasse@wur.nl
parents:
diff
changeset
|
23 |
85fd05d0d16c
New tool to Query multiple public repositories for elemental compositions
pieter.lukasse@wur.nl
parents:
diff
changeset
|
24 #Build up arguments and run |
85fd05d0d16c
New tool to Query multiple public repositories for elemental compositions
pieter.lukasse@wur.nl
parents:
diff
changeset
|
25 |
85fd05d0d16c
New tool to Query multiple public repositories for elemental compositions
pieter.lukasse@wur.nl
parents:
diff
changeset
|
26 # input_file = sys.argv[1] |
85fd05d0d16c
New tool to Query multiple public repositories for elemental compositions
pieter.lukasse@wur.nl
parents:
diff
changeset
|
27 # molecular_mass_col = sys.argv[2] |
85fd05d0d16c
New tool to Query multiple public repositories for elemental compositions
pieter.lukasse@wur.nl
parents:
diff
changeset
|
28 # repository_file = sys.argv[3] |
85fd05d0d16c
New tool to Query multiple public repositories for elemental compositions
pieter.lukasse@wur.nl
parents:
diff
changeset
|
29 # mass_tolerance = float(sys.argv[4]) |
85fd05d0d16c
New tool to Query multiple public repositories for elemental compositions
pieter.lukasse@wur.nl
parents:
diff
changeset
|
30 # output_result = sys.argv[5] |
85fd05d0d16c
New tool to Query multiple public repositories for elemental compositions
pieter.lukasse@wur.nl
parents:
diff
changeset
|
31 |
85fd05d0d16c
New tool to Query multiple public repositories for elemental compositions
pieter.lukasse@wur.nl
parents:
diff
changeset
|
32 input_file = resource_filename(__name__, "data/service_query_tabular.txt") |
85fd05d0d16c
New tool to Query multiple public repositories for elemental compositions
pieter.lukasse@wur.nl
parents:
diff
changeset
|
33 |
26
637830ac8bcd
added validation in metexp to tabular tool; added workaround/fix for L and D compound types
pieter.lukasse@wur.nl
parents:
23
diff
changeset
|
34 molecular_mass_col = "mass (Da)" |
23
85fd05d0d16c
New tool to Query multiple public repositories for elemental compositions
pieter.lukasse@wur.nl
parents:
diff
changeset
|
35 dblink_file = resource_filename(__name__, "data/MFSearcher ExactMassDB service.txt") |
85fd05d0d16c
New tool to Query multiple public repositories for elemental compositions
pieter.lukasse@wur.nl
parents:
diff
changeset
|
36 output_result = resource_filename(__name__, outdir + "metexp_query_results_added.txt") |
85fd05d0d16c
New tool to Query multiple public repositories for elemental compositions
pieter.lukasse@wur.nl
parents:
diff
changeset
|
37 |
85fd05d0d16c
New tool to Query multiple public repositories for elemental compositions
pieter.lukasse@wur.nl
parents:
diff
changeset
|
38 |
85fd05d0d16c
New tool to Query multiple public repositories for elemental compositions
pieter.lukasse@wur.nl
parents:
diff
changeset
|
39 |
85fd05d0d16c
New tool to Query multiple public repositories for elemental compositions
pieter.lukasse@wur.nl
parents:
diff
changeset
|
40 |
85fd05d0d16c
New tool to Query multiple public repositories for elemental compositions
pieter.lukasse@wur.nl
parents:
diff
changeset
|
41 sys.argv = ['test', |
85fd05d0d16c
New tool to Query multiple public repositories for elemental compositions
pieter.lukasse@wur.nl
parents:
diff
changeset
|
42 input_file, |
85fd05d0d16c
New tool to Query multiple public repositories for elemental compositions
pieter.lukasse@wur.nl
parents:
diff
changeset
|
43 molecular_mass_col, |
85fd05d0d16c
New tool to Query multiple public repositories for elemental compositions
pieter.lukasse@wur.nl
parents:
diff
changeset
|
44 dblink_file, |
85fd05d0d16c
New tool to Query multiple public repositories for elemental compositions
pieter.lukasse@wur.nl
parents:
diff
changeset
|
45 '0.001', |
85fd05d0d16c
New tool to Query multiple public repositories for elemental compositions
pieter.lukasse@wur.nl
parents:
diff
changeset
|
46 'ms', |
85fd05d0d16c
New tool to Query multiple public repositories for elemental compositions
pieter.lukasse@wur.nl
parents:
diff
changeset
|
47 output_result] |
85fd05d0d16c
New tool to Query multiple public repositories for elemental compositions
pieter.lukasse@wur.nl
parents:
diff
changeset
|
48 |
85fd05d0d16c
New tool to Query multiple public repositories for elemental compositions
pieter.lukasse@wur.nl
parents:
diff
changeset
|
49 # Execute main function with arguments provided through sys.argv |
85fd05d0d16c
New tool to Query multiple public repositories for elemental compositions
pieter.lukasse@wur.nl
parents:
diff
changeset
|
50 query_mass_repos.main() |
85fd05d0d16c
New tool to Query multiple public repositories for elemental compositions
pieter.lukasse@wur.nl
parents:
diff
changeset
|
51 |
85fd05d0d16c
New tool to Query multiple public repositories for elemental compositions
pieter.lukasse@wur.nl
parents:
diff
changeset
|
52 |
85fd05d0d16c
New tool to Query multiple public repositories for elemental compositions
pieter.lukasse@wur.nl
parents:
diff
changeset
|
53 |
85fd05d0d16c
New tool to Query multiple public repositories for elemental compositions
pieter.lukasse@wur.nl
parents:
diff
changeset
|
54 |
85fd05d0d16c
New tool to Query multiple public repositories for elemental compositions
pieter.lukasse@wur.nl
parents:
diff
changeset
|
55 |
85fd05d0d16c
New tool to Query multiple public repositories for elemental compositions
pieter.lukasse@wur.nl
parents:
diff
changeset
|
56 def _read_file(filename): |
85fd05d0d16c
New tool to Query multiple public repositories for elemental compositions
pieter.lukasse@wur.nl
parents:
diff
changeset
|
57 ''' |
85fd05d0d16c
New tool to Query multiple public repositories for elemental compositions
pieter.lukasse@wur.nl
parents:
diff
changeset
|
58 Helper method to quickly read a file |
85fd05d0d16c
New tool to Query multiple public repositories for elemental compositions
pieter.lukasse@wur.nl
parents:
diff
changeset
|
59 @param filename: |
85fd05d0d16c
New tool to Query multiple public repositories for elemental compositions
pieter.lukasse@wur.nl
parents:
diff
changeset
|
60 ''' |
85fd05d0d16c
New tool to Query multiple public repositories for elemental compositions
pieter.lukasse@wur.nl
parents:
diff
changeset
|
61 with open(filename) as handle: |
85fd05d0d16c
New tool to Query multiple public repositories for elemental compositions
pieter.lukasse@wur.nl
parents:
diff
changeset
|
62 return handle.read() |