Mercurial > repos > nick > allele_counts
comparison tests/run-tests.py @ 5:31361191d2d2
Uploaded tarball.
Version 1.1: Stranded output, slightly different handling of minor allele ties and 0 coverage sites, revised help text, added test datasets.
author | nick |
---|---|
date | Thu, 12 Sep 2013 11:34:23 -0400 |
parents | |
children | 411adeff1eec |
comparison
equal
deleted
inserted
replaced
4:898eb3daab43 | 5:31361191d2d2 |
---|---|
1 #!/usr/bin/env python | |
2 import os | |
3 import sys | |
4 import subprocess | |
5 | |
6 DATASETS = [ | |
7 'artificial', | |
8 'artificial-samples', | |
9 'artificial-nofilt', | |
10 'real', | |
11 'real-mit', | |
12 'real-mit-s', | |
13 'real-nofilt', | |
14 ] | |
15 IN_EXT = '.vcf.in' | |
16 OUT_EXT = '.csv.out' | |
17 ARGS_KEY = '##comment="ARGS=' | |
18 | |
19 def main(): | |
20 | |
21 test_dir = os.path.dirname(os.path.relpath(sys.argv[0])) | |
22 if test_dir: | |
23 test_dir += os.sep | |
24 | |
25 for dataset in DATASETS: | |
26 infile = test_dir+dataset+IN_EXT | |
27 outfile = test_dir+dataset+OUT_EXT | |
28 | |
29 if not os.path.exists(infile): | |
30 sys.stderr.write("Error: file not found: "+infile+"\n") | |
31 continue | |
32 if not os.path.exists(outfile): | |
33 sys.stderr.write("Error: file not found: "+outfile+"\n") | |
34 continue | |
35 | |
36 options = read_options(infile) | |
37 script_cmd = 'allele-counts.py '+options+' -i '+infile | |
38 bash_cmd = 'diff '+outfile+' <('+script_cmd+')' | |
39 # print infile+":" | |
40 print script_cmd | |
41 subprocess.call(['bash', '-c', bash_cmd]) | |
42 | |
43 | |
44 def read_options(infile): | |
45 with open(infile, 'r') as infilehandle: | |
46 for line in infilehandle: | |
47 line.strip() | |
48 if ARGS_KEY == line[:len(ARGS_KEY)]: | |
49 return line[len(ARGS_KEY):-2] | |
50 return '' | |
51 | |
52 | |
53 if __name__ == '__main__': | |
54 main() |