Ejemplo n.º 1
0
 def test_find(self):
     from Bio import triefind
     trieobj = trie.trie()
     trieobj["hello"] = 5
     trieobj["he"] = 7
     trieobj["hej"] = 9
     trieobj["foo"] = "bar"
     trieobj["wor"] = "ld"
     self.assertEqual(triefind.match("hello world!", trieobj), "hello")
     k = triefind.match_all("hello world!", trieobj)
     k.sort()
     self.assertEqual(k, ["he", "hello"])
     k = triefind.find("hello world!", trieobj)
     k.sort()
     self.assertEqual(k, [("he", 0, 2), ("hello", 0, 5), ("wor", 6, 9)])
     k = triefind.find_words("hello world!", trieobj)
     k.sort()
     self.assertEqual(k, [("hello", 0, 5)])
     trieobj["world"] = "full"
     k = triefind.find("hello world!", trieobj)
     k.sort()
     self.assertEqual(k, [("he", 0, 2), ("hello", 0, 5), ("wor", 6, 9),
                          ("world", 6, 11)])
     k = triefind.find_words("hello world!", trieobj)
     k.sort()
     self.assertEqual(k, [("hello", 0, 5), ("world", 6, 11)])
Ejemplo n.º 2
0
 def test_find(self):
     from Bio import triefind
     trieobj = trie.trie()
     trieobj["hello"] = 5
     trieobj["he"] = 7
     trieobj["hej"] = 9
     trieobj["foo"] = "bar"
     trieobj["wor"] = "ld"
     self.assertEqual(triefind.match("hello world!", trieobj), "hello")
     k = triefind.match_all("hello world!", trieobj)
     k.sort()
     self.assertEqual(k, ["he", "hello"])
     k = triefind.find("hello world!", trieobj)
     k.sort()
     self.assertEqual(k, [("he", 0, 2), ("hello", 0, 5), ("wor", 6, 9)])
     k = triefind.find_words("hello world!", trieobj)
     k.sort()
     self.assertEqual(k, [("hello", 0, 5)])
     trieobj["world"] = "full"
     k = triefind.find("hello world!", trieobj)
     k.sort()
     self.assertEqual(k, [("he", 0, 2), ("hello", 0, 5), ("wor", 6, 9), ("world", 6, 11)])
     k = triefind.find_words("hello world!", trieobj)
     k.sort()
     self.assertEqual(k, [("hello", 0, 5), ("world", 6, 11)])
Ejemplo n.º 3
0
trieobj = trie.trie()

trieobj["hello"] = 5
trieobj["he"] = 7
trieobj["hej"] = 9
trieobj["foo"] = "bar"
trieobj["wor"] = "ld"

print triefind.match("hello world!", trieobj)    # "hello"
k = triefind.match_all("hello world!", trieobj)
k.sort()
print k     # ["he", "hello"]

k = triefind.find("hello world!", trieobj)
k.sort()
print k     # [("he", 0, 2), ("hello", 0, 5), ("wor", 6, 9)]

k = triefind.find_words("hello world!", trieobj)
k.sort()
print k     # [("hello", 0, 5)]

trieobj["world"] = "full"
k = triefind.find("hello world!", trieobj)
k.sort()
print k     # [("he", 0, 2), ("hello", 0, 5), ("wor", 6, 9), ("world", 6, 11)]

k = triefind.find_words("hello world!", trieobj)
k.sort()
print k     # [("hello", 0, 5), ("world", 6, 11)]
Ejemplo n.º 4
0
trieobj = trie.trie()

trieobj["hello"] = 5
trieobj["he"] = 7
trieobj["hej"] = 9
trieobj["foo"] = "bar"
trieobj["wor"] = "ld"

print triefind.match("hello world!", trieobj)  # "hello"
k = triefind.match_all("hello world!", trieobj)
k.sort()
print k  # ["he", "hello"]

k = triefind.find("hello world!", trieobj)
k.sort()
print k  # [("he", 0, 2), ("hello", 0, 5), ("wor", 6, 9)]

k = triefind.find_words("hello world!", trieobj)
k.sort()
print k  # [("hello", 0, 5)]

trieobj["world"] = "full"
k = triefind.find("hello world!", trieobj)
k.sort()
print k  # [("he", 0, 2), ("hello", 0, 5), ("wor", 6, 9), ("world", 6, 11)]

k = triefind.find_words("hello world!", trieobj)
k.sort()
print k  # [("hello", 0, 5), ("world", 6, 11)]