From 14c1698ed44501d45379ac0e7bf6f8cee18f8f65 Mon Sep 17 00:00:00 2001 From: Tyghe Vallard Date: Mon, 8 Feb 2016 12:55:11 -0500 Subject: [PATCH] adding in generic test libraries and converted trim_reads tests to use them --- .gitignore | 3 +++ tests/common_robot.txt | 23 +++++++++++++++++++++++ tests/trim_reads.robot | 40 +++++++++++++++------------------------- 3 files changed, 41 insertions(+), 25 deletions(-) diff --git a/.gitignore b/.gitignore index 91d92b5..22e0688 100644 --- a/.gitignore +++ b/.gitignore @@ -69,3 +69,6 @@ target/ *~ *.swp *.swo + +# Project ignores +tests/testoutput diff --git a/tests/common_robot.txt b/tests/common_robot.txt index 77a3e60..39459be 100644 --- a/tests/common_robot.txt +++ b/tests/common_robot.txt @@ -32,3 +32,26 @@ Directory Should Have Items [Arguments] ${path} @{expected} ${items} = List Directory ${path} Lists Should Be Equal ${items} ${expected} + +Run JIP Tool And Return RC And Output + [Arguments] ${cmdline} ${expected_rc}=0 ${jipdb}=${TESTOUTPUTDIR}/jip.db ${log_to_console}=True + ${result} = Run Process ${cmdline} shell=True stderr=STDOUT env:JIP_DB=${jipdb} + Run Keyword If ${log_to_console} Log To Console ${result.stdout} + Should Be Equal As Integers ${result.rc} ${expected_rc} + [return] ${result.rc} ${result.stdout} + +Ensure Tool Accepts Stdin And Outputs Stdout + [Arguments] ${tool_and_options} ${input_contents} ${expected_contents} + ${in_fastq} = Set Variable ${TESTOUTPUTDIR}/input.fastq + ${out_fastq} = Set Variable ${TESTOUTPUTDIR}/output.fastq + Create File ${in_fastq} ${input_contents} + ${rc} ${stdout} = Run Jip Tool And Return RC And Output cat ${in_fastq} | ${tool_and_options} | cat > ${out_fastq} + Log To Console ${stdout} + Should Be Equal As Integers ${rc} 0 + Verify File ${out_fastq} ${expected_contents} + +Normalized Input And Output Usage Statement + [Arguments] ${tool} + ${rc} ${stdout} = Run JIP Tool And Return RC And Output ${tool} --help expected_rc=1 + Should Contain ${stdout} [] [-p] + Should Contain ${stdout} [] diff --git a/tests/trim_reads.robot b/tests/trim_reads.robot index e6dc9bc..2bf32de 100644 --- a/tests/trim_reads.robot +++ b/tests/trim_reads.robot @@ -14,8 +14,8 @@ ${fastq_content} @trimid\nNNNNNNNNNNAAAAAAAAAANNNNNNNNNN\n+\n5555555 ${interleave_content} ${fastq_content}\n${fastq_content} ${in_fastq} = ${TESTOUTPUTDIR}/trim_me.fastq ${testout} = ${TESTOUTPUTDIR}/output -${trimmed_fq} = @trimid\nAAAAAAAAAA\n+\nIIIIIIIIII -${out_fastq} = ${trimmed_fq}\n${trimmed_fq}\n +${trimmed_fq} = @trimid\nAAAAAAAAAA\n+\nIIIIIIIIII\n +${out_fastq} = ${trimmed_fq}${trimmed_fq} ${tool} = ${jip_path}/trim_reads.jip ${jipdb} = ${TESTOUTPUTDIR}/jip.db @@ -23,41 +23,31 @@ ${jipdb} = ${TESTOUTPUTDIR}/jip.db # Normal execution trim_reads paired trims Ns Create File ${in_fastq} ${interleave_content} - ${result} = Run Process ${tool} ${in_fastq} -p -o ${testout}.fastq -t shell=True stderr=STDOUT env:JIP_DB=${jipdb} - Log To Console ${result.stdout} - Should Contain ${result.stdout} --trim-n is not supported at this time - #Should Be Equal As Integers ${result.rc} 0 - #Verify File ${testout}.fastq ${out_fastq} + ${rc} ${stdout} = Run JIP Tool And Return RC And Output ${tool} ${in_fastq} -p -o ${testout}.fastq -t expected_rc=1 + Should Contain ${stdout} --trim-n is not supported at this time trim_reads paired trims low quality Create File ${in_fastq} ${interleave_content} - ${result} = Run Process ${tool} ${in_fastq} -p -o ${testout}.fastq -q 25 30 shell=True stderr=STDOUT env:JIP_DB=${jipdb} - Log To Console ${result.stdout} - Should Be Equal As Integers ${result.rc} 0 + ${rc} ${stdout} = Run JIP Tool And Return RC And Output ${tool} ${in_fastq} -p -o ${testout}.fastq -q 25 30 Verify File ${testout}.fastq ${out_fastq} trim_reads paired removes bases Create File ${in_fastq} ${interleave_content} - ${result} = Run Process ${tool} ${in_fastq} -p -o ${testout}.fastq -x 10 -10 shell=True stderr=STDOUT env:JIP_DB=${jipdb} - Log To Console ${result.stdout} - Should Be Equal As Integers ${result.rc} 0 + ${rc} ${stdout} = Run JIP Tool And Return RC And Output ${tool} ${in_fastq} -p -o ${testout}.fastq -x 10 -10 Verify File ${testout}.fastq ${out_fastq} -trim_reads paired accepts interleave input - Create File ${in_fastq} ${interleave_content} - ${result} = Run Process ${tool} ${in_fastq} -p -o ${testout}.fastq -x 10 -10 shell=True stderr=STDOUT env:JIP_DB=${jipdb} - Log To Console ${result.stdout} - Should Be Equal As Integers ${result.rc} 0 - Verify File ${testout}.fastq ${out_fastq} +trim_reads paired accepts unpaired input + Create File ${in_fastq} ${fastq_content} + ${rc} ${stdout} = Run JIP Tool And Return RC And Output ${tool} ${in_fastq} -p -o ${testout}.fastq -x 10 -10 + Verify File ${testout}.fastq ${trimmed_fq} trim_reads handles stdin/stdout pipe - Create File ${in_fastq} ${interleave_content} - ${result} = Run Process cat ${in_fastq} | ${tool} -x 10 -10 | cat > ${testout}.fastq shell=True stderr=STDOUT env:JIP_DB=${jipdb} - Log To Console ${result.stdout} - Should Be Equal As Integers ${result.rc} 0 - Verify File ${testout}.fastq ${out_fastq} - + Ensure Tool Accepts Stdin And Outputs Stdout ${tool} -x 10 -10 ${interleave_content} ${out_fastq} # End Normal execution +# Ensure normalized usage statements +trim_reads supports input and output + Normalized input And Output Usage Statement ${tool} + # Expected failures # End Expected failures