From dda7cf975383ca35201af709dc577efb2153f90c Mon Sep 17 00:00:00 2001 From: s181706 <jonathan.gesell@utsouthwestern.edu> Date: Thu, 23 Jan 2020 14:36:28 -0600 Subject: [PATCH] Added files necessary for CI of output files. --- pytest.ini | 2 ++ workflow/rna-seq.nf | 8 +++++--- workflow/tests/test_align.py | 40 ++++++++++++++++++++++++++++++++++++ 3 files changed, 47 insertions(+), 3 deletions(-) create mode 100644 pytest.ini create mode 100644 workflow/tests/test_align.py diff --git a/pytest.ini b/pytest.ini new file mode 100644 index 0000000..c8d98f2 --- /dev/null +++ b/pytest.ini @@ -0,0 +1,2 @@ +[pytest] +python_paths = workflow/scripts diff --git a/workflow/rna-seq.nf b/workflow/rna-seq.nf index 940baa4..0c4077e 100755 --- a/workflow/rna-seq.nf +++ b/workflow/rna-seq.nf @@ -17,7 +17,7 @@ bdbag = Channel .ifEmpty { exit 1, "deriva cookie file for bdbag not found: ${params.bdbag}" } repRID = params.repRID outDir = params.outDir -reference = params.reference +referenceBase = file ("${params.reference}") logsDir = "${outDir}/Logs" // Define fixed files @@ -203,7 +203,7 @@ referenceDir.into { */ process trimData { tag "${repRID}" - publishDir "${logsDir}", mode: 'copy', pattern: "\${repRID}.trimData.*" + publishDir "${logsDir}", mode: 'copy', pattern: "${repRID}.trimData.*" input: val endsManual_trimData @@ -234,7 +234,8 @@ process trimData { */ process alignReads { tag "align-${repRID}" - publishDir "${outDir}/aligned", mode: "copy" + publishDir "${outDir}/aligned", mode: "copy", pattern: "${repRID}.{unal,sorted}.{gz,bam,bai}" + publishDir "${logsDir}", mode: 'copy', pattern: "${repRID}.align.{out,err}" input: val endsManual_alignReads @@ -244,6 +245,7 @@ process alignReads { output: set repRID, file ("${repRID}.unal.gz"), file ("${repRID}.sorted.bam"), file ("${repRID}.sorted.bai") + set repRID, file ("${repRID}.align.out"), file ("${repRID}.align.err") script: """ diff --git a/workflow/tests/test_align.py b/workflow/tests/test_align.py new file mode 100644 index 0000000..dcbeceb --- /dev/null +++ b/workflow/tests/test_align.py @@ -0,0 +1,40 @@ +#!/usr/bin/env python3 + +import pytest +import pandas as pd +import os +import utils + +data_output_path = os.path.dirname(os.path.abspath(__file__)) + \ + '/../../output/aligned' +logs_output_path = os.path.dirname(os.path.abspath(__file__)) + \ + '/../../output/Logs' + +@pytest.mark.alignData +def test_alignData_se(): + assert os.path.exists(os.path.join(data_output_path, '16-1ZX4.unal.gz')) + assert utils.count_lines(os.path.join(data_output_path, '16-1ZX4.unal.gz')) == 3070504 + assert os.path.exists(os.path.join(data_output_path, 'Q-Y5JA.sorted.bam')) + assert utils.count_lines(os.path.join(data_output_path, 'Q-Y5JA.sorted.bam')) == 5805611 + assert os.path.exists(os.path.join(data_output_path, 'Q-Y5JA.sorted.bai')) + assert utils.count_lines(os.path.join(data_output_path, 'Q-Y5JA.sorted.bai')) == 12824 +def test_alignData_pe(): + assert os.path.exists(os.path.join(data_output_path, 'Q-Y5JA.unal.gz')) + assert utils.count_lines(os.path.join(data_output_path, 'Q-Y5JA.unal.gz')) == 0 + assert os.path.exists(os.path.join(data_output_path, 'Q-Y5JA.sorted.bam')) + assert utils.count_lines(os.path.join(data_output_path, 'Q-Y5JA.sorted.bam')) == 5805611 + assert os.path.exists(os.path.join(data_output_path, 'Q-Y5JA.sorted.bai')) + assert utils.count_lines(os.path.join(data_output_path, 'Q-Y5JA.sorted.bai')) == 12824 +@pytest.mark.alignLogs +def test_alignLogs_se(): + assert os.path.exists(os.path.join(logs_output_path, '16-1ZX4.align.err')) + assert utils.count_lines(os.path.join(logs_output_path, '16-1ZX4.align.err')) == 7 + assert '34497376 reads; of these:' in open(os.path.join(logs_output_path, '16-1ZX4.align.err')).readlines()[0] + assert os.path.exists(os.path.join(logs_output_path, '16-1ZX4.align.out')) + assert utils.count_lines(os.path.join(logs_output_path, '16-1ZX4.align.out')) == 0 +def test_alignLogs_pe(): + assert os.path.exists(os.path.join(logs_output_path, 'Q-Y5JA.align.err')) + assert utils.count_lines(os.path.join(logs_output_path, 'Q-Y5JA.align.err')) == 7 + assert '15824858 reads; of these:' in open(os.path.join(logs_output_path, 'Q-Y5JA.align.err')).readlines()[0] + assert os.path.exists(os.path.join(logs_output_path, 'Q-Y5JA.align.out')) + assert utils.count_lines(os.path.join(logs_output_path, 'Q-Y5JA.align.out')) == 0 -- GitLab