本文整理汇总了Python中dark.reads.Reads类的典型用法代码示例。如果您正苦于以下问题:Python Reads类的具体用法?Python Reads怎么用?Python Reads使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Reads类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: 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)
示例2: testExpectedTitleDetails
def testExpectedTitleDetails(self):
"""
An instance of TitleAlignments in a TitlesAlignments instance must
have the expected attributes.
"""
mockOpener = mockOpen(read_data=(
dumps(PARAMS) + '\n' + dumps(RECORD0) + '\n'))
with patch.object(builtins, 'open', mockOpener):
reads = Reads()
read = Read('id0', 'A' * 70)
reads.add(read)
readsAlignments = BlastReadsAlignments(reads, 'file.json')
titlesAlignments = TitlesAlignments(readsAlignments)
title = 'gi|887699|gb|DQ37780 Squirrelpox virus 1296/99'
titleAlignments = titlesAlignments[title]
self.assertEqual(title, titleAlignments.subjectTitle)
self.assertEqual(37000, titleAlignments.subjectLength)
self.assertEqual(1, len(titleAlignments))
self.assertEqual(read, titleAlignments[0].read)
self.assertEqual(HSP(20), titleAlignments[0].hsps[0])
title = 'gi|887699|gb|DQ37780 Squirrelpox virus 55'
titleAlignments = titlesAlignments[title]
self.assertEqual(title, titleAlignments.subjectTitle)
self.assertEqual(38000, titleAlignments.subjectLength)
self.assertEqual(1, len(titleAlignments))
self.assertEqual(read, titleAlignments[0].read)
self.assertEqual(HSP(25), titleAlignments[0].hsps[0])
示例3: testMaxScore_Bits
def testMaxScore_Bits(self):
"""
Sorting on max 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'))
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.sortTitles('maxScore')
self.assertEqual([
'gi|887699|gb|DQ37780 Squirrelpox virus 55', # 25
'gi|887699|gb|DQ37780 Cowpox virus 15', # 20
'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
], result)
示例4: 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)
示例5: 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()))
示例6: 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()))
示例7: 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)
示例8: testLengthOne
def testLengthOne(self):
"""
A FASTA list with just one item gets de-duped to the same one item.
"""
reads = Reads()
reads.add(Read('id', 'GGG'))
self.assertEqual(list(dedupFasta(reads)), [Read('id', 'GGG')])
示例9: add
def add(self, virusTitle, sampleName):
"""
Add a a virus title, sample name combination and get its FASTA file
name. Write the FASTA file if it does not already exist.
@param virusTitle: A C{str} virus title.
@param sampleName: A C{str} sample name.
@return: A C{str} FASTA file name holding all the reads (without
duplicates) from the sample that matched the proteins in the given
virus.
"""
virusIndex = self._viruses.setdefault(virusTitle, len(self._viruses))
sampleIndex = self._samples.setdefault(sampleName, len(self._samples))
try:
return self._fastaFilenames[(virusIndex, sampleIndex)]
except KeyError:
result = Reads()
for proteinMatch in self._proteinGrouper.virusTitles[
virusTitle][sampleName]:
for read in FastaReads(proteinMatch['fastaFilename'],
checkAlphabet=0):
result.add(read)
saveFilename = join(
proteinMatch['outDir'],
'virus-%d-sample-%d.fasta' % (virusIndex, sampleIndex))
result.filter(removeDuplicates=True).save(saveFilename)
self._fastaFilenames[(virusIndex, sampleIndex)] = saveFilename
return saveFilename
示例10: testTitleCollection
def testTitleCollection(self):
"""
A title that occurs in the alignments of multiple reads must have
the data from both reads collected properly.
"""
mockOpener = mockOpen(read_data=(
dumps(PARAMS) + '\n' + dumps(RECORD2) + '\n' +
dumps(RECORD3) + '\n'))
with patch.object(builtins, 'open', mockOpener):
reads = Reads()
read2 = Read('id2', 'A' * 70)
read3 = Read('id3', 'A' * 70)
reads.add(read2)
reads.add(read3)
readsAlignments = BlastReadsAlignments(reads, 'file.json')
titlesAlignments = TitlesAlignments(readsAlignments)
title = 'gi|887699|gb|DQ37780 Cowpox virus 15'
titleAlignments = titlesAlignments[title]
self.assertEqual(title, titleAlignments.subjectTitle)
self.assertEqual(30000, titleAlignments.subjectLength)
self.assertEqual(2, len(titleAlignments))
self.assertEqual(read2, titleAlignments[0].read)
self.assertEqual(HSP(20), titleAlignments[0].hsps[0])
self.assertEqual(read3, titleAlignments[1].read)
self.assertEqual(HSP(20), titleAlignments[1].hsps[0])
示例11: 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()))
示例12: 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)
示例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: 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()))
示例15: 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()))