Skip to content
This repository has been archived by the owner on Mar 20, 2020. It is now read-only.

Commit

Permalink
#4: Debug of dp conditions
Browse files Browse the repository at this point in the history
  • Loading branch information
Toshiyuki Yokoyama committed Jul 9, 2019
1 parent 205e2bc commit 1321465
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 9 deletions.
17 changes: 9 additions & 8 deletions src/sort.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,28 +46,28 @@ def lcs(self, s1: List[Profile], s2: Path) -> List[Profile]:
index = []
prev = set()

while i > 0 or j > 0:
while i > 0 and j > 0:
if s1[i-1].node == s2.nodes[j-1]:
prev_paths = s1[i-1].paths
prev_paths.append(s2)
index.append(Profile(s1[i-1].node, prev_paths, s1[i-1].node in prev))
prev.add(s1[i-1].node)
index.append(Profile(s1[i-1].node, prev_paths, s1[i-1].node.node.index in prev))
prev.add(s1[i-1].node.node.index)
i -= 1
j -= 1
elif dp[i-1][j] > dp[i][j-1]:
prev_paths = s1[i-1].paths
index.append(Profile(s1[i-1].node, prev_paths, s1[i-1].node in prev))
prev.add(s1[i-1].node)
index.append(Profile(s1[i-1].node, prev_paths, s1[i-1].node.node.index in prev))
prev.add(s1[i-1].node.node.index)
i -= 1
else:
index.append(Profile(s2.nodes[j-1], [s2], False))
prev.add(s2.nodes[j-1])
prev.add(s2.nodes[j-1].node.index)
j -= 1

while i > 0:
prev_paths = s1[i - 1].paths
index.append(Profile(s1[i - 1].node, prev_paths, s1[i - 1].node in prev))
prev.add(s1[i - 1].node)
index.append(Profile(s1[i - 1].node, prev_paths, s1[i - 1].node.node.index in prev))
prev.add(s1[i - 1].node.node.index)
i -= 1

while j > 0:
Expand All @@ -83,6 +83,7 @@ def lcs(self, s1: List[Profile], s2: Path) -> List[Profile]:
def to_graph(self):
factory_input = []
current_slice = Slice([])
print(self.profile)
for prof in self.profile:
paths = [x.name for x in prof.paths]
if len(prof.paths) == len(self.paths):
Expand Down
12 changes: 12 additions & 0 deletions src/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,18 @@ def test_dagify(self):
z = 'z'
self.assertEqual(graph, graph_by_toplogical_sort)

def test_dagify2(self):
gfa = GFA.load_from_gfa("../test/test2.gfa")
paths = gfa.to_paths
dagify = DAGify(paths)
dagify.recursive_merge(0)
graph = dagify.to_graph()

graph_by_toplogical_sort = gfa.to_graph
x = 'x'
y = 'y'
z = 'z'
self.assertEqual(graph, graph_by_toplogical_sort)

class GFATest(unittest.TestCase):
""" test class of gfa.py
Expand Down
2 changes: 1 addition & 1 deletion test/test2.gfa
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ H VN:Z:1.0
P x 1+,3+,5+,6+,8+,9+,11+,12+,14+,15+ *,*,*,*,*,*,*,*,*
P y 1+,2+,5+,6+,8+,9+,11+,12+,14+,15+ *,*,*,*,*,*,*,*,*
P z 1+,2+,4+,6+,7+,9+,10+,12+,14+,15+ *,*,*,*,*,*,*,*,*
P a 12+,13+,15+ *,*
P a 7+,9+,10+ *,*
S 1 CAAATAAG
L 1 + 2 + 0M
L 1 + 3 + 0M
Expand Down
38 changes: 38 additions & 0 deletions test/test3.gfa
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
H VN:Z:1.0
P x 1+,3+,5+,6+,8+,9+,11+,12+,14+,15+ *,*,*,*,*,*,*,*,*
P y 1+,15+,5+,6+,8+,9+,11+,12+,14+,15+ *,*,*,*,*,*,*,*,*
S 1 CAAATAAG
L 1 + 15 + 0M
L 1 + 3 + 0M
S 2 A
L 2 + 4 + 0M
L 15 + 5 + 0M
S 3 G
L 3 + 4 + 0M
L 3 + 5 + 0M
S 4 T
L 4 + 6 + 0M
S 5 C
L 5 + 6 + 0M
S 6 TTG
L 6 + 7 + 0M
L 6 + 8 + 0M
S 7 A
L 7 + 9 + 0M
S 8 G
L 8 + 9 + 0M
S 9 AAATTTTCTGGAGTTCTAT
L 9 + 10 + 0M
L 9 + 11 + 0M
S 10 A
L 10 + 12 + 0M
S 11 T
L 11 + 12 + 0M
S 12 ATAT
L 12 + 13 + 0M
L 12 + 14 + 0M
S 13 A
L 13 + 15 + 0M
S 14 T
L 14 + 15 + 0M
S 15 CCAACTCTCTG

0 comments on commit 1321465

Please sign in to comment.