From 0bd2c98834da6cc0cfbb9fcb66fe8a98d41dd76e Mon Sep 17 00:00:00 2001
From: Venkat Malladi <venkat.malladi@utsouthwestern.edu>
Date: Tue, 15 Jan 2019 11:16:44 -0600
Subject: [PATCH] Split tests to make more readable.

---
 workflow/tests/test_annotate_peaks.py  | 19 ++++++++++++++--
 workflow/tests/test_call_peaks_macs.py | 28 +++++++++++++++++++++--
 workflow/tests/test_convert_reads.py   | 12 ++++++++--
 workflow/tests/test_diff_peaks.py      | 31 +++++++++++++++++++++++---
 workflow/tests/test_experiment_qc.py   | 25 +++++++++++++++++----
 workflow/tests/test_map_qc.py          | 20 +++++++++++++++--
 workflow/tests/test_motif_search.py    | 21 ++++++++++++-----
 workflow/tests/test_trim_reads.py      |  8 +++++++
 workflow/tests/test_xcor.py            | 12 ++++++++--
 9 files changed, 153 insertions(+), 23 deletions(-)

diff --git a/workflow/tests/test_annotate_peaks.py b/workflow/tests/test_annotate_peaks.py
index 4608f66..5c67640 100644
--- a/workflow/tests/test_annotate_peaks.py
+++ b/workflow/tests/test_annotate_peaks.py
@@ -11,18 +11,33 @@ test_output_path = os.path.dirname(os.path.abspath(__file__)) + \
 
 
 @pytest.mark.singleend
-def test_annotate_peaks_singleend():
+def test_pie_singleend():
     assert os.path.exists(os.path.join(test_output_path, 'ENCSR238SGC.chipseeker_pie.pdf'))
+
+
+@pytest.mark.singleend
+def test_upsetplot_singleend():
     assert os.path.exists(os.path.join(test_output_path, 'ENCSR238SGC.chipseeker_upsetplot.pdf'))
+
+@pytest.mark.singleend
+def test_annotation_singleend():
     annotation_file = test_output_path + 'ENCSR238SGC.chipseeker_annotation.tsv'
     assert os.path.exists(annotation_file)
     assert utils.count_lines(annotation_file) == 149820
 
 
 @pytest.mark.pairedend
-def test_annotate_peaks_pairedend():
+def test_pie_pairedend():
     assert os.path.exists(os.path.join(test_output_path, 'ENCSR729LGA.chipseeker_pie.pdf'))
+
+
+@pytest.mark.pairedend
+def test_upsetplot_pairedend():
     assert os.path.exists(os.path.join(test_output_path, 'ENCSR729LGA.chipseeker_upsetplot.pdf'))
+
+
+@pytest.mark.pairedend
+def test_annotation_pairedend():
     annotation_file = test_output_path + 'ENCSR729LGA.chipseeker_annotation.tsv'
     assert os.path.exists(annotation_file)
     assert utils.count_lines(annotation_file) == 25579
diff --git a/workflow/tests/test_call_peaks_macs.py b/workflow/tests/test_call_peaks_macs.py
index 628a914..91c1d0e 100644
--- a/workflow/tests/test_call_peaks_macs.py
+++ b/workflow/tests/test_call_peaks_macs.py
@@ -9,18 +9,42 @@ test_output_path = os.path.dirname(os.path.abspath(__file__)) + \
 
 
 @pytest.mark.singleend
-def test_call_peaks_macs_singleend():
+def test_fc_signal_singleend():
     assert os.path.exists(os.path.join(test_output_path, 'ENCLB144FDT.fc_signal.bw'))
+
+
+@pytest.mark.singleend
+def test_pvalue_signal_singleend():
     assert os.path.exists(os.path.join(test_output_path, 'ENCLB144FDT.pvalue_signal.bw'))
+
+
+@pytest.mark.singleend
+def test_peaks_xls_singleend():
     assert os.path.exists(os.path.join(test_output_path, 'ENCLB144FDT_peaks.xls'))
