diff --git a/test_polyfun.py b/test_polyfun.py index b13b32e..e7b7faa 100644 --- a/test_polyfun.py +++ b/test_polyfun.py @@ -98,9 +98,10 @@ def test_munge_sumstats(tmpdir, python3_exe): output_file = os.path.join(tmpdir, outfile) gold_file = os.path.join(gold_dir, outfile) - retval = os.system('%s %s --sumstats %s --out %s --n 327209 --min-info 0.6 --min-maf 0.001'%(python3_exe, script_exe, input_file, output_file)) + cmd = '%s %s --sumstats %s --out %s --n 327209 --min-info 0.6 --min-maf 0.001'%(python3_exe, script_exe, input_file, output_file) + retval = os.system(cmd) if retval != 0: - raise ValueError('munge_sumstats command failed') + raise ValueError('munge_sumstats command failed when running the following command:\n%s'%(cmd)) compare_dfs(tmpdir, gold_dir, outfile) @@ -123,26 +124,29 @@ def test_polyfun(tmpdir, python3_exe): plink_prefix = os.path.join(example_dir, 'reference.') #polyfun stage 2 - retval = os.system('%s %s --compute-h2-L2 --output-prefix %s --sumstats %s --ref-ld-chr %s --w-ld-chr %s --nnls-exact'% - (python3_exe, script_exe, output_prefix, sumstats_file, ref_ld_prefix, w_ld_prefix)) + cmd = '%s %s --compute-h2-L2 --output-prefix %s --sumstats %s --ref-ld-chr %s --w-ld-chr %s --nnls-exact' % \ + (python3_exe, script_exe, output_prefix, sumstats_file, ref_ld_prefix, w_ld_prefix) + retval = os.system(cmd) if retval != 0: - raise ValueError('PolyFun command failed') + raise ValueError('PolyFun command failed when running the following command:\n%s'%(cmd)) for outfile in ['testrun.22.bins.parquet', 'testrun.22.snpvar_ridge_constrained.gz', 'testrun.22.snpvar_ridge.gz', 'testrun.22.l2.M']: compare_dfs(tmpdir, gold_dir, outfile) #polyfun stage 3 - retval = os.system('%s %s --compute-ldscores --output-prefix %s --bfile-chr %s --nnls-exact'% - (python3_exe, script_exe, output_prefix, plink_prefix)) + cmd = '%s %s --compute-ldscores --output-prefix %s --bfile-chr %s --nnls-exact'% \ + (python3_exe, script_exe, output_prefix, plink_prefix) + retval = os.system(cmd) if retval != 0: - raise ValueError('PolyFun command failed') + raise ValueError('PolyFun command failed when running the following command:\n%s'%(cmd)) compare_dfs(tmpdir, gold_dir, 'testrun.22.l2.ldscore.parquet') #polyfun stage 4 - retval = os.system('%s %s --compute-h2-bins --output-prefix %s --sumstats %s --w-ld-chr %s --nnls-exact'% - (python3_exe, script_exe, output_prefix, sumstats_file, w_ld_prefix)) + cmd = '%s %s --compute-h2-bins --output-prefix %s --sumstats %s --w-ld-chr %s --nnls-exact'% \ + (python3_exe, script_exe, output_prefix, sumstats_file, w_ld_prefix) + retval = os.system(cmd) if retval != 0: - raise ValueError('PolyFun command failed') + raise ValueError('PolyFun command failed when running the following command:\n%s'%(cmd)) compare_dfs(tmpdir, gold_dir, 'testrun.22.snpvar_constrained.gz') @@ -164,29 +168,29 @@ def test_polyloc(tmpdir, python3_exe): posterior_file = os.path.join(example_dir, 'posterior_betas.gz') #polyloc stage 1 - polyloc_cmd = ('%s %s --compute-partitions --output-prefix %s --posterior %s --bfile-chr %s --nnls-exact'% + polyloc_cmd = ('%s %s --compute-partitions --output-prefix %s --posterior %s --bfile-chr %s --nnls-exact'% \ (python3_exe, script_exe, output_prefix, posterior_file, plink_prefix)) retval = os.system(polyloc_cmd) if retval != 0: - raise ValueError('PolyLoc command failed') + raise ValueError('PolyLoc command failed when running the following command:\n%s'%(polyloc_cmd)) for outfile in ['polyloc_test.22.bins.parquet', 'polyloc_test.22.l2.M']: compare_dfs(tmpdir, gold_dir, outfile) #polyloc stage 2 - polyloc_cmd = ('%s %s --compute-ldscores --output-prefix %s --bfile-chr %s --nnls-exact'% + polyloc_cmd = ('%s %s --compute-ldscores --output-prefix %s --bfile-chr %s --nnls-exact'% \ (python3_exe, script_exe, output_prefix, plink_prefix)) retval = os.system(polyloc_cmd) if retval != 0: - raise ValueError('PolyLoc command failed') + raise ValueError('PolyLoc command failed when running the following command:\n%s'%(polyloc_cmd)) compare_dfs(tmpdir, gold_dir, 'polyloc_test.22.l2.ldscore.parquet') #polyloc stage 3 - polyloc_cmd = ('%s %s --compute-polyloc --output-prefix %s --w-ld-chr %s --sumstats %s --nnls-exact'% + polyloc_cmd = ('%s %s --compute-polyloc --output-prefix %s --w-ld-chr %s --sumstats %s --nnls-exact'% \ (python3_exe, script_exe, output_prefix, w_ld_prefix, sumstats_file)) retval = os.system(polyloc_cmd) if retval != 0: - raise ValueError('PolyLoc command failed') + raise ValueError('PolyLoc command failed when running the following command:\n%s'%(polyloc_cmd)) for outfile in ['polyloc_test.bin_h2', 'polyloc_test.Mp']: compare_dfs(tmpdir, gold_dir, outfile) @@ -205,9 +209,10 @@ def test_extract_snpvar(tmpdir, python3_exe): output_file = os.path.join(tmpdir, outfile) gold_file = os.path.join(gold_dir, outfile) - retval = os.system('%s %s --sumstats %s --out %s'%(python3_exe, script_exe, input_file, output_file)) + cmd = '%s %s --sumstats %s --out %s'%(python3_exe, script_exe, input_file, output_file) + retval = os.system(cmd) if retval != 0: - raise ValueError('extract_snpvar command failed') + raise ValueError('extract_snpvar command failed when running the following command:\n%s'%(cmd)) compare_dfs(tmpdir, gold_dir, outfile) @@ -244,7 +249,7 @@ def test_finemapper_susie(tmpdir, python3_exe): #print(finemapper_cmd) retval = os.system(finemapper_cmd) if retval != 0: - raise ValueError('finemapper command failed') + raise ValueError('finemapper command failed when running the following command:\n%s'%(cmd)) compare_dfs(tmpdir, gold_dir, outfile, sort_column='SNP') @@ -282,7 +287,7 @@ def test_finemapper_finemap(tmpdir, python3_exe, finemap_exe): #print(finemapper_cmd) retval = os.system(finemapper_cmd) if retval != 0: - raise ValueError('finemapper command failed') + raise ValueError('finemapper command failed when running the following command:\n%s'%(cmd)) compare_dfs(tmpdir, gold_dir, outfile, sort_column='SNP')