Skip to content

Commit 341a796

Browse files
authored
Merge pull request #184 from LouisLeNezet/csi
Add csi index authorization for bam files
2 parents c8ac468 + 25e716f commit 341a796

File tree

5 files changed

+43
-71
lines changed

5 files changed

+43
-71
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99

1010
- [#175](https://github.com/nf-core/phaseimpute/pull/175) - Add support for all input files in `.json` or `.yaml` format.
1111
- [#181](https://github.com/nf-core/phaseimpute/pull/181) - Add nf-co2footprint plugin to the config file.
12+
- [#184](https://github.com/nf-core/phaseimpute/pull/184) - Add support `.csi` index for `.bam` files.
1213

1314
### `Changed`
1415

subworkflows/local/utils_nfcore_phaseimpute_pipeline/main.nf

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -569,16 +569,16 @@ def checkFileIndex(ch_input) {
569569
def index_ext = getFileExtension(index)
570570
if (file_ext in ["vcf", "bcf"] && !(index_ext in ["tbi", "csi"]) ) {
571571
log.info("File: ${file} ${file_ext}, Index: ${index} ${index_ext}")
572-
error "${meta}: Index file for [.vcf, .vcf.gz, bcf] must have the extension [.tbi, .csi]"
572+
error "${meta}: Index file for .vcf, .vcf.gz and .bcf must have the extension .tbi or .csi"
573573
}
574-
if (file_ext == "bam" && index_ext != "bai") {
575-
error "${meta}: Index file for .bam must have the extension .bai"
574+
if (file_ext == "bam" && !(index_ext in ["bai", "csi"])) {
575+
error "${meta}: Index file for .bam must have the extension .bai or .csi"
576576
}
577577
if (file_ext == "cram" && index_ext != "crai") {
578578
error "${meta}: Index file for .cram must have the extension .crai"
579579
}
580580
if (file_ext in ["fa", "fasta"] && index_ext != "fai") {
581-
error "${meta}: Index file for [fa, fasta] must have the extension .fai"
581+
error "${meta}: Index file for .fa and .fasta must have the extension .fai"
582582
}
583583
}
584584
return null

subworkflows/local/utils_nfcore_phaseimpute_pipeline/tests/function.nf.test

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
nextflow_function {
2+
/*
3+
The following tests are for the functions in the main.nf script
4+
They are tested using the --verbose argument
5+
*/
26

37
name "Test function phaseimpute"
48
script "../main.nf"
@@ -103,10 +107,11 @@ nextflow_function {
103107
[[id: "input4"], file("input4.bcf"), file("input4.tbi")],
104108
[[id: "input5"], file("input5.vcf.gz"), file("input5.csi")],
105109
[[id: "input6"], file("input6.vcf.gz"), file("input6.tbi")],
106-
[[id: "input7"], file("input7.bam"), file("input5.bai")],
107-
[[id: "input8"], file("input8.cram"), file("input6.crai")],
108-
[[id: "input9"], file("input9.fa"), file("input9.fai")],
109-
[[id: "input10"], file("input10.fa"), file("input10.fai")]
110+
[[id: "input7"], file("input7.bam"), file("input7.bai")],
111+
[[id: "input7"], file("input8.bam"), file("input8.csi")],
112+
[[id: "input8"], file("input9.cram"), file("input9.crai")],
113+
[[id: "input9"], file("input10.fa"), file("input10.fai")],
114+
[[id: "input10"], file("input11.fa"), file("input111.fai")]
110115
])
111116
"""
112117
}
@@ -123,7 +128,7 @@ nextflow_function {
123128
function {
124129
"""
125130
input[0] = Channel.fromList([
126-
[[id: "input7"], file("input7.bam"), file("input5.csi")],
131+
[[id: "input7"], file("input7.bam"), file("input5.crai")],
127132
[[id: "input6"], file("input6.vcf.gz"), file("input6.tbi")],
128133
[[id: "input8"], file("input8.bam"), file("input8.bai")]
129134
])
@@ -132,7 +137,7 @@ nextflow_function {
132137
}
133138
then {
134139
assert function.failed
135-
assert function.stdout.contains("[id:input7]: Index file for .bam must have the extension .bai")
140+
assert function.stdout.contains("[id:input7]: Index file for .bam must have the extension .bai or .csi")
136141
}
137142
}
138143

@@ -172,7 +177,7 @@ nextflow_function {
172177
}
173178
then {
174179
assert function.failed
175-
assert function.stdout.contains("[id:input7]: Index file for [.vcf, .vcf.gz, bcf] must have the extension [.tbi, .csi]")
180+
assert function.stdout.contains("[id:input7]: Index file for .vcf, .vcf.gz and .bcf must have the extension .tbi or .csi")
176181
}
177182
}
178183

@@ -192,7 +197,7 @@ nextflow_function {
192197
}
193198
then {
194199
assert function.failed
195-
assert function.stdout.contains("[id:input7]: Index file for [.vcf, .vcf.gz, bcf] must have the extension [.tbi, .csi]")
200+
assert function.stdout.contains("[id:input7]: Index file for .vcf, .vcf.gz and .bcf must have the extension .tbi or .csi")
196201
}
197202
}
198203

@@ -212,7 +217,7 @@ nextflow_function {
212217
}
213218
then {
214219
assert function.failed
215-
assert function.stdout.contains("[id:input7]: Index file for [.vcf, .vcf.gz, bcf] must have the extension [.tbi, .csi]")
220+
assert function.stdout.contains("[id:input7]: Index file for .vcf, .vcf.gz and .bcf must have the extension .tbi or .csi")
216221
}
217222
}
218223

@@ -232,7 +237,7 @@ nextflow_function {
232237
}
233238
then {
234239
assert function.failed
235-
assert function.stdout.contains("[id:input7]: Index file for [fa, fasta] must have the extension .fai")
240+
assert function.stdout.contains("[id:input7]: Index file for .fa and .fasta must have the extension .fai")
236241
}
237242
}
238243

@@ -252,7 +257,7 @@ nextflow_function {
252257
}
253258
then {
254259
assert function.failed
255-
assert function.stdout.contains("[id:input7]: Index file for [fa, fasta] must have the extension .fai")
260+
assert function.stdout.contains("[id:input7]: Index file for .fa and .fasta must have the extension .fai")
256261
}
257262
}
258263

Lines changed: 21 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,4 @@
11
{
2-
"Test checkMetaChr error": {
3-
"content": [
4-
[
5-
"N E X T F L O W ~ version 24.04.3",
6-
"Launching `/mnt/s/Users/Main/Documents/Louis/Travail/IGDR/Repositories/phaseimpute/.nf-test/tests/ed90b74f1c9354d03a69767c5df96bbc/meta/mock.nf` [cheesy_golick] DSL2 - revision: 184c64ccc5",
7-
"WARN: Chr : [chrY] is missing from test"
8-
]
9-
],
10-
"meta": {
11-
"nf-test": "0.8.4",
12-
"nextflow": "24.04.3"
13-
},
14-
"timestamp": "2024-07-16T15:31:57.920377701"
15-
},
16-
"Test getFileExtension": {
17-
"content": [
18-
"vcf"
19-
],
20-
"meta": {
21-
"nf-test": "0.8.4",
22-
"nextflow": "24.04.3"
23-
},
24-
"timestamp": "2024-07-12T17:12:47.079086374"
25-
},
262
"Test checkFileIndex no error with empty channel": {
273
"content": null,
284
"meta": {
@@ -34,28 +10,30 @@
3410
"Test validateInputBatchTools only one vcf": {
3511
"content": [
3612
[
37-
"N E X T F L O W ~ version 24.10.0",
38-
"Launching `/mnt/c/Users/llenezet/Documents/Repositories/phaseimpute/.nf-test-d46c3ae4355f57c428b5399cb25385a3.nf` [deadly_lamarck] DSL2 - revision: 89cd7edbc5",
13+
"N E X T F L O W ~ version 24.10.1",
14+
"Launching `/home/llenezet/repositories/phaseimpute/.nf-test-4fd3137d00243621dd8890f50dc172b6.nf` [tiny_joliot] DSL2 - revision: 187359daf3",
3915
"When using a Variant Calling Format file as input, only one file can be provided. If you have multiple single-sample VCF files, please merge them into a single multisample VCF file."
4016
]
4117
],
4218
"meta": {
4319
"nf-test": "0.9.1",
44-
"nextflow": "24.10.0"
20+
"nextflow": "24.10.1"
4521
},
46-
"timestamp": "2024-11-07T16:40:38.015152671"
22+
"timestamp": "2025-02-21T09:28:56.687203026"
4723
},
4824
"Test checkMetaChr warning": {
4925
"content": [
5026
[
51-
27+
"N E X T F L O W ~ version 24.10.1",
28+
"Launching `/home/llenezet/repositories/phaseimpute/.nf-test-31b2c458e8c6ce6ddf450eb32ea28631.nf` [drunk_mahavira] DSL2 - revision: 2443da0500",
29+
"WARN: Chr : [chrY] is missing from test"
5230
]
5331
],
5432
"meta": {
5533
"nf-test": "0.9.1",
56-
"nextflow": "24.10.0"
34+
"nextflow": "24.10.1"
5735
},
58-
"timestamp": "2024-11-07T14:03:45.047353204"
36+
"timestamp": "2025-02-21T09:28:42.524572007"
5937
},
6038
"Test Function exportCsv": {
6139
"content": null,
@@ -68,30 +46,30 @@
6846
"Test validateInputBatchTools vcf only for glimpse": {
6947
"content": [
7048
[
71-
"N E X T F L O W ~ version 24.10.0",
72-
"Launching `/mnt/c/Users/llenezet/Documents/Repositories/phaseimpute/.nf-test-ee1562fb7668b97a4ee2fa78f0a93342.nf` [stupefied_gautier] DSL2 - revision: 33e883fb97",
49+
"N E X T F L O W ~ version 24.10.1",
50+
"Launching `/home/llenezet/repositories/phaseimpute/.nf-test-985177066200b5ce5b0de4074aa78c09.nf` [spontaneous_yalow] DSL2 - revision: e002e0bfb7",
7351
"Stitch or Quilt software cannot run with VCF or BCF files. Please provide alignment files (i.e. BAM or CRAM)."
7452
]
7553
],
7654
"meta": {
7755
"nf-test": "0.9.1",
78-
"nextflow": "24.10.0"
56+
"nextflow": "24.10.1"
7957
},
80-
"timestamp": "2024-11-07T16:40:24.343659957"
58+
"timestamp": "2025-02-21T09:28:49.440526671"
8159
},
8260
"Test validateInputBatchTools success batch": {
8361
"content": [
8462
[
85-
"N E X T F L O W ~ version 24.10.0",
86-
"Launching `/mnt/c/Users/llenezet/Documents/Repositories/phaseimpute/.nf-test-a882e6f88e44c954568a3552c82f8d3c.nf` [compassionate_keller] DSL2 - revision: edfeedf8f1",
63+
"N E X T F L O W ~ version 24.10.1",
64+
"Launching `/home/llenezet/repositories/phaseimpute/.nf-test-4cc378945f5cde91be4d1b076949eb0e.nf` [desperate_miescher] DSL2 - revision: af75e755d1",
8765
"WARN: Glimpse2 or Quilt software is selected and the number of input files (151) is less than the batch size (60). The input files will be processed in 3 batches."
8866
]
8967
],
9068
"meta": {
9169
"nf-test": "0.9.1",
92-
"nextflow": "24.10.0"
70+
"nextflow": "24.10.1"
9371
},
94-
"timestamp": "2024-11-07T16:41:05.86605167"
72+
"timestamp": "2025-02-21T09:29:11.538542285"
9573
},
9674
"Test getFileExtension non empty list": {
9775
"content": [
@@ -106,31 +84,19 @@
10684
},
10785
"timestamp": "2024-10-31T13:15:08.856706046"
10886
},
109-
"Test getFileExtension empty list": {
110-
"content": [
111-
[
112-
113-
]
114-
],
115-
"meta": {
116-
"nf-test": "0.8.4",
117-
"nextflow": "24.04.4"
118-
},
119-
"timestamp": "2024-10-30T20:00:55.32420517"
120-
},
12187
"Test validateInputBatchTools error batch": {
12288
"content": [
12389
[
124-
"N E X T F L O W ~ version 24.10.0",
125-
"Launching `/mnt/c/Users/llenezet/Documents/Repositories/phaseimpute/.nf-test-87470b2a8c60f98b5dc561cea5e9bc6f.nf` [prickly_euclid] DSL2 - revision: 45ae3df33f",
90+
"N E X T F L O W ~ version 24.10.1",
91+
"Launching `/home/llenezet/repositories/phaseimpute/.nf-test-7d26cf5ac00827d2d108edb45e040f7f.nf` [hungry_banach] DSL2 - revision: b43a7ecbe2",
12692
"WARN: Glimpse2 or Quilt software is selected and the number of input files (151) is less than the batch size (60). The input files will be processed in 3 batches.",
12793
"Stitch or Glimpse1 software is selected and the number of input files (151) is less than the batch size (60). Splitting the input files in batches would induce batch effect."
12894
]
12995
],
13096
"meta": {
13197
"nf-test": "0.9.1",
132-
"nextflow": "24.10.0"
98+
"nextflow": "24.10.1"
13399
},
134-
"timestamp": "2024-11-07T16:40:50.034843333"
100+
"timestamp": "2025-02-21T09:29:04.24007658"
135101
}
136102
}

tests/csv/sample_bam.csv

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
sample,file,index
22
NA12878,https://raw.githubusercontent.com/nf-core/test-datasets/phaseimpute/hum_data/individuals/NA12878/NA12878.s.1x.bam,https://raw.githubusercontent.com/nf-core/test-datasets/phaseimpute/hum_data/individuals/NA12878/NA12878.s.1x.bam.bai
3-
NA19401,https://raw.githubusercontent.com/nf-core/test-datasets/phaseimpute/hum_data/individuals/NA19401/NA19401.s.1x.bam,https://raw.githubusercontent.com/nf-core/test-datasets/phaseimpute/hum_data/individuals/NA19401/NA19401.s.1x.bam.bai
3+
NA19401,https://raw.githubusercontent.com/nf-core/test-datasets/phaseimpute/hum_data/individuals/NA19401/NA19401.s.1x.bam,https://raw.githubusercontent.com/nf-core/test-datasets/phaseimpute/hum_data/individuals/NA19401/NA19401.s.1x.bam.csi
44
NA20359,https://raw.githubusercontent.com/nf-core/test-datasets/phaseimpute/hum_data/individuals/NA20359/NA20359.s.1x.bam,https://raw.githubusercontent.com/nf-core/test-datasets/phaseimpute/hum_data/individuals/NA20359/NA20359.s.1x.bam.bai

0 commit comments

Comments
 (0)