-
Notifications
You must be signed in to change notification settings - Fork 295
/
reassemble-contigs.py
executable file
·50 lines (39 loc) · 1.28 KB
/
reassemble-contigs.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
#! /usr/bin/env python
import argparse
import screed
import khmer
K = 31
def main():
p = argparse.ArgumentParser()
p.add_argument('contig_files', nargs='+')
args = p.parse_args()
ng = khmer.Nodegraph(K, 1e8, 4)
starts = []
for filename in args.contig_files:
for n, record in enumerate(screed.open(filename)):
if n and n % 10000 == 0:
print('...', n)
ng.consume(record.sequence)
starts.append(record.sequence[:K])
hdn = khmer.HashSet(K)
for filename in args.contig_files:
for n, record in enumerate(screed.open(filename)):
if n and n % 10000 == 0:
print('...', n)
hdn += ng.find_high_degree_nodes(record.sequence)
lh = khmer._GraphLabels(ng)
for filename in args.contig_files:
for n, record in enumerate(screed.open(filename)):
if n and n % 10000 == 0:
print('...', n)
lh.label_across_high_degree_nodes(record.sequence, hdn, n)
counter = 0
for k in starts:
contigs = lh.assemble_labeled_path(k)
if not contigs:
print('nada...')
for c in contigs:
print('>%d\n%s' % (counter, c))
counter += 1
if __name__ == '__main__':
main()