Skip to content

Commit

Permalink
test: Add UTILS functions from function guy
Browse files Browse the repository at this point in the history
nf-core/eager#1063

Co-authored-by: jfy133 <[email protected]>
Co-authored-by: nvnieuwk <[email protected]>
  • Loading branch information
3 people committed Aug 10, 2024
1 parent 45cfed6 commit f5aa9e1
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 12 deletions.
34 changes: 34 additions & 0 deletions tests/lib/UTILS.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,38 @@ class UTILS {
}
return softwareVersions
}

// Recursively list all files in a directory and its sub-directories, matching a given suffix
// TODO: use regex pattern instead of suffix?
public static getAllFilesFromDir(dir, suffix) {
def output = []
new File(dir).eachFileRecurse() {
if (it.name.toString().endsWith(suffix)) {
output.add(it)
}
}
return output.sort()
}
// Recursively list all files names in a directory and its sub-directories, matching a given suffix, return file names
public static getAllFileNamesFromDir(dir, suffix) {
def output = []
new File(dir).eachFileRecurse() {
if (it.name.toString().endsWith(suffix)) {
output.add(it.toString().split("/")[-1])
}
}
return output.sort()
}

// Recursively list all files names in a directory and its sub-directories, matching a given suffix, return if check if given string is in file
public static checkAllFilesNamesFromDirForString(dir, suffix, string) {
def output = []
new File(dir).eachFileRecurse() {
if (it.name.toString().endsWith(suffix)) {
output.add(it.text.contains(string))
}
}
return output.sort()
}

}
10 changes: 3 additions & 7 deletions workflows/tests/aligner/bwa.nf.test
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,19 @@ nextflow_pipeline {
{ assert snapshot(UTILS.removeNextflowVersion("$outputDir/pipeline_info/nf_core_pipeline_software_mqc_versions.yml")).match("software_versions") },
{ assert snapshot(
workflow.trace.tasks().size(),
// TODO path("$outputDir/preprocessing/fastp/*.json").list(),
UTILS.getAllFilesFromDir("$outputDir/preprocessing/fastp/", ".json"),
path("$outputDir/bwa/log").list(),
path("$outputDir/bwa/samtools_stats").list(),
path("$outputDir/quality_control/bbsplit").list(),
// FIXME Empty
path("$outputDir/quality_control/preseq").list().findAll { it.contains(".txt") },
// process.out.outs[0][1].findAll { file(it).name.contains('.pb') },
UTILS.getAllFilesFromDir("$outputDir/quality_control/preseq", ".txt"),
path("$outputDir/quality_control/rseqc/read_duplication/xls").list(),
path("$outputDir/quality_control/rseqc/read_duplication/rscript").list(),
path("$outputDir/quality_control/rseqc/infer_experiment").list(),
path("$outputDir/quality_control/rseqc/read_distribution").list(),
path("$outputDir/coverage_graphs/").list(),
// FIXME Empty
path("$outputDir/transcript_identification/").list().findAll { file(it.toString()).name.contains('.bed') },
path("$outputDir/transcript_identification/homer/cd4.bed"),
path("$outputDir/transcript_identification/homer/jurkat.bed"),
// FIXME path("$outputDir/transcript_identification/pints/").list().findAll(),
// FIXME UTILS.getAllFilesFromDir("$outputDir/transcript_identification/pints/", ".bed"),
path("$outputDir/transcript_identification/intersect/").list(),
path("$outputDir/transcript_identification/filtered/").list(),
// FIXME path("$outputDir/quantification/").list(),
Expand Down
26 changes: 21 additions & 5 deletions workflows/tests/aligner/bwa.nf.test.snap
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@
"output_files": {
"content": [
134,
[
"cd4_REP1.trimmed.fastp.json:md5,bd9a3344c1591d6be4d524451f9dca53",
"cd4_REP2.trimmed.fastp.json:md5,bc6e3f9ff7835f220535cc393b8eb25f",
"cd4_REP3.trimmed.fastp.json:md5,c9c3a1dd0a2ebac77c9d7c3b0daf3790",
"cd4_REP4.trimmed.fastp.json:md5,c073bd26609ddca91396d0f374ec5b80",
"jurkat_REP1.trimmed.fastp.json:md5,329fd8e56421a196fc2ebd37ab3bc22d",
"jurkat_REP2.trimmed.fastp.json:md5,8bad5b02a27e5386255b998a6a69db15"
],
[

],
Expand Down Expand Up @@ -40,7 +48,18 @@
"jurkat_REP2.coverage.stats.txt:md5,b1940346719e4070091f2eef6e508f49"
],
[

"cd4_REP1.c_curve.txt:md5,cf4743abdd355595d6ec1fb3f38e66e5",
"cd4_REP1.lc_extrap.txt:md5,8633f84ccd5cc725db9af4b33edd63b0",
"cd4_REP2.c_curve.txt:md5,cf4743abdd355595d6ec1fb3f38e66e5",
"cd4_REP2.lc_extrap.txt:md5,3ad9e4028c3711e6d46831c10ed04200",
"cd4_REP3.c_curve.txt:md5,cf4743abdd355595d6ec1fb3f38e66e5",
"cd4_REP3.lc_extrap.txt:md5,25ebbeabee46caa86a4d6d82dd0091f1",
"cd4_REP4.c_curve.txt:md5,cf4743abdd355595d6ec1fb3f38e66e5",
"cd4_REP4.lc_extrap.txt:md5,d0df86774dd54421fd362d46faa3f937",
"jurkat_REP1.c_curve.txt:md5,cf4743abdd355595d6ec1fb3f38e66e5",
"jurkat_REP1.lc_extrap.txt:md5,84faa937faa88476c942f330c5762cb5",
"jurkat_REP2.c_curve.txt:md5,cf4743abdd355595d6ec1fb3f38e66e5",
"jurkat_REP2.lc_extrap.txt:md5,8ae0a77bcc59da38ec2da0fc1f973227"
],
[
"cd4_REP1.pos.DupRate.xls:md5,a80db2d20096ca839a7847ec5b11bf75",
Expand Down Expand Up @@ -111,9 +130,6 @@
"jurkat_REP2.minus.bigWig:md5,686f719978de948f7045acc95f9d1c82",
"jurkat_REP2.plus.bedGraph:md5,569e8a25c9cf48d1ef953f3da77c48a1",
"jurkat_REP2.plus.bigWig:md5,cbe3fd38fe8f9508645bbfad83924212"
],
[

],
"cd4.bed:md5,ab94918610a560772fdbec591200295f",
"jurkat.bed:md5,41908723fa423a78476feb2e7627a3a4",
Expand All @@ -131,7 +147,7 @@
"nf-test": "0.9.0",
"nextflow": "24.04.4"
},
"timestamp": "2024-08-09T17:35:32.797123474"
"timestamp": "2024-08-10T12:48:55.984269469"
},
"Should work with gzipped references": {
"content": [
Expand Down

0 comments on commit f5aa9e1

Please sign in to comment.