def load_lcp_structures(fileprefix): llcp_filename = "%s_llcp.pck" % fileprefix rlcp_filename = "%s_rlcp.pck" % fileprefix global llcp global rlcp global n print "Pre-processing LCP search datastructures..." if exists(llcp_filename) and exists(rlcp_filename): print " Reading llcp array from %s..." % llcp_filename llcp = unpickle(llcp_filename) print " Reading rlcp array from %s..." % rlcp_filename rlcp = unpickle(rlcp_filename) else: print " Computing binary search paths..." lm, m, rm = compute_binary_search_path(n) print " Computing rlcp array..." rlcp = compute_xlcp(rm, m, suffix_array, text) print " Writing rlcp array to %s..." % rlcp_filename picklefy(rlcp_filename, rlcp) print " Computing llcp array..." llcp = compute_xlcp(lm, m, suffix_array, text) print " Writing llcp array to %s..." % llcp_filename picklefy(llcp_filename, llcp) print " Done."
def test_binary_search_path_n_equals_10(self): n = 10 lm = [0, 0, 2, 0, 4, 4, 6, 7] rm = [2, 4, 4, 9, 6, 9, 9, 9] m = [1, 2, 3, 4, 5, 6, 7, 8] (new_lm, new_m, new_rm) = compute_binary_search_path(n) self.assertEquals(new_lm, lm) self.assertEquals(new_rm, rm) self.assertEquals(new_m, m)
def test_binary_search_path_n_equals_9(self): n = 9 lm = [0, 0, 2, 0, 4, 4, 6] rm = [2, 4, 4, 8, 6, 8, 8] m = [1, 2, 3, 4, 5, 6, 7] (new_lm, new_m, new_rm) = compute_binary_search_path(n) self.assertEquals(new_lm, lm) self.assertEquals(new_rm, rm) self.assertEquals(new_m, m)