本文整理汇总了Python中dark.titles.TitlesAlignments类的典型用法代码示例。如果您正苦于以下问题:Python TitlesAlignments类的具体用法?Python TitlesAlignments怎么用?Python TitlesAlignments使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TitlesAlignments类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testReadSetFilterAllowAnything
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()))
示例2: testTabSeparatedSummary
def testTabSeparatedSummary(self):
"""
The summary function must return the correct result.
"""
mockOpener = mockOpen(read_data=(
dumps(PARAMS) + '\n' + dumps(RECORD0) + '\n'))
with patch.object(builtins, 'open', mockOpener):
reads = Reads()
reads.add(Read('id0', 'A' * 70))
readsAlignments = DiamondReadsAlignments(reads, 'f.json', 'db')
titlesAlignments = TitlesAlignments(readsAlignments)
summary = titlesAlignments.tabSeparatedSummary(sortOn='title')
expected = (
'0.000297\t'
'20.000000\t'
'20.000000\t'
'1\t'
'1\t'
'37000\t'
'gi|887699|gb|DQ37780 Squirrelpox virus 1296/99'
'\n'
'0.000289\t'
'25.000000\t'
'25.000000\t'
'1\t'
'1\t'
'38000\t'
'gi|887699|gb|DQ37780 Squirrelpox virus 55')
self.assertEqual(expected, summary)
示例3: testCoverageIncludesSome
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()))
示例4: testCoverageIncludesAll
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()))
示例5: testLength
def testLength(self):
"""
Sorting on sequence length must work, including a secondary sort on
title.
"""
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', scoreClass=LowerIsBetterScore)
titlesAlignments = TitlesAlignments(readsAlignments)
result = titlesAlignments.sortTitles('length')
self.assertEqual([
'gi|887699|gb|DQ37780 Squirrelpox virus 55', # 38000
'gi|887699|gb|DQ37780 Squirrelpox virus 1296/99', # 37000
'gi|887699|gb|DQ37780 Monkeypox virus 456', # 35000
'gi|887699|gb|DQ37780 Mummypox virus 3000 B.C.', # 35000
'gi|887699|gb|DQ37780 Cowpox virus 15', # 30000
], result)
示例6: testMedianScore_Bits
def testMedianScore_Bits(self):
"""
Sorting on median score must work when scores are bit scores,
including a secondary sort on title.
"""
mockOpener = mockOpen(read_data=(
dumps(PARAMS) + '\n' + dumps(RECORD0) + '\n' +
dumps(RECORD1) + '\n' + dumps(RECORD2) + '\n' +
dumps(RECORD3) + '\n' + dumps(RECORD4) + '\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))
reads.add(Read('id4', 'A' * 70))
readsAlignments = BlastReadsAlignments(reads, 'file.json')
titlesAlignments = TitlesAlignments(readsAlignments)
result = titlesAlignments.sortTitles('medianScore')
self.assertEqual([
'gi|887699|gb|DQ37780 Squirrelpox virus 55', # 25
'gi|887699|gb|DQ37780 Monkeypox virus 456', # 20
'gi|887699|gb|DQ37780 Mummypox virus 3000 B.C.', # 20
'gi|887699|gb|DQ37780 Squirrelpox virus 1296/99', # 20
'gi|887699|gb|DQ37780 Cowpox virus 15', # 20
], result)
示例7: testMaxScore_EValue
def testMaxScore_EValue(self):
"""
Sorting on max score must work when scores are e values, including a
secondary sort on title.
"""
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.sortTitles('maxScore')
# self.assertEqual([
# 'gi|887699|gb|DQ37780 Cowpox virus 15', # 1e-6
# 'gi|887699|gb|DQ37780 Mummypox virus 3000 B.C.', # 1e-7
# 'gi|887699|gb|DQ37780 Monkeypox virus 456', # 1e-8
# 'gi|887699|gb|DQ37780 Squirrelpox virus 55', # 1e-10
# 'gi|887699|gb|DQ37780 Squirrelpox virus 1296/99', # 1e-11
# ], result)
self.assertEqual([
'gi|887699|gb|DQ37780 Squirrelpox virus 1296/99', # 1e-11
'gi|887699|gb|DQ37780 Squirrelpox virus 55', # 1e-10
'gi|887699|gb|DQ37780 Monkeypox virus 456', # 1e-8
'gi|887699|gb|DQ37780 Mummypox virus 3000 B.C.', # 1e-7
'gi|887699|gb|DQ37780 Cowpox virus 15', # 1e-6
], result)
示例8: testMedianScore_EValue
def testMedianScore_EValue(self):
"""
Sorting on median score must work when scores are bit scores,
including a secondary sort on title.
"""
mockOpener = mockOpen(read_data=(
dumps(PARAMS) + '\n' + dumps(RECORD0) + '\n' +
dumps(RECORD1) + '\n' + dumps(RECORD2) + '\n' +
dumps(RECORD3) + '\n' + dumps(RECORD4) + '\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))
reads.add(Read('id4', 'A' * 70))
readsAlignments = BlastReadsAlignments(
reads, 'file.json', scoreClass=LowerIsBetterScore)
titlesAlignments = TitlesAlignments(readsAlignments)
result = titlesAlignments.sortTitles('medianScore')
self.assertEqual([
'gi|887699|gb|DQ37780 Squirrelpox virus 1296/99', # 1e-11
'gi|887699|gb|DQ37780 Squirrelpox virus 55', # 1e-10
'gi|887699|gb|DQ37780 Monkeypox virus 456', # 1e-8
'gi|887699|gb|DQ37780 Mummypox virus 3000 B.C.', # 1e-7
'gi|887699|gb|DQ37780 Cowpox virus 15', # worst :-)
], result)
示例9: testMaxTitlesTwoSortOnLength
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()))
示例10: testTitle
def testTitle(self):
"""
Sorting on title must work.
"""
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.sortTitles('title')
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',
], result)
示例11: testWithScoreBetterThan_EValue
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()))
示例12: testFilterWithNoArguments
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()))
示例13: testMinMedianScore_EValue
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()))
示例14: testSummary
def testSummary(self):
"""
The summary function must return the correct result.
"""
mockOpener = mockOpen(read_data=(
dumps(PARAMS) + '\n' + dumps(RECORD0) + '\n' +
dumps(RECORD1) + '\n'))
with patch.object(builtins, 'open', mockOpener):
reads = Reads()
reads.add(Read('id0', 'A' * 70))
reads.add(Read('id1', 'A' * 70))
readsAlignments = DiamondReadsAlignments(reads, 'file.json',
'database.fasta')
titlesAlignments = TitlesAlignments(readsAlignments)
self.assertEqual(
[
{
'bestScore': 20.0,
'coverage': 0.00031428571428571427,
'hspCount': 1,
'medianScore': 20.0,
'readCount': 1,
'subjectLength': 35000,
'subjectTitle': (
'gi|887699|gb|DQ37780 Monkeypox virus 456'),
},
{
'bestScore': 20.0,
'coverage': 0.00031428571428571427,
'hspCount': 1,
'medianScore': 20.0,
'readCount': 1,
'subjectLength': 35000,
'subjectTitle': (
'gi|887699|gb|DQ37780 Mummypox virus 3000 B.C.'),
},
{
'bestScore': 20.0,
'coverage': 0.0002972972972972973,
'hspCount': 1,
'medianScore': 20.0,
'readCount': 1,
'subjectLength': 37000,
'subjectTitle': (
'gi|887699|gb|DQ37780 Squirrelpox virus 1296/99'),
},
{
'bestScore': 25.0,
'coverage': 0.00028947368421052634,
'hspCount': 1,
'medianScore': 25.0,
'readCount': 1,
'subjectLength': 38000,
'subjectTitle': (
'gi|887699|gb|DQ37780 Squirrelpox virus 55'),
},
],
list(titlesAlignments.summary(sortOn='title')))
示例15: testEmpty
def testEmpty(self):
"""
Sorting when there are no titles must return the empty list.
"""
mockOpener = mockOpen(read_data=dumps(PARAMS) + '\n')
with patch.object(builtins, 'open', mockOpener):
reads = Reads()
readsAlignments = BlastReadsAlignments(reads, 'file.json')
titlesAlignments = TitlesAlignments(readsAlignments)
result = titlesAlignments.sortTitles('title')
self.assertEqual([], result)