Exemple #1
0
    def test_SimpleAlignmentIo_readLines(self, its=50):
        for it in range(its):
            alignment = gen_alignment()
            framePeriod = gen_framePeriod()
            alignmentIo = alio.SimpleAlignmentIo(framePeriod)

            alignmentLines = alignmentIo.writeLines(alignment)
            alignmentAgain = alignmentIo.readLines(alignmentLines)
            self.assertEqual(alignmentAgain, alignment)
Exemple #2
0
    def test_AlignmentIo_writeLines_1_level(self, its=50):
        for it in range(its):
            framePeriod = gen_framePeriod()
            alignment = gen_alignment()
            simpleAlignmentIo = alio.SimpleAlignmentIo(framePeriod)
            alignmentIo = alio.AlignmentIo(framePeriod)

            self.assertEqual(
                simpleAlignmentIo.writeLines(alignment),
                alignmentIo.writeLines(alignment)
            )
Exemple #3
0
    def test_SimpleAlignmentIo_writeLines_concat(self, its=50):
        for it in range(its):
            framePeriod = gen_framePeriod()
            alignmentIo = alio.SimpleAlignmentIo(framePeriod)
            alignment = gen_alignment()
            breakIndex = randint(len(alignment) + 1)
            alignment0 = alignment[:breakIndex]
            alignment1 = alignment[breakIndex:]

            alignmentLines0 = alignmentIo.writeLines(alignment0)
            alignmentLines1 = alignmentIo.writeLines(alignment1)
            alignmentLines = alignmentIo.writeLines(alignment)
            self.assertEqual(alignmentLines0 + alignmentLines1, alignmentLines)
Exemple #4
0
    def test_SimpleAlignmentIo_writeLines_single_line(self, its=50):
        for it in range(its):
            framePeriod = gen_framePeriod()
            alignmentIo = alio.SimpleAlignmentIo(framePeriod)
            startTime = randint(-10, 11)
            dur = randint(10)
            endTime = startTime + dur
            label = gen_label()
            alignment = [(startTime, endTime, label, None)]

            alignmentLines = alignmentIo.writeLines(alignment)

            startTicks = int(round(startTime * framePeriod * 1e7))
            endTicks = int(round(endTime * framePeriod * 1e7))
            alignmentLinesGood = ['%s %s %s' % (startTicks, endTicks, label)]
            self.assertEqual(alignmentLines, alignmentLinesGood)
Exemple #5
0
 def test_SimpleAlignmentIo_writeLines_empty(self):
     framePeriod = gen_framePeriod()
     alignmentIo = alio.SimpleAlignmentIo(framePeriod)
     self.assertEqual(alignmentIo.writeLines([]), [])