Mercurial > repos > nick > allele_counts_1
comparison tests/run-tests.py @ 10:db6f217dc45a
Uploaded tarball.
Version 1.1.
- Added stranded output.
- Added, tested no-filter mode.
- now prints all sites.
- Changed handling of minor allele ties.
- Added test datasets.
- Revised help text.
| author | nick |
|---|---|
| date | Fri, 06 Sep 2013 20:37:07 -0400 |
| parents | |
| children | 566e42c97532 |
comparison
equal
deleted
inserted
replaced
| 9:eca1ea054d0d | 10:db6f217dc45a |
|---|---|
| 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() |
