コード例 #1
0
 def test_primer_provided(self):
     res = quality_filter.parse_barcode_file(self.fp, primer='CATTGCCTATG')
     self.assertEqual(9, len(res.keys()))
     self.assertEqual('p1d1bc210', res['TACAGTCGCATTGCCTATG'])
     self.assertEqual(None, triefind.match('TACAGTCGCATTGCCTAT', res))
     self.assertEqual('TACAGTCGCATTGCCTATG',
                      triefind.match('TACAGTCGCATTGCCTATGCTACCTA', res))
コード例 #2
0
 def test_primer_provided(self):
     res = quality_filter.parse_barcode_file(self.fp, primer='CATTGCCTATG')
     self.assertEqual(9, len(list(res.keys())))
     self.assertEqual('p1d1bc210', res['TACAGTCGCATTGCCTATG'])
     self.assertEqual(None, triefind.match('TACAGTCGCATTGCCTAT', res))
     self.assertEqual('TACAGTCGCATTGCCTATG',
                      triefind.match('TACAGTCGCATTGCCTATGCTACCTA', res))
コード例 #3
0
ファイル: test_trie.py プロジェクト: wl2wl2/biopython
 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)])
コード例 #4
0
ファイル: test_trie.py プロジェクト: DunbrackLab/biopython
 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)])
コード例 #5
0
 def filter_record(self, record):
     m = triefind.match(str(record.seq), self.trie)
     if m:
         if self.listener:
             self.listener('found_barcode', record, barcode=m, sample=self.trie[m])
         if self.trim:
             record = record[len(m):]
         return record
     else:
         raise FailedFilter()
コード例 #6
0
ファイル: quality_filter.py プロジェクト: peterjc/seqmagick
 def filter_record(self, record):
     m = triefind.match(str(record.seq), self.trie)
     if m:
         if self.listener:
             self.listener(
                 'found_barcode', record, barcode=m, sample=self.trie[m])
         if self.trim:
             record = record[len(m):]
         return record
     else:
         raise FailedFilter()
コード例 #7
0
ファイル: test_triefind.py プロジェクト: frankkl/biopython
    else :
        message = "Could not import Bio.trie, check C code was compiled."
    raise MissingExternalDependencyError(message)


from Bio import triefind

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()
コード例 #8
0
import StringIO
from operator import truth

from Bio import trie
from Bio import triefind

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()