Example #1
0
 def testorder(self):
     """ mafRowOrderer should order blocks according to user input
     """
     global g_header
     mtt.makeTempDirParent()
     customOpts = mafval.GenericValidationOptions()
     for i in xrange(0, len(g_blocks)):
         tmpDir = os.path.abspath(mtt.makeTempDir('order'))
         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 = []
         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)
         ordered = mafIsOrdered(os.path.join(tmpDir, 'ordered.maf'),
                                g_blocks[i][1], g_header)
         self.assertTrue(
             mafval.validateMaf(os.path.join(tmpDir, 'ordered.maf'),
                                customOpts))
         self.assertTrue(ordered)
         if ordered:
             mtt.removeDir(tmpDir)
Example #2
0
 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)
Example #3
0
 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)
Example #4
0
 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)
Example #5
0
 def testCoercion(self):
     """ mafStrander should coerce blocks into strandedness based on user input
     """
     mtt.makeTempDirParent()
     tmpDir = os.path.abspath(mtt.makeTempDir('coercion'))
     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 = [
             os.path.abspath(os.path.join(parent, 'test',
                                          'mafStrander')), '--maf',
             os.path.abspath(os.path.join(tmpDir, 'test.maf')), '--seq',
             'target.chr0', '--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(
             mafIsCoerced(os.path.join(tmpDir, 'coerced.maf'), expected))
         self.assertTrue(
             mafval.validateMaf(os.path.join(tmpDir, 'coerced.maf'),
                                customOpts))
     mtt.removeDir(tmpDir)
