Commit 2560d6e7 authored by MARIJON Pierre's avatar MARIJON Pierre

New method for compute overhang len

parent 1e1151e6
......@@ -70,7 +70,7 @@ class Parser:
l = Parser.__line_type_correction(l)
overhang = min(l.beg_a, l.beg_b) + min(l.len_a - l.end_a, l.len_b - l.end_b)
overhang = Parser.__compute_overhang(l)
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))
......@@ -220,6 +220,13 @@ class Parser:
return l
@staticmethod
def __compute_overhang(l):
if l.strand == "+":
return min(l.beg_a, l.beg_b) + min(l.len_a - l.end_a, l.len_b - l.end_b)
else:
return min(l.beg_a, l.len_b - l.end_b) + min(l.beg_b, l.len_a - l.end_a)
def main(args):
......
......@@ -5,7 +5,7 @@ import paf2gfa
def test_basic():
line = """
1 10000 2000 10000 - 2 10000 1999 10000 8001 8001 255
1 10000 0 8000 - 5 12000 1 8000 7999 7999 255
1 10000 0 8000 - 5 10000 1 8000 7999 7999 255
2 10000 1 8000 - 3 10000 0 8000 8000 8000 255
3 10000 2000 10000 + 4 10000 0 8000 8000 8000 255
"""
......@@ -13,12 +13,12 @@ def test_basic():
resu = """
S 1 * LN:i:10000
S 2 * LN:i:10000
S 5 * LN:i:12000
S 5 * LN:i:10000
S 3 * LN:i:10000
S 4 * LN:i:10000
L 1 - 2 + 8001M NM:i:0 om:f:0.25
L 5 + 1 - 7999M NM:i:0 om:f:0.25
L 2 + 3 - 8000M NM:i:0 om:f:0.25
L 1 - 2 + 8001M NM:i:0 om:f:0.00
L 5 + 1 - 7999M NM:i:0 om:f:0.00
L 2 + 3 - 8000M NM:i:0 om:f:0.00
L 3 - 4 - 8000M NM:i:0 om:f:0.00
"""
......@@ -30,7 +30,7 @@ L 3 - 4 - 8000M NM:i:0 om:f:0.00
def test_with_2_repetition_strand_diff():
line = """
1 10000 2000 10000 - 2 10000 1999 10000 8001 8001 255
5 12000 1 8000 - 1 10000 0 8000 8000 8000 255
5 10000 1 8000 - 1 10000 0 8000 8000 8000 255
2 10000 1 8000 - 3 10000 0 8000 8000 8000 255
3 10000 2000 10000 + 4 10000 0 8000 8000 8000 255
4 10000 2000 10000 + 9 10000 0 8000 8000 8000 255
......@@ -50,14 +50,14 @@ S 9 * LN:i:10000
S 7 * LN:i:10000
S 8 * LN:i:10000
S 6 * LN:i:10000
L 2 + 3 - 8000M NM:i:0 om:f:0.25
L 1 - 2 + 8001M NM:i:0 om:f:0.25
L 4 - 7 + 8000M NM:i:0 om:f:0.00
L 2 + 3 - 8000M NM:i:0 om:f:0.00
L 1 - 2 + 8001M NM:i:0 om:f:0.00
L 4 - 7 + 8000M NM:i:0 om:f:0.25
L 4 - 9 - 8000M NM:i:0 om:f:0.00
L 7 + 6 + 8000M NM:i:0 om:f:0.00
L 3 - 4 - 8000M NM:i:0 om:f:0.00
L 5 + 1 - 8000M NM:i:0 om:f:0.25
L 6 + 5 - 8000M NM:i:0 om:f:0.25
L 5 + 1 - 8000M NM:i:0 om:f:0.00
L 6 + 5 - 8000M NM:i:0 om:f:0.00
L 8 + 7 + 8000M NM:i:0 om:f:0.00
"""
......
......@@ -11,8 +11,8 @@ def test_minimap_3contain():
S 63107 * LN:i:23535
S 59727 * LN:i:27255
S 59847 * LN:i:18269
L 59727 - 63107 + 12461M NM:i:11163 om:f:0.90
C 63107 + 56001 + 5870 3275M
C 59727 + 63107 - 14393 12461M
C 63107 + 59847 - 4047 18235M
"""
p = paf2gfa.Parser()
......
......@@ -19,7 +19,7 @@ def test_A_3_same():
# <-------------
def test_A_3_diff():
line = "1\t1000\t10\t1000\t-\t2\t1000\t10\t1000\t30\t980\t255"
resu = "S\t1\t*\tLN:i:1000\nS\t2\t*\tLN:i:1000\nL\t2\t-\t1\t+\t980M\tNM:i:950\tom:f:0.01\n"
resu = "S\t1\t*\tLN:i:1000\nS\t2\t*\tLN:i:1000\nL\t2\t-\t1\t+\t980M\tNM:i:950\tom:f:0.00\n"
p = paf2gfa.Parser()
p.parse_line(line)
......@@ -43,7 +43,7 @@ def test_A_5_same():
# <----------------
def test_A_5_diff():
line = "1\t1000\t0\t980\t-\t2\t1000\t0\t980\t30\t960\t255"
resu = "S\t1\t*\tLN:i:1000\nS\t2\t*\tLN:i:1000\nL\t2\t-\t1\t+\t960M\tNM:i:930\tom:f:0.02\n"
resu = "S\t1\t*\tLN:i:1000\nS\t2\t*\tLN:i:1000\nL\t2\t-\t1\t+\t960M\tNM:i:930\tom:f:0.00\n"
p = paf2gfa.Parser()
p.parse_lines(line.split("\n"))
......
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