+
+
+@pytest.mark.singleend
+def test_peaks_bed_singleend():
     peak_file = test_output_path + 'ENCLB144FDT.narrowPeak'
     assert utils.count_lines(peak_file) == 227389
 
 
 @pytest.mark.pairedend
-def test_call_peaks_macs_pairedend():
+def test_fc_signal_pairedend():
     assert os.path.exists(os.path.join(test_output_path, 'ENCLB568IYX.fc_signal.bw'))
+
+
+@pytest.mark.pairedend
+def test_pvalue_signal_pairedend():
     assert os.path.exists(os.path.join(test_output_path, 'ENCLB568IYX.pvalue_signal.bw'))
+
+
+@pytest.mark.pairedend
+def test_peaks_xls_pairedend():
     assert os.path.exists(os.path.join(test_output_path, 'ENCLB568IYX_peak.xls'))
+
+
+@pytest.mark.pairedend
+def test_peaks_bed_pairedend():
     peak_file = test_output_path + 'ENCLB568IYX.narrowPeak'
     assert utils.count_lines(peak_file) == 113821
diff --git a/workflow/tests/test_convert_reads.py b/workflow/tests/test_convert_reads.py
index d1ef045..8dda746 100644
--- a/workflow/tests/test_convert_reads.py
+++ b/workflow/tests/test_convert_reads.py
@@ -8,12 +8,20 @@ test_output_path = os.path.dirname(os.path.abspath(__file__)) + \
 
 
 @pytest.mark.singleend
-def test_convert_reads_singleend():
+def test_tag_reads_singleend():
     assert os.path.exists(os.path.join(test_output_path, 'ENCLB831RUI.tagAlign.gz'))
+
+
+@pytest.mark.singleend
+def test_bed_reads_singleend():
     assert os.path.exists(os.path.join(test_output_path, 'ENCLB831RUI.bedse.gz'))
 
 
 @pytest.mark.pairedend
-def test_map_qc_pairedend():
+def test_tag_reads_pairedend():
     assert os.path.exists(os.path.join(test_output_path, 'ENCLB568IYX.tagAlign.gz'))
+
+
+@pytest.mark.pairedend
+def test_bed_reads_pairedend():
     assert os.path.exists(os.path.join(test_output_path, 'ENCLB568IYX.bedpe.gz'))
diff --git a/workflow/tests/test_diff_peaks.py b/workflow/tests/test_diff_peaks.py
index 59b1e3a..84c5179 100644
--- a/workflow/tests/test_diff_peaks.py
+++ b/workflow/tests/test_diff_peaks.py
@@ -15,14 +15,26 @@ def test_diff_peaks_singleend_single_rep():
     assert os.path.isdir(test_output_path) == False
 
 @pytest.mark.pairedend
-def test_annotate_peaks_pairedend_single_rep():
+def test_diff_peaks_pairedend_single_rep():
     assert os.path.isdir(test_output_path) == False
 
 @pytest.mark.singlediff
-def test_diff_peaks_singleend_multiple_rep():
+def test_heatmap_singleend_multiple_rep():
     assert os.path.exists(os.path.join(test_output_path, 'heatmap.pdf'))
+
+
+@pytest.mark.singlediff
+def test_pca_singleend_multiple_rep():
     assert os.path.exists(os.path.join(test_output_path, 'pca.pdf'))
+
+
+@pytest.mark.singlediff
+def test_normcount_singleend_multiple_rep():
     assert os.path.exists(os.path.join(test_output_path, 'normcount_peaksets.txt'))
+
+
+@pytest.mark.singlediff
+def test_diffbind_singleend_multiple_rep():
     if os.path.isfile(os.path.join(test_output_path, 'ENCSR272GNQ_vs_ENCSR238SGC_diffbind.bed')):
         assert os.path.exists(os.path.join(test_output_path, 'ENCSR272GNQ_vs_ENCSR238SGC_diffbind.bed'))
         diffbind_file = test_output_path + 'ENCSR272GNQ_vs_ENCSR238SGC_diffbind.csv'
