-
Notifications
You must be signed in to change notification settings - Fork 2
/
get_tss_pwm.py
69 lines (60 loc) · 1.77 KB
/
get_tss_pwm.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
#!/usr/bin/env python3
"""
This script calculates TSS position weight matrices from a fit clipnet.py model.
"""
import argparse
import logging
import os
import joblib
import seqlogo
os.environ["TF_CPP_MIN_LOG_LEVEL"] = "4"
logging.getLogger("tensorflow").setLevel(logging.FATAL)
import clipnet
def main():
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument(
"fasta_fp",
type=str,
default=None,
help="If pyfastx throws an error, try deleting .fxi index files.",
)
parser.add_argument(
"output",
type=str,
help="where should the output be written? Will export a joblib.gz file.",
)
parser.add_argument(
"--model_dir",
type=str,
default="ensemble_models/",
help="directory where to load models from.",
)
parser.add_argument(
"--img_output",
type=str,
help="where should the output seqlogo image be written?",
)
parser.add_argument(
"--window",
type=int,
default=8,
help="how wide of a window around tss to select.",
)
parser.add_argument(
"--gpu",
type=int,
default=None,
help="Index of GPU to use (starting at 0). If None, will use CPU.",
)
args = parser.parse_args()
if args.gpu is not None:
nn = clipnet.CLIPNET(n_gpus=1, use_specific_gpu=args.gpu)
else:
nn = clipnet.CLIPNET(n_gpus=0)
tss = nn.compute_tss_pwm(args.model_dir, args.fasta_fp, window=args.window)
joblib.dump(tss, args.output)
if args.img_output is not None:
file_ext = os.path.splitext(args.img_output)[-1].strip(".")
seqlogo.seqlogo(tss, format=file_ext, filename=args.img_output, size="medium")
if __name__ == "__main__":
main()