annotate tests/run-tests.py @ 6:df3b28364cd2

allele-counts.{py,xml}: Add strand bias, documentation updates.
author nicksto <nmapsy@gmail.com>
date Wed, 09 Dec 2015 11:20:51 -0500
parents 31361191d2d2
children 411adeff1eec
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5
31361191d2d2 Uploaded tarball.
nick
parents:
diff changeset
1 #!/usr/bin/env python
31361191d2d2 Uploaded tarball.
nick
parents:
diff changeset
2 import os
31361191d2d2 Uploaded tarball.
nick
parents:
diff changeset
3 import sys
31361191d2d2 Uploaded tarball.
nick
parents:
diff changeset
4 import subprocess
31361191d2d2 Uploaded tarball.
nick
parents:
diff changeset
5
31361191d2d2 Uploaded tarball.
nick
parents:
diff changeset
6 DATASETS = [
31361191d2d2 Uploaded tarball.
nick
parents:
diff changeset
7 'artificial',
31361191d2d2 Uploaded tarball.
nick
parents:
diff changeset
8 'artificial-samples',
31361191d2d2 Uploaded tarball.
nick
parents:
diff changeset
9 'artificial-nofilt',
31361191d2d2 Uploaded tarball.
nick
parents:
diff changeset
10 'real',
31361191d2d2 Uploaded tarball.
nick
parents:
diff changeset
11 'real-mit',
31361191d2d2 Uploaded tarball.
nick
parents:
diff changeset
12 'real-mit-s',
31361191d2d2 Uploaded tarball.
nick
parents:
diff changeset
13 'real-nofilt',
31361191d2d2 Uploaded tarball.
nick
parents:
diff changeset
14 ]
31361191d2d2 Uploaded tarball.
nick
parents:
diff changeset
15 IN_EXT = '.vcf.in'
31361191d2d2 Uploaded tarball.
nick
parents:
diff changeset
16 OUT_EXT = '.csv.out'
31361191d2d2 Uploaded tarball.
nick
parents:
diff changeset
17 ARGS_KEY = '##comment="ARGS='
31361191d2d2 Uploaded tarball.
nick
parents:
diff changeset
18
31361191d2d2 Uploaded tarball.
nick
parents:
diff changeset
19 def main():
31361191d2d2 Uploaded tarball.
nick
parents:
diff changeset
20
31361191d2d2 Uploaded tarball.
nick
parents:
diff changeset
21 test_dir = os.path.dirname(os.path.relpath(sys.argv[0]))
31361191d2d2 Uploaded tarball.
nick
parents:
diff changeset
22 if test_dir:
31361191d2d2 Uploaded tarball.
nick
parents:
diff changeset
23 test_dir += os.sep
31361191d2d2 Uploaded tarball.
nick
parents:
diff changeset
24
31361191d2d2 Uploaded tarball.
nick
parents:
diff changeset
25 for dataset in DATASETS:
31361191d2d2 Uploaded tarball.
nick
parents:
diff changeset
26 infile = test_dir+dataset+IN_EXT
31361191d2d2 Uploaded tarball.
nick
parents:
diff changeset
27 outfile = test_dir+dataset+OUT_EXT
31361191d2d2 Uploaded tarball.
nick
parents:
diff changeset
28
31361191d2d2 Uploaded tarball.
nick
parents:
diff changeset
29 if not os.path.exists(infile):
31361191d2d2 Uploaded tarball.
nick
parents:
diff changeset
30 sys.stderr.write("Error: file not found: "+infile+"\n")
31361191d2d2 Uploaded tarball.
nick
parents:
diff changeset
31 continue
31361191d2d2 Uploaded tarball.
nick
parents:
diff changeset
32 if not os.path.exists(outfile):
31361191d2d2 Uploaded tarball.
nick
parents:
diff changeset
33 sys.stderr.write("Error: file not found: "+outfile+"\n")
31361191d2d2 Uploaded tarball.
nick
parents:
diff changeset
34 continue
31361191d2d2 Uploaded tarball.
nick
parents:
diff changeset
35
31361191d2d2 Uploaded tarball.
nick
parents:
diff changeset
36 options = read_options(infile)
31361191d2d2 Uploaded tarball.
nick
parents:
diff changeset
37 script_cmd = 'allele-counts.py '+options+' -i '+infile
31361191d2d2 Uploaded tarball.
nick
parents:
diff changeset
38 bash_cmd = 'diff '+outfile+' <('+script_cmd+')'
31361191d2d2 Uploaded tarball.
nick
parents:
diff changeset
39 # print infile+":"
31361191d2d2 Uploaded tarball.
nick
parents:
diff changeset
40 print script_cmd
31361191d2d2 Uploaded tarball.
nick
parents:
diff changeset
41 subprocess.call(['bash', '-c', bash_cmd])
31361191d2d2 Uploaded tarball.
nick
parents:
diff changeset
42
31361191d2d2 Uploaded tarball.
nick
parents:
diff changeset
43
31361191d2d2 Uploaded tarball.
nick
parents:
diff changeset
44 def read_options(infile):
31361191d2d2 Uploaded tarball.
nick
parents:
diff changeset
45 with open(infile, 'r') as infilehandle:
31361191d2d2 Uploaded tarball.
nick
parents:
diff changeset
46 for line in infilehandle:
31361191d2d2 Uploaded tarball.
nick
parents:
diff changeset
47 line.strip()
31361191d2d2 Uploaded tarball.
nick
parents:
diff changeset
48 if ARGS_KEY == line[:len(ARGS_KEY)]:
31361191d2d2 Uploaded tarball.
nick
parents:
diff changeset
49 return line[len(ARGS_KEY):-2]
31361191d2d2 Uploaded tarball.
nick
parents:
diff changeset
50 return ''
31361191d2d2 Uploaded tarball.
nick
parents:
diff changeset
51
31361191d2d2 Uploaded tarball.
nick
parents:
diff changeset
52
31361191d2d2 Uploaded tarball.
nick
parents:
diff changeset
53 if __name__ == '__main__':
31361191d2d2 Uploaded tarball.
nick
parents:
diff changeset
54 main()