-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbuild_database.py
66 lines (35 loc) · 1.43 KB
/
build_database.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
import sys
import getopt
import os
from GeneralClasses.Context import DatabaseBuildingContext
from DatabaseClasses.IndexBuilder import IndexBuilder
from DatabaseClasses.TaxonomyBuilder import TaxonomyBuilder
# takes the folder to process as positional arg
def main(argv):
opts, args = getopt.getopt(argv, "hd:t:p:", ["taxonomy-only", "database-only", "rebuild", "map-pb"])
context = DatabaseBuildingContext(opts)
check_existing_build(context)
for opt, arg in opts:
if opt == '--taxonomy-only':
build_taxonomy(context)
sys.exit()
elif opt == '--database-only':
build_minimap2_index(context)
sys.exit()
build_taxonomy(context)
build_minimap2_index(context)
print('\nfinished database build.')
def check_existing_build(context):
path = context.database_path
if os.path.exists(path + 'taxonomy/accessions_genomes.json') or os.path.exists(path + 'database.mmi'):
if context.rebuild is False:
print('database has already been built. If you wish to override, give the "--rebuild" option to this program')
sys.exit()
def build_minimap2_index(context):
ib = IndexBuilder(context)
ib.build()
def build_taxonomy(context):
tb = TaxonomyBuilder(context)
tb.build()
if __name__ == '__main__':
main(sys.argv[1:])