Skip to content

Commit

Permalink
Merge bbb127b into 20df516
Browse files Browse the repository at this point in the history
  • Loading branch information
ezorita committed Jun 13, 2018
2 parents 20df516 + bbb127b commit cb64262
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
language: c

compiler:
- clang
- gcc

branches:
only:
- master

before_install:
- sudo pip install cpp-coveralls
- sudo pip install -U cpp-coveralls

script: make && make lib && python setup.py build && cd test && make test && python python_lib_test.py

Expand Down
12 changes: 10 additions & 2 deletions src/libseeq.c
Original file line number Diff line number Diff line change
Expand Up @@ -288,19 +288,27 @@ seeqStringMatch
size_t j = 0;
uint32_t rnode = DFA_ROOT_STATE;
int d = sq->tau + 1;
int last_d, ignores = 0;
// Find match start with RDFA.
do {
int c = (int)translate[(int)data[i-++j]];
last_d = d;
if (c < NBASES) {
ignores = 0;
vertex_t * vertex = (vertex_t *) (((dfa_t *)sq->rdfa)->states + rnode * state_size);
uint32_t next = vertex->next[c];
if (next == DFA_COMPUTE)
if (dfa_step(rnode, c, sq->wlen, sq->tau, (dfa_t **) &(sq->rdfa), sq->rkeys, &next)) return -1;
rnode = next;
vertex = (vertex_t *) (((dfa_t *)sq->rdfa)->states + rnode * state_size);
d = get_match(vertex->match);
} else continue;
} while (d > streak_dist && j < i);
} else {
ignores++;
continue;
}
// } while (d > streak_dist && j < i);
} while (d <= last_d && j < i);
j = (last_d < d ? j-1 : j) - ignores;
size_t match_start = i-j;
size_t match_end = i;
int match_dist = streak_dist;
Expand Down
8 changes: 4 additions & 4 deletions test/python_lib_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ def test_matchPrefix(self):
nomatch = "ATGCTGATGCTGGGGG"
match = "GGGGCGCTAATAATGGAATGGGG"

self.assertEqual(matcher.matchPrefix(nomatch, True), "")
self.assertEqual(matcher.matchPrefix(nomatch, False), "")
self.assertEqual(matcher.matchPrefix(nomatch, True), None)
self.assertEqual(matcher.matchPrefix(nomatch, False), None)
self.assertEqual(matcher.matchPrefix(match, True),
"GGGGCGCTAATAATGGAAT")
self.assertEqual(matcher.matchPrefix(match, False), "GGGG")
Expand All @@ -28,8 +28,8 @@ def test_matchSuffix(self):
nomatch = "ATGCTGATGCTGGGGG"
match = "GGGGCGCTAATAATGGAATGGGG"

self.assertEqual(matcher.matchSuffix(nomatch, True), "")
self.assertEqual(matcher.matchSuffix(nomatch, False), "")
self.assertEqual(matcher.matchSuffix(nomatch, True), None)
self.assertEqual(matcher.matchSuffix(nomatch, False), None)
self.assertEqual(matcher.matchSuffix(match, True),
"CGCTAATAATGGAATGGGG")
self.assertEqual(matcher.matchSuffix(match, False), "GGGG")
Expand Down

0 comments on commit cb64262

Please sign in to comment.