Example #1
0
 def testCigarReadWrite(self):
     tempFile = getTempFile()
     self.tempFiles.append(tempFile)
     for test in xrange(0, self.testNo):
         cigarNumber = random.choice(xrange(10))
         l = [ getRandomPairwiseAlignment() for i in xrange(cigarNumber) ]
         fileHandle = open(tempFile, 'w')
         for cigar in l:
             cigarWrite(fileHandle, cigar)
         fileHandle.close()
         fileHandle = open(tempFile, 'r')
         l.reverse()
         for cigar in cigarRead(fileHandle):
             cigarWrite(sys.stdout, l[-1])
             cigarWrite(sys.stdout, cigar)
             assert cigar == l.pop()
         assert len(l) == 0
         fileHandle.close()
Example #2
0
    def testCigarReadWrite(self):
        """Tests the C code for reading and writing cigars against the python parser for cigars.
        """
        tempFile = getTempFile()
        self.tempFiles.append(tempFile)
        for test in xrange(0, self.testNo):
            pairwiseAlignmentNumber = random.choice(xrange(10))
            l = [
                getRandomPairwiseAlignment()
                for i in xrange(pairwiseAlignmentNumber)
            ]
            fileHandle = open(tempFile, 'w')

            keepProbs = random.random() > 0.5
            if keepProbs == False:
                for pA in l:
                    for op in pA.operationList:
                        op.score = 0.0

            for pairwiseAlignment in l:
                cigarWrite(fileHandle, pairwiseAlignment, keepProbs)
            fileHandle.close()

            #Now call sonLib_cigarsTest and read and write chains
            command = "sonLib_cigarTest %s %s" % (tempFile, keepProbs)
            #return
            system(command)

            #Now check the chain is okay
            fileHandle = open(tempFile, 'r')
            l.reverse()

            for pairwiseAlignment in cigarRead(fileHandle):
                pairwiseAlignment2 = l.pop()
                cigarWrite(sys.stdout, pairwiseAlignment, keepProbs)
                cigarWrite(sys.stdout, pairwiseAlignment2, keepProbs)
                assert pairwiseAlignment == pairwiseAlignment2
            assert len(l) == 0
            fileHandle.close()
Example #3
0
    def testCigarReadWrite(self):
        """Tests the C code for reading and writing cigars against the python parser for cigars.
        """
        tempFile = getTempFile()
        self.tempFiles.append(tempFile)
        for test in xrange(0, self.testNo):
            pairwiseAlignmentNumber = random.choice(xrange(10))
            l = [ getRandomPairwiseAlignment() for i in xrange(pairwiseAlignmentNumber) ]
            fileHandle = open(tempFile, 'w')
            
            keepProbs = random.random() > 0.5
            if keepProbs == False:
                for pA in l:
                    for op in pA.operationList:
                        op.score = 0.0
            
            for pairwiseAlignment in l:
                cigarWrite(fileHandle, pairwiseAlignment, keepProbs)
            fileHandle.close()

            #Now call sonLib_cigarsTest and read and write chains
            command = "sonLib_cigarTest %s %s" % (tempFile, keepProbs)
            #return
            system(command)
            
            #Now check the chain is okay
            fileHandle = open(tempFile, 'r')
            l.reverse()
            
            for pairwiseAlignment in cigarRead(fileHandle):
                pairwiseAlignment2 = l.pop()
                cigarWrite(sys.stdout, pairwiseAlignment, keepProbs)
                cigarWrite(sys.stdout, pairwiseAlignment2, keepProbs)
                assert pairwiseAlignment == pairwiseAlignment2
            assert len(l) == 0
            fileHandle.close()