-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathmerge-stoptags.py
executable file
·66 lines (50 loc) · 1.58 KB
/
merge-stoptags.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
#!/usr/bin/env python
#
"""
Merge lump stop tags.
% python scripts/merge-stoptags.py <base>
"""
import argparse
import khmer
from khmer import Nodegraph
from khmer.khmer_args import info
from khmer.kfile import check_input_files, check_space
import textwrap
import os
import sys
import glob
DEFAULT_K = 32
def get_parser():
epilog = """
Merge all lump.stoptags generated by find-knots.py
"""
parser = argparse.ArgumentParser(
description="Merge all lump.stoptags",
epilog=textwrap.dedent(epilog),
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument('--ksize', '-k', default=DEFAULT_K, type=int,
help='k-mer size')
parser.add_argument('stdbase', help='Basename for the input directories')
parser.add_argument('--version', action='version', version='%(prog)s ' +
khmer.__version__)
return parser
def main():
info('merge-stoptags.py')
args = get_parser().parse_args()
stdbase = args.stdbase
# @RamRS: This might need some more work
infiles = []
for _ in glob.glob(stdbase + "*/*.stoptags") :
if os.path.exists(_):
check_input_files(_, False)
infiles.append(_)
check_space(infiles, False)
ht = Nodegraph(args.ksize, 1, 1)
for _ in infiles:
print('loading stoptags ', _, file=sys.stderr)
ht.load_stop_tags(_, 0)
print('writing file merge.stoptags, with K', args.ksize, file=sys.stderr)
ht.save_stop_tags('merge.stoptags')
print('done!', file=sys.stderr)
if __name__ == '__main__':
main()