diff --git a/pytest.ini b/pytest.ini new file mode 100644 index 0000000000000000000000000000000000000000..c8d98f29942ac24e83b741a0e102714b44230eab --- /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 940baa44123513af34bc00f464b9bb25bc849eda..0c4077ee501500129fd5d2596efbb5db48cfe63d 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 0000000000000000000000000000000000000000..dcbecebd6ce24ac96184f6fe06c24bdb9207751e --- /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