@@ -32,11 +44,24 @@ def test_diff_peaks_singleend_multiple_rep():
     assert os.path.exists(diffbind_file)
     assert utils.count_lines(diffbind_file) == 201039
 
+
 @pytest.mark.paireddiff
-def test_annotate_peaks_pairedend_single_rep():
+def test_heatmap_pairedend_single_rep():
     assert os.path.exists(os.path.join(test_output_path, 'heatmap.pdf'))
+
+
+@pytest.mark.paireddiff
+def test_pca_pairedend_single_rep():
     assert os.path.exists(os.path.join(test_output_path, 'pca.pdf'))
+
+
+@pytest.mark.paireddiff
+def test_normcount_pairedend_single_rep():
     assert os.path.exists(os.path.join(test_output_path, 'normcount_peaksets.txt'))
+
+
+@pytest.mark.paireddiff
+def test_diffbind_pairedend_single_rep():
     if os.path.isfile(os.path.join(test_output_path, 'ENCSR757EMK_vs_ENCSR729LGA_diffbind.bed')):
         assert os.path.exists(os.path.join(test_output_path, 'ENCSR757EMK_vs_ENCSR729LGA_diffbind.bed'))
         diffbind_file = test_output_path + 'ENCSR757EMK_vs_ENCSR729LGA_diffbind.csv'
diff --git a/workflow/tests/test_experiment_qc.py b/workflow/tests/test_experiment_qc.py
index 5256da5..98853b9 100644
--- a/workflow/tests/test_experiment_qc.py
+++ b/workflow/tests/test_experiment_qc.py
@@ -31,17 +31,34 @@ def test_check_update_controls(design_bam):
 
 
 @pytest.mark.singleend
-def test_experiment_qc_singleend():
+def test_coverage_singleend():
     assert os.path.exists(os.path.join(test_output_path, 'sample_mbs.npz'))
-    assert os.path.exists(os.path.join(test_output_path, 'heatmap_SpearmanCorr.png'))
     assert os.path.exists(os.path.join(test_output_path, 'coverage.png'))
+
+
+@pytest.mark.singleend
+def test_spearman_singleend():
+    assert os.path.exists(os.path.join(test_output_path, 'heatmap_SpearmanCorr.png'))
+
+
+@pytest.mark.singleend
+def test_fingerprint_singleend():
     assert os.path.exists(os.path.join(test_output_path, 'ENCLB144FDT_fingerprint.png'))
     assert os.path.exists(os.path.join(test_output_path, 'ENCLB831RUI_fingerprint.png'))
 
+
 @pytest.mark.pairdend
-def test_experiment_qc_pairedend():
+def test_coverage_pairedend():
     assert os.path.exists(os.path.join(test_output_path, 'sample_mbs.npz'))
-    assert os.path.exists(os.path.join(test_output_path, 'heatmap_SpearmanCorr.png'))
     assert os.path.exists(os.path.join(test_output_path, 'coverage.png'))
+
+
+@pytest.mark.pairdend
+def test_spearman_pairedend():
+    assert os.path.exists(os.path.join(test_output_path, 'heatmap_SpearmanCorr.png'))
+
+
+@pytest.mark.pairdend
+def test_fingerprint_pairedend():
     assert os.path.exists(os.path.join(test_output_path, 'ENCLB568IYX_fingerprint.png'))
     assert os.path.exists(os.path.join(test_output_path, 'ENCLB637LZP_fingerprint.png'))
diff --git a/workflow/tests/test_map_qc.py b/workflow/tests/test_map_qc.py
index 1c0d23e..f292559 100644
--- a/workflow/tests/test_map_qc.py
+++ b/workflow/tests/test_map_qc.py
@@ -9,14 +9,22 @@ test_output_path = os.path.dirname(os.path.abspath(__file__)) + \
 
 
 @pytest.mark.singleend
