Commit e8ff1f4f authored by MARIJON Pierre's avatar MARIJON Pierre

Add version number of gfa generated

parent cd968e96
......@@ -164,6 +164,7 @@ class Parser:
self.parse_line(line)
def generate_gfa(self):
yield "H\tVN:Z:1.0"
for seq, length in self.__segments.items():
if not self.containment and seq in self.__containments:
continue
......
......@@ -11,6 +11,7 @@ def test_basic():
"""
resu = """
H VN:Z:1.0
S 1 * LN:i:10000
S 2 * LN:i:10000
S 5 * LN:i:10000
......@@ -41,6 +42,7 @@ def test_with_2_repetition_strand_diff():
"""
resu = """
H VN:Z:1.0
S 1 * LN:i:10000
S 2 * LN:i:10000
S 5 * LN:i:10000
......
......@@ -7,7 +7,7 @@ import paf2gfa
# --------->
def test_A_contain_B_keep_contain_same():
line = "1\t2000\t500\t1500\t+\t2\t1000\t0\t1000\t30\t1000\t255"
resu = "S\t1\t*\tLN:i:2000\nS\t2\t*\tLN:i:1000\nC\t1\t+\t2\t+\t500\t1000M\n"
resu = "H\tVN:Z:1.0\nS\t1\t*\tLN:i:2000\nS\t2\t*\tLN:i:1000\nC\t1\t+\t2\t+\t500\t1000M\n"
p = paf2gfa.Parser()
p.parse_line(line)
......@@ -19,7 +19,7 @@ def test_A_contain_B_keep_contain_same():
# <---------
def test_A_contain_B_keep_contain_diff():
line = "1\t2000\t500\t1500\t-\t2\t1000\t0\t1000\t30\t1000\t255"
resu = "S\t1\t*\tLN:i:2000\nS\t2\t*\tLN:i:1000\nC\t1\t+\t2\t-\t500\t1000M\n"
resu = "H\tVN:Z:1.0\nS\t1\t*\tLN:i:2000\nS\t2\t*\tLN:i:1000\nC\t1\t+\t2\t-\t500\t1000M\n"
p = paf2gfa.Parser()
p.parse_line(line)
......@@ -31,7 +31,7 @@ def test_A_contain_B_keep_contain_diff():
# --------------------------->
def test_A_contained_B_keep_contain_same():
line = "2\t1000\t0\t1000\t+\t1\t2000\t500\t1500\t30\t1000\t255"
resu = "S\t2\t*\tLN:i:1000\nS\t1\t*\tLN:i:2000\nC\t1\t+\t2\t+\t500\t1000M\n"
resu = "H\tVN:Z:1.0\nS\t2\t*\tLN:i:1000\nS\t1\t*\tLN:i:2000\nC\t1\t+\t2\t+\t500\t1000M\n"
p = paf2gfa.Parser()
p.parse_line(line)
......@@ -43,7 +43,7 @@ def test_A_contained_B_keep_contain_same():
# <---------------------------
def test_A_contained_B_keep_contain_diff():
line = "2\t1000\t0\t1000\t-\t1\t2000\t500\t1500\t30\t1000\t255"
resu = "S\t2\t*\tLN:i:1000\nS\t1\t*\tLN:i:2000\nC\t1\t+\t2\t-\t500\t1000M\n"
resu = "H\tVN:Z:1.0\nS\t2\t*\tLN:i:1000\nS\t1\t*\tLN:i:2000\nC\t1\t+\t2\t-\t500\t1000M\n"
p = paf2gfa.Parser()
p.parse_line(line)
......@@ -55,7 +55,7 @@ def test_A_contained_B_keep_contain_diff():
# --------->
def test_A_contain_B_leave_contain_same():
line = "1\t2000\t500\t1500\t+\t2\t1000\t0\t1000\t30\t1000\t255"
resu = "S\t1\t*\tLN:i:2000\nC\t1\t+\t2\t+\t500\t1000M\n"
resu = "H\tVN:Z:1.0\nS\t1\t*\tLN:i:2000\nC\t1\t+\t2\t+\t500\t1000M\n"
p = paf2gfa.Parser(False)
p.parse_line(line)
......@@ -67,7 +67,7 @@ def test_A_contain_B_leave_contain_same():
# <---------
def test_A_contain_B_leave_contain_diff():
line = "1\t2000\t500\t1500\t-\t2\t1000\t0\t1000\t30\t1000\t255"
resu = "S\t1\t*\tLN:i:2000\nC\t1\t+\t2\t-\t500\t1000M\n"
resu = "H\tVN:Z:1.0\nS\t1\t*\tLN:i:2000\nC\t1\t+\t2\t-\t500\t1000M\n"
p = paf2gfa.Parser(False)
p.parse_line(line)
......@@ -79,7 +79,7 @@ def test_A_contain_B_leave_contain_diff():
# --------------------------->
def test_A_contained_B_leave_contain_same():
line = "2\t1000\t0\t1000\t+\t1\t2000\t500\t1500\t30\t1000\t255"
resu = "S\t1\t*\tLN:i:2000\nC\t1\t+\t2\t+\t500\t1000M\n"
resu = "H\tVN:Z:1.0\nS\t1\t*\tLN:i:2000\nC\t1\t+\t2\t+\t500\t1000M\n"
p = paf2gfa.Parser(False)
p.parse_line(line)
......@@ -91,7 +91,7 @@ def test_A_contained_B_leave_contain_same():
# <---------------------------
def test_A_contained_B_leave_contain_diff():
line = "2\t1000\t0\t1000\t-\t1\t2000\t500\t1500\t30\t1000\t255"
resu = "S\t1\t*\tLN:i:2000\nC\t1\t+\t2\t-\t500\t1000M\n"
resu = "H\tVN:Z:1.0\nS\t1\t*\tLN:i:2000\nC\t1\t+\t2\t-\t500\t1000M\n"
p = paf2gfa.Parser(False)
p.parse_line(line)
......@@ -108,6 +108,7 @@ A\t1000\t0\t1000\t+\tB\t1000\t1\t999\t0\t1000\t255
B\t1000\t0\t1000\t+\tA\t1000\t1\t999\t0\t1000\t255
"""
resu = """
H\tVN:Z:1.0
S\tA\t*\tLN:i:1000
S\tB\t*\tLN:i:1000
C\tB\t+\tA\t+\t1\t1000M
......
import pytest
import paf2gfa
# A and B internal match same strand
# -- -->
# \ /
# -------
# -------
# / \
# -- -->
def test_A_B_internal_match_keep_same():
line = "A\t10000\t200\t5100\t+\tB\t10000\t100\t5000\t30\t4900\t255"
resu = """
H\tVN:Z:1.0
S\tA\t*\tLN:i:10000
S\tB\t*\tLN:i:10000
L\tA\t+\tB\t+\t4900M\tNM:i:4870\tom:f:1.02
"""
p = paf2gfa.Parser()
p.parse_line(line)
assert resu.strip() == p.get_gfa().strip()
# A and B internal match diff strand
# -- -->
# \ /
# -------
# -------
# / \
# <-- --
def test_A_B_internal_match_keep_diff():
line = "A\t10000\t2200\t7100\t-\tB\t10000\t2100\t7000\t30\t4900\t255"
resu = """
H\tVN:Z:1.0
S\tA\t*\tLN:i:10000
S\tB\t*\tLN:i:10000
L\tA\t+\tB\t-\t4900M\tNM:i:4870\tom:f:0.88
"""
p = paf2gfa.Parser()
p.parse_line(line)
assert resu.strip() == p.get_gfa().strip()
# A and B internal match same strand
# -- -->
# \ /
# -------
# -------
# / \
# -- -->
def test_A_B_internal_match_remove_same():
line = "A\t10000\t200\t5100\t+\tB\t10000\t100\t5000\t30\t4900\t255"
resu = """
H\tVN:Z:1.0
S\tA\t*\tLN:i:10000
S\tB\t*\tLN:i:10000
"""
p = paf2gfa.Parser(internal=False)
p.parse_line(line)
assert resu.strip() == p.get_gfa().strip()
# A and B internal match diff strand
# -- -->
# \ /
# -------
# -------
# / \
# <-- --
def test_A_B_internal_match_remove_diff():
line = "A\t10000\t2200\t7100\t-\tB\t10000\t2100\t7000\t30\t4900\t255"
resu = """
H\tVN:Z:1.0
S\tA\t*\tLN:i:10000
S\tB\t*\tLN:i:10000
"""
p = paf2gfa.Parser(internal=False)
p.parse_line(line)
assert resu.strip() == p.get_gfa().strip()
......@@ -8,6 +8,7 @@ def test_minimap_3contain():
59847 18269 51 18268 - 63107 23535 4047 22282 2124 18235 255 cm:i:247"""
resu = """
H VN:Z:1.0
S 56001 * LN:i:3693
S 63107 * LN:i:23535
S 59727 * LN:i:27255
......
......@@ -7,7 +7,7 @@ import paf2gfa
# ------------->
def test_A_3_same():
line = "1\t1000\t20\t1000\t+\t2\t1000\t0\t980\t30\t980\t255"
resu = "S\t1\t*\tLN:i:1000\nS\t2\t*\tLN:i:1000\nL\t1\t+\t2\t+\t980M\tNM:i:950\tom:f:0.00\n"
resu = "H\tVN:Z:1.0\nS\t1\t*\tLN:i:1000\nS\t2\t*\tLN:i:1000\nL\t1\t+\t2\t+\t980M\tNM:i:950\tom:f:0.00\n"
p = paf2gfa.Parser()
p.parse_line(line)
......@@ -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\t1\t+\t2\t-\t980M\tNM:i:950\tom:f:0.00\n"
resu = "H\tVN:Z:1.0\nS\t1\t*\tLN:i:1000\nS\t2\t*\tLN:i:1000\nL\t1\t+\t2\t-\t980M\tNM:i:950\tom:f:0.00\n"
p = paf2gfa.Parser()
p.parse_line(line)
......@@ -31,7 +31,7 @@ def test_A_3_diff():
# ---------------->
def test_A_5_same():
line = "1\t1000\t0\t980\t+\t2\t1000\t20\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.00\n"
resu = "H\tVN:Z:1.0\nS\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\t1\t-\t2\t+\t960M\tNM:i:930\tom:f:0.00\n"
resu = "H\tVN:Z:1.0\nS\t1\t*\tLN:i:1000\nS\t2\t*\tLN:i:1000\nL\t1\t-\t2\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