コード例 #1
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)
コード例 #2
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)