Skip to content

Commit

Permalink
Fixed error due to altering vcf_calc
Browse files Browse the repository at this point in the history
  • Loading branch information
aewebb80 committed Jun 15, 2017
1 parent 7813ee0 commit 9e6fbf7
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions andrew/andrew_tests.py
Original file line number Diff line number Diff line change
@@ -1,56 +1,56 @@
import unittest, filecmp, sys, os
import vcftools
import vcftools_calc
import vcf_calc

def compare_to_expected(test_output, expected_output):
return filecmp.cmp(test_output, expected_output)

class vcftools_tests (unittest.TestCase):

def test_vcf_argument_parser (self):
input_arg = vcftools.assign_vcftools_input_arg('example/locus8.vcf.gz')
self.assertEqual(input_arg, ['--gzvcf', 'example/locus8.vcf.gz'])

def test_produce_vcftools_log (self):
vcftools.produce_vcftools_log('Log Test:\n1\n2\n3\n', 'out', '.logTest')
self.assertTrue(compare_to_expected('out.logTest.log', 'example/locus8.logTest.log'))
self.addCleanup(os.remove, 'out.logTest.log')

def test_check_vcftools_for_errors (self):
self.assertTrue(vcftools.check_vcftools_for_errors('Log Test:\n1\n2\n3\nRun Time'))
with self.assertRaises(SystemExit) as cm:
vcftools.check_vcftools_for_errors('Log Test:\n1\n2\n3\nError: No Input')
self.assertEqual(cm.exception.code, 'Error: No Input')

def test_Fst_window (self):
vcftools_calc.run(['example/locus8.vcf.gz', '--calc-statistic', 'windowed-weir-fst', '--pop-file', 'example/Paniscus.txt', '--pop-file', 'example/Troglodytes.txt', '--out', 'out'])
vcf_calc.run(['example/locus8.vcf.gz', '--calc-statistic', 'windowed-weir-fst', '--pop-file', 'example/Paniscus.txt', '--pop-file', 'example/Troglodytes.txt', '--out', 'out'])
self.assertTrue(compare_to_expected('out.windowed.weir.fst', 'example/locus8.windowed.weir.fst'))
self.addCleanup(os.remove, 'out.windowed.weir.fst')
self.addCleanup(os.remove, 'out.windowed.weir.fst.log')

def test_tajimasD (self):
vcftools_calc.run(['example/locus8.vcf.gz', '--calc-statistic', 'TajimaD', '--out', 'out'])
def test_tajimasD (self):
vcf_calc.run(['example/locus8.vcf.gz', '--calc-statistic', 'TajimaD', '--out', 'out'])
self.assertTrue(compare_to_expected('out.Tajima.D', 'example/locus8.Tajima.D'))
self.addCleanup(os.remove, 'out.Tajima.D')
self.addCleanup(os.remove, 'out.Tajima.D.log')
def test_window_pi (self):
vcftools_calc.run(['example/locus8.vcf.gz', '--calc-statistic', 'pi', '--out', 'out'])

def test_window_pi (self):
vcf_calc.run(['example/locus8.vcf.gz', '--calc-statistic', 'pi', '--out', 'out'])
self.assertTrue(compare_to_expected('out.windowed.pi', 'example/locus8.windowed.pi'))
self.addCleanup(os.remove, 'out.windowed.pi')
self.addCleanup(os.remove, 'out.windowed.pi.log')
def test_freq (self):
vcftools_calc.run(['example/locus8.vcf.gz', '--calc-statistic', 'freq', '--out', 'out'])

def test_freq (self):
vcf_calc.run(['example/locus8.vcf.gz', '--calc-statistic', 'freq', '--out', 'out'])
self.assertTrue(compare_to_expected('out.frq', 'example/locus8.frq'))
self.addCleanup(os.remove, 'out.frq')
self.addCleanup(os.remove, 'out.frq.log')
def test_het (self):
vcftools_calc.run(['example/locus8.vcf.gz', '--calc-statistic', 'het', '--out', 'out'])

def test_het (self):
vcf_calc.run(['example/locus8.vcf.gz', '--calc-statistic', 'het', '--out', 'out'])
self.assertTrue(compare_to_expected('out.het', 'example/locus8.het'))
self.addCleanup(os.remove, 'out.het')
self.addCleanup(os.remove, 'out.het.log')

if __name__ == "__main__":
unittest.main()
unittest.main()

0 comments on commit 9e6fbf7

Please sign in to comment.