forked from dib-lab/khmer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathannotate-partitions.py
executable file
·45 lines (31 loc) · 1.17 KB
/
annotate-partitions.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
#! /usr/bin/env python
"""
Annotate sequences with partition numbers.
% python scripts/annotate-partitions.py <pmap_file> <file1> [ <file2> ... ]
Partition-annotated sequences will be in <fileN>.part.
Use '-h' for parameter help.
"""
import os
import argparse
import khmer
DEFAULT_K=32
def main():
parser = argparse.ArgumentParser(description="Annotate seqs with partitions.")
parser.add_argument('--ksize', '-k', type=int, default=DEFAULT_K,
help="k-mer size (default: %d)" % DEFAULT_K)
parser.add_argument('graphbase')
parser.add_argument('input_filenames', nargs='+')
args = parser.parse_args()
K = args.ksize
ht = khmer.new_hashbits(K, 1, 1)
partitionmap_file = args.graphbase + '.pmap.merged'
print 'loading partition map from:', partitionmap_file
ht.load_partitionmap(partitionmap_file)
for infile in args.input_filenames:
print 'outputting partitions for', infile
outfile = os.path.basename(infile) + '.part'
n = ht.output_partitions(infile, outfile)
print 'output %d partitions for %s' % (n, infile)
print 'partitions are in', outfile
if __name__ == '__main__':
main()