Commit 07c8d194 authored by MARIJON Pierre's avatar MARIJON Pierre

If no internal switch activate didn't write segment with only internal link. close #6

parent 44b171c4
......@@ -20,10 +20,10 @@ class Parser:
self.__containment = containment
self.__internal = internal
self.__not_all_internal = set()
self.__segments = OrderedDict()
self.__links = dict()
self.__containments = OrderedDict()
self.__first_meet = dict()
@property
def containment(self):
......@@ -72,7 +72,6 @@ class Parser:
maplen = max(l.end_a - l.beg_a, l.end_b - l.beg_b)
logging.debug("name A {} name B {}, beg_A {} beg_B {}".format(l.read_a, l.read_b, l.beg_a, l.beg_b))
internal_match = False
if overhang > maplen*0.8 or overhang > 1000:
# Strange overlap
logging.debug("Internal match between {} {}".format(l.read_a, l.read_b))
......@@ -166,7 +165,10 @@ class Parser:
for seq, length in self.__segments.items():
if not self.containment and seq in self.__containments:
continue
if not self.internal and seq not in self.__not_all_internal:
continue
yield "S\t{}\t*\tLN:i:{}".format(seq, length)
for (read_a, _, read_b, _), link in self.__links.items():
if not self.containment and (read_a in self.__containments or read_b in self.__containments):
......@@ -191,6 +193,9 @@ class Parser:
self.__segments[name] = length
def _add_link(self, name_a, strand_a, name_b, strand_b, ov_len, nb_match, overhang_maplen):
self.__not_all_internal.add(name_a)
self.__not_all_internal.add(name_b)
signature = (name_a, strand_a, name_b, strand_b)
value = (name_a, strand_a, name_b, strand_b, ov_len+"M",
"NM:i:"+str(int(ov_len) - int(nb_match)),
......
......@@ -58,8 +58,6 @@ def test_A_B_internal_match_remove_same():
resu = """
H\tVN:Z:1.0
S\tA\t*\tLN:i:10000
S\tB\t*\tLN:i:10000
"""
p = paf2gfa.Parser(internal=False)
......@@ -79,8 +77,6 @@ def test_A_B_internal_match_remove_diff():
resu = """
H\tVN:Z:1.0
S\tA\t*\tLN:i:10000
S\tB\t*\tLN:i:10000
"""
p = paf2gfa.Parser(internal=False)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment