-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathtest_installation.py
More file actions
executable file
·103 lines (75 loc) · 3.12 KB
/
test_installation.py
File metadata and controls
executable file
·103 lines (75 loc) · 3.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#!/usr/bin/env python
"""
Last updated: 15.06.2016
"""
from subprocess import call
import os
import sys
import shutil
import filecmp
import os.path
def isReferenceAdded(scriptdir):
for line in open(scriptdir + '/config.txt'):
line = line.strip()
if line == '': continue
if line.startswith('#'): continue
if not '=' in line: continue
[key, value] = line.split('=')
key = key.strip()
value = value.strip()
if key == 'REFERENCE' and value not in ['','.']: return True
return False
def compareVCF(vcf_x, vcf_y):
content_x = []
content_y = []
for line in open(vcf_x):
line = line.strip()
if not line.startswith('#'): content_x.append(line)
for line in open(vcf_y):
line = line.strip()
if not line.startswith('#'): content_y.append(line)
return (content_x == content_y)
scriptdir = os.path.dirname(os.path.realpath(__file__))
os.chdir(scriptdir)
if not os.path.isfile(scriptdir + '/config.txt'):
print '\nOpEx not yet installed. Please install it first (See Section 3 in the Documentation).\n'
quit()
if not isReferenceAdded(scriptdir):
print '\nReference genome not yet added to the configuration file. You must have performed Quick or Manual installation.'
print 'Please run Full Installation (see Section 3.2 in the Documentation) or add the reference genome manually (Section 7.4).\n'
quit()
print '\n'+'='*80
sys.stdout.write('Checking OpEx installation ... ')
sys.stdout.flush()
if os.path.isdir('_testinstall'): shutil.rmtree('_testinstall')
FNULL = open(os.devnull, 'w')
call(['mkdir','_testinstall'])
call(['cp','test/test_R1.fastq.gz','_testinstall'])
call(['cp','test/test_R2.fastq.gz','_testinstall'])
call(['cp','test/test.bed','_testinstall'])
os.chdir('_testinstall')
call(['python','../opex.py','-i','test_R1.fastq.gz,test_R2.fastq.gz','-b','test.bed','-o','test'], stdout=FNULL, stderr=FNULL)
os.chdir('..')
outputs = { '_testinstall/test_calls.vcf': 'test/output/test_calls.vcf',
'_testinstall/test_annotated_calls.vcf': 'test/output/test_annotated_calls.vcf',
'_testinstall/test_annotated_calls.txt': 'test/output/test_annotated_calls.txt',
'_testinstall/test_coverview_summary.txt': 'test/output/test_coverview_summary.txt',
'_testinstall/test_coverview_regions.txt': 'test/output/test_coverview_regions.txt',
'_testinstall/test_coverview_profiles.txt': 'test/output/test_coverview_profiles.txt',
'_testinstall/test_coverview_poor.txt': 'test/output/test_coverview_poor.txt' }
for output, expected in outputs.iteritems():
if not os.path.isfile(output) or not os.path.isfile(expected):
print '- Done.'
print 'OpEx is not installed correctly.'
print '='*80+'\n'
quit()
if output.endswith('.vcf'): same = compareVCF(output, expected)
else: same = filecmp.cmp(output, expected)
if not same:
print '- Done.'
print 'OpEx is not installed correctly.'
print '='*80+'\n'
quit()
print '- Done.'
print 'OpEx is correctly installed.'
shutil.rmtree('_testinstall')