-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
lots of updates to testing and docuementation
- Loading branch information
Showing
38 changed files
with
5,405 additions
and
993 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,3 +40,5 @@ cache: pip | |
script: | ||
- sh run_jared_tests.sh | ||
- sh run_andrew_tests.sh | ||
- sh run_jh_tests.sh | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
================================ | ||
================================================ | ||
vcf_to_sfs.py: Site Frequency Spectrum generator | ||
================================ | ||
================================================ | ||
.. automodule:: vcf_to_sfs | ||
|
||
|
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,222 @@ | ||
import unittest | ||
import filecmp | ||
import sys | ||
import os | ||
import logging | ||
import shutil | ||
import zipfile | ||
|
||
## Import scripts to test | ||
|
||
import pgpipe.vcf_bed_to_seq as vcf_bed_to_seq | ||
import pgpipe.vcf_to_sfs as vcf_to_sfs | ||
import pgpipe.vcf_to_dadi as vcf_to_dadi | ||
import pgpipe.vcf_to_treemix as vcf_to_treemix | ||
import pgpipe.vcf_to_gphocs as vcf_to_gphocs | ||
import pgpipe.vcf_to_fastsimcoal as vcf_to_fastsimcoal | ||
|
||
|
||
## Used to compare two files, returns bool | ||
def file_comp(test_output, expected_output): | ||
return filecmp.cmp(test_output, expected_output) | ||
|
||
|
||
|
||
class jh_function_tests (unittest.TestCase): | ||
|
||
def test_vcf_bed_to_seq1 (self): | ||
vcf_bed_to_seq.run(['--vcf','pan_example.vcf.gz', | ||
'--fasta-reference',"pan_example_ref.fa", | ||
'--model-file',"panmodels.model", | ||
'--modelname',"4Pop", | ||
'--region',"21:4431001-4499000", | ||
'--out','ppp_test_temp.out']) | ||
|
||
# Confirm that the output is what is expected | ||
self.assertTrue(file_comp('ppp_test_temp.out', | ||
'results/vcf_bed_to_seq_test.out')) | ||
|
||
# Remove the ouput | ||
self.addCleanup(os.remove, 'ppp_test_temp.out') | ||
|
||
|
||
def test_vcf_to_sfs1 (self): | ||
|
||
vcf_to_sfs.run(['--vcf',"pan_example2.vcf.gz", | ||
'--model-file',"panmodels.model", | ||
'--modelname','4Pop', | ||
'--downsamplesizes','3','3','3','4', | ||
'--folded','--outgroup-fasta',"chr22_pan_example2_ref.fa", | ||
'--out',"ppp_test_temp.out"]) | ||
|
||
# Confirm that the output is what is expected | ||
self.assertTrue(file_comp('ppp_test_temp.out', | ||
'results/vcf_to_sfs_test1.txt')) | ||
|
||
# Remove the ouput | ||
self.addCleanup(os.remove, 'ppp_test_temp.out') | ||
|
||
def test_vcf_to_sfs2 (self): | ||
vcf_to_sfs.run(['--vcf',"pan_example.vcf.gz", | ||
'--model-file',"panmodels.model",'--modelname','5Pop', | ||
'--downsamplesizes','3','3','3','4','2', | ||
'--folded','--outgroup-fasta',"pan_example_ref.fa", | ||
'--out',"ppp_test_temp.out"]) | ||
|
||
|
||
# Confirm that the output is what is expected | ||
self.assertTrue(file_comp('ppp_test_temp.out', | ||
'results/vcf_to_sfs_test2.txt')) | ||
|
||
# Remove the ouput | ||
self.addCleanup(os.remove, 'ppp_test_temp.out') | ||
|
||
|
||
def test_vcf_to_gphocs1 (self): | ||
vcf_to_gphocs.run(['--vcf','pan_example.vcf.gz','--reference', | ||
"pan_example_ref.fa", | ||
'--model-file',"panmodels.model",'--modelname',"4Pop", | ||
'--bed-file',"pan_example_regions.bed", | ||
'--out','ppp_test_temp.out']) | ||
|
||
|
||
|
||
# Confirm that the output is what is expected | ||
self.assertTrue(file_comp('ppp_test_temp.out', | ||
'results/vcf_gphocs_test.out')) | ||
|
||
# Remove the ouput | ||
self.addCleanup(os.remove, 'ppp_test_temp.out') | ||
def test_vcf_to_gphocs2 (self): | ||
vcf_to_gphocs.run(['--vcf','pan_example2.vcf.gz','--reference', | ||
"chr22_pan_example2_ref.fa", | ||
'--model-file',"panmodels.model",'--modelname',"4Pop", | ||
'--bed-file',"pan_test_regions.bed", | ||
'--out','ppp_test_temp.out','--diploid','False']) | ||
|
||
|
||
# Confirm that the output is what is expected | ||
self.assertTrue(file_comp('ppp_test_temp.out', | ||
'results/vcf_gphocs_test2.out')) | ||
|
||
# Remove the ouput | ||
self.addCleanup(os.remove, 'ppp_test_temp.out') | ||
|
||
def test_vcf_to_treemix1(self): | ||
|
||
vcf_to_treemix.run(['--vcf','pan_example.vcf.gz', | ||
'--model-file',"panmodels.model", | ||
'--modelname',"4Pop", | ||
'--out','ppp_test_temp.out', | ||
'--bed-file',"pan_example_regions.bed", | ||
'--kblock','1000']) | ||
# Confirm that the output is what is expected | ||
self.assertTrue(file_comp('ppp_test_temp.out.gz', | ||
'results/vcf_treemixtest1.gz')) | ||
|
||
# Remove the ouput | ||
self.addCleanup(os.remove, 'ppp_test_temp.out.gz') | ||
|
||
def test_vcf_to_treemix2(self): | ||
vcf_to_treemix.run(['--vcf','pan_example.vcf.gz', | ||
'--model-file',"panmodels.model", | ||
'--modelname',"4Pop", | ||
'--out','ppp_test_temp.out']) | ||
# Confirm that the output is what is expected | ||
self.assertTrue(file_comp('ppp_test_temp.out.gz', | ||
'results/vcf_treemixtest2.gz')) | ||
|
||
# Remove the ouput | ||
self.addCleanup(os.remove, 'ppp_test_temp.out.gz') | ||
|
||
|
||
def test_vcf_to_fastsimcoal1(self): | ||
|
||
vcf_to_fastsimcoal.run(['--vcf',"pan_example.vcf.gz", | ||
'--model-file',"panmodels.model", | ||
'--modelname','3Pop', | ||
'--dim','1','2','m', | ||
'--basename','ppp_test_temp.out']) | ||
# must extract archives to check that files match | ||
pz = zipfile.ZipFile('ppp_test_temp.out.zip',mode='r') | ||
vz = zipfile.ZipFile('results/vcf_fsc1.zip',mode='r') | ||
pznl = pz.namelist() | ||
vznl = vz.namelist() | ||
assert len(pznl) == len(vznl) | ||
for fi in range(len(pznl)): | ||
pz.extract(pznl[fi]) | ||
vz.extract(vznl[fi]) | ||
# Confirm that the output is what is expected | ||
self.assertTrue(file_comp(pznl[fi],vznl[fi])) | ||
# remove extracted files | ||
self.addCleanup(os.remove, pznl[fi]) | ||
self.addCleanup(os.remove, vznl[fi]) | ||
|
||
|
||
def test_vcf_to_fastsimcoal2(self): | ||
|
||
vcf_to_fastsimcoal.run(['--vcf',"pan_example2.vcf.gz", | ||
'--model-file',"panmodels.model", | ||
'--modelname','5Pop', | ||
'--downsamplesizes','3','3','3','4','2', | ||
'--basename','ppp_test_temp.out', | ||
'--folded','--dim','1','2','m', | ||
'--outgroup-fasta',"chr22_pan_example2_ref.fa"]) | ||
# must extract archives to check that files match | ||
pz = zipfile.ZipFile('ppp_test_temp.out.zip',mode='r') | ||
vz = zipfile.ZipFile('results/vcf_fsc2.zip',mode='r') | ||
pznl = pz.namelist() | ||
vznl = vz.namelist() | ||
assert len(pznl) == len(vznl) | ||
for fi in range(len(pznl)): | ||
pz.extract(pznl[fi]) | ||
vz.extract(vznl[fi]) | ||
# Confirm that the output is what is expected | ||
self.assertTrue(file_comp(pznl[fi],vznl[fi])) | ||
# remove extracted files | ||
self.addCleanup(os.remove, pznl[fi]) | ||
self.addCleanup(os.remove, vznl[fi]) | ||
|
||
|
||
def test_vcf_to_dadi1(self): | ||
|
||
vcf_to_dadi.run(['--vcf','pan_example.vcf.gz', | ||
'--model-file',"panmodels.model", | ||
'--modelname',"4Pop",'--out','ppp_test_temp.out', | ||
'--comment','testing bedfile', | ||
'--bed-file',"pan_example_regions.bed"]) | ||
# Confirm that the output is what is expected | ||
self.assertTrue(file_comp('ppp_test_temp.out', | ||
'results/vcf_dadisnp_bedfile_test.out')) | ||
# Remove the ouput | ||
self.addCleanup(os.remove, 'ppp_test_temp.out') | ||
|
||
|
||
def test_vcf_to_dadi2(self): | ||
vcf_to_dadi.run(['--vcf',"pan_example2.vcf.gz", | ||
'--model-file',"panmodels.model", | ||
'--modelname',"4Pop",'--out','ppp_test_temp.out', | ||
'--comment','testing comment']) | ||
# Confirm that the output is what is expected | ||
self.assertTrue(file_comp('ppp_test_temp.out', | ||
'results/vcf_dadisnp_test.out')) | ||
# Remove the ouput | ||
self.addCleanup(os.remove, 'ppp_test_temp.out') | ||
|
||
def test_vcf_to_dadi3(self): | ||
vcf_to_dadi.run(['--vcf',"pan_example2.vcf.gz",'--model-file', | ||
"panmodels.model", | ||
'--modelname',"4Pop",'--out','ppp_test_temp.out', | ||
'--comment','testing outgroup-fasta','--outgroup-fasta', | ||
"chr22_pan_example2_ref.fa"]) | ||
# Confirm that the output is what is expected | ||
self.assertTrue(file_comp('ppp_test_temp.out', | ||
'results/vcf_dadisnp_fasta_test.out')) | ||
# Remove the ouput | ||
self.addCleanup(os.remove, 'ppp_test_temp.out') | ||
|
||
if __name__ == "__main__": | ||
unittest.main(verbosity = 2) | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
22 19999999 20001000 | ||
22 29999999 30010000 | ||
22 14430599 14431600 | ||
22 15658547 15659548 | ||
|
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.