-
Notifications
You must be signed in to change notification settings - Fork 1
/
mk_test_files.py
executable file
·103 lines (71 loc) · 2.67 KB
/
mk_test_files.py
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
95
96
97
98
99
100
101
102
103
#!/usr/bin/env python3
"""
Author : Ken Youens-Clark <kyclark@gmail.com>
Date : 2024-12-10
Purpose: Recreate test files
"""
import argparse
import sys
from functools import partial
from subprocess import getstatusoutput
from typing import NamedTuple
SUFR = "./target/release/sufr"
SEQ1 = "data/inputs/1.fa"
SEQ2 = "data/inputs/2.fa"
SEQ3 = "data/inputs/3.fa"
UNIPROT = "data/inputs/uniprot.fa"
LONG = "data/inputs/long_dna_sequence.fa"
ABBA = "data/inputs/abba.fa"
OUTDIR = "./data/expected"
class Args(NamedTuple):
""" Command-line arguments """
build: bool
verbose: bool
# --------------------------------------------------
def get_args() -> Args:
""" Get command-line arguments """
parser = argparse.ArgumentParser(
description='Recreate test files',
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument('-b',
'--build',
help='Build release',
action='store_true')
parser.add_argument('-v',
'--verbose',
help='Verbose',
action='store_true')
args = parser.parse_args()
return Args(build=args.build, verbose=args.verbose)
# --------------------------------------------------
def main() -> None:
""" Make a jazz noise here """
args = get_args()
runner = partial(run, args.verbose)
if args.build:
runner("cargo build --release")
runner(f'{SUFR} create --dna -o {OUTDIR}/1.sufr {SEQ1}')
runner(f'{SUFR} create --dna -o {OUTDIR}/2.sufr {SEQ2}')
runner(f'{SUFR} create --dna -o {OUTDIR}/3.sufr {SEQ3}')
runner(f'{SUFR} create --dna --sequence-delimiter N '
f'-o {OUTDIR}/2d.sufr {SEQ2}')
runner(f'{SUFR} create -o {OUTDIR}/abba.sufr {ABBA}')
runner(f'{SUFR} create --dna --allow-ambiguity -o {OUTDIR}/1n.sufr {SEQ1}')
runner(f'{SUFR} create --dna --allow-ambiguity -o {OUTDIR}/2n.sufr {SEQ2}')
runner(f'{SUFR} create --dna --ignore-softmask -o {OUTDIR}/2s.sufr {SEQ2}')
runner(f'{SUFR} create --dna --allow-ambiguity --ignore-softmask '
f'-o {OUTDIR}/2ns.sufr {SEQ2}')
runner(f'{SUFR} create --dna -o {OUTDIR}/long_dna_sequence.sufr {LONG}')
runner(f'{SUFR} create -o {OUTDIR}/uniprot.sufr {UNIPROT}')
runner(f'{SUFR} create -s 10111011 -o {OUTDIR}/uniprot-masked.sufr {UNIPROT}')
# --------------------------------------------------
def run(verbose: bool, cmd: str):
""" Run command """
if verbose:
print(cmd)
rv, out = getstatusoutput(cmd)
if rv != 0:
sys.exit(out)
# --------------------------------------------------
if __name__ == '__main__':
main()