-def test_map_qc_singleend():
+def test_dedup_files_singleend():
     assert os.path.exists(os.path.join(test_output_path, 'ENCLB831RUI.dedup.bam'))
     assert os.path.exists(os.path.join(test_output_path, 'ENCLB831RUI.dedup.bam.bai'))
     assert os.path.exists(os.path.join(test_output_path, 'ENCLB831RUI.dedup.qc'))
+
+
+@pytest.mark.singleend
+def test_map_qc_singleend():
     filtered_reads_report = test_output_path + 'ENCLB831RUI.dedup.flagstat.qc'
     samtools_report = open(filtered_reads_report).readlines()
     assert '64962570 + 0 in total' in samtools_report[0]
     assert '64962570 + 0 mapped (100.00%:N/A)' in samtools_report[4]
+
+
+@pytest.mark.singleend
+def test_library_complexity_singleend():
     library_complexity = test_output_path + 'ENCLB831RUI.pbc.qc'
     df_library_complexity = pd.read_csv(library_complexity, sep='\t')
     assert  df_library_complexity["NRF"].iloc[0] == 0.926192
@@ -25,14 +33,22 @@ def test_map_qc_singleend():
 
 
 @pytest.mark.pairedend
-def test_map_qc_pairedend():
+def test_dedup_files_pairedend():
     assert os.path.exists(os.path.join(test_output_path, 'ENCLB568IYX.dedup.bam'))
     assert os.path.exists(os.path.join(test_output_path, 'ENCLB568IYX.dedup.bam.bai'))
     assert os.path.exists(os.path.join(test_output_path, 'ENCLB568IYX.dedup.qc'))
+
+
+@pytest.mark.pairedend
+def test_map_qc_pairedend():
     filtered_reads_report = test_output_path + 'ENCLB568IYX.dedup.flagstat.qc'
     samtools_report = open(filtered_reads_report).readlines()
     assert '47388510 + 0 in total' in samtools_report[0]
     assert '47388510 + 0 mapped (100.00%:N/A)' in samtools_report[4]
+
+
+@pytest.mark.pairedend
+def test_library_complexity_pairedend():
     library_complexity = test_output_path + 'ENCLB568IYX.pbc.qc'
     df_library_complexity = pd.read_csv(library_complexity, sep='\t')
     assert  df_library_complexity["NRF"].iloc[0] == 0.947064
diff --git a/workflow/tests/test_motif_search.py b/workflow/tests/test_motif_search.py
index 09b4ca9..8c12652 100644
--- a/workflow/tests/test_motif_search.py
+++ b/workflow/tests/test_motif_search.py
@@ -11,17 +11,26 @@ test_output_path = os.path.dirname(os.path.abspath(__file__)) + \
 
 
 @pytest.mark.singleend
-def test_motif_search_singleend():
-    assert os.path.exists(os.path.join(test_output_path, 'ENCSR238SGC_memechip', 'ENCSR238SGC.fa'))
-    assert os.path.exists(os.path.join(test_output_path, 'ENCSR238SGC_memechip', 'index.html'))
+def test_limited_peaks_singleend():
     peak_file_ENCSR238SGC = test_output_path + 'ENCSR238SGC.600.narrowPeak'
     assert os.path.exists(peak_file_ENCSR238SGC)
     assert utils.count_lines(peak_file_ENCSR238SGC) == 600
 
+
+@pytest.mark.singleend
+def test_motif_search_singleend():
+    assert os.path.exists(os.path.join(test_output_path, 'ENCSR238SGC_memechip', 'ENCSR238SGC.fa'))
+    assert os.path.exists(os.path.join(test_output_path, 'ENCSR238SGC_memechip', 'index.html'))
+
+
 @pytest.mark.pairedend
