| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
import sys |
| 12 |
import os |
| 13 |
import subprocess |
| 14 |
|
| 15 |
if len(sys.argv) != 4: |
| 16 |
sys.exit('usage: esl-shuffle.itest.py <builddir> <srcdir> <tmppfx>') |
| 17 |
|
| 18 |
builddir = sys.argv[1] |
| 19 |
srcdir = sys.argv[2] |
| 20 |
tmppfx = sys.argv[3] |
| 21 |
|
| 22 |
if not os.path.isfile('{0}/miniapps/esl-shuffle'.format(builddir)): |
| 23 |
sys.exit('FAIL: no esl-shuffle program in {0}'.format(builddir)) |
| 24 |
errmsg = 'FAIL: esl-shuffle.itest.py integration test failed' |
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
with open('{0}.sto'.format(tmppfx), 'w') as f: |
| 30 |
print( |
| 31 |
"""# STOCKHOLM 1.0 |
| 32 |
|
| 33 |
seq1 ACDEFGHIKLMNPQRSTVWY |
| 34 |
seq2 ACDEFGHIKLMNPQRSTVWY |
| 35 |
seq3 ACDEFGHIKLMNPQRSTVWY |
| 36 |
seq4 ACDEFGHIKLMNPQRSTVWY |
| 37 |
seq5 ACDEFGHIKLMNPQRSTVWY |
| 38 |
// |
| 39 |
""", end='', file=f) |
| 40 |
|
| 41 |
|
| 42 |
with open('{0}.fa'.format(tmppfx), 'w') as f: |
| 43 |
print( |
| 44 |
""">seq1 |
| 45 |
ACDEFGHIKLMNPQRSTVWY |
| 46 |
>seq2 |
| 47 |
ACACACACACACACACACAC |
| 48 |
>seq3 |
| 49 |
WYWYWYWYWYWYWYWYWYWY |
| 50 |
""", end='', file=f) |
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
try: |
| 58 |
output = subprocess.check_output([ '{}/miniapps/esl-shuffle'.format(builddir), '--seed', '42', '{}.fa'.format(tmppfx) ], |
| 59 |
stderr=subprocess.STDOUT, universal_newlines=True) |
| 60 |
except: |
| 61 |
sys.exit(errmsg) |
| 62 |
|
| 63 |
lines = output.splitlines() |
| 64 |
if len(lines) != 6: sys.exit(errmsg) |
| 65 |
if (lines[0] != '>seq1-shuffled' or |
| 66 |
lines[1] != 'TIGEYHFWCKVSALQNPDRM' or |
| 67 |
lines[2] != '>seq2-shuffled' or |
| 68 |
lines[3] != 'CACAAAACCCACCAACAACC' or |
| 69 |
lines[4] != '>seq3-shuffled' or |
| 70 |
lines[5] != 'WWYYWWYWWYYWYYWYYWYW'): sys.exit(errmsg) |
| 71 |
|
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
try: |
| 76 |
output = subprocess.check_output([ '{}/miniapps/esl-shuffle'.format(builddir), '--seed', '42', '-N', '2', '{}.fa'.format(tmppfx) ], |
| 77 |
stderr=subprocess.STDOUT, universal_newlines=True) |
| 78 |
except: |
| 79 |
sys.exit(errmsg) |
| 80 |
|
| 81 |
lines = output.splitlines() |
| 82 |
if len(lines) != 12: sys.exit(errmsg) |
| 83 |
if (lines[2] != '>seq1-shuffled-1' or |
| 84 |
lines[3] != 'NTEPDRFIQYKLCMWVHAGS'): sys.exit(errmsg); |
| 85 |
|
| 86 |
|
| 87 |
|
| 88 |
try: |
| 89 |
output = subprocess.check_output([ '{}/miniapps/esl-shuffle'.format(builddir), '--seed', '42', '-A', '{}.sto'.format(tmppfx) ], |
| 90 |
stderr=subprocess.STDOUT, universal_newlines=True) |
| 91 |
except: |
| 92 |
sys.exit(errmsg) |
| 93 |
|
| 94 |
lines = output.splitlines() |
| 95 |
if len(lines) != 9: sys.exit(errmsg) |
| 96 |
if (lines[3] != 'seq1 TIGEYHFWCKVSALQNPDRM'): sys.exit(errmsg) |
| 97 |
|
| 98 |
print('ok') |
| 99 |
|
| 100 |
os.remove('{0}.sto'.format(tmppfx)) |
| 101 |
os.remove('{0}.fa'.format(tmppfx)) |
| 102 |
sys.exit(0) |