当前位置: 首页>>代码示例>>Python>>正文


Python MinHash.add_sequence方法代码示例

本文整理汇总了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
开发者ID:dib-lab,项目名称:sourmash,代码行数:10,代码来源:test__minhash.py

示例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)
开发者ID:dib-lab,项目名称:sourmash,代码行数:11,代码来源:test__minhash.py

示例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}
开发者ID:dib-lab,项目名称:sourmash,代码行数:12,代码来源:test__minhash.py

示例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
开发者ID:dib-lab,项目名称:sourmash,代码行数:13,代码来源:test__minhash.py

示例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
开发者ID:dib-lab,项目名称:sourmash,代码行数:14,代码来源:test__minhash.py

示例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
开发者ID:dib-lab,项目名称:sourmash,代码行数:55,代码来源:benchmarks.py

示例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
开发者ID:dib-lab,项目名称:sourmash,代码行数:29,代码来源:test__minhash.py

示例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]
开发者ID:dib-lab,项目名称:sourmash,代码行数:18,代码来源:test__minhash.py

示例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)
开发者ID:dib-lab,项目名称:sourmash,代码行数:21,代码来源:benchmarks.py

示例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
开发者ID:dib-lab,项目名称:sourmash,代码行数:17,代码来源:test__minhash.py

示例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)
开发者ID:dib-lab,项目名称:sourmash,代码行数:12,代码来源:test__minhash.py

示例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)
开发者ID:dib-lab,项目名称:sourmash,代码行数:13,代码来源:test__minhash.py

示例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
开发者ID:dib-lab,项目名称:sourmash,代码行数:7,代码来源:test__minhash.py

示例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
开发者ID:dib-lab,项目名称:sourmash,代码行数:8,代码来源:test__minhash.py

示例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
开发者ID:dib-lab,项目名称:sourmash,代码行数:8,代码来源:test__minhash.py


注:本文中的sourmash._minhash.MinHash.add_sequence方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。