Example #6
0
 def testCoverage_0(self):
     """ mafCoverage should output numbers that accurately reflect the coverage between sequences.
 """
     mtt.makeTempDirParent()
     tmpDir = os.path.abspath(mtt.makeTempDir('testCoverage_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 = [
             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(tmpDir, 'output.txt')]
         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(
             coverageIsCorrect(os.path.join(tmpDir, 'output.txt'),
                               solutionDict))
     mtt.removeDir(tmpDir)
Example #7
0
 def testHardExtraction_0(self):
     """ mafExtractor should output trimmed blocks by default.
     """
     valgrind = mtt.which('valgrind')
     if valgrind is None:
         return
     mtt.makeTempDirParent()
     customOpts = mafval.GenericValidationOptions()
     i = -1
     for inblocks, seq, start, stop, outblocks in self.testSet:
         i += 1
         tmpDir = os.path.abspath(mtt.makeTempDir('hardextraction_0'))
         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 = [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(mafIsHardExtracted('hardextraction_0_%d' % i, outblocks, 
                                            os.path.join(tmpDir, 'extracted.maf')))
         self.assertTrue(mafval.validateMaf(os.path.join(tmpDir, 'extracted.maf'), customOpts))
         mtt.removeDir(tmpDir)
Example #8
0
    def testNonExtraction1(self):
        """ mafExtractor should not extract blocks when they do not match.
        """
        customOpts = mafval.GenericValidationOptions()
        mtt.makeTempDirParent()
        tmpDir = os.path.abspath(mtt.makeTempDir('nonExtraction_1'))
        block = '''a degree=4
s simChimp.chrA     15393341 348 + 53121445 ATATTGAGGAGCAGGATGGGTATAGAGGCCCTGACCCATTAATGTGTAAGCACTAGGCAGCTGGGAGATACCCCAGAGGGCGGGGTCACTGAATTCACTGGCCCACCACTGTAAATACATTCTAACCAGTGGGTTTAGGGCTCTGTGCATTAGAACCACTCTGAAGAAGTGTAACACACCACCTAGTGAGCTGCCGGGCCGCCAGCAACTTCTTTTTCCCACATGACCCATGCAAGCCCGTGATTTCTCCCTGGTACATGATATTTGGGATTCCAGGGACCTAATGGAGCATGCTATTCCTGTGTTAGTTATCACTTCGAAGGGGGTGCAAGAGTGTAAGTAATGGGT
s simGorilla.chrA   15595743 348 + 53120926 ATATTGAGGAGCAGGATGGGTATAGAAGCCCTGACCCATTAATGTGTAAGCACTAGGCAGCTGGGAGATACTCCAGAGGGAGGGGTCACTGAATTCACTGGCCCACCACTGTAAATACATTCTAACCAGTGGGTTTAGGGCTCGGTGCATTAGAACCACCCTGAAGAAGTGTAACGCACCACCTAGTGAGCTGCCGGGCCGCCAGCAACTTCTTTTTCCCACATGACCCATGCATGCCCGTGATTTCTCCCTGGTACATGGTTTTTGGGATTCCAGGGACCTAATGGAGCATACTATTCCTGTGTTAGTTATCACTTCGAAGGGGGTGCGAGAGTGTAAGTAATGGGT
s simHuman.chrA     36713600 348 - 53106993 ATATTGAGGAGCAGGATGGGTATAGAAGCCCTGACCTATTAATGTGTAAGCACTAGGCAGCTGGGCGATACCCCAGAGGGAGGGGTCACTGAATTCACTGGCCCACCACTGTAAATACATTCTAACCAGTGGGTTTAGGGCTCTGTGCATTAGAACCACCCTGAAGAAGAGTAACGCACCACCTAGTGAGCTGCCGGGCCGCCAGCAAGTTCTTTTTCCCACATGACCCATGCAAGCCCGTGATTTCTCCCTGGTACATGATATTTGGGATTCCAGGGACCTAATGGAGCATGCTATTCCTGTGTTAGTTATCACTTCGAAGGGGGTGCAAGAGTGTAAGTAATGGGT
s simOrang.chrE       126390 348 + 37692687 ATTTTGAGGAGCAGGATGGGTATAGAAGCCCTGACCCATTAATGTGTGAGCTCTAGGCAGCTTGGAGATACTGCAGAGGGAGGGGTCACTGAATTCACTGGCCCACCACTGTAAATACATACTAACCGGTGGGTTTAGGGCTCTGTGCATTAGAACCACCCTGAGGAAGTGTAACGCACCACCTAGTGAGCTGCCGGGCCACCAGCAACTTCTTTTTCCCACATGACCCATGCAAGCCCGTGATTTCTCCCTGGTACATGATCTTTGGGATTCCAGGGACCTAATGGCGGATGCTATTCCTGTGTTAGTTATCACTTCGAAGGGGGCGCAAGAGTGTAAGTAATGGGT
s target.chr0       36713600 348 - 53106993 ATATTGAGGAGCAGGATGGGTATAGAAGCCCTGACCTATTAATGTGTAAGCACTAGGCAGCTGGGCGATACCCCAGAGGGAGGGGTCACTGAATTCACTGGCCCACCACTGTAAATACATTCTAACCAGTGGGTTTAGGGCTCTGTGCATTAGAACCACCCTGAAGAAGAGTAACGCACCACCTAGTGAGCTGCCGGGCCGCCAGCAAGTTCTTTTTCCCACATGACCCATGCAAGCCCGTGATTTCTCCCTGGTACATGATATTTGGGATTCCAGGGACCTAATGGAGCATGCTATTCCTGTGTTAGTTATCACTTCGAAGGGGGTGCAAGAGTGTAAGTAATGGGT

'''
        testMaf = mtt.testFile(os.path.abspath(os.path.join(tmpDir, 'test.maf')),
                               block, g_headers)
        parent = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
        cmd = [os.path.abspath(os.path.join(parent, 'test', 'mafExtractor'))]
        cmd += ['--maf', os.path.abspath(os.path.join(tmpDir, 'test.maf')),
                '--seq', 'simHuman.chrA', '--start', '%d' % 29953315, 
                '--stop', '%d' % 29953315,
                '--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.mafIsEmpty(os.path.join(tmpDir, 'extracted.maf'), g_headers))
        self.assertTrue(mafval.validateMaf(os.path.join(tmpDir, 'extracted.maf'), customOpts))
        mtt.removeDir(tmpDir)
 def testFastaStitch(self):
     """ mafToFastaStitcher should produce known output for a given known input
     """
     mtt.makeTempDirParent()
     tmpDir = os.path.abspath(mtt.makeTempDir('fasta'))
     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 = []
         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(fastaIsCorrect(os.path.abspath(os.path.join(tmpDir, 'out.fa')), outFa))
         self.assertTrue(mafIsCorrect(os.path.abspath(os.path.join(tmpDir, 'out.maf')), outMaf))
         self.assertTrue(mafval.validateMaf(os.path.join(tmpDir, 'out.maf'), customOpts))
     mtt.removeDir(tmpDir)
Example #10
0
 def testExtraction(self):
     """ mafExtractor should output blocks that meet the criteria for extraction. That is they contain the target sequence and have at least one base in the target range.
     """
     mtt.makeTempDirParent()
     customOpts = mafval.GenericValidationOptions()
     for i in xrange(0, 10):
         shuffledBlocks = []
         tmpDir = os.path.abspath(mtt.makeTempDir('extraction'))
         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])
                 j += 1
             else:
                 shuffledBlocks.append(g_nonOverlappingBlocks[k])
                 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 = [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(mafIsExtracted(os.path.join(tmpDir, 'extracted.maf')))
         self.assertTrue(mafval.validateMaf(os.path.join(tmpDir, 'extracted.maf'), customOpts))
         mtt.removeDir(tmpDir)
Example #11
0
 def testGoodMafs(self):
     """ mafValidator should accept known good mafs
     """
     for g in goodMafs:
         makeTempDir()
         mafFile = testFile(g)
         self.assertTrue(mafval.validateMaf(mafFile, options))
         removeTempDir()
Example #12
0
 def testGoodMafs(self):
     """ mafValidator should accept known good mafs
     """
     tmpDir = mtt.makeTempDir('knownGoodMafs')
     for g in g_goodMafs:
         mafFile, header = mtt.testFile(os.path.abspath(os.path.join(tmpDir, 'test.maf')), g, g_headers)
         self.assertTrue(mafval.validateMaf(mafFile, options))
     mtt.removeDir(tmpDir)
Example #13
0
 def testNotTestingDuplicateColumns(self):
     """ mafValidator should ignore when a column is duplicated if option is switched off
     """
     customOpts = GenericObject()
     customOpts.lookForDuplicateColumns = False
     customOpts.testChromNames = True
     for g in self.badMafs:
         makeTempDir()
         mafFile = testFile(g)
         self.assertTrue(mafval.validateMaf(mafFile, customOpts))
         removeTempDir()
Example #14
0
 def testNotTestingDuplicateColumns(self):
     """ mafValidator should ignore when a column is duplicated if option is switched off
     """
     customOpts = GenericObject()
     customOpts.lookForDuplicateColumns = False
     customOpts.testChromNames = True
     customOpts.validateSequence = True
     tmpDir = mtt.makeTempDir('notTestingDuplicateColumns')
     for g in self.badMafs:
         mafFile, header = mtt.testFile(os.path.abspath(os.path.join(tmpDir, 'test.maf')), g, g_headers)
         self.assertTrue(mafval.validateMaf(mafFile, customOpts))
     mtt.removeDir(tmpDir)
 def testFastaStitch(self):
     """ mafToFastaStitcher should produce known output for a given known input
     """
     mtt.makeTempDirParent()
     tmpDir = os.path.abspath(mtt.makeTempDir('fasta'))
     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 = []
         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(
             fastaIsCorrect(os.path.abspath(os.path.join(tmpDir, 'out.fa')),
                            outFa))
         self.assertTrue(
             mafIsCorrect(os.path.abspath(os.path.join(tmpDir, 'out.maf')),
                          outMaf))
         self.assertTrue(
             mafval.validateMaf(os.path.join(tmpDir, 'out.maf'),
                                customOpts))
     mtt.removeDir(tmpDir)
Example #16
0
 def testCoercion(self):
     """ mafStrander should coerce blocks into strandedness based on user input
     """
     mtt.makeTempDirParent()
     tmpDir = os.path.abspath(mtt.makeTempDir('coercion'))
     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 = [os.path.abspath(os.path.join(parent, 'test', 'mafStrander')), 
                '--maf', os.path.abspath(os.path.join(tmpDir, 'test.maf')),
                '--seq', 'target.chr0', '--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(mafIsCoerced(os.path.join(tmpDir, 'coerced.maf'), expected))
         self.assertTrue(mafval.validateMaf(os.path.join(tmpDir, 'coerced.maf'), customOpts))
     mtt.removeDir(tmpDir)
Example #17
0
 def testCoverage_0(self):
   """ mafCoverage should output numbers that accurately reflect the coverage between sequences.
   """
   mtt.makeTempDirParent()
   tmpDir = os.path.abspath(mtt.makeTempDir('testCoverage_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 = [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(tmpDir, 'output.txt')]
     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(coverageIsCorrect(os.path.join(tmpDir, 'output.txt'),
                                       solutionDict))
   mtt.removeDir(tmpDir)
Example #18
0
 def testorder(self):
     """ mafRowOrderer should order blocks according to user input
     """
     global g_header
     mtt.makeTempDirParent()
     customOpts = mafval.GenericValidationOptions()
     for i in xrange(0, len(g_blocks)):
         tmpDir = os.path.abspath(mtt.makeTempDir('order'))
         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 = []
         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)
         ordered = mafIsOrdered(os.path.join(tmpDir, 'ordered.maf'), g_blocks[i][1], g_header)
         self.assertTrue(mafval.validateMaf(os.path.join(tmpDir, 'ordered.maf'), customOpts))
         self.assertTrue(ordered)
         if ordered:
             mtt.removeDir(tmpDir)
Example #19
0
 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)
Example #20
0
 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)
Example #21
0
 def testNonExtraction0(self):
     """ mafExtractor should not extract blocks when they do not match.
     """
     customOpts = mafval.GenericValidationOptions()
     mtt.makeTempDirParent()
     for i in xrange(0, 10):
         tmpDir = os.path.abspath(mtt.makeTempDir('nonExtraction_0'))
         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 = [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.mafIsEmpty(os.path.join(tmpDir, 'extracted.maf'), g_headers))
         self.assertTrue(mafval.validateMaf(os.path.join(tmpDir, 'extracted.maf'), customOpts))
         mtt.removeDir(tmpDir)
Example #22
0
 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)