def test_coalescences_memoryTest(self): """Test that valgrind doesn't catch any memory errors when running mafPhyloComparator in coalescence mode.""" valgrind = mtt.which('valgrind') if valgrind is None: return mtt.makeTempDirParent() tmpDir = os.path.abspath(mtt.makeTempDir("coalescencesMem")) # only leaves for i, (maf1, maf2, earlyCoalescences, lateCoalescences, identicalCoalescences) in enumerate(knownValuesOnlyLeaves): testMaf1 = mtt.testFile(os.path.abspath(os.path.join(tmpDir, 'maf1.maf')), maf1, g_headers) testMaf2 = mtt.testFile(os.path.abspath(os.path.join(tmpDir, 'maf2.maf')), maf2, g_headers) parent = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) cmd = mtt.genericValgrind(tmpDir) cmd += [os.path.abspath(os.path.join(parent, 'test', 'mafPhyloComparator')), '--mafFile1', os.path.abspath(os.path.join(tmpDir, 'maf1.maf')), '--mafFile2', os.path.abspath(os.path.join(tmpDir, 'maf2.maf')), '--out', os.path.abspath(os.path.join(tmpDir, 'output.xml')), '--numSamples=10000', '--logLevel=critical', "--speciesTree=%s" % g_speciesTree, "--onlyLeaves" ] mtt.recordCommands([cmd], tmpDir) mtt.runCommandsS([cmd], tmpDir) passed = mtt.noMemoryErrors(os.path.join(tmpDir, 'valgrind.xml')) self.assertTrue(passed) # with ancestors for i, (maf1, maf2, earlyCoalescences, lateCoalescences, identicalCoalescences) in enumerate(knownValues): testMaf1 = mtt.testFile(os.path.abspath(os.path.join(tmpDir, 'maf1.maf')), maf1, g_headers) testMaf2 = mtt.testFile(os.path.abspath(os.path.join(tmpDir, 'maf2.maf')), maf2, g_headers) parent = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) cmd = mtt.genericValgrind(tmpDir) cmd += [os.path.abspath(os.path.join(parent, 'test', 'mafPhyloComparator')), '--mafFile1', os.path.abspath(os.path.join(tmpDir, 'maf1.maf')), '--mafFile2', os.path.abspath(os.path.join(tmpDir, 'maf2.maf')), '--out', os.path.abspath(os.path.join(tmpDir, 'output.xml')), '--numSamples=10000', '--logLevel=critical', "--speciesTree=%s" % g_speciesTree, ] mtt.recordCommands([cmd], tmpDir) mtt.runCommandsS([cmd], tmpDir) passed = mtt.noMemoryErrors(os.path.join(tmpDir, 'valgrind.xml')) self.assertTrue(passed) mtt.removeDir(tmpDir)
def test_memory_1(self): """ mafComparator should be memory clean for seed testing examples """ valgrind = mtt.which('valgrind') if valgrind is None: return mtt.makeTempDirParent() tmpDir = os.path.abspath(mtt.makeTempDir('memory_1')) parent = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) for maf1, maf2 in knownValuesSeed: testMaf1 = mtt.testFile(os.path.abspath(os.path.join(tmpDir, 'maf1.maf')), maf1, g_headers) testMaf2 = mtt.testFile(os.path.abspath(os.path.join(tmpDir, 'maf2.maf')), maf2, g_headers) cmd = mtt.genericValgrind(tmpDir) cmd += [os.path.abspath(os.path.join(parent, 'test', 'mafComparator')), '--maf1', os.path.abspath(os.path.join(tmpDir, 'maf1.maf')), '--maf2', os.path.abspath(os.path.join(tmpDir, 'maf2.maf')), '--out', os.path.join(tmpDir, 'output.xml'), '--samples=10', '--logLevel=critical'] mtt.recordCommands([cmd], tmpDir) mtt.runCommandsS([cmd], tmpDir) self.assertTrue(mtt.noMemoryErrors(os.path.join(tmpDir, 'valgrind.xml'))) for i in xrange(0, 4): mtt.recordCommands([cmd], tmpDir) mtt.runCommandsS([cmd], tmpDir) self.assertTrue(mtt.noMemoryErrors(os.path.join(tmpDir, 'valgrind.xml'))) mtt.removeDir(tmpDir)
def testMemory_3(self): """ mafTransitiveClosure should be memory clean. """ mtt.makeTempDirParent() valgrind = mtt.which('valgrind') if valgrind is None: return tmpDir = os.path.abspath(mtt.makeTempDir('memory_3')) for inMaf, outList in self.knownResults: testMaf = mtt.testFile( os.path.abspath(os.path.join(tmpDir, 'test.maf')), inMaf, g_headers) parent = os.path.dirname(os.path.dirname( os.path.abspath(__file__))) cmd = mtt.genericValgrind(tmpDir) cmd += [ os.path.abspath( os.path.join(parent, 'test', 'mafTransitiveClosure')), '--maf', os.path.abspath(os.path.join(tmpDir, 'test.maf')), '--sort' ] outpipes = [ os.path.abspath(os.path.join(tmpDir, 'transitiveClosure.maf')) ] mtt.recordCommands([cmd], tmpDir, outPipes=outpipes) mtt.runCommandsS([cmd], tmpDir, outPipes=outpipes) passed = mtt.noMemoryErrors(os.path.join(tmpDir, 'valgrind.xml')) self.assertTrue(passed) mtt.removeDir(tmpDir)
def testMemory1(self): """ If valgrind is installed on the system, check for memory related errors (1). """ mtt.makeTempDirParent() valgrind = mtt.which('valgrind') if valgrind is None: return tmpDir = os.path.abspath(mtt.makeTempDir('memeory1')) customOpts = mafval.GenericValidationOptions() for a, expected, strand in g_blocks: testMaf = mtt.testFile( os.path.abspath(os.path.join(tmpDir, 'test.maf')), ''.join(a), g_headers) parent = os.path.dirname(os.path.dirname( os.path.abspath(__file__))) cmd = mtt.genericValgrind(tmpDir) cmd += [ os.path.abspath(os.path.join(parent, 'test', 'mafStrander')), '--maf', os.path.abspath(os.path.join(tmpDir, 'test.maf')), '--seq', 'target', '--strand', strand ] outpipes = [os.path.abspath(os.path.join(tmpDir, 'coerced.maf'))] mtt.recordCommands([cmd], tmpDir, outPipes=outpipes) mtt.runCommandsS([cmd], tmpDir, outPipes=outpipes) self.assertTrue( mtt.noMemoryErrors(os.path.join(tmpDir, 'valgrind.xml'))) self.assertTrue( mafval.validateMaf(os.path.join(tmpDir, 'coerced.maf'), customOpts)) mtt.removeDir(tmpDir)
def _testMemory1(self): """ If valgrind is installed on the system, check for memory related errors (0). """ valgrind = mtt.which('valgrind') if valgrind is None: return mtt.makeTempDirParent() for i in xrange(0, 10): shuffledBlocks = [] tmpDir = os.path.abspath(mtt.makeTempDir('memory_1')) order = [1] * len(g_overlappingBlocks) + [0] * len(g_nonOverlappingBlocks) random.shuffle(order) random.shuffle(g_overlappingBlocks) random.shuffle(g_nonOverlappingBlocks) j, k = 0, 0 for isOverlapping in order: if isOverlapping: shuffledBlocks.append(g_overlappingBlocks[j][0]) j += 1 else: shuffledBlocks.append(g_nonOverlappingBlocks[k][0]) k += 1 testMaf = mtt.testFile(os.path.abspath(os.path.join(tmpDir, 'test_%d.maf' % i)), ''.join(shuffledBlocks), g_headers) parent = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) cmd = mtt.genericValgrind(tmpDir) cmd.append(os.path.abspath(os.path.join(parent, 'test', 'mafPairCoverage'))) cmd += ['--maf', os.path.abspath(os.path.join(tmpDir, 'test_%d.maf' % i)), '--seq1', 'target.*', '--seq2', g_targetSeq2, ] outpipes = [os.path.join('/dev', 'null')] mtt.recordCommands([cmd], tmpDir, outPipes=outpipes) mtt.runCommandsS([cmd], tmpDir, outPipes=outpipes) self.assertTrue(mtt.noMemoryErrors(os.path.join(tmpDir, 'valgrind.xml'))) mtt.removeDir(tmpDir)
def testMemory2(self): """ If valgrind is installed on the system, check for memory related errors (2). """ mtt.makeTempDirParent() valgrind = mtt.which('valgrind') if valgrind is None: return global g_header for i in xrange(0, len(g_nonOverlappingBlocks)): tmpDir = os.path.abspath(mtt.makeTempDir('memory2')) testMafPath, g_header = mtt.testFile( os.path.abspath(os.path.join(tmpDir, 'test.maf')), ''.join(g_nonOverlappingBlocks[i][0]), g_headers) parent = os.path.dirname(os.path.dirname( os.path.abspath(__file__))) cmd = mtt.genericValgrind(tmpDir) cmd.append( os.path.abspath( os.path.join(parent, 'test', 'mafPositionFinder'))) cmd += [ '--maf', testMafPath, '--seq', g_targetSeq, '--pos', '%d' % g_nonOverlappingBlocks[i][1] ] outpipes = [os.path.abspath(os.path.join(tmpDir, 'found.txt'))] mtt.recordCommands([cmd], tmpDir, outPipes=outpipes) mtt.runCommandsS([cmd], tmpDir, outPipes=outpipes) self.assertTrue( mtt.noMemoryErrors(os.path.join(tmpDir, 'valgrind.xml'))) mtt.removeDir(tmpDir)
def testMemory0(self): """ If valgrind is installed on the system, check for memory related errors (0). """ valgrind = mtt.which('valgrind') if valgrind is None: return mtt.makeTempDirParent() tmpDir = os.path.abspath(mtt.makeTempDir('memory_0')) parent = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) customOpts = mafval.GenericValidationOptions() for target, mafSeq, solutionDict in g_knownGood: testMaf = mtt.testFile( os.path.join(os.path.abspath(tmpDir), 'test.maf'), mafSeq, g_headers) cmd = mtt.genericValgrind(tmpDir) cmd.append( os.path.abspath(os.path.join(parent, 'test', 'mafCoverage'))) cmd += [ '--maf', os.path.abspath(os.path.join(tmpDir, 'test.maf')), '--species', target ] outpipes = [os.path.join('/dev', 'null')] mtt.recordCommands([cmd], tmpDir, outPipes=outpipes) mtt.runCommandsS([cmd], tmpDir, outPipes=outpipes) self.assertTrue( mafval.validateMaf(os.path.join(tmpDir, 'test.maf'), customOpts)) self.assertTrue( mtt.noMemoryErrors(os.path.join(tmpDir, 'valgrind.xml'))) mtt.removeDir(tmpDir)
def testMemory2(self): """ If valgrind is installed on the system, check for memory related errors (2). """ valgrind = mtt.which('valgrind') if valgrind is None: return mtt.makeTempDirParent() i = -1 for inblocks, seq, start, stop, outblocks in self.testSet: i += 1 tmpDir = os.path.abspath(mtt.makeTempDir('memory_2')) random.shuffle(g_nonOverlappingBlocks) testMaf = mtt.testFile(os.path.abspath(os.path.join(tmpDir, 'test_%d.maf' % i)), ''.join(map(str, inblocks)), g_headers) parent = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) cmd = mtt.genericValgrind(tmpDir) cmd.append(os.path.abspath(os.path.join(parent, 'test', 'mafExtractor'))) cmd += ['--maf', os.path.abspath(os.path.join(tmpDir, 'test_%d.maf' % i)), '--seq', seq, '--start', '%d' % start, '--stop', '%d' % stop, ] outpipes = [os.path.abspath(os.path.join(tmpDir, 'extracted.maf'))] mtt.recordCommands([cmd], tmpDir, outPipes=outpipes) mtt.runCommandsS([cmd], tmpDir, outPipes=outpipes) self.assertTrue(mtt.noMemoryErrors(os.path.join(tmpDir, 'valgrind.xml'))) mtt.removeDir(tmpDir)
def test_memory_3(self): """ mafComparator should be memory clean for known values using --near option """ valgrind = mtt.which('valgrind') if valgrind is None: return mtt.makeTempDirParent() tmpDir = os.path.abspath(mtt.makeTempDir('memory_3')) for maf1, maf2, near, totalTrue, totalFalse in knownValuesNear: testMaf1 = mtt.testFile(os.path.abspath(os.path.join(tmpDir, 'maf1.maf')), maf1, g_headers) testMaf2 = mtt.testFile(os.path.abspath(os.path.join(tmpDir, 'maf2.maf')), maf2, g_headers) parent = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) cmd = mtt.genericValgrind(tmpDir) cmd += [os.path.abspath(os.path.join(parent, 'test', 'mafComparator')), '--maf1', os.path.abspath(os.path.join(tmpDir, 'maf1.maf')), '--maf2', os.path.abspath(os.path.join(tmpDir, 'maf2.maf')), '--out', os.path.abspath(os.path.join(tmpDir, 'output.xml')), '--near=%d' % near, '--samples=1000', '--logLevel=critical', ] mtt.recordCommands([cmd], tmpDir) mtt.runCommandsS([cmd], tmpDir) passed = mtt.noMemoryErrors(os.path.join(tmpDir, 'valgrind.xml')) self.assertTrue(passed) mtt.removeDir(tmpDir)
def test_memoryTest_4(self): """ --wigglePairs options should be memory clean """ valgrind = mtt.which('valgrind') if valgrind is None: return mtt.makeTempDirParent() tmpDir = os.path.abspath(mtt.makeTempDir('memory_4')) for maf1, maf2, ref, partner, binlen, valuesDictList in knownValuesWiggles: testMaf1 = mtt.testFile(os.path.abspath(os.path.join(tmpDir, 'maf1.maf')), maf1, g_headers) testMaf2 = mtt.testFile(os.path.abspath(os.path.join(tmpDir, 'maf2.maf')), maf2, g_headers) parent = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) cmd = mtt.genericValgrind(tmpDir) cmd += [os.path.abspath(os.path.join(parent, 'test', 'mafComparator')), '--maf1', os.path.abspath(os.path.join(tmpDir, 'maf1.maf')), '--maf2', os.path.abspath(os.path.join(tmpDir, 'maf2.maf')), '--out', os.path.abspath(os.path.join(tmpDir, 'output.xml')), '--samples=1000', '--logLevel=critical', '--wigglePairs=%s:%s' % (ref, partner), '--wiggleBinLength=%d' % binlen, ] mtt.recordCommands([cmd], tmpDir) mtt.runCommandsS([cmd], tmpDir) passed = mtt.noMemoryErrors(os.path.join(tmpDir, 'valgrind.xml')) self.assertTrue(passed) mtt.removeDir(tmpDir)
def test_memoryTest_6(self): valgrind = mtt.which('valgrind') if valgrind is None: return mtt.makeTempDirParent() tmpDir = os.path.abspath(mtt.makeTempDir('memory_6')) i = -1 for maf1, maf2, totalTrue, totalFalse in knownValues: i += 1 testMaf1 = mtt.testFile(os.path.abspath(os.path.join(tmpDir, 'maf1.maf')), maf1, g_headers) testMaf2 = mtt.testFile(os.path.abspath(os.path.join(tmpDir, 'maf2.maf')), maf2, g_headers) parent = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) cmd = mtt.genericValgrind(tmpDir) cmd += [os.path.abspath(os.path.join(parent, 'test', 'mafComparator')), '--maf1', os.path.abspath(os.path.join(tmpDir, 'maf1.maf')), '--maf2', os.path.abspath(os.path.join(tmpDir, 'maf2.maf')), '--out', os.path.abspath(os.path.join(tmpDir, 'output.xml')), '--samples=1000', '--logLevel=critical', '--numberOfPairs=%s' % knownValuesNumberOfPairs[i], ] mtt.recordCommands([cmd], tmpDir) mtt.runCommandsS([cmd], tmpDir) passed = mtt.noMemoryErrors(os.path.join(tmpDir, 'valgrind.xml')) self.assertTrue(passed) mtt.removeDir(tmpDir)
def test_memory_0(self): """ mafComparator should be memory clean for bed parsing examples """ valgrind = mtt.which('valgrind') if valgrind is None: return mtt.makeTempDirParent() tmpDir = os.path.abspath(mtt.makeTempDir('memory_0')) for maf1, maf2, bed, totalTrue, totalTrueInInterval in knownValuesBed: testMaf1 = mtt.testFile(os.path.abspath(os.path.join(tmpDir, 'maf1.maf')), maf1, g_headers) testMaf2 = mtt.testFile(os.path.abspath(os.path.join(tmpDir, 'maf2.maf')), maf2, g_headers) testBed = mtt.testFile(os.path.abspath(os.path.join(tmpDir, 'bed.bed')), bed, ['']) parent = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) cmd = mtt.genericValgrind(tmpDir) cmd += [os.path.abspath(os.path.join(parent, 'test', 'mafComparator')), '--maf1', os.path.abspath(os.path.join(tmpDir, 'maf1.maf')), '--maf2', os.path.abspath(os.path.join(tmpDir, 'maf2.maf')), '--out', os.path.abspath(os.path.join(tmpDir, 'output.xml')), '--samples=1000', '--logLevel=critical', ] if bed != '': cmd += ['--bedFiles', os.path.abspath(os.path.join(tmpDir, 'bed.bed'))] mtt.recordCommands([cmd], tmpDir) mtt.runCommandsS([cmd], tmpDir) passed = mtt.noMemoryErrors(os.path.join(tmpDir, 'valgrind.xml')) self.assertTrue(passed) mtt.removeDir(tmpDir)
def testMemory1(self): """ If valgrind is installed on the system, check for memory related errors (1). """ mtt.makeTempDirParent() valgrind = mtt.which('valgrind') if valgrind is None: return tmpDir = os.path.abspath(mtt.makeTempDir('memory1')) customOpts = mafval.GenericValidationOptions() for reference, inMaf, inFaList, outFa, outMaf in g_knownData: testMaf = mtt.testFile(os.path.abspath(os.path.join(tmpDir, 'test.maf')), ''.join(inMaf), g_headers) testFaNames = testFasta(os.path.abspath(tmpDir), inFaList) parent = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) cmd = mtt.genericValgrind(tmpDir) cmd += [os.path.abspath(os.path.join(parent, 'test', 'mafToFastaStitcher')), '--maf', os.path.abspath(os.path.join(tmpDir, 'test.maf')), '--seqs', testFaNames, '--breakpointPenalty', '6', '--interstitialSequence', '20', '--outMfa', os.path.abspath(os.path.join(tmpDir, 'out.fa')), '--outMaf', os.path.abspath(os.path.join(tmpDir, 'out.maf')),] if reference is not None: cmd += ['--reference', reference] mtt.recordCommands([cmd], tmpDir) mtt.runCommandsS([cmd], tmpDir) self.assertTrue(mtt.noMemoryErrors(os.path.join(tmpDir, 'valgrind.xml'))) mtt.removeDir(tmpDir)
def testMemory1(self): """ If valgrind is installed on the system, check for memory related errors (1). """ mtt.makeTempDirParent() valgrind = mtt.which('valgrind') if valgrind is None: return global g_header customOpts = mafval.GenericValidationOptions() for i in xrange(0, len(g_blocks)): tmpDir = os.path.abspath(mtt.makeTempDir('memory1')) testMafPath, g_header = mtt.testFile( os.path.abspath(os.path.join(tmpDir, 'test.maf')), g_blocks[i][0], g_headers) parent = os.path.dirname(os.path.dirname( os.path.abspath(__file__))) cmd = mtt.genericValgrind(tmpDir) cmd.append( os.path.abspath(os.path.join(parent, 'test', 'mafRowOrderer'))) cmd += ['--maf', testMafPath, '--order', '%s' % g_order] outpipes = [os.path.abspath(os.path.join(tmpDir, 'ordered.maf'))] mtt.recordCommands([cmd], tmpDir, outPipes=outpipes) mtt.runCommandsS([cmd], tmpDir, outPipes=outpipes) self.assertTrue( mtt.noMemoryErrors(os.path.join(tmpDir, 'valgrind.xml'))) self.assertTrue( mafval.validateMaf(os.path.join(tmpDir, 'ordered.maf'), customOpts)) mtt.removeDir(tmpDir)
def testMemory1(self): """ If valgrind is installed on the system, check for memory related errors (1). """ mtt.makeTempDirParent() valgrind = mtt.which("valgrind") if valgrind is None: return shuffledTargets = list(g_targetBlocks) for i in xrange(0, 20): tmpDir = os.path.abspath(mtt.makeTempDir("memory1")) random.shuffle(g_nonTargetBlocks) random.shuffle(shuffledTargets) shuffledBlocks = list(shuffledTargets) lower = 0 for j in xrange(0, len(g_nonTargetBlocks)): # randomly insert the non target blocks, but keep a record # of their relative order. index = random.randint(lower, len(shuffledBlocks)) shuffledBlocks.insert(index, g_nonTargetBlocks[j]) lower = index + 1 testMaf = mtt.testFile( os.path.abspath(os.path.join(tmpDir, "test.maf")), "".join(shuffledBlocks), g_headers ) parent = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) cmd = mtt.genericValgrind(tmpDir) cmd.append(os.path.abspath(os.path.join(parent, "test", "mafSorter"))) cmd += ["--maf", os.path.abspath(os.path.join(tmpDir, "test.maf")), "--seq", "hg18.chr7"] outpipes = [os.path.abspath(os.path.join(tmpDir, "sorted.maf"))] mtt.recordCommands([cmd], tmpDir, outPipes=outpipes) mtt.runCommandsS([cmd], tmpDir, outPipes=outpipes) self.assertTrue(mtt.noMemoryErrors(os.path.join(tmpDir, "valgrind.xml"))) mtt.removeDir(tmpDir)
def gtest_CuTestTests(self): """ Yo dawg, I heard you liked unit tests so I put some unit tests in your unit test so now you can unit test when you unit test. """ mtt.makeTempDirParent() tmpDir = os.path.abspath(mtt.makeTempDir('CuTestAllTests')) cmd = mtt.genericValgrind(tmpDir) cmd += [os.path.abspath(os.path.join(os.curdir, 'test', 'allTests'))] outpipes = [os.path.join('/dev', 'null')] mtt.recordCommands([cmd], tmpDir) mtt.runCommandsS([cmd], tmpDir, outPipes=outpipes) self.assertTrue(mtt.noMemoryErrors(os.path.join(tmpDir, 'valgrind.xml'))) mtt.removeDir(tmpDir)
def testMemory(self): """ sharedMaf.h should be memory clean. """ mtt.makeTempDirParent() valgrind = mtt.which('valgrind') if valgrind is None: return tmpDir = os.path.abspath(mtt.makeTempDir('allTests')) cmd = mtt.genericValgrind(tmpDir) cmd.append(os.path.abspath(os.path.join(os.curdir, 'allTests'))) mtt.runCommandsS([cmd], tmpDir) self.assertTrue(mtt.noMemoryErrors(os.path.join(tmpDir, 'valgrind.xml'))) mtt.removeDir(tmpDir)
def testMemory(self): """ sharedMaf.h should be memory clean. """ mtt.makeTempDirParent() valgrind = mtt.which('valgrind') if valgrind is None: return tmpDir = os.path.abspath(mtt.makeTempDir('allTests')) cmd = mtt.genericValgrind(tmpDir) cmd.append(os.path.abspath(os.path.join(os.curdir, 'allTests'))) mtt.runCommandsS([cmd], tmpDir) self.assertTrue( mtt.noMemoryErrors(os.path.join(tmpDir, 'valgrind.xml'))) mtt.removeDir(tmpDir)
def testMemory_2(self): """ the CuTest tests should be memory clean. """ valgrind = mtt.which('valgrind') if valgrind is None: return tmpDir = os.path.abspath(mtt.makeTempDir('memory_2')) parent = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) cmd = mtt.genericValgrind(tmpDir) cmd += [os.path.abspath(os.path.join(parent, 'test', 'mafTransitiveClosure')), '--test'] outpipes = [os.path.abspath(os.path.join(tmpDir, 'transitiveClosure.maf'))] mtt.recordCommands([cmd], tmpDir, outPipes=outpipes) mtt.runCommandsS([cmd], tmpDir, outPipes=outpipes) passed = mtt.noMemoryErrors(os.path.join(tmpDir, 'valgrind.xml')) self.assertTrue(passed) mtt.removeDir(tmpDir)
def test_CuTestMemory(self): """ If valgrind is installed on the system, check for memory related errors in CuTests. """ mtt.makeTempDirParent() valgrind = mtt.which('valgrind') if valgrind is None: return tmpDir = os.path.abspath(mtt.makeTempDir('memory_CuTest')) parent = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) cmd = mtt.genericValgrind(tmpDir) cmd.append(os.path.abspath(os.path.join(parent, 'test', 'allTests'))) outpipes = [os.path.join('/dev', 'null')] mtt.recordCommands([cmd], tmpDir) mtt.runCommandsS([cmd], tmpDir, outPipes=outpipes) self.assertTrue(mtt.noMemoryErrors(os.path.join(tmpDir, 'valgrind.xml'))) mtt.removeDir(tmpDir)
def testMemory_2(self): """ the CuTest tests should be memory clean. """ valgrind = mtt.which('valgrind') if valgrind is None: return tmpDir = os.path.abspath(mtt.makeTempDir('memory_2')) parent = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) cmd = mtt.genericValgrind(tmpDir) cmd += [ os.path.abspath( os.path.join(parent, 'test', 'mafTransitiveClosure')), '--test' ] outpipes = [ os.path.abspath(os.path.join(tmpDir, 'transitiveClosure.maf')) ] mtt.recordCommands([cmd], tmpDir, outPipes=outpipes) mtt.runCommandsS([cmd], tmpDir, outPipes=outpipes) passed = mtt.noMemoryErrors(os.path.join(tmpDir, 'valgrind.xml')) self.assertTrue(passed) mtt.removeDir(tmpDir)
def testMemory2(self): """ If valgrind is installed on the system, check for memory related errors (2). """ mtt.makeTempDirParent() valgrind = mtt.which('valgrind') if valgrind is None: return global g_header for i in xrange(0, len(g_knownExcludes)): tmpDir = os.path.abspath(mtt.makeTempDir('memory2')) testMafPath, g_header = mtt.testFile(os.path.abspath(os.path.join(tmpDir, 'test.maf')), g_knownExcludes[i][0], g_headers) parent = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) cmd = mtt.genericValgrind(tmpDir) cmd.append(os.path.abspath(os.path.join(parent, 'test', 'mafFilter'))) cmd += ['--maf', testMafPath, '--excludeSeq', '%s' % g_sequenceList] outpipes = [os.path.abspath(os.path.join(tmpDir, 'filtered.maf'))] mtt.recordCommands([cmd], tmpDir, outPipes=outpipes) mtt.runCommandsS([cmd], tmpDir, outPipes=outpipes) self.assertTrue(mtt.noMemoryErrors(os.path.join(tmpDir, 'valgrind.xml'))) mtt.removeDir(tmpDir)
def testMemory_3(self): """ mafTransitiveClosure should be memory clean. """ mtt.makeTempDirParent() valgrind = mtt.which('valgrind') if valgrind is None: return tmpDir = os.path.abspath(mtt.makeTempDir('memory_3')) for inMaf, outList in self.knownResults: testMaf = mtt.testFile(os.path.abspath(os.path.join(tmpDir, 'test.maf')), inMaf, g_headers) parent = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) cmd = mtt.genericValgrind(tmpDir) cmd += [os.path.abspath(os.path.join(parent, 'test', 'mafTransitiveClosure')), '--maf', os.path.abspath(os.path.join(tmpDir, 'test.maf')), '--sort'] outpipes = [os.path.abspath(os.path.join(tmpDir, 'transitiveClosure.maf'))] mtt.recordCommands([cmd], tmpDir, outPipes=outpipes) mtt.runCommandsS([cmd], tmpDir, outPipes=outpipes) passed = mtt.noMemoryErrors(os.path.join(tmpDir, 'valgrind.xml')) self.assertTrue(passed) mtt.removeDir(tmpDir)
def testMemory2(self): """ If valgrind is installed on the system, check for memory related errors (2). """ mtt.makeTempDirParent() valgrind = mtt.which('valgrind') if valgrind is None: return global g_header for i in xrange(0, len(g_nonOverlappingBlocks)): tmpDir = os.path.abspath(mtt.makeTempDir('memory2')) testMafPath, g_header = mtt.testFile(os.path.abspath(os.path.join(tmpDir, 'test.maf')), ''.join(g_nonOverlappingBlocks[i][0]), g_headers) parent = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) cmd = mtt.genericValgrind(tmpDir) cmd.append(os.path.abspath(os.path.join(parent, 'test', 'mafPositionFinder'))) cmd += ['--maf', testMafPath, '--seq', g_targetSeq, '--pos', '%d' % g_nonOverlappingBlocks[i][1]] outpipes = [os.path.abspath(os.path.join(tmpDir, 'found.txt'))] mtt.recordCommands([cmd], tmpDir, outPipes=outpipes) mtt.runCommandsS([cmd], tmpDir, outPipes=outpipes) self.assertTrue(mtt.noMemoryErrors(os.path.join(tmpDir, 'valgrind.xml'))) mtt.removeDir(tmpDir)
def testMemory1(self): """ If valgrind is installed on the system, check for memory related errors (1). """ mtt.makeTempDirParent() valgrind = mtt.which('valgrind') if valgrind is None: return tmpDir = os.path.abspath(mtt.makeTempDir('memory1')) customOpts = mafval.GenericValidationOptions() for reference, inMaf, inFaList, outFa, outMaf in g_knownData: testMaf = mtt.testFile( os.path.abspath(os.path.join(tmpDir, 'test.maf')), ''.join(inMaf), g_headers) testFaNames = testFasta(os.path.abspath(tmpDir), inFaList) parent = os.path.dirname(os.path.dirname( os.path.abspath(__file__))) cmd = mtt.genericValgrind(tmpDir) cmd += [ os.path.abspath( os.path.join(parent, 'test', 'mafToFastaStitcher')), '--maf', os.path.abspath(os.path.join(tmpDir, 'test.maf')), '--seqs', testFaNames, '--breakpointPenalty', '6', '--interstitialSequence', '20', '--outMfa', os.path.abspath(os.path.join(tmpDir, 'out.fa')), '--outMaf', os.path.abspath(os.path.join(tmpDir, 'out.maf')), ] if reference is not None: cmd += ['--reference', reference] mtt.recordCommands([cmd], tmpDir) mtt.runCommandsS([cmd], tmpDir) self.assertTrue( mtt.noMemoryErrors(os.path.join(tmpDir, 'valgrind.xml'))) mtt.removeDir(tmpDir)
def testMemory1(self): """ If valgrind is installed on the system, check for memory related errors (1). """ mtt.makeTempDirParent() valgrind = mtt.which('valgrind') if valgrind is None: return shuffledTargets = list(g_targetBlocks) for i in xrange(0, 20): tmpDir = os.path.abspath(mtt.makeTempDir('memory1')) random.shuffle(g_nonTargetBlocks) random.shuffle(shuffledTargets) shuffledBlocks = list(shuffledTargets) lower = 0 for j in xrange(0, len(g_nonTargetBlocks)): # randomly insert the non target blocks, but keep a record # of their relative order. index = random.randint(lower, len(shuffledBlocks)) shuffledBlocks.insert(index, g_nonTargetBlocks[j]) lower = index + 1 testMaf = mtt.testFile( os.path.abspath(os.path.join(tmpDir, 'test.maf')), ''.join(shuffledBlocks), g_headers) parent = os.path.dirname(os.path.dirname( os.path.abspath(__file__))) cmd = mtt.genericValgrind(tmpDir) cmd.append( os.path.abspath(os.path.join(parent, 'test', 'mafSorter'))) cmd += [ '--maf', os.path.abspath(os.path.join(tmpDir, 'test.maf')), '--seq', 'hg18.chr7' ] outpipes = [os.path.abspath(os.path.join(tmpDir, 'sorted.maf'))] mtt.recordCommands([cmd], tmpDir, outPipes=outpipes) mtt.runCommandsS([cmd], tmpDir, outPipes=outpipes) self.assertTrue( mtt.noMemoryErrors(os.path.join(tmpDir, 'valgrind.xml'))) mtt.removeDir(tmpDir)
def testMemory2(self): """ If valgrind is installed on the system, check for memory related errors (2). """ mtt.makeTempDirParent() valgrind = mtt.which('valgrind') if valgrind is None: return for i in xrange(0, 10): tmpDir = os.path.abspath(mtt.makeTempDir('memory2')) random.shuffle(g_nonDuplicateBlocks) testMaf = mtt.testFile(os.path.abspath(os.path.join(tmpDir, 'test.maf')), ''.join(g_nonDuplicateBlocks), g_headers) expectedOutput = g_nonDuplicateBlocks parent = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) cmd = mtt.genericValgrind(tmpDir) cmd += [os.path.abspath(os.path.join(parent, 'test', 'mafDuplicateFilter')), '--maf', os.path.abspath(os.path.join(tmpDir, 'test.maf'))] outpipes = [os.path.abspath(os.path.join(tmpDir, 'filtered.maf'))] mtt.recordCommands([cmd], tmpDir, outPipes=outpipes) mtt.runCommandsS([cmd], tmpDir, outPipes=outpipes) self.assertTrue(mtt.noMemoryErrors(os.path.join(tmpDir, 'valgrind.xml'))) mtt.removeDir(tmpDir)
def testMemory1(self): """ If valgrind is installed on the system, check for memory related errors (1). """ mtt.makeTempDirParent() valgrind = mtt.which('valgrind') if valgrind is None: return global g_header customOpts = mafval.GenericValidationOptions() for i in xrange(0, len(g_blocks)): tmpDir = os.path.abspath(mtt.makeTempDir('memory1')) testMafPath, g_header = mtt.testFile(os.path.abspath(os.path.join(tmpDir, 'test.maf')), g_blocks[i][0], g_headers) parent = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) cmd = mtt.genericValgrind(tmpDir) cmd.append(os.path.abspath(os.path.join(parent, 'test', 'mafRowOrderer'))) cmd += ['--maf', testMafPath, '--order', '%s' % g_order] outpipes = [os.path.abspath(os.path.join(tmpDir, 'ordered.maf'))] mtt.recordCommands([cmd], tmpDir, outPipes=outpipes) mtt.runCommandsS([cmd], tmpDir, outPipes=outpipes) self.assertTrue(mtt.noMemoryErrors(os.path.join(tmpDir, 'valgrind.xml'))) self.assertTrue(mafval.validateMaf(os.path.join(tmpDir, 'ordered.maf'), customOpts)) mtt.removeDir(tmpDir)
def testMemory1(self): """ If valgrind is installed on the system, check for memory related errors (1). """ mtt.makeTempDirParent() valgrind = mtt.which('valgrind') if valgrind is None: return tmpDir = os.path.abspath(mtt.makeTempDir('memeory1')) customOpts = mafval.GenericValidationOptions() for a, expected, strand in g_blocks: testMaf = mtt.testFile(os.path.abspath(os.path.join(tmpDir, 'test.maf')), ''.join(a), g_headers) parent = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) cmd = mtt.genericValgrind(tmpDir) cmd += [os.path.abspath(os.path.join(parent, 'test', 'mafStrander')), '--maf', os.path.abspath(os.path.join(tmpDir, 'test.maf')), '--seq', 'target', '--strand', strand] outpipes = [os.path.abspath(os.path.join(tmpDir, 'coerced.maf'))] mtt.recordCommands([cmd], tmpDir, outPipes=outpipes) mtt.runCommandsS([cmd], tmpDir, outPipes=outpipes) self.assertTrue(mtt.noMemoryErrors(os.path.join(tmpDir, 'valgrind.xml'))) self.assertTrue(mafval.validateMaf(os.path.join(tmpDir, 'coerced.maf'), customOpts)) mtt.removeDir(tmpDir)
def testMemory0(self): """ If valgrind is installed on the system, check for memory related errors (0). """ valgrind = mtt.which('valgrind') if valgrind is None: return mtt.makeTempDirParent() tmpDir = os.path.abspath(mtt.makeTempDir('memory_0')) parent = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) customOpts = mafval.GenericValidationOptions() for target, mafSeq, solutionDict in g_knownGood: testMaf = mtt.testFile(os.path.join(os.path.abspath(tmpDir), 'test.maf'), mafSeq, g_headers) cmd = mtt.genericValgrind(tmpDir) cmd.append(os.path.abspath(os.path.join(parent, 'test', 'mafCoverage'))) cmd += ['--maf', os.path.abspath(os.path.join(tmpDir, 'test.maf')), '--species', target] outpipes = [os.path.join('/dev', 'null')] mtt.recordCommands([cmd], tmpDir, outPipes=outpipes) mtt.runCommandsS([cmd], tmpDir, outPipes=outpipes) self.assertTrue(mafval.validateMaf(os.path.join(tmpDir, 'test.maf'), customOpts)) self.assertTrue(mtt.noMemoryErrors(os.path.join(tmpDir, 'valgrind.xml'))) mtt.removeDir(tmpDir)
def testMemory1(self): """ If valgrind is installed on the system, check for memory related errors (1). """ valgrind = mtt.which('valgrind') if valgrind is None: return mtt.makeTempDirParent() for i in xrange(0, 10): tmpDir = os.path.abspath(mtt.makeTempDir('memory_1')) random.shuffle(g_nonOverlappingBlocks) testMaf = mtt.testFile(os.path.abspath(os.path.join(tmpDir, 'test_%d.maf' % i)), ''.join(g_nonOverlappingBlocks), g_headers) parent = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) cmd = mtt.genericValgrind(tmpDir) cmd.append(os.path.abspath(os.path.join(parent, 'test', 'mafExtractor'))) cmd += ['--maf', os.path.abspath(os.path.join(tmpDir, 'test_%d.maf' % i)), '--seq', g_targetSeq, '--start', '%d' % g_targetRange[0], '--stop', '%d' % g_targetRange[1], '--soft'] outpipes = [os.path.abspath(os.path.join(tmpDir, 'extracted.maf'))] mtt.recordCommands([cmd], tmpDir, outPipes=outpipes) mtt.runCommandsS([cmd], tmpDir, outPipes=outpipes) self.assertTrue(mtt.noMemoryErrors(os.path.join(tmpDir, 'valgrind.xml'))) mtt.removeDir(tmpDir)
def testMemory1(self): """ If valgrind is installed on the system, check for memory related errors (1). """ mtt.makeTempDirParent() valgrind = mtt.which('valgrind') if valgrind is None: return for i in xrange(0, 10): shuffledBlocks = [] expectedOutput = [] tmpDir = os.path.abspath(mtt.makeTempDir('memory1')) order = [1] * len(g_duplicateBlocks) + [0] * len(g_nonDuplicateBlocks) random.shuffle(order) random.shuffle(g_duplicateBlocks) random.shuffle(g_nonDuplicateBlocks) j, k = 0, 0 for dupBlock in order: if dupBlock: shuffledBlocks.append(g_duplicateBlocks[j][0]) expectedOutput.append(g_duplicateBlocks[j][1]) j += 1 else: shuffledBlocks.append(g_nonDuplicateBlocks[k]) expectedOutput.append(g_nonDuplicateBlocks[k]) k += 1 testMaf = mtt.testFile(os.path.abspath(os.path.join(tmpDir, 'test.maf')), ''.join(shuffledBlocks), g_headers) parent = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) cmd = mtt.genericValgrind(tmpDir) cmd += [os.path.abspath(os.path.join(parent, 'test', 'mafDuplicateFilter')), '--maf', os.path.abspath(os.path.join(tmpDir, 'test.maf'))] outpipes = [os.path.abspath(os.path.join(tmpDir, 'filtered.maf'))] mtt.recordCommands([cmd], tmpDir, outPipes=outpipes) mtt.runCommandsS([cmd], tmpDir, outPipes=outpipes) self.assertTrue(mtt.noMemoryErrors(os.path.join(tmpDir, 'valgrind.xml'))) mtt.removeDir(tmpDir)