-def test_motif_search_pairedend():
-    assert os.path.exists(os.path.join(test_output_path, 'ENCSR729LGA_memechip',  'ENCSR729LGA.fa'))
-    assert os.path.exists(os.path.join(test_output_path, 'ENCSR729LGA_memechip', 'index.html'))
+def test_limited_peaks_pairedend():
     peak_file_ENCSR729LGA= test_output_path + 'ENCSR729LGA.600.narrowPeak'
     assert os.path.exists(peak_file_ENCSR729LGA)
     assert utils.count_lines(peak_file_ENCSR729LGA) == 600
+
+    
+@pytest.mark.pairedend
+def test_motif_search_pairedend():
+    assert os.path.exists(os.path.join(test_output_path, 'ENCSR729LGA_memechip',  'ENCSR729LGA.fa'))
+    assert os.path.exists(os.path.join(test_output_path, 'ENCSR729LGA_memechip', 'index.html'))
diff --git a/workflow/tests/test_trim_reads.py b/workflow/tests/test_trim_reads.py
index dd3f779..449b5fd 100644
--- a/workflow/tests/test_trim_reads.py
+++ b/workflow/tests/test_trim_reads.py
@@ -14,6 +14,10 @@ test_output_path = os.path.dirname(os.path.abspath(__file__)) + \
 def test_trim_reads_singleend():
     raw_fastq = test_data_path + 'ENCFF833BLU.fastq.gz'
     trimmed_fastq = test_output_path + 'ENCLB144FDT_R1_trimmed.fq.gz'
+
+
+@pytest.mark.singleend
+def test_trim_report_singleend():
     trimmed_fastq_report = test_output_path + \
                             'ENCLB144FDT_R1_trimmed.fq.gz_trimming_report.txt'
     assert os.path.getsize(raw_fastq) != os.path.getsize(trimmed_fastq)
@@ -25,6 +29,10 @@ def test_trim_reads_singleend():
 def test_trim_reads_pairedend():
     raw_fastq = test_data_path + 'ENCFF582IOZ.fastq.gz'
     trimmed_fastq = test_output_path + 'ENCLB637LZP_R2_val_2.fq.gz'
+
+
+@pytest.mark.pairedend
+def test_trim_report_pairedend():
     trimmed_fastq_report = test_output_path + \
                             'ENCLB637LZP_R2.fastq.gz_trimming_report.txt'
     assert os.path.getsize(raw_fastq) != os.path.getsize(trimmed_fastq)
diff --git a/workflow/tests/test_xcor.py b/workflow/tests/test_xcor.py
index c408c98..259ecfb 100644
--- a/workflow/tests/test_xcor.py
+++ b/workflow/tests/test_xcor.py
@@ -9,8 +9,12 @@ test_output_path = os.path.dirname(os.path.abspath(__file__)) + \
 
 
 @pytest.mark.singleend
-def test_cross_singleend():
+def test_cross_plot_singleend():
     assert os.path.exists(os.path.join(test_output_path, 'ENCLB144FDT.cc.plot.pdf'))
+
+
+@pytest.mark.singleend
+def test_cross_qc_singleend():
     qc_file = os.path.join(test_output_path,"ENCLB144FDT.cc.qc")
     df_xcor = pd.read_csv(qc_file, sep="\t", header=None)
     assert df_xcor[2].iloc[0] == '190,200,210'
@@ -19,8 +23,12 @@ def test_cross_singleend():
 
 
 @pytest.mark.pairedend
-def test_cross_pairedend():
+def test_cross_qc_pairedend():
     assert os.path.exists(os.path.join(test_output_path, 'ENCLB568IYX.cc.plot.pdf'))
+
+
+@pytest.mark.pairedend
+def test_cross_plot_pairedend():
     qc_file = os.path.join(test_output_path,"ENCLB568IYX.cc.qc")
     df_xcor = pd.read_csv(qc_file, sep="\t", header=None)
     assert df_xcor[2].iloc[0] == '220,430,475'
-- 
GitLab