1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
|
# Copyright 2006 by Tiago Antao <tiagoantao@gmail.com>. All rights reserved.
# This code is part of the Biopython distribution and governed by its
# license. Please see the LICENSE file that should have been included
# as part of this package.
import commands
import os
import shutil
import sys
import tempfile
import unittest
from Bio.PopGen import SimCoal
from Bio.PopGen.SimCoal.Template import generate_simcoal_from_template
#Tests simcoal related code. Note: this case doesn't require simcoal
#test_PopGen_SimCoal tests code that requires simcoal
def run_tests(argv):
test_suite = testing_suite()
runner = unittest.TextTestRunner(sys.stdout, verbosity = 2)
runner.run(test_suite)
def testing_suite():
"""Generate the suite of tests.
"""
test_suite = unittest.TestSuite()
test_loader = unittest.TestLoader()
test_loader.testMethodPrefix = 't_'
tests = [TemplateTest]
for test in tests:
cur_suite = test_loader.loadTestsFromTestCase(test)
test_suite.addTest(cur_suite)
return test_suite
class TemplateTest(unittest.TestCase):
def t_template_full(self):
"""Full template creation test
"""
generate_simcoal_from_template('simple',
[(1, [('SNP', [24, 0.0005, 0.0])])],
[('sample_size', [30]),
('pop_size', [100])],
'PopGen')
assert(os.stat('PopGen' + os.sep + 'simple.par').st_size ==
os.stat('PopGen' + os.sep + 'simple_100_30.par').st_size)
def tearDown(self):
os.remove('PopGen' + os.sep + 'tmp.par')
os.remove('PopGen' + os.sep + 'simple_100_30.par')
if __name__ == "__main__":
sys.exit(run_tests(sys.argv))
|