本文整理汇总了Python中dark.titles.TitlesAlignments.filter方法的典型用法代码示例。如果您正苦于以下问题:Python TitlesAlignments.filter方法的具体用法?Python TitlesAlignments.filter怎么用?Python TitlesAlignments.filter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dark.titles.TitlesAlignments
的用法示例。
在下文中一共展示了TitlesAlignments.filter方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testCoverageIncludesSome
# 需要导入模块: from dark.titles import TitlesAlignments [as 别名]
# 或者: from dark.titles.TitlesAlignments import filter [as 别名]
def testCoverageIncludesSome(self):
"""
The coverage function must return an titlesAlignments instance with
only the expected titles if only some of its titles have sufficient
coverage.
"""
mockOpener = mockOpen(read_data=(
dumps(PARAMS) + '\n' + dumps(RECORD0) + '\n' +
dumps(RECORD1) + '\n' + dumps(RECORD2) + '\n' +
dumps(RECORD3) + '\n'))
with patch.object(builtins, 'open', mockOpener):
reads = Reads()
reads.add(Read('id0', 'A' * 70))
reads.add(Read('id1', 'A' * 70))
reads.add(Read('id2', 'A' * 70))
reads.add(Read('id3', 'A' * 70))
readsAlignments = BlastReadsAlignments(reads, 'file.json')
titlesAlignments = TitlesAlignments(readsAlignments)
# To understand why the following produces the result it does,
# you need to look at the HSP coverage in sample_data.py and
# calculate the coverage by hand.
result = titlesAlignments.filter(minCoverage=0.0011)
self.assertEqual(
[
'gi|887699|gb|DQ37780 Cowpox virus 15',
'gi|887699|gb|DQ37780 Monkeypox virus 456',
'gi|887699|gb|DQ37780 Mummypox virus 3000 B.C.',
],
sorted(result.keys()))
示例2: testFilterWithNoArguments
# 需要导入模块: from dark.titles import TitlesAlignments [as 别名]
# 或者: from dark.titles.TitlesAlignments import filter [as 别名]
def testFilterWithNoArguments(self):
"""
The filter function must return a TitlesAlignments instance with all
the titles of the original when called with no arguments.
"""
mockOpener = mockOpen(read_data=(
dumps(PARAMS) + '\n' + dumps(RECORD0) + '\n' +
dumps(RECORD1) + '\n' + dumps(RECORD2) + '\n'))
with patch.object(builtins, 'open', mockOpener):
reads = Reads()
reads.add(Read('id0', 'A' * 70))
reads.add(Read('id1', 'A' * 70))
reads.add(Read('id2', 'A' * 70))
readsAlignments = BlastReadsAlignments(reads, 'file.json')
titlesAlignments = TitlesAlignments(readsAlignments)
result = titlesAlignments.filter()
self.assertEqual(
[
'gi|887699|gb|DQ37780 Cowpox virus 15',
'gi|887699|gb|DQ37780 Monkeypox virus 456',
'gi|887699|gb|DQ37780 Mummypox virus 3000 B.C.',
'gi|887699|gb|DQ37780 Squirrelpox virus 1296/99',
'gi|887699|gb|DQ37780 Squirrelpox virus 55',
],
sorted(result.keys()))
示例3: testCoverageIncludesAll
# 需要导入模块: from dark.titles import TitlesAlignments [as 别名]
# 或者: from dark.titles.TitlesAlignments import filter [as 别名]
def testCoverageIncludesAll(self):
"""
The coverage function must return an titlesAlignments instance with
all titles if all its titles has sufficient coverage.
"""
mockOpener = mockOpen(read_data=(
dumps(PARAMS) + '\n' + dumps(RECORD0) + '\n' +
dumps(RECORD1) + '\n' + dumps(RECORD2) + '\n' +
dumps(RECORD3) + '\n'))
with patch.object(builtins, 'open', mockOpener):
reads = Reads()
reads.add(Read('id0', 'A' * 70))
reads.add(Read('id1', 'A' * 70))
reads.add(Read('id2', 'A' * 70))
reads.add(Read('id3', 'A' * 70))
readsAlignments = BlastReadsAlignments(reads, 'file.json')
titlesAlignments = TitlesAlignments(readsAlignments)
result = titlesAlignments.filter(minCoverage=0.0)
self.assertEqual(
[
'gi|887699|gb|DQ37780 Cowpox virus 15',
'gi|887699|gb|DQ37780 Monkeypox virus 456',
'gi|887699|gb|DQ37780 Mummypox virus 3000 B.C.',
'gi|887699|gb|DQ37780 Squirrelpox virus 1296/99',
'gi|887699|gb|DQ37780 Squirrelpox virus 55',
],
sorted(result.keys()))
示例4: testReadSetFilterAllowAnything
# 需要导入模块: from dark.titles import TitlesAlignments [as 别名]
# 或者: from dark.titles.TitlesAlignments import filter [as 别名]
def testReadSetFilterAllowAnything(self):
"""
The filter function work correctly when passed a 0.0 value for
minNewReads, i.e. that considers any read set sufficiently novel.
"""
mockOpener = mockOpen(read_data=(
dumps(PARAMS) + '\n' + dumps(RECORD0) + '\n' +
dumps(RECORD1) + '\n' + dumps(RECORD2) + '\n' +
dumps(RECORD3) + '\n'))
with patch.object(builtins, 'open', mockOpener):
reads = Reads()
reads.add(Read('id0', 'A' * 70))
reads.add(Read('id1', 'A' * 70))
reads.add(Read('id2', 'A' * 70))
reads.add(Read('id3', 'A' * 70))
readsAlignments = BlastReadsAlignments(reads, 'file.json')
titlesAlignments = TitlesAlignments(readsAlignments)
result = titlesAlignments.filter(minNewReads=0.0)
self.assertEqual(
[
'gi|887699|gb|DQ37780 Cowpox virus 15',
'gi|887699|gb|DQ37780 Monkeypox virus 456',
'gi|887699|gb|DQ37780 Mummypox virus 3000 B.C.',
'gi|887699|gb|DQ37780 Squirrelpox virus 1296/99',
'gi|887699|gb|DQ37780 Squirrelpox virus 55',
],
sorted(result.keys()))
示例5: testMinMedianScore_EValue
# 需要导入模块: from dark.titles import TitlesAlignments [as 别名]
# 或者: from dark.titles.TitlesAlignments import filter [as 别名]
def testMinMedianScore_EValue(self):
"""
The filter function work correctly when passed a value for
minMedianScore when using e values.
"""
mockOpener = mockOpen(read_data=(
dumps(PARAMS) + '\n' + dumps(RECORD0) + '\n' +
dumps(RECORD1) + '\n' + dumps(RECORD2) + '\n' +
dumps(RECORD3) + '\n'))
with patch.object(builtins, 'open', mockOpener):
reads = Reads()
reads.add(Read('id0', 'A' * 70))
reads.add(Read('id1', 'A' * 70))
reads.add(Read('id2', 'A' * 70))
reads.add(Read('id3', 'A' * 70))
readsAlignments = BlastReadsAlignments(
reads, 'file.json', scoreClass=LowerIsBetterScore)
titlesAlignments = TitlesAlignments(readsAlignments)
result = titlesAlignments.filter(minMedianScore=1e-9)
self.assertEqual(
[
'gi|887699|gb|DQ37780 Squirrelpox virus 1296/99',
'gi|887699|gb|DQ37780 Squirrelpox virus 55',
],
sorted(result.keys()))
示例6: testMaxTitlesTwoSortOnLength
# 需要导入模块: from dark.titles import TitlesAlignments [as 别名]
# 或者: from dark.titles.TitlesAlignments import filter [as 别名]
def testMaxTitlesTwoSortOnLength(self):
"""
The filter function must return the two titles whose sequences are the
longest when maxTitles is 2 and sortOn is 'length'.
"""
mockOpener = mockOpen(read_data=(
dumps(PARAMS) + '\n' + dumps(RECORD0) + '\n' +
dumps(RECORD1) + '\n' + dumps(RECORD2) + '\n' +
dumps(RECORD3) + '\n'))
with patch.object(builtins, 'open', mockOpener):
reads = Reads()
reads.add(Read('id0', 'A' * 70))
reads.add(Read('id1', 'A' * 70))
reads.add(Read('id2', 'A' * 70))
reads.add(Read('id3', 'A' * 70))
readsAlignments = DiamondReadsAlignments(reads, 'file.json',
'database.fasta')
titlesAlignments = TitlesAlignments(readsAlignments)
result = titlesAlignments.filter(maxTitles=2, sortOn='length')
self.assertEqual(
[
'gi|887699|gb|DQ37780 Squirrelpox virus 1296/99',
'gi|887699|gb|DQ37780 Squirrelpox virus 55',
],
sorted(result.keys()))
示例7: testWithScoreBetterThan_EValue
# 需要导入模块: from dark.titles import TitlesAlignments [as 别名]
# 或者: from dark.titles.TitlesAlignments import filter [as 别名]
def testWithScoreBetterThan_EValue(self):
"""
The filter function work correctly when passed a value for
withScoreBetterThan when using e values.
"""
mockOpener = mockOpen(read_data=(
dumps(PARAMS) + '\n' + dumps(RECORD0) + '\n' +
dumps(RECORD1) + '\n' + dumps(RECORD2) + '\n' +
dumps(RECORD3) + '\n'))
with patch.object(builtins, 'open', mockOpener):
reads = Reads()
reads.add(Read('id0', 'A' * 70))
reads.add(Read('id1', 'A' * 70))
reads.add(Read('id2', 'A' * 70))
reads.add(Read('id3', 'A' * 70))
readsAlignments = DiamondReadsAlignments(
reads, 'file.json', 'database.fasta',
scoreClass=LowerIsBetterScore)
titlesAlignments = TitlesAlignments(readsAlignments)
result = titlesAlignments.filter(withScoreBetterThan=1e-10)
self.assertEqual(
[
'gi|887699|gb|DQ37780 Squirrelpox virus 1296/99',
],
list(result.keys()))
示例8: testMaxTitlesZero
# 需要导入模块: from dark.titles import TitlesAlignments [as 别名]
# 或者: from dark.titles.TitlesAlignments import filter [as 别名]
def testMaxTitlesZero(self):
"""
The filter function must return an empty result when maxTitles is zero.
"""
mockOpener = mockOpen(read_data=(
dumps(PARAMS) + '\n' + dumps(RECORD0) + '\n' +
dumps(RECORD1) + '\n' + dumps(RECORD2) + '\n' +
dumps(RECORD3) + '\n'))
with patch.object(builtins, 'open', mockOpener):
reads = Reads()
reads.add(Read('id0', 'A' * 70))
reads.add(Read('id1', 'A' * 70))
reads.add(Read('id2', 'A' * 70))
reads.add(Read('id3', 'A' * 70))
readsAlignments = BlastReadsAlignments(reads, 'file.json')
titlesAlignments = TitlesAlignments(readsAlignments)
result = titlesAlignments.filter(maxTitles=0, sortOn='maxScore')
self.assertEqual(0, len(result))
示例9: testCoverageExcludesAll
# 需要导入模块: from dark.titles import TitlesAlignments [as 别名]
# 或者: from dark.titles.TitlesAlignments import filter [as 别名]
def testCoverageExcludesAll(self):
"""
The coverage function must return an titlesAlignments instance with
no titles if none of its titles has sufficient coverage.
"""
mockOpener = mockOpen(read_data=(
dumps(PARAMS) + '\n' + dumps(RECORD0) + '\n' +
dumps(RECORD1) + '\n' + dumps(RECORD2) + '\n' +
dumps(RECORD3) + '\n'))
with patch.object(builtins, 'open', mockOpener):
reads = Reads()
reads.add(Read('id0', 'A' * 70))
reads.add(Read('id1', 'A' * 70))
reads.add(Read('id2', 'A' * 70))
reads.add(Read('id3', 'A' * 70))
readsAlignments = BlastReadsAlignments(reads, 'file.json')
titlesAlignments = TitlesAlignments(readsAlignments)
result = titlesAlignments.filter(minCoverage=0.1)
self.assertEqual(0, len(result))
示例10: testReadSetFilterStrict
# 需要导入模块: from dark.titles import TitlesAlignments [as 别名]
# 或者: from dark.titles.TitlesAlignments import filter [as 别名]
def testReadSetFilterStrict(self):
"""
The filter function work correctly when passed a 1.0 value for
minNewReads.
"""
mockOpener = mockOpen(read_data=(
dumps(PARAMS) + '\n' + dumps(RECORD0) + '\n' +
dumps(RECORD1) + '\n' + dumps(RECORD2) + '\n' +
dumps(RECORD3) + '\n'))
with patch.object(builtins, 'open', mockOpener):
reads = Reads()
reads.add(Read('id0', 'A' * 70))
reads.add(Read('id1', 'A' * 70))
reads.add(Read('id2', 'A' * 70))
reads.add(Read('id3', 'A' * 70))
readsAlignments = DiamondReadsAlignments(reads, 'file.json',
'database.fasta')
titlesAlignments = TitlesAlignments(readsAlignments)
result = titlesAlignments.filter(minNewReads=1.0)
# Either 'gi|887699|gb|DQ37780 Mummypox virus 3000 B.C.'
# invalidates 'gi|887699|gb|DQ37780 Monkeypox virus 456' or
# vice-versa. It depends on Python's dict walking order. Check
# for both, making sure just one of them is true.
mummypox = 'gi|887699|gb|DQ37780 Mummypox virus 3000 B.C.'
monkeypox = 'gi|887699|gb|DQ37780 Monkeypox virus 456'
assertionCount = 0
if mummypox in result:
self.assertTrue(monkeypox in
result.readSetFilter.invalidates(mummypox))
assertionCount += 1
if monkeypox in result:
self.assertTrue(mummypox in
result.readSetFilter.invalidates(monkeypox))
assertionCount += 1
self.assertEqual(1, assertionCount)
示例11: testMaxTitlesOne
# 需要导入模块: from dark.titles import TitlesAlignments [as 别名]
# 或者: from dark.titles.TitlesAlignments import filter [as 别名]
def testMaxTitlesOne(self):
"""
The filter function must return just the best title when maxTitles
is one.
"""
mockOpener = mockOpen(read_data=(
dumps(PARAMS) + '\n' + dumps(RECORD0) + '\n' +
dumps(RECORD1) + '\n' + dumps(RECORD2) + '\n' +
dumps(RECORD3) + '\n'))
with patch.object(builtins, 'open', mockOpener):
reads = Reads()
reads.add(Read('id0', 'A' * 70))
reads.add(Read('id1', 'A' * 70))
reads.add(Read('id2', 'A' * 70))
reads.add(Read('id3', 'A' * 70))
readsAlignments = BlastReadsAlignments(reads, 'file.json')
titlesAlignments = TitlesAlignments(readsAlignments)
result = titlesAlignments.filter(maxTitles=1, sortOn='maxScore')
self.assertEqual(
[
'gi|887699|gb|DQ37780 Squirrelpox virus 55',
],
sorted(result.keys()))
示例12: testWithScoreBetterThan_Bits
# 需要导入模块: from dark.titles import TitlesAlignments [as 别名]
# 或者: from dark.titles.TitlesAlignments import filter [as 别名]
def testWithScoreBetterThan_Bits(self):
"""
The filter function work correctly when passed a value for
withScoreBetterThan when using bit scores.
"""
mockOpener = mockOpen(read_data=(
dumps(PARAMS) + '\n' + dumps(RECORD0) + '\n' +
dumps(RECORD1) + '\n' + dumps(RECORD2) + '\n' +
dumps(RECORD3) + '\n'))
with patch.object(builtins, 'open', mockOpener):
reads = Reads()
reads.add(Read('id0', 'A' * 70))
reads.add(Read('id1', 'A' * 70))
reads.add(Read('id2', 'A' * 70))
reads.add(Read('id3', 'A' * 70))
readsAlignments = BlastReadsAlignments(reads, 'file.json')
titlesAlignments = TitlesAlignments(readsAlignments)
result = titlesAlignments.filter(withScoreBetterThan=24)
self.assertEqual(
[
'gi|887699|gb|DQ37780 Squirrelpox virus 55',
],
list(result.keys()))
示例13: testMinMatchingReads
# 需要导入模块: from dark.titles import TitlesAlignments [as 别名]
# 或者: from dark.titles.TitlesAlignments import filter [as 别名]
def testMinMatchingReads(self):
"""
The filter function work correctly when passed a value for
minMatchingReads.
"""
mockOpener = mockOpen(read_data=(
dumps(PARAMS) + '\n' + dumps(RECORD0) + '\n' +
dumps(RECORD1) + '\n' + dumps(RECORD2) + '\n' +
dumps(RECORD3) + '\n'))
with patch.object(builtins, 'open', mockOpener):
reads = Reads()
reads.add(Read('id0', 'A' * 70))
reads.add(Read('id1', 'A' * 70))
reads.add(Read('id2', 'A' * 70))
reads.add(Read('id3', 'A' * 70))
readsAlignments = BlastReadsAlignments(reads, 'file.json')
titlesAlignments = TitlesAlignments(readsAlignments)
result = titlesAlignments.filter(minMatchingReads=2)
self.assertEqual(
[
'gi|887699|gb|DQ37780 Cowpox virus 15',
],
list(result.keys()))
示例14: testMinMedianScore_Bits
# 需要导入模块: from dark.titles import TitlesAlignments [as 别名]
# 或者: from dark.titles.TitlesAlignments import filter [as 别名]
def testMinMedianScore_Bits(self):
"""
The filter function work correctly when passed a value for
minMedianScore when using bit scores.
"""
mockOpener = mockOpen(read_data=(
dumps(PARAMS) + '\n' + dumps(RECORD0) + '\n' +
dumps(RECORD1) + '\n' + dumps(RECORD2) + '\n' +
dumps(RECORD3) + '\n'))
with patch('__builtin__.open', mockOpener, create=True):
reads = Reads()
reads.add(Read('id0', 'A' * 70))
reads.add(Read('id1', 'A' * 70))
reads.add(Read('id2', 'A' * 70))
reads.add(Read('id3', 'A' * 70))
readsAlignments = BlastReadsAlignments(reads, 'file.json')
titlesAlignments = TitlesAlignments(readsAlignments)
result = titlesAlignments.filter(minMedianScore=22)
self.assertEqual(
[
'gi|887699|gb|DQ37780 Squirrelpox virus 55',
],
result.keys())