1 '''small run test cases'''
4 from __future__
import with_statement
11 from nose
.tools
import *
13 from greylag_grind
import *
16 # parallel job processes
20 GREYLAG_PROGRAM
= '../greylag_grind.py'
21 GREYLAGMP_PROGRAM
= '../greylag.py'
23 # temporary output file
24 GREYLAG_OUTPUT
= 'tmp-greylag-out.xml'
26 # cd to the test directory, but restore when we're done
27 SAVE_CWD
= os
.getcwd()
29 if os
.path
.exists(GREYLAG_OUTPUT
):
30 os
.remove(GREYLAG_OUTPUT
)
33 if os
.path
.exists(GREYLAG_OUTPUT
):
34 os
.remove(GREYLAG_OUTPUT
)
39 "Run greylag in a subprocess, checking for error return."
40 subprocess
.check_call(("%s -q -o %s %s"
41 % (GREYLAG_PROGRAM
, GREYLAG_OUTPUT
, args
)).split())
44 "Run greylag in multiple subprocesses, checking for error return."
45 subprocess
.check_call(("%s %s -q -o %s %s"
46 % (GREYLAGMP_PROGRAM
, CPUS
, GREYLAG_OUTPUT
,
49 def run_combination(combination
=None):
50 """Run a greylag test, as specified by combination.
52 If combination is not given, it defaults to the name of the calling
55 For a combination 'greylag_params_0__test_2_test', greylag will be run
56 with a parameter file 'greylag-params-0.xml' and spectrum file
57 'test-2.ms2'. (Additional spectrum files can be specified, separated by
58 '__'.) The results will be compared to 'greylag-params-0--test-2-ok.xml'.
59 If this baseline file is not present and the environment variable
60 NOSEUPDATE is set, a new baseline will be created.
62 Normally the test will only be done using greylag-mp.py, to speed things
63 up. If single_cpu is True, a single greylag.py process is used. The
64 results should be identical.
66 if combination
== None:
68 combination
= inspect
.getouterframes(inspect
.currentframe())[1][3]
69 assert combination
.endswith('_test')
70 combination
= combination
.rpartition('_test')[0]
72 if combination
.endswith('_mp'):
74 combination
= combination
.rpartition('_mp')[0]
75 parts
= combination
.split('__')
76 params
, spectra
= parts
[0], parts
[1:]
77 assert len(spectra
) >= 1
78 params
= params
.replace('_', '-') + '.xml'
79 spectra
= [ sp
.replace('_', '-') + '.ms2' for sp
in spectra
]
80 ok_fn
= combination
.replace('_', '-') + '-ok.xml'
81 assert os
.path
.exists(ok_fn
) or 'NOSEUPDATE' in os
.environ
, 'no baseline'
83 run(params
+ ' ' + ' '.join(spectra
))
84 if os
.path
.exists(ok_fn
):
85 assert filecmp
.cmp(GREYLAG_OUTPUT
, ok_fn
), 'output differs'
87 os
.rename(GREYLAG_OUTPUT
, ok_fn
)
88 # also do it for --quirks?
91 # Could do xtandem and rough compare to quirks? Is this worth doing, since we
92 # can expect at least small differences? Probably we should have a separate
93 # framework for comparing and contrasting output from any two of { greylag,
98 class modless_run_tests
:
99 def greylag_params_0__test_2_test(self
):
101 def greylag_params_0__test_2_mp_test(self
):
103 def greylag_params_0__6323840_test(self
):
105 def greylag_params_0__6323840_mp_test(self
):
108 def greylag_params_yeast_0__test_2_test(self
):
110 def greylag_params_yeast_0__test_2_mp_test(self
):