本文整理汇总了Python中sourmash._minhash.MinHash.add_sequence方法的典型用法代码示例。如果您正苦于以下问题:Python MinHash.add_sequence方法的具体用法?Python MinHash.add_sequence怎么用?Python MinHash.add_sequence使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sourmash._minhash.MinHash
的用法示例。
在下文中一共展示了MinHash.add_sequence方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_div_zero_contained
# 需要导入模块: from sourmash._minhash import MinHash [as 别名]
# 或者: from sourmash._minhash.MinHash import add_sequence [as 别名]
def test_div_zero_contained(track_abundance):
# verify that empty MHs do not yield divide by zero errors for contained_by
mh = MinHash(1, 4, track_abundance=track_abundance)
mh2 = mh.copy_and_clear()
mh.add_sequence('ATGC')
assert mh.contained_by(mh2) == 0
assert mh2.contained_by(mh) == 0
示例2: test_basic_dna_bad
# 需要导入模块: from sourmash._minhash import MinHash [as 别名]
# 或者: from sourmash._minhash.MinHash import add_sequence [as 别名]
def test_basic_dna_bad(track_abundance):
# test behavior on bad DNA
mh = MinHash(1, 4, track_abundance=track_abundance)
with pytest.raises(ValueError) as e:
mh.add_sequence('ATGR')
print(e)
assert 'invalid DNA character in input k-mer: ATGR' in str(e)
示例3: test_abundance_simple
# 需要导入模块: from sourmash._minhash import MinHash [as 别名]
# 或者: from sourmash._minhash.MinHash import add_sequence [as 别名]
def test_abundance_simple():
a = MinHash(20, 5, False, track_abundance=True)
a.add_sequence('AAAAA')
assert a.get_mins() == [2110480117637990133]
assert a.get_mins(with_abundance=True) == {2110480117637990133: 1}
a.add_sequence('AAAAA')
assert a.get_mins() == [2110480117637990133]
assert a.get_mins(with_abundance=True) == {2110480117637990133: 2}
示例4: test_consume_lowercase
# 需要导入模块: from sourmash._minhash import MinHash [as 别名]
# 或者: from sourmash._minhash.MinHash import add_sequence [as 别名]
def test_consume_lowercase(track_abundance):
a = MinHash(20, 10, track_abundance=track_abundance)
b = MinHash(20, 10, track_abundance=track_abundance)
a.add_sequence('TGCCGCCCAGCACCGGGTGACTAGGTTGAGCCATGATTAACCTGCAATGA'.lower())
b.add_sequence('TGCCGCCCAGCACCGGGTGACTAGGTTGAGCCATGATTAACCTGCAATGA')
assert a.compare(b) == 1.0
assert b.compare(b) == 1.0
assert b.compare(a) == 1.0
assert a.compare(a) == 1.0
示例5: test_basic_dna
# 需要导入模块: from sourmash._minhash import MinHash [as 别名]
# 或者: from sourmash._minhash.MinHash import add_sequence [as 别名]
def test_basic_dna(track_abundance):
# verify that MHs of size 1 stay size 1, & act properly as bottom sketches.
mh = MinHash(1, 4, track_abundance=track_abundance)
mh.add_sequence('ATGC')
a = mh.get_mins()
mh.add_sequence('GCAT') # this will not get added; hash > ATGC
b = mh.get_mins()
print(a, b)
assert a == b
assert len(b) == 1
示例6: setup
# 需要导入模块: from sourmash._minhash import MinHash [as 别名]
# 或者: from sourmash._minhash.MinHash import add_sequence [as 别名]
class TimeMinHashSuite:
def setup(self):
self.mh = MinHash(500, 21, track_abundance=False)
self.sequences = load_sequences(get_test_data('ecoli.genes.fna')) * 10
self.populated_mh = MinHash(500, 21, track_abundance=False)
for seq in self.sequences:
self.populated_mh.add_sequence(seq)
def time_add_sequence(self):
mh = self.mh
sequences = self.sequences
for seq in sequences:
mh.add_sequence(seq)
def time_get_mins(self):
mh = self.populated_mh
for i in range(500):
mh.get_mins()
def time_add_hash(self):
mh = self.mh
for i in range(10000):
mh.add_hash(i)
def time_compare(self):
mh = self.mh
other_mh = self.populated_mh
for i in range(500):
mh.compare(other_mh)
def time_count_common(self):
mh = self.mh
other_mh = self.populated_mh
for i in range(500):
mh.count_common(other_mh)
def time_merge(self):
mh = self.mh
other_mh = self.populated_mh
for i in range(500):
mh.merge(other_mh)
def time_copy(self):
mh = self.populated_mh
for i in range(500):
mh.__copy__()
def time_concat(self):
mh = self.mh
other_mh = self.populated_mh
for i in range(500):
mh += other_mh
示例7: test_abundance_compare
# 需要导入模块: from sourmash._minhash import MinHash [as 别名]
# 或者: from sourmash._minhash.MinHash import add_sequence [as 别名]
def test_abundance_compare():
a = MinHash(20, 10, track_abundance=True)
b = MinHash(20, 10, track_abundance=False)
a.add_sequence('TGCCGCCCAGCACCGGGTGACTAGGTTGAGCCATGATTAACCTGCAATGA')
b.add_sequence('TGCCGCCCAGCACCGGGTGACTAGGTTGAGCCATGATTAACCTGCAATGA')
assert a.compare(b) == 1.0
assert b.compare(b) == 1.0
assert b.compare(a) == 1.0
assert a.compare(a) == 1.0
# add same sequence again
b.add_sequence('TGCCGCCCAGCACCGGGTGACTAGGTTGAGCCATGATTAACCTGCAATGA')
assert a.compare(b) == 1.0
assert b.compare(b) == 1.0
assert b.compare(a) == 1.0
assert a.compare(a) == 1.0
b.add_sequence('GATTGGTGCACACTTAACTGGGTGCCGCGCTGGTGCTGATCCATGAAGTT')
x = a.compare(b)
assert x >= 0.3, x
x = b.compare(a)
assert x >= 0.3, x
assert a.compare(a) == 1.0
assert b.compare(b) == 1.0
示例8: test_abundance_count_common
# 需要导入模块: from sourmash._minhash import MinHash [as 别名]
# 或者: from sourmash._minhash.MinHash import add_sequence [as 别名]
def test_abundance_count_common():
a = MinHash(20, 5, False, track_abundance=True)
b = MinHash(20, 5, False, track_abundance=False)
a.add_sequence('AAAAA')
a.add_sequence('AAAAA')
assert a.get_mins() == [2110480117637990133]
assert a.get_mins(with_abundance=True) == {2110480117637990133: 2}
b.add_sequence('AAAAA')
b.add_sequence('GGGGG')
assert a.count_common(b) == 1
assert a.count_common(b) == b.count_common(a)
assert b.get_mins(with_abundance=True) == [2110480117637990133,
10798773792509008305]
示例9: TimeMinAbundanceSuite
# 需要导入模块: from sourmash._minhash import MinHash [as 别名]
# 或者: from sourmash._minhash.MinHash import add_sequence [as 别名]
class TimeMinAbundanceSuite(TimeMinHashSuite):
def setup(self):
TimeMinHashSuite.setup(self)
self.mh = MinHash(500, 21, track_abundance=True)
self.populated_mh = MinHash(500, 21, track_abundance=True)
for seq in self.sequences:
self.populated_mh.add_sequence(seq)
def time_get_mins_abundance(self):
mh = self.populated_mh
for i in range(500):
mh.get_mins(with_abundance=True)
def time_set_abundances(self):
mh = self.mh
mins = self.populated_mh.get_mins(with_abundance=True)
for i in range(500):
mh.set_abundances(mins)
示例10: test_bytes_dna
# 需要导入模块: from sourmash._minhash import MinHash [as 别名]
# 或者: from sourmash._minhash.MinHash import add_sequence [as 别名]
def test_bytes_dna(track_abundance):
mh = MinHash(1, 4, track_abundance=track_abundance)
mh.add_sequence('ATGC')
mh.add_sequence(b'ATGC')
mh.add_sequence(u'ATGC')
a = mh.get_mins()
mh.add_sequence('GCAT') # this will not get added; hash > ATGC
mh.add_sequence(b'GCAT') # this will not get added; hash > ATGC
mh.add_sequence(u'GCAT') # this will not get added; hash > ATGC
b = mh.get_mins()
print(a, b)
assert a == b
assert len(b) == 1
示例11: test_basic_dna_bad_force
# 需要导入模块: from sourmash._minhash import MinHash [as 别名]
# 或者: from sourmash._minhash.MinHash import add_sequence [as 别名]
def test_basic_dna_bad_force(track_abundance):
# test behavior on bad DNA; use 100 so multiple hashes get added.
mh = MinHash(100, 4, track_abundance=track_abundance)
assert len(mh.get_mins()) == 0
mh.add_sequence('ATGN', True) # ambiguous kmer skipped.
assert len(mh.get_mins()) == 0
mh.add_sequence('AATGN', True) # but good k-mers still used.
assert len(mh.get_mins()) == 1
mh.add_sequence('AATG', True) # checking that right kmer was added
assert len(mh.get_mins()) == 1 # (only 1 hash <- this is a dup)
示例12: test_basic_dna_bad_force_2
# 需要导入模块: from sourmash._minhash import MinHash [as 别名]
# 或者: from sourmash._minhash.MinHash import add_sequence [as 别名]
def test_basic_dna_bad_force_2(track_abundance):
# test behavior on bad DNA
mh = MinHash(100, 4, track_abundance=track_abundance)
assert len(mh.get_mins()) == 0
mh.add_sequence('AAGNCGG', True) # ambiguous kmers skipped.
assert len(mh.get_mins()) == 0
mh.add_sequence('AATGNGCGG', True) # ambiguous kmers skipped.
assert len(mh.get_mins()) == 2
mh.add_sequence('AATG', True) # checking that right kmers were added
mh.add_sequence('GCGG', True)
assert len(mh.get_mins()) == 2 # (only 2 hashes should be there)
示例13: test_short_sequence
# 需要导入模块: from sourmash._minhash import MinHash [as 别名]
# 或者: from sourmash._minhash.MinHash import add_sequence [as 别名]
def test_short_sequence(track_abundance):
a = MinHash(20, 5, track_abundance=track_abundance)
a.add_sequence('GGGG')
# adding a short sequence should fail silently
assert len(a.get_mins()) == 0
示例14: test_mh_len
# 需要导入模块: from sourmash._minhash import MinHash [as 别名]
# 或者: from sourmash._minhash.MinHash import add_sequence [as 别名]
def test_mh_len(track_abundance):
a = MinHash(20, 10, track_abundance=track_abundance)
assert len(a) == 20
a.add_sequence('TGCCGCCCAGCACCGGGTGACTAGGTTGAGCCATGATTAACCTGCAATGA')
assert len(a) == 20
示例15: test_mh_copy
# 需要导入模块: from sourmash._minhash import MinHash [as 别名]
# 或者: from sourmash._minhash.MinHash import add_sequence [as 别名]
def test_mh_copy(track_abundance):
a = MinHash(20, 10, track_abundance=track_abundance)
a.add_sequence('TGCCGCCCAGCACCGGGTGACTAGGTTGAGCCATGATTAACCTGCAATGA')
b = a.__copy__()
assert b.compare(a) == 1.0