Skip to content

Commit

Permalink
Merge pull request #152
Browse files Browse the repository at this point in the history
Refactor tests
  • Loading branch information
edmundmiller authored Aug 5, 2024
2 parents 6592199 + 04d4162 commit 98d646b
Show file tree
Hide file tree
Showing 24 changed files with 648 additions and 550 deletions.
4 changes: 4 additions & 0 deletions assets/small_samplesheet.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
sample,fastq_1,fastq_2
cd4_REP1,https://raw.githubusercontent.com/nf-core/test-datasets/nascent/testdata/SRX882903_T1.fastq.gz,
cd4_REP2,https://raw.githubusercontent.com/nf-core/test-datasets/nascent/testdata/SRX882903_T2.fastq.gz,
jurkat,https://raw.githubusercontent.com/nf-core/test-datasets/nascent/testdata/SRX882904_T1.fastq.gz,
3 changes: 3 additions & 0 deletions nf-test.config
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,8 @@ config {
testsDir "."
workDir System.getenv("NFT_WORKDIR") ?: ".nf-test"
configFile "tests/nextflow.config"
plugins {
load "nft-bam@0.3.0"
}

}
11 changes: 11 additions & 0 deletions tests/lib/UTILS.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Function to remove Nextflow version from pipeline_software_mqc_versions.yml

class UTILS {
public static String removeNextflowVersion(pipeline_software_mqc_versions) {
def softwareVersions = path(pipeline_software_mqc_versions).yaml
if (softwareVersions.containsKey("Workflow")) {
softwareVersions.Workflow.remove("Nextflow")
}
return softwareVersions
}
}
2 changes: 1 addition & 1 deletion tests/nextflow.config
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ dag { enabled = false }
// HACK Hard code all the params for now
params {
// Input data
input = "${projectDir}/assets/samplesheet.csv"
input = "${projectDir}/assets/small_samplesheet.csv"

// Genome references
fasta = 'https://raw.githubusercontent.com/nf-core/test-datasets/nascent/reference/GRCh38_chr21.fa'
Expand Down
48 changes: 48 additions & 0 deletions workflows/tests/aligner/bowtie2.nf.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
nextflow_pipeline {

name "Bowtie2"
script "../../../main.nf"
tag "aligner"
tag "bowtie2"

test("Should run with defaults") {

when {
params {
outdir = "$outputDir"
aligner = "bowtie2"
}
}

then {
assertAll(
{ assert workflow.success },
{ assert snapshot(UTILS.removeNextflowVersion("$outputDir/pipeline_info/nf_core_pipeline_software_mqc_versions.yml")).match("software_versions") },
{ assert snapshot(
workflow.trace.tasks().size(),
path("$outputDir/bbmap").list(),
// BUG https://github.com/nf-core/nascent/issues/102
// path("$outputDir/bedtools").list(),
// FIXME gtf2bed isn't deterministic
// path("$outputDir/bwa/featurecounts/gene").list(),
// FIXME cd4 isn't deterministic
// path("$outputDir/bwa/featurecounts/predicted").list(),
// path("$outputDir/deeptools").list(),
// path("$outputDir/fastp/*.json").list(),
// FIXME gtf2bed isn't deterministic
// path("$outputDir/gtf2bed").list(),
path("$outputDir/homer/cd4.bed"),
path("$outputDir/homer/jurkat.bed"),
// FIXME https://github.com/nf-core/nascent/issues/148
// path("$outputDir/preseq").list(),
// path("$outputDir/rseqc").list(),
// FIXME Bowtie2 isn't deterministic
bam("$outputDir/samtools/cd4_REP1.sorted.bam").getHeaderMD5(),
bam("$outputDir/samtools/cd4_REP2.sorted.bam").getHeaderMD5(),
bam("$outputDir/samtools/jurkat.sorted.bam").getHeaderMD5(),
).match("output_files")
}
)
}
}
}
35 changes: 35 additions & 0 deletions workflows/tests/aligner/bowtie2.nf.test.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"output_files": {
"content": [
75,
[
"cd4_REP1.coverage.hist.txt:md5,ffd8c0a94869dd782779fc871a9b781a",
"cd4_REP1.coverage.stats.txt:md5,bebdef1adcce4296878f8699a0f5cb32",
"cd4_REP2.coverage.hist.txt:md5,6e0ca13df7b06ff6a81fb21596df4ca4",
"cd4_REP2.coverage.stats.txt:md5,ffb701c2be33360a96ce85b1330b13f8",
"jurkat.coverage.hist.txt:md5,656e30e8c4bd12e45a036c62c18730c1",
"jurkat.coverage.stats.txt:md5,627f0ec96ea9bdbd7f41b09b64c389d6"
],
"cd4.bed:md5,c311e32ebdca7f3e978a271407de7241",
"jurkat.bed:md5,5e170e72c4e2b27a7bb0a6de7b735c1c",
"7945f971cd63ad99ff2d9cc81e19ea39",
"43982cec9077e7030428267841cf04ef",
"8813c6dd42cabd94042f4f9e4aee3560"
],
"meta": {
"nf-test": "0.9.0",
"nextflow": "24.04.4"
},
"timestamp": "2024-08-03T22:17:27.92555495"
},
"software_versions": {
"content": [
"{BBMAP_PILEUP={bbmap=39.01, samtools=1.16.1, pigz=2.6}, BEDTOOLS_GENOMECOV_MINUS={bedtools=2.31.1}, BEDTOOLS_GENOMECOV_PLUS={bedtools=2.31.1}, BEDTOOLS_INTERSECT={bedtools=2.31.1}, BEDTOOLS_INTERSECT_FILTER={bedtools=2.31.1}, BOWTIE2_ALIGN={bowtie2=2.5.2, samtools=1.18, pigz=2.6}, DEEPTOOLS_BAMCOVERAGE_MINUS={deeptools=3.5.1}, DEEPTOOLS_BAMCOVERAGE_PLUS={deeptools=3.5.1}, FASTP={fastp=0.23.4}, FASTQC={fastqc=0.12.1}, GTF2BED={perl=5.26.2}, HOMER_MAKETAGDIRECTORY={homer=4.11, samtools=1.11}, PRESEQ_CCURVE={preseq=3.1.1}, PRESEQ_LCEXTRAP={preseq=3.1.1}, RSEQC_INFEREXPERIMENT={rseqc=5.0.2}, RSEQC_READDISTRIBUTION={rseqc=5.0.2}, RSEQC_READDUPLICATION={rseqc=5.0.2}, SAMTOOLS_FLAGSTAT={samtools=1.2}, SAMTOOLS_IDXSTATS={samtools=1.2}, SAMTOOLS_INDEX={samtools=1.2}, SAMTOOLS_SORT={samtools=1.2}, SAMTOOLS_STATS={samtools=1.2}, SUBREAD_FEATURECOUNTS_GENE={subread=2.0.1}, Workflow={nf-core/nascent=v2.3.0dev}}"
],
"meta": {
"nf-test": "0.9.0",
"nextflow": "24.04.4"
},
"timestamp": "2024-08-03T21:20:15.261777672"
}
}
97 changes: 97 additions & 0 deletions workflows/tests/aligner/bwa.nf.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
nextflow_pipeline {

name "BWA"
script "../../../main.nf"
tag "aligner"
tag "bwa"

test("Should run with defaults") {

when {
params {
outdir = "$outputDir"
aligner = "bwa"
input = "${projectDir}/assets/samplesheet.csv"
}
}

then {
assertAll(
{ assert workflow.success },
{ assert snapshot(UTILS.removeNextflowVersion("$outputDir/pipeline_info/nf_core_pipeline_software_mqc_versions.yml")).match("software_versions") },
{ assert snapshot(
workflow.trace.tasks().size(),
path("$outputDir/bbmap").list(),
// BUG https://github.com/nf-core/nascent/issues/102
// path("$outputDir/bedtools").list(),
// FIXME gtf2bed isn't deterministic
// path("$outputDir/bwa/featurecounts/gene").list(),
// FIXME cd4 isn't deterministic
// path("$outputDir/bwa/featurecounts/predicted").list(),
// path("$outputDir/deeptools").list(),
// path("$outputDir/fastp/*.json").list(),
// FIXME gtf2bed isn't deterministic
// path("$outputDir/gtf2bed").list(),
path("$outputDir/homer/cd4.bed"),
path("$outputDir/homer/jurkat.bed"),
// FIXME https://github.com/nf-core/nascent/issues/148
// path("$outputDir/preseq").list(),
// path("$outputDir/rseqc").list(),
bam("$outputDir/samtools/cd4_REP1.sorted.bam").getSamLinesMD5(),
bam("$outputDir/samtools/cd4_REP2.sorted.bam").getSamLinesMD5(),
bam("$outputDir/samtools/cd4_REP3.sorted.bam").getSamLinesMD5(),
bam("$outputDir/samtools/cd4_REP4.sorted.bam").getSamLinesMD5(),
bam("$outputDir/samtools/jurkat_REP1.sorted.bam").getSamLinesMD5(),
bam("$outputDir/samtools/jurkat_REP2.sorted.bam").getSamLinesMD5(),
).match("output_files")
}
)
}
}

def igenomes_base = 's3://ngi-igenomes/igenomes'

// https://github.com/nf-core/nascent/issues/106
test("Should work with BWA Index") {
// FIXME PINTS Fails because it doesn't find anything.
config '../skip_pints.config'
when {
params {
outdir = "$outputDir"
aligner = "bwa"
// TODO Update these to human
bwa_index = "${igenomes_base}/Saccharomyces_cerevisiae/Ensembl/R64-1-1/Sequence/BWAIndex/version0.6.0/"
fasta = "${igenomes_base}/Saccharomyces_cerevisiae/Ensembl/R64-1-1/Sequence/WholeGenomeFasta/genome.fa"
gtf = "${igenomes_base}/Saccharomyces_cerevisiae/Ensembl/R64-1-1/Annotation/Genes/genes.gtf"
}
}

then {
assert workflow.success
assert snapshot(
workflow.trace.tasks().size(),
).match()
}
}

// https://github.com/nf-core/nascent/issues/119
test("Should work with gzipped references") {
config '../skip_gzip.config'
when {
params {
outdir = "$outputDir"
aligner = "bwa"
fasta = 'https://raw.githubusercontent.com/nf-core/test-datasets/rnaseq/reference/genome.fasta.gz'
gtf = 'https://raw.githubusercontent.com/nf-core/test-datasets/rnaseq/reference/genes.gtf.gz'
}
}

then {
assert workflow.success
assert snapshot(
workflow.trace.tasks().size(),
).match()
}

}
}
64 changes: 64 additions & 0 deletions workflows/tests/aligner/bwa.nf.test.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
{
"output_files": {
"content": [
134,
[
"cd4_REP1.coverage.hist.txt:md5,7cbb473be8d3b32ff2e52fdf4e5d10d2",
"cd4_REP1.coverage.stats.txt:md5,f1471b61ac17dba283d80e08450c7e55",
"cd4_REP2.coverage.hist.txt:md5,8d5258a0882494bc4e3f1aa6aa5ed685",
"cd4_REP2.coverage.stats.txt:md5,3cdb4473211f9da44166ffa6aaa5b602",
"cd4_REP3.coverage.hist.txt:md5,4a8397c1ea08f35ca7046e3c2c014a08",
"cd4_REP3.coverage.stats.txt:md5,b88592b469d504a93f2389255ac15f38",
"cd4_REP4.coverage.hist.txt:md5,d2cbf89e1f753d99bcd03b4e472270dd",
"cd4_REP4.coverage.stats.txt:md5,4c2b5fe6793aab8560cc87c176ac06ab",
"jurkat_REP1.coverage.hist.txt:md5,71a893d9d1d55fd47399f6d47b628d6e",
"jurkat_REP1.coverage.stats.txt:md5,381c69a30099d82066a959deab1a2569",
"jurkat_REP2.coverage.hist.txt:md5,d124bdadaf2dc5cdd9e3db5a1ab4c588",
"jurkat_REP2.coverage.stats.txt:md5,b1940346719e4070091f2eef6e508f49"
],
"cd4.bed:md5,ab94918610a560772fdbec591200295f",
"jurkat.bed:md5,41908723fa423a78476feb2e7627a3a4",
"c529a16c839e85e119b98354f109352d",
"9e63b682af88fa902cf92b5c485845b1",
"2aa200bbbce374ec7dedb9b46ce4aae1",
"122274730dd5386e1b26c174df886a8b",
"c2adf5327ff6d4edda2fdad00c7cb9bf",
"63fea3b1e2e08e5f6fdf3f7ba0aa7818"
],
"meta": {
"nf-test": "0.9.0",
"nextflow": "24.04.4"
},
"timestamp": "2024-08-03T08:58:17.037588077"
},
"Should work with gzipped references": {
"content": [
53
],
"meta": {
"nf-test": "0.9.0",
"nextflow": "24.04.4"
},
"timestamp": "2024-08-03T07:39:38.160960801"
},
"software_versions": {
"content": [
"{BBMAP_PILEUP={bbmap=39.01, samtools=1.16.1, pigz=2.6}, BEDTOOLS_GENOMECOV_MINUS={bedtools=2.31.1}, BEDTOOLS_GENOMECOV_PLUS={bedtools=2.31.1}, BEDTOOLS_INTERSECT={bedtools=2.31.1}, BEDTOOLS_INTERSECT_FILTER={bedtools=2.31.1}, BWA_MEM={bwa=0.7.18-r1243-dirty, samtools=1.2}, DEEPTOOLS_BAMCOVERAGE_MINUS={deeptools=3.5.1}, DEEPTOOLS_BAMCOVERAGE_PLUS={deeptools=3.5.1}, FASTP={fastp=0.23.4}, FASTQC={fastqc=0.12.1}, GTF2BED={perl=5.26.2}, HOMER_MAKETAGDIRECTORY={homer=4.11, samtools=1.11}, PINTS_CALLER={python=3.10.6, pints=1.1.8}, PRESEQ_CCURVE={preseq=3.1.1}, PRESEQ_LCEXTRAP={preseq=3.1.1}, RSEQC_INFEREXPERIMENT={rseqc=5.0.2}, RSEQC_READDISTRIBUTION={rseqc=5.0.2}, RSEQC_READDUPLICATION={rseqc=5.0.2}, SUBREAD_FEATURECOUNTS_GENE={subread=2.0.1}, Workflow={nf-core/nascent=v2.3.0dev}}"
],
"meta": {
"nf-test": "0.9.0",
"nextflow": "24.04.4"
},
"timestamp": "2024-08-03T07:37:00.256122533"
},
"Should work with BWA Index": {
"content": [
59
],
"meta": {
"nf-test": "0.9.0",
"nextflow": "24.04.4"
},
"timestamp": "2024-08-03T07:38:19.100788775"
}
}
45 changes: 45 additions & 0 deletions workflows/tests/aligner/bwamem2.nf.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
nextflow_pipeline {

name "bwamem2"
script "../../../main.nf"

test("Should run with defaults") {

when {
params {
outdir = "$outputDir"
aligner = "bwamem2"
}
}

then {
assertAll(
{ assert workflow.success },
{ assert snapshot(UTILS.removeNextflowVersion("$outputDir/pipeline_info/nf_core_pipeline_software_mqc_versions.yml")).match("software_versions") },
{ assert snapshot(
workflow.trace.tasks().size(),
path("$outputDir/bbmap").list(),
// BUG https://github.com/nf-core/nascent/issues/102
// path("$outputDir/bedtools").list(),
// FIXME gtf2bed isn't deterministic
// path("$outputDir/bwa/featurecounts/gene").list(),
// FIXME cd4 isn't deterministic
// path("$outputDir/bwa/featurecounts/predicted").list(),
// path("$outputDir/deeptools").list(),
// path("$outputDir/fastp/*.json").list(),
// FIXME gtf2bed isn't deterministic
// path("$outputDir/gtf2bed").list(),
path("$outputDir/homer/cd4.bed"),
path("$outputDir/homer/jurkat.bed"),
// FIXME https://github.com/nf-core/nascent/issues/148
// path("$outputDir/preseq").list(),
// path("$outputDir/rseqc").list(),
bam("$outputDir/samtools/cd4_REP1.sorted.bam").getSamLinesMD5(),
bam("$outputDir/samtools/cd4_REP2.sorted.bam").getSamLinesMD5(),
bam("$outputDir/samtools/jurkat.sorted.bam").getSamLinesMD5(),
).match("output_files")
}
)
}
}
}
35 changes: 35 additions & 0 deletions workflows/tests/aligner/bwamem2.nf.test.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"output_files": {
"content": [
77,
[
"cd4_REP1.coverage.hist.txt:md5,7cbb473be8d3b32ff2e52fdf4e5d10d2",
"cd4_REP1.coverage.stats.txt:md5,f1471b61ac17dba283d80e08450c7e55",
"cd4_REP2.coverage.hist.txt:md5,8d5258a0882494bc4e3f1aa6aa5ed685",
"cd4_REP2.coverage.stats.txt:md5,3cdb4473211f9da44166ffa6aaa5b602",
"jurkat.coverage.hist.txt:md5,71a893d9d1d55fd47399f6d47b628d6e",
"jurkat.coverage.stats.txt:md5,381c69a30099d82066a959deab1a2569"
],
"cd4.bed:md5,b55e5290d78941f36c3d1ecfef8e0062",
"jurkat.bed:md5,383cfaf10535dbe5d7f47607e345f4cb",
"c529a16c839e85e119b98354f109352d",
"9e63b682af88fa902cf92b5c485845b1",
"c2adf5327ff6d4edda2fdad00c7cb9bf"
],
"meta": {
"nf-test": "0.9.0",
"nextflow": "24.04.4"
},
"timestamp": "2024-08-03T10:28:23.205786296"
},
"software_versions": {
"content": [
"{BBMAP_PILEUP={bbmap=39.01, samtools=1.16.1, pigz=2.6}, BEDTOOLS_GENOMECOV_MINUS={bedtools=2.31.1}, BEDTOOLS_GENOMECOV_PLUS={bedtools=2.31.1}, BEDTOOLS_INTERSECT={bedtools=2.31.1}, BEDTOOLS_INTERSECT_FILTER={bedtools=2.31.1}, BWAMEM2_MEM={bwamem2=2.2.1, samtools=1.19.2}, DEEPTOOLS_BAMCOVERAGE_MINUS={deeptools=3.5.1}, DEEPTOOLS_BAMCOVERAGE_PLUS={deeptools=3.5.1}, FASTP={fastp=0.23.4}, FASTQC={fastqc=0.12.1}, GTF2BED={perl=5.26.2}, HOMER_MAKETAGDIRECTORY={homer=4.11, samtools=1.11}, PINTS_CALLER={python=3.10.6, pints=1.1.8}, PRESEQ_CCURVE={preseq=3.1.1}, PRESEQ_LCEXTRAP={preseq=3.1.1}, RSEQC_INFEREXPERIMENT={rseqc=5.0.2}, RSEQC_READDISTRIBUTION={rseqc=5.0.2}, RSEQC_READDUPLICATION={rseqc=5.0.2}, SAMTOOLS_FLAGSTAT={samtools=1.2}, SAMTOOLS_IDXSTATS={samtools=1.2}, SAMTOOLS_INDEX={samtools=1.2}, SAMTOOLS_SORT={samtools=1.2}, SAMTOOLS_STATS={samtools=1.2}, SUBREAD_FEATURECOUNTS_GENE={subread=2.0.1}, Workflow={nf-core/nascent=v2.3.0dev}}"
],
"meta": {
"nf-test": "0.9.0",
"nextflow": "24.04.4"
},
"timestamp": "2024-08-01T19:59:55.332896924"
}
}
Loading

0 comments on commit 98d646b

Please sign in to comment.