예제 #1
0
class ApproximateMatcher:
    def __init__(self, target):
        self._text = target + '$'
        self._bwt = BWT(self._text)

    # return indices in target that contain
    # matches of string pattern with up to d
    # mismatches
    def get_matches(self, pattern, d):
        # initialze seed and check object
        seed_checker = SeedChecker(pattern, d)

        # for each seed k-mer in pattern
        for seed, seed_index in seed_checker.enumerate():
            # find exact matches of seed using BWT
            indices = self._bwt.get_matches(seed)
            # add candidate approximate matches based on
            # seed exact matches
            seed_checker.add_candidates(indices, seed_index)
        # verify that candidate approximate matches are within
        # minimum edit distance, and return final matches
        matches = seed_checker.filter_candidates(self._text)
        return matches
예제 #2
0
class ApproximateMatcher:
    def __init__(self, target):
        self._text = target + "$"
        self._bwt = BWT(self._text)

    # return indices in target that contain
    # matches of string pattern with up to d
    # mismatches
    def get_matches(self, pattern, d):
        # initialze seed and check object
        seed_checker = SeedChecker(pattern, d)

        # for each seed k-mer in pattern
        for seed, seed_index in seed_checker.enumerate():
            # find exact matches of seed using BWT
            indices = self._bwt.get_matches(seed)
            # add candidate approximate matches based on
            # seed exact matches
            seed_checker.add_candidates(indices, seed_index)
        # verify that candidate approximate matches are within
        # minimum edit distance, and return final matches
        matches = seed_checker.filter_candidates(self._text)
        return matches