forked from jgurtowski/ectools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
alignment_verify.py
32 lines (23 loc) · 872 Bytes
/
alignment_verify.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
#!/usr/bin/env python
import sys
from nucio import getNucmerAlignmentIterator, nucRecordToString
from itertools import groupby
from operator import attrgetter
#dist from the end
#that is considered in the middle
END_CUTOFF = 200
if not len(sys.argv) == 2:
sys.exit("alignment_verify.py alignments.sc")
fh = open(sys.argv[1])
for pbname, alignments in groupby(getNucmerAlignmentIterator(fh), attrgetter("sname")):
al = list(alignments)
##if all alignments are to the same unitig
if all(map(lambda x: x.qname == al[0].qname , al)):
continue
for aln in al:
if (aln.qstart > END_CUTOFF and aln.qstart < (aln.qlen-END_CUTOFF)
and aln.qend > END_CUTOFF and aln.qend < (aln.qlen-END_CUTOFF)):
print nucRecordToString(aln)+"\tMIDDLE"
else:
print nucRecordToString(aln)
fh.close()