def testFastaReadWriteC(self): """Tests consistency with C version of this function. """ tempFile = getTempFile() self.tempFiles.append(tempFile) tempFile2 = getTempFile() self.tempFiles.append(tempFile2) for test in xrange(0, self.testNo): fastaNumber = random.choice(xrange(10)) l = [ getRandomSequence() for i in xrange(fastaNumber) ] fileHandle = open(tempFile, 'w') for name, seq in l: fastaWrite(fileHandle, name, seq) fileHandle.close() command = "sonLib_fastaCTest %s %s" % (tempFile, tempFile2) print command system(command) fileHandle = open(tempFile2, 'r') l.reverse() for i in fastaRead(fileHandle): name, seq = i assert i == l.pop() fastaWrite(sys.stdout, name, seq) fileHandle.close()
def testFastaReadWrite(self): tempFile = getTempFile() self.tempFiles.append(tempFile) for test in xrange(0, self.testNo): fastaNumber = random.choice(xrange(10)) l = [ getRandomSequence() for i in xrange(fastaNumber) ] fileHandle = open(tempFile, 'w') for name, seq in l: fastaWrite(fileHandle, name, seq) fileHandle.close() fileHandle = open(tempFile, 'r') l.reverse() for i in fastaRead(fileHandle): assert i == l.pop() name, seq = i fastaWrite(sys.stdout, name, seq) fileHandle.close()
def testFastqReadWrite(self): tempFile = getTempFile() self.tempFiles.append(tempFile) for test in xrange(0, self.testNo): fastaNumber = random.choice(xrange(10)) fastqs = [ (name, seq, [ random.randint(33, 126) for i in range(len(seq)) ]) for name, seq in [ getRandomSequence() for i in xrange(fastaNumber) ]] fH = open(tempFile, 'w') for name, seq, quals in fastqs: fastqWrite(fH, name, seq, quals) fH.close() fastqs.reverse() for i in fastqRead(tempFile): assert i == fastqs.pop() name, seq, quals = i fastqWrite(sys.stdout, name, seq, quals)