-
Notifications
You must be signed in to change notification settings - Fork 11
/
deepnovo_main.py
93 lines (82 loc) · 3.34 KB
/
deepnovo_main.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
# Copyright 2017 Hieu Tran. All Rights Reserved.
#
# DeepNovo is publicly available for non-commercial uses.
# ==============================================================================
"""TODO(nh2tran): docstring."""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import os
#export pbr version for tensorflow to build with pyinstaller
os.environ["PBR_VERSION"]='3.1.0'
import tensorflow as tf
import deepnovo_config
import deepnovo_model
import deepnovo_worker_db
import deepnovo_worker_denovo
import deepnovo_worker_io
import deepnovo_worker_test
import deepnovo_main_modules
def main(_):
"""TODO(nh2tran): docstring."""
print("main()")
if deepnovo_config.FLAGS.knapsack_build:
deepnovo_main_modules.knapsack_build()
elif deepnovo_config.FLAGS.train:
deepnovo_main_modules.train()
elif deepnovo_config.FLAGS.test_true_feeding:
deepnovo_main_modules.test_true_feeding()
elif deepnovo_config.FLAGS.decode:
deepnovo_main_modules.decode()
elif deepnovo_config.FLAGS.search_denovo:
model = deepnovo_model.ModelInference()
model.build_model()
worker_io = deepnovo_worker_io.WorkerIO(
input_spectrum_file=deepnovo_config.denovo_input_spectrum_file,
input_feature_file=deepnovo_config.denovo_input_feature_file,
output_file=deepnovo_config.denovo_output_file)
worker_denovo = deepnovo_worker_denovo.WorkerDenovo()
worker_denovo.search_denovo(model, worker_io)
elif deepnovo_config.FLAGS.search_db:
model = deepnovo_model.ModelInference()
model.build_model()
worker_io = deepnovo_worker_io.WorkerIO(
input_spectrum_file=deepnovo_config.db_input_spectrum_file,
input_feature_file=deepnovo_config.db_input_feature_file,
output_file=deepnovo_config.db_output_file)
worker_db = deepnovo_worker_db.WorkerDB(
db_fasta_file=deepnovo_config.db_fasta_file)
worker_db.build_db()
worker_db.search_db(model, worker_io)
elif deepnovo_config.FLAGS.search_hybrid:
model = deepnovo_model.ModelInference()
model.build_model()
# denovo search
worker_io = deepnovo_worker_io.WorkerIO(
input_spectrum_file=deepnovo_config.hybrid_input_spectrum_file,
input_feature_file=deepnovo_config.hybrid_input_feature_file,
output_file=deepnovo_config.hybrid_denovo_file)
worker_denovo = deepnovo_worker_denovo.WorkerDenovo()
predicted_denovo_list = worker_denovo.search_denovo(model, worker_io)
# db search with predicted_denovo_list
worker_io = deepnovo_worker_io.WorkerIO(
input_spectrum_file=deepnovo_config.hybrid_input_spectrum_file,
input_feature_file=deepnovo_config.hybrid_input_feature_file,
output_file=deepnovo_config.hybrid_output_file)
worker_db = deepnovo_worker_db.WorkerDB(
db_fasta_file=deepnovo_config.hybrid_fasta_file)
worker_db.build_db()
worker_db.search_db(model, worker_io, predicted_denovo_list)
elif deepnovo_config.FLAGS.test:
# test 1%FDR
#~ worker_db = deepnovo_worker_db.WorkerDB()
#~ worker_db.build_db()
#~ worker_test = deepnovo_worker_test.WorkerTest()
#~ worker_test.test_accuracy(worker_db.peptide_list)
worker_test = deepnovo_worker_test.WorkerTest()
worker_test.test_accuracy()
else:
print("ERROR: wrong option!")
sys.exit()
if __name__ == "__main__":
tf.app.run()