Skip to content

Commit 2d049ff

Browse files
edmundmillerjfy133nvnieuwk
committed
test: Add UTILS functions from function guy
nf-core/eager#1063 Co-authored-by: jfy133 <[email protected]> Co-authored-by: nvnieuwk <[email protected]>
1 parent 5e91c40 commit 2d049ff

File tree

3 files changed

+58
-12
lines changed

3 files changed

+58
-12
lines changed

tests/lib/UTILS.groovy

+34
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,38 @@ class UTILS {
88
}
99
return softwareVersions
1010
}
11+
12+
// Recursively list all files in a directory and its sub-directories, matching a given suffix
13+
// TODO: use regex pattern instead of suffix?
14+
public static getAllFilesFromDir(dir, suffix) {
15+
def output = []
16+
new File(dir).eachFileRecurse() {
17+
if (it.name.toString().endsWith(suffix)) {
18+
output.add(it)
19+
}
20+
}
21+
return output.sort()
22+
}
23+
// Recursively list all files names in a directory and its sub-directories, matching a given suffix, return file names
24+
public static getAllFileNamesFromDir(dir, suffix) {
25+
def output = []
26+
new File(dir).eachFileRecurse() {
27+
if (it.name.toString().endsWith(suffix)) {
28+
output.add(it.toString().split("/")[-1])
29+
}
30+
}
31+
return output.sort()
32+
}
33+
34+
// 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
35+
public static checkAllFilesNamesFromDirForString(dir, suffix, string) {
36+
def output = []
37+
new File(dir).eachFileRecurse() {
38+
if (it.name.toString().endsWith(suffix)) {
39+
output.add(it.text.contains(string))
40+
}
41+
}
42+
return output.sort()
43+
}
44+
1145
}

workflows/tests/aligner/bwa.nf.test

+3-7
Original file line numberDiff line numberDiff line change
@@ -21,23 +21,19 @@ nextflow_pipeline {
2121
{ assert snapshot(UTILS.removeNextflowVersion("$outputDir/pipeline_info/nf_core_pipeline_software_mqc_versions.yml")).match("software_versions") },
2222
{ assert snapshot(
2323
workflow.trace.tasks().size(),
24-
// TODO path("$outputDir/preprocessing/fastp/*.json").list(),
24+
UTILS.getAllFilesFromDir("$outputDir/preprocessing/fastp/", ".json"),
2525
path("$outputDir/bwa/log").list(),
2626
path("$outputDir/bwa/samtools_stats").list(),
2727
path("$outputDir/quality_control/bbsplit").list(),
28-
// FIXME Empty
29-
path("$outputDir/quality_control/preseq").list().findAll { it.contains(".txt") },
30-
// process.out.outs[0][1].findAll { file(it).name.contains('.pb') },
28+
UTILS.getAllFilesFromDir("$outputDir/quality_control/preseq", ".txt"),
3129
path("$outputDir/quality_control/rseqc/read_duplication/xls").list(),
3230
path("$outputDir/quality_control/rseqc/read_duplication/rscript").list(),
3331
path("$outputDir/quality_control/rseqc/infer_experiment").list(),
3432
path("$outputDir/quality_control/rseqc/read_distribution").list(),
3533
path("$outputDir/coverage_graphs/").list(),
36-
// FIXME Empty
37-
path("$outputDir/transcript_identification/").list().findAll { file(it.toString()).name.contains('.bed') },
3834
path("$outputDir/transcript_identification/homer/cd4.bed"),
3935
path("$outputDir/transcript_identification/homer/jurkat.bed"),
40-
// FIXME path("$outputDir/transcript_identification/pints/").list().findAll(),
36+
// FIXME UTILS.getAllFilesFromDir("$outputDir/transcript_identification/pints/", ".bed"),
4137
path("$outputDir/transcript_identification/intersect/").list(),
4238
path("$outputDir/transcript_identification/filtered/").list(),
4339
// FIXME path("$outputDir/quantification/").list(),

workflows/tests/aligner/bwa.nf.test.snap

+21-5
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@
22
"output_files": {
33
"content": [
44
134,
5+
[
6+
"cd4_REP1.trimmed.fastp.json:md5,bd9a3344c1591d6be4d524451f9dca53",
7+
"cd4_REP2.trimmed.fastp.json:md5,bc6e3f9ff7835f220535cc393b8eb25f",
8+
"cd4_REP3.trimmed.fastp.json:md5,c9c3a1dd0a2ebac77c9d7c3b0daf3790",
9+
"cd4_REP4.trimmed.fastp.json:md5,c073bd26609ddca91396d0f374ec5b80",
10+
"jurkat_REP1.trimmed.fastp.json:md5,329fd8e56421a196fc2ebd37ab3bc22d",
11+
"jurkat_REP2.trimmed.fastp.json:md5,8bad5b02a27e5386255b998a6a69db15"
12+
],
513
[
614

715
],
@@ -40,7 +48,18 @@
4048
"jurkat_REP2.coverage.stats.txt:md5,b1940346719e4070091f2eef6e508f49"
4149
],
4250
[
43-
51+
"cd4_REP1.c_curve.txt:md5,cf4743abdd355595d6ec1fb3f38e66e5",
52+
"cd4_REP1.lc_extrap.txt:md5,8633f84ccd5cc725db9af4b33edd63b0",
53+
"cd4_REP2.c_curve.txt:md5,cf4743abdd355595d6ec1fb3f38e66e5",
54+
"cd4_REP2.lc_extrap.txt:md5,3ad9e4028c3711e6d46831c10ed04200",
55+
"cd4_REP3.c_curve.txt:md5,cf4743abdd355595d6ec1fb3f38e66e5",
56+
"cd4_REP3.lc_extrap.txt:md5,25ebbeabee46caa86a4d6d82dd0091f1",
57+
"cd4_REP4.c_curve.txt:md5,cf4743abdd355595d6ec1fb3f38e66e5",
58+
"cd4_REP4.lc_extrap.txt:md5,d0df86774dd54421fd362d46faa3f937",
59+
"jurkat_REP1.c_curve.txt:md5,cf4743abdd355595d6ec1fb3f38e66e5",
60+
"jurkat_REP1.lc_extrap.txt:md5,84faa937faa88476c942f330c5762cb5",
61+
"jurkat_REP2.c_curve.txt:md5,cf4743abdd355595d6ec1fb3f38e66e5",
62+
"jurkat_REP2.lc_extrap.txt:md5,8ae0a77bcc59da38ec2da0fc1f973227"
4463
],
4564
[
4665
"cd4_REP1.pos.DupRate.xls:md5,a80db2d20096ca839a7847ec5b11bf75",
@@ -111,9 +130,6 @@
111130
"jurkat_REP2.minus.bigWig:md5,686f719978de948f7045acc95f9d1c82",
112131
"jurkat_REP2.plus.bedGraph:md5,569e8a25c9cf48d1ef953f3da77c48a1",
113132
"jurkat_REP2.plus.bigWig:md5,cbe3fd38fe8f9508645bbfad83924212"
114-
],
115-
[
116-
117133
],
118134
"cd4.bed:md5,ab94918610a560772fdbec591200295f",
119135
"jurkat.bed:md5,41908723fa423a78476feb2e7627a3a4",
@@ -131,7 +147,7 @@
131147
"nf-test": "0.9.0",
132148
"nextflow": "24.04.4"
133149
},
134-
"timestamp": "2024-08-09T17:35:32.797123474"
150+
"timestamp": "2024-08-10T12:48:55.984269469"
135151
},
136152
"Should work with gzipped references": {
137153
"content": [

0 commit comments

Comments
 (0)