def testToDict(self): """ The toDict method must return the expected dictionary. """ lsp = LSP(0, readStart=1, readEnd=2, readStartInSubject=3, readEndInSubject=4, subjectStart=5, subjectEnd=6, readMatchedSequence='aaa', subjectMatchedSequence='ccc', readFrame=7, subjectFrame=8, identicalCount=9, positiveCount=10) self.assertEqual( { 'score': 0, 'readStart': 1, 'readEnd': 2, 'readStartInSubject': 3, 'readEndInSubject': 4, 'subjectStart': 5, 'subjectEnd': 6, 'readFrame': 7, 'subjectFrame': 8, 'identicalCount': 9, 'positiveCount': 10, 'readMatchedSequence': 'aaa', 'subjectMatchedSequence': 'ccc', }, lsp.toDict())
def testOneAlignment(self): """ When one alignment is present that alignment must be returned by bestAlignment. """ alignment = Alignment(44, 'Seq 1') alignment.addHsp(LSP(10)) alignment.addHsp(LSP(9)) alignments = [alignment] readAlignments = ReadAlignments(Read('id0', 'aaa'), alignments) best = bestAlignment(readAlignments) self.assertEqual('Seq 1', best.subjectTitle) self.assertEqual(44, best.subjectLength)
def testExpectedAttributes(self): """ An LSP must have the expected attributes. """ lsp = LSP(7, readStart=1, readEnd=2, readStartInSubject=3, readEndInSubject=4, subjectStart=5, subjectEnd=6, readMatchedSequence='aaa', subjectMatchedSequence='ccc', readFrame=8, subjectFrame=9) self.assertEqual(1, lsp.readStart) self.assertEqual(2, lsp.readEnd) self.assertEqual(3, lsp.readStartInSubject) self.assertEqual(4, lsp.readEndInSubject) self.assertEqual(5, lsp.subjectStart) self.assertEqual(6, lsp.subjectEnd) self.assertEqual('aaa', lsp.readMatchedSequence) self.assertEqual('ccc', lsp.subjectMatchedSequence) self.assertEqual(7, lsp.score.score) self.assertEqual(8, lsp.readFrame) self.assertEqual(9, lsp.subjectFrame)
def testReadIds(self): """ The readIds function must return the set of read ids for the alignments matching a title. """ hsp1 = LSP(7) hsp2 = LSP(15) hsp3 = LSP(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(set(['id1', 'id2']), titleAlignments.readIds())
def testBetterThanTrue(self): """ The hasScoreBetterThan function must return True if there is an HSP with a score better than the passed value. """ hsp1 = LSP(7) hsp2 = LSP(15) hsp3 = LSP(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.assertTrue(titleAlignments.hasScoreBetterThan(9))
def testWorstHsp(self): """ The worstHsp function must return the HSP with the worst score for all the HSPs for all the alignments matching a title. """ hsp1 = LSP(7) hsp2 = LSP(15) hsp3 = LSP(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(hsp3, titleAlignments.worstHsp())
def testThreeAlignments(self): """ When three alignments are present, the one with the lowest first HSP must be returned by bestAlignment. """ alignment1 = Alignment(33, 'Seq 1') alignment1.addHsp(LSP(10)) alignment1.addHsp(LSP(9)) alignment2 = Alignment(44, 'Seq 2') alignment2.addHsp(LSP(3)) alignment2.addHsp(LSP(2)) alignment3 = Alignment(55, 'Seq 3') alignment3.addHsp(LSP(20)) alignment3.addHsp(LSP(19)) alignments = [alignment1, alignment2, alignment3] readAlignments = ReadAlignments(Read('id0', 'aaa'), alignments) best = bestAlignment(readAlignments) self.assertEqual('Seq 2', best.subjectTitle) self.assertEqual(44, best.subjectLength)
def testBetterThanFalse(self): """ Two LSP scores must compare properly with betterThan if the passed score is better than the score of the LSP. """ self.assertFalse(LSP(7).betterThan(5))
def testBetterThanTrue(self): """ Two LSP scores must compare properly with betterThan if the passed score is worse than the score of the LSP. """ self.assertTrue(LSP(5).betterThan(7))
def testLt(self): """ Two LSPs must compare properly with < """ self.assertTrue(LSP(8) < LSP(7))
def testEqual(self): """ Two LSPs must compare properly with == """ self.assertEqual(LSP(7), LSP(7))