本文整理汇总了Python中dark.titles.TitleAlignments.addAlignment方法的典型用法代码示例。如果您正苦于以下问题:Python TitleAlignments.addAlignment方法的具体用法?Python TitleAlignments.addAlignment怎么用?Python TitleAlignments.addAlignment使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dark.titles.TitleAlignments
的用法示例。
在下文中一共展示了TitleAlignments.addAlignment方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testResidueCountsOneReadTwoHSPsNotOverlapping
# 需要导入模块: from dark.titles import TitleAlignments [as 别名]
# 或者: from dark.titles.TitleAlignments import addAlignment [as 别名]
def testResidueCountsOneReadTwoHSPsNotOverlapping(self):
"""
The residueCounts method must return the correct result when just one
read with two HSPs is aligned to a title and the HSPs do not overlap
one another.
HSP1: ACGT
HSP2: CGTT
"""
read = Read('id', 'ACGT')
hsp1 = HSP(33, readStart=0, readEnd=4, readStartInSubject=0,
readEndInSubject=4, subjectStart=0, subjectEnd=4,
readMatchedSequence='ACGT', subjectMatchedSequence='ACGT')
hsp2 = HSP(33, readStart=0, readEnd=4, readStartInSubject=10,
readEndInSubject=14, subjectStart=10, subjectEnd=14,
readMatchedSequence='CGTT', subjectMatchedSequence='CGTT')
titleAlignments = TitleAlignments('subject title', 55)
titleAlignment = TitleAlignment(read, [hsp1, hsp2])
titleAlignments.addAlignment(titleAlignment)
self.assertEqual(
{
0: {'A': 1},
1: {'C': 1},
2: {'G': 1},
3: {'T': 1},
10: {'C': 1},
11: {'G': 1},
12: {'T': 1},
13: {'T': 1},
},
titleAlignments.residueCounts())
示例2: testSummary
# 需要导入模块: from dark.titles import TitleAlignments [as 别名]
# 或者: from dark.titles.TitleAlignments import addAlignment [as 别名]
def testSummary(self):
"""
The summary method must return the correct result.
"""
titleAlignments = TitleAlignments('subject title', 10)
titleAlignments.addAlignment(
TitleAlignment(Read('id1', 'ACGT'), [
HSP(30, subjectStart=0, subjectEnd=2),
]))
titleAlignments.addAlignment(
TitleAlignment(Read('id2', 'ACGT'), [
HSP(55, subjectStart=2, subjectEnd=4),
HSP(40, subjectStart=8, subjectEnd=9),
]))
self.assertEqual(
{
'bestScore': 55,
'coverage': 0.5,
'hspCount': 3,
'medianScore': 40,
'readCount': 2,
'subjectLength': 10,
'subjectTitle': 'subject title',
},
titleAlignments.summary())
示例3: testResidueCountsCaseConvertUpperIsDefault
# 需要导入模块: from dark.titles import TitleAlignments [as 别名]
# 或者: from dark.titles.TitleAlignments import addAlignment [as 别名]
def testResidueCountsCaseConvertUpperIsDefault(self):
"""
The residueCounts method must convert to uppercase by default.
HSP1: AcgT
HSP2: CGTT
"""
read = Read('id', 'ACGT')
hsp1 = HSP(33, readStart=0, readEnd=4, readStartInSubject=10,
readEndInSubject=14, subjectStart=10, subjectEnd=14,
readMatchedSequence='AcgT', subjectMatchedSequence='ACGT')
hsp2 = HSP(33, readStart=0, readEnd=4, readStartInSubject=11,
readEndInSubject=15, subjectStart=11, subjectEnd=15,
readMatchedSequence='CGTT', subjectMatchedSequence='CGTT')
titleAlignments = TitleAlignments('subject title', 55)
titleAlignment = TitleAlignment(read, [hsp1, hsp2])
titleAlignments.addAlignment(titleAlignment)
self.assertEqual(
{
10: {'A': 1},
11: {'C': 2},
12: {'G': 2},
13: {'T': 2},
14: {'T': 1},
},
titleAlignments.residueCounts())
示例4: testResidueCountsOneReadTwoHSPsNotAtStartOfSubject
# 需要导入模块: from dark.titles import TitleAlignments [as 别名]
# 或者: from dark.titles.TitleAlignments import addAlignment [as 别名]
def testResidueCountsOneReadTwoHSPsNotAtStartOfSubject(self):
"""
The residueCounts method must return the correct result when just one
read with two HSPs is aligned to a title and the leftmost HSP is not
aligned with the left edge of the subject.
HSP1: ACGT
HSP2: CGTT
"""
read = Read('id', 'ACGT')
hsp1 = HSP(33, readStart=0, readEnd=4, readStartInSubject=10,
readEndInSubject=14, subjectStart=10, subjectEnd=14,
readMatchedSequence='ACGT', subjectMatchedSequence='ACGT')
hsp2 = HSP(33, readStart=0, readEnd=4, readStartInSubject=11,
readEndInSubject=15, subjectStart=11, subjectEnd=15,
readMatchedSequence='CGTT', subjectMatchedSequence='CGTT')
titleAlignments = TitleAlignments('subject title', 55)
titleAlignment = TitleAlignment(read, [hsp1, hsp2])
titleAlignments.addAlignment(titleAlignment)
self.assertEqual(
{
10: {'A': 1},
11: {'C': 2},
12: {'G': 2},
13: {'T': 2},
14: {'T': 1},
},
titleAlignments.residueCounts())
示例5: testResidueCountsTwoReadsTwoHSPsLeftOverhang
# 需要导入模块: from dark.titles import TitleAlignments [as 别名]
# 或者: from dark.titles.TitleAlignments import addAlignment [as 别名]
def testResidueCountsTwoReadsTwoHSPsLeftOverhang(self):
"""
The residueCounts method must return the correct result when two
reads, each with one HSP are aligned to a title and the leftmost HSP
is aligned before the left edge of the subject (i.e, will include
negative subject offsets).
Subject: GTT
HSP1: ACGT
HSP2: CGTT
"""
read1 = Read('id', 'ACGT')
hsp1 = HSP(33, readStart=0, readEnd=4, readStartInSubject=-2,
readEndInSubject=2, subjectStart=0, subjectEnd=2,
readMatchedSequence='GT', subjectMatchedSequence='GT')
read2 = Read('id', 'CGTT')
hsp2 = HSP(33, readStart=0, readEnd=4, readStartInSubject=-1,
readEndInSubject=3, subjectStart=0, subjectEnd=3,
readMatchedSequence='GTT', subjectMatchedSequence='GTT')
titleAlignments = TitleAlignments('subject title', 55)
titleAlignment = TitleAlignment(read1, [hsp1])
titleAlignments.addAlignment(titleAlignment)
titleAlignment = TitleAlignment(read2, [hsp2])
titleAlignments.addAlignment(titleAlignment)
self.assertEqual(
{
-2: {'A': 1},
-1: {'C': 2},
0: {'G': 2},
1: {'T': 2},
2: {'T': 1},
},
titleAlignments.residueCounts())
示例6: testResidueCountsCaseConvertLower
# 需要导入模块: from dark.titles import TitleAlignments [as 别名]
# 或者: from dark.titles.TitleAlignments import addAlignment [as 别名]
def testResidueCountsCaseConvertLower(self):
"""
The residueCounts method must return the correct result when asked to
convert residues to lower case.
HSP1: AcgT
HSP2: CGTT
"""
read = Read('id', 'ACGT')
hsp1 = HSP(33, readStart=0, readEnd=4, readStartInSubject=10,
readEndInSubject=14, subjectStart=10, subjectEnd=14,
readMatchedSequence='AcgT', subjectMatchedSequence='ACGT')
hsp2 = HSP(33, readStart=0, readEnd=4, readStartInSubject=11,
readEndInSubject=15, subjectStart=11, subjectEnd=15,
readMatchedSequence='CGTT', subjectMatchedSequence='CGTT')
titleAlignments = TitleAlignments('subject title', 55)
titleAlignment = TitleAlignment(read, [hsp1, hsp2])
titleAlignments.addAlignment(titleAlignment)
self.assertEqual(
{
10: {'a': 1},
11: {'c': 2},
12: {'g': 2},
13: {'t': 2},
14: {'t': 1},
},
titleAlignments.residueCounts(convertCaseTo='lower'))
示例7: testAddAlignment
# 需要导入模块: from dark.titles import TitleAlignments [as 别名]
# 或者: from dark.titles.TitleAlignments import addAlignment [as 别名]
def testAddAlignment(self):
"""
It must be possible to add an alignment to an instance of
TitleAlignments.
"""
titleAlignments = TitleAlignments('subject title', 55)
read = Read('id', 'AAA')
titleAlignment = TitleAlignment(read, [])
titleAlignments.addAlignment(titleAlignment)
self.assertEqual(read, titleAlignments[0].read)
self.assertEqual([], titleAlignments[0].hsps)
示例8: testMedianScoreWithNoHsps
# 需要导入模块: from dark.titles import TitleAlignments [as 别名]
# 或者: from dark.titles.TitleAlignments import addAlignment [as 别名]
def testMedianScoreWithNoHsps(self):
"""
The medianScore function must raise ValueError if there are no HSPs.
"""
titleAlignments = TitleAlignments('subject title', 55)
read = Read('id1', 'AAA')
titleAlignment = TitleAlignment(read, [])
titleAlignments.addAlignment(titleAlignment)
error = '^arg is an empty sequence$'
six.assertRaisesRegex(self, ValueError, error,
titleAlignments.medianScore)
示例9: testMedianScoreOfTwo
# 需要导入模块: from dark.titles import TitleAlignments [as 别名]
# 或者: from dark.titles.TitleAlignments import addAlignment [as 别名]
def testMedianScoreOfTwo(self):
"""
The medianScore function must return the median score for the HSPs in
all the alignments matching a title when given 2 scores.
"""
hsp1 = HSP(7)
hsp2 = HSP(15)
titleAlignments = TitleAlignments('subject title', 55)
read = Read('id1', 'AAA')
titleAlignment = TitleAlignment(read, [hsp1, hsp2])
titleAlignments.addAlignment(titleAlignment)
self.assertEqual(11, titleAlignments.medianScore())
示例10: testFullCoverage
# 需要导入模块: from dark.titles import TitleAlignments [as 别名]
# 或者: from dark.titles.TitleAlignments import addAlignment [as 别名]
def testFullCoverage(self):
"""
The coverage method must return the correct value when the title is
fully covered by its reads.
"""
hsp1 = HSP(7, subjectStart=0, subjectEnd=50)
hsp2 = HSP(8, subjectStart=50, subjectEnd=100)
titleAlignments = TitleAlignments('subject title', 100)
read = Read('id1', 'AAA')
titleAlignment = TitleAlignment(read, [hsp1, hsp2])
titleAlignments.addAlignment(titleAlignment)
self.assertEqual(1.0, titleAlignments.coverage())
示例11: makeTitleAlignments
# 需要导入模块: from dark.titles import TitleAlignments [as 别名]
# 或者: from dark.titles.TitleAlignments import addAlignment [as 别名]
def makeTitleAlignments(self, *readIds):
"""
Create a TitleAlignments instance containing reads with the
ids given by C{ids}.
param readIds: A C{list} of integer ids for reads.
@return: A C{TitleAlignments} instance with reads with the given ids.
"""
titleAlignments = TitleAlignments("subject title", 55)
for readId in readIds:
titleAlignment = TitleAlignment(Read("id" + str(readId), "A"), [])
titleAlignments.addAlignment(titleAlignment)
return titleAlignments
示例12: testFullCoverageCounts
# 需要导入模块: from dark.titles import TitleAlignments [as 别名]
# 或者: from dark.titles.TitleAlignments import addAlignment [as 别名]
def testFullCoverageCounts(self):
"""
The coverageCounts method must return the correct result when the title
is fully covered by its reads.
"""
hsp1 = HSP(7, subjectStart=0, subjectEnd=5)
hsp2 = HSP(8, subjectStart=5, subjectEnd=10)
titleAlignments = TitleAlignments('subject title', 10)
read = Read('id1', 'AAA')
titleAlignment = TitleAlignment(read, [hsp1, hsp2])
titleAlignments.addAlignment(titleAlignment)
c = Counter([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
self.assertEqual(c, titleAlignments.coverageCounts())
示例13: testReadCount
# 需要导入模块: from dark.titles import TitleAlignments [as 别名]
# 或者: from dark.titles.TitleAlignments import addAlignment [as 别名]
def testReadCount(self):
"""
The readCount function must indicate how many reads matched a title.
"""
hsp1 = HSP(7)
hsp2 = HSP(14)
hsp3 = HSP(21)
titleAlignments = TitleAlignments('subject title', 55)
read = Read('id1', 'AAA')
titleAlignment = TitleAlignment(read, [hsp1, hsp2])
titleAlignments.addAlignment(titleAlignment)
read = Read('id2', 'AAA')
titleAlignment = TitleAlignment(read, [hsp3])
titleAlignments.addAlignment(titleAlignment)
self.assertEqual(2, titleAlignments.readCount())
示例14: testHSPs
# 需要导入模块: from dark.titles import TitleAlignments [as 别名]
# 或者: from dark.titles.TitleAlignments import addAlignment [as 别名]
def testHSPs(self):
"""
The hsps function must produce a list of all HSPs.
"""
hsp1 = HSP(7)
hsp2 = HSP(14)
hsp3 = HSP(21)
titleAlignments = TitleAlignments("subject title", 55)
read = Read("id1", "AAA")
titleAlignment = TitleAlignment(read, [hsp1, hsp2])
titleAlignments.addAlignment(titleAlignment)
read = Read("id2", "AAA")
titleAlignment = TitleAlignment(read, [hsp3])
titleAlignments.addAlignment(titleAlignment)
self.assertEqual([7, 14, 21], [hsp.score.score for hsp in titleAlignments.hsps()])
示例15: testPartialCoverage
# 需要导入模块: from dark.titles import TitleAlignments [as 别名]
# 或者: from dark.titles.TitleAlignments import addAlignment [as 别名]
def testPartialCoverage(self):
"""
The coverage method must return the correct value when the title is
partially covered by its reads.
"""
hsp1 = HSP(7, subjectStart=10, subjectEnd=20)
hsp2 = HSP(15, subjectStart=30, subjectEnd=40)
hsp3 = HSP(21, subjectStart=50, subjectEnd=60)
titleAlignments = TitleAlignments('subject title', 100)
read = Read('id1', 'AAA')
titleAlignment = TitleAlignment(read, [hsp1, hsp2])
titleAlignments.addAlignment(titleAlignment)
read = Read('id2', 'AAA')
titleAlignment = TitleAlignment(read, [hsp3])
titleAlignments.addAlignment(titleAlignment)
self.assertEqual(0.3, titleAlignments.coverage())