Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update nf-tests and language server fixes #153

Merged
merged 34 commits into from
Nov 11, 2024
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
0eff9c2
Remove map
LouisLeNezet Oct 30, 2024
610993e
Fix gstring error
LouisLeNezet Oct 30, 2024
d7ce7bd
Update Changelog
LouisLeNezet Oct 30, 2024
8ae7179
Update Changelog
LouisLeNezet Oct 30, 2024
22559e7
Simplify getFileExtension
LouisLeNezet Oct 31, 2024
94befe0
Deactivate features in fulltest
LouisLeNezet Oct 31, 2024
849c055
Merge branch 'simplify_filename' into fulltest
LouisLeNezet Oct 31, 2024
33375b3
Fix nf-test of stitch sbwf
LouisLeNezet Oct 31, 2024
92dc6fd
Change nf-test
LouisLeNezet Oct 31, 2024
640d11a
Fix snapshot
LouisLeNezet Oct 31, 2024
b45b139
Fix linting
LouisLeNezet Oct 31, 2024
f28ccb2
Fix link in usage.md
LouisLeNezet Nov 5, 2024
d3844b3
Update language server
Nov 6, 2024
d8ee2b7
Remove input from input initialisation
Nov 6, 2024
eb5ef67
Update changelog
Nov 6, 2024
98dba2a
Fix numbering batch
Nov 6, 2024
1dd253a
Update nf-test modules
Nov 6, 2024
d12bca6
Fix fulltest
Nov 6, 2024
85f3753
Update nf-test
Nov 6, 2024
c2a59ff
Update nf-test
Nov 6, 2024
01a51d0
Update nf-test
Nov 6, 2024
0d20965
Remove .view()
Nov 6, 2024
bbc99d7
Set resourceLimits
Nov 6, 2024
ebf7f9e
Fix region processed with subset
Nov 6, 2024
c7af9b8
Set resourceLimits
Nov 6, 2024
5f86447
Update nf-test
Nov 6, 2024
9f814d8
Update nf-test
LouisLeNezet Nov 7, 2024
9400b16
Fix function validateInputBatchTools
LouisLeNezet Nov 7, 2024
55dc003
Add null return
LouisLeNezet Nov 7, 2024
1527591
Remove println
Nov 7, 2024
ca6c5a5
Update CHANGELOG
Nov 7, 2024
53a7173
Set back fulltest to glimpse1
Nov 8, 2024
ee27981
Reduce spec of PR
Nov 10, 2024
3f52128
Merge branch 'dev' into fulltest
LouisLeNezet Nov 10, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions conf/test_full.config
LouisLeNezet marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ params {

// Panelprep optional args
remove_samples = "NA12878,NA12891,NA12892"
normalize = true
compute_freq = true
phase = true
normalize = false
LouisLeNezet marked this conversation as resolved.
Show resolved Hide resolved
compute_freq = false
phase = false

// Impute tools
tools = "glimpse1"
tools = "glimpse2"
LouisLeNezet marked this conversation as resolved.
Show resolved Hide resolved
}
2 changes: 1 addition & 1 deletion docs/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ For starting from the imputation steps, the required flags are:

Here is a representation on how the input files will be processed depending on the input files type and the selected imputation tool.

[![InputSoftwareCompatibility](images/InputSoftware_compatibility.png)](images/InputSoftware_compatibility.png)
![InputSoftwareCompatibility](images/InputSoftware_compatibility.png)

#### Argument `--batch_size`

Expand Down
1 change: 0 additions & 1 deletion modules/local/bam_chr_extract/main.nf
LouisLeNezet marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ process BAM_CHR_EXTRACT {
"""

stub:
def args = task.ext.args ?: ''
def prefix = task.ext.prefix ?: "${meta.id}"
"""
touch ${prefix}.txt
Expand Down
1 change: 0 additions & 1 deletion modules/local/vcf_chr_extract/main.nf
LouisLeNezet marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ process VCF_CHR_EXTRACT {
"""

stub:
def args = task.ext.args ?: ''
def prefix = task.ext.prefix ?: "${meta.id}"
"""
touch ${prefix}.txt
Expand Down
1 change: 1 addition & 0 deletions subworkflows/local/bam_chr_rename_samtools/main.nf
LouisLeNezet marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ workflow BAM_CHR_RENAME_SAMTOOLS {
SAMTOOLS_REHEADER(
ch_bam.map{
meta, bam, index, prefix ->
def cmd = ""
if (prefix == "nochr") {
cmd = 'sed -E "s/^(@SQ.*\\tSN:)chr/\\1/"'
} else if (prefix == "chr") {
Expand Down
6 changes: 3 additions & 3 deletions subworkflows/local/bam_impute_quilt/main.nf
LouisLeNezet marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ workflow BAM_IMPUTE_QUILT {
posfile_phasefile = [[id: null], posfile, phasefile]
genetic_map_file = []

ngen = params.ngen
buffer = params.buffer
ngen_params = params.ngen
buffer_params = params.buffer

ch_hap_chunks = ch_hap_legend
.combine(ch_chunks, by:0)
.map { it + ngen + buffer + [[]] }
.map { it + ngen_params + buffer_params + [[]] }

if (!genetic_map_file.isEmpty()) {
// Add genetic map file (untested)
Expand Down
6 changes: 3 additions & 3 deletions subworkflows/local/bam_impute_stitch/main.nf
LouisLeNezet marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ workflow BAM_IMPUTE_STITCH {
// Value channels
def input_empty = [[]]
def rdata_empty = [[]]
k_val = params.k_val
ngen = params.ngen
k_val_params = params.k_val
ngen_params = params.ngen

// Transform posfile to TSV with ','
GAWK(ch_posfile, [])
Expand All @@ -38,7 +38,7 @@ workflow BAM_IMPUTE_STITCH {
ch_parameters = ch_posfile
.map { it + input_empty + rdata_empty}
.join(ch_chromosomes)
.map { it + k_val + ngen}
.map { it + k_val_params + ngen_params}
.map { metaC, metaPC, posfile, input, rdata, chr, k_val, ngen ->
[metaPC, posfile, input, rdata, chr, k_val, ngen]
}
Expand Down
50 changes: 23 additions & 27 deletions subworkflows/local/bam_impute_stitch/tests/main.nf.test
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@ nextflow_workflow {
tag "bcftools_index"

test("Prepare input stitch") {
setup {
run("PREPARE_INPUT_STITCH") {
script "../../prepare_input_stitch/main.nf"
process {
"""
input[0] = Channel.fromList([
when {
params {
max_cpus = 2
max_memory = '2.GB'
}
workflow {
"""
ch_samples = Channel.fromList([
[
[id: "NA12878"],
file(params.pipelines_testdata_base_path + "hum_data/individuals/NA12878/NA12878.s.bam", checkIfExist:true),
Expand All @@ -33,27 +35,21 @@ nextflow_workflow {
file(params.pipelines_testdata_base_path + "hum_data/individuals/NA19401/NA19401.s.bam.bai", checkIfExist:true),
],
])
input[1] = Channel.of([
[id: "1000GP", chr: "chr22"],
file(params.pipelines_testdata_base_path + "hum_data/panel/chr22/1000GP.chr22.legend.gz", checkIfExist:true)
]).collect()
input[2] = Channel.of([
[chr: "chr22", region: "chr22:16570000-16610000"], "chr22:16570000-16610000"
]).collect()
"""
}
}
}
when {
params {
max_cpus = 2
max_memory = '2.GB'
}
workflow {
"""
input[0] = PREPARE_INPUT_STITCH.out.stitch_samples
input[1] = PREPARE_INPUT_STITCH.out.stitch_parameters
input[2] = Channel.of([
bamlist = Channel.of("NA12878.s.bam", "NA19401.s.bam").collectFile(name: "bamlist")

ch_posfile = Channel.of([
[id: "1000GP", chr: "chr22"],
file(params.pipelines_testdata_base_path + "hum_data/panel/chr22/1000GP.chr22.legend.gz", checkIfExist:true)
])

ch_region = Channel.of([
[chr: "chr22", region: "chr22:16570000-16610000"], "chr22:16570000-16610000"
])

input[0] = ch_samples.combine(bamlist)
input[1] = ch_posfile
input[2] = ch_region
input[3] = Channel.of([
[id: "GRCh38"],
file(params.pipelines_testdata_base_path + "hum_data/reference_genome/GRCh38.s.fa.gz", checkIfExist:true),
file(params.pipelines_testdata_base_path + "hum_data/reference_genome/GRCh38.s.fa.gz.fai", checkIfExist:true),
Expand Down
20 changes: 10 additions & 10 deletions subworkflows/local/utils_nfcore_chrcheck_pipeline/main.nf
LouisLeNezet marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Check if the contig names in the input files match the reference contig names.
//
def checkChr(ch_chr, ch_input){
chr_checked = ch_chr
def chr_checked = ch_chr
.combine(ch_input, by:0)
.map{meta, chr, file, index, lst ->
[
Expand All @@ -12,9 +12,9 @@ def checkChr(ch_chr, ch_input){
]
}
.branch{ meta, file, index, chr, lst ->
lst_diff = diffChr(chr, lst, file)
diff = lst_diff[0]
prefix = lst_diff[1]
def lst_diff = diffChr(chr, lst, file)
def diff = lst_diff[0]
def prefix = lst_diff[1]
no_rename: diff.size() == 0
return [meta, file, index]
to_rename: true
Expand All @@ -27,22 +27,22 @@ def checkChr(ch_chr, ch_input){
// Check if the contig names can be solved by adding/removing the `chr` prefix.
//
def diffChr(chr_target, chr_ref, file) {
diff = chr_ref - chr_target
prefix = (chr_ref - chr_target) =~ "chr" ? "chr" : "nochr"
def diff = chr_ref - chr_target
def prefix = (chr_ref - chr_target) =~ "chr" ? "chr" : "nochr"
if (diff.size() != 0) {
// Ensure that by adding/removing the prefix we can solve the problem
new_chr = []
to_rename = []
def new_chr = []
def to_rename = []
if (prefix == "chr") {
chr_target.each{ new_chr += "chr${it}" }
diff.each{ to_rename += it.replace('chr', '') }
} else {
chr_target.each{ new_chr += it.replace('chr', '') }
diff.each{ to_rename += "chr${it}" }
}
new_diff = diff - new_chr
def new_diff = diff - new_chr
if (new_diff.size() != 0) {
chr_names = new_diff.size() > params.max_chr_names ? new_diff[0..params.max_chr_names - 1] + ['...'] : new_diff
def chr_names = new_diff.size() > params.max_chr_names ? new_diff[0..params.max_chr_names - 1] + ['...'] : new_diff
error "Contig names: ${chr_names} absent from file: ${file} and cannot be solved by adding or removing the `chr` prefix."
}
diff = to_rename
Expand Down
43 changes: 23 additions & 20 deletions subworkflows/local/utils_nfcore_phaseimpute_pipeline/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -351,40 +351,40 @@ workflow PIPELINE_COMPLETION {
def validateInputParameters() {
genomeExistsError()
// Check that only genome or fasta is provided
assert params.genome == null || params.fasta == null, "Either --genome or --fasta must be provided"
assert !(params.genome == null && params.fasta == null), "Only one of --genome or --fasta must be provided"
assert (params.genome == null || params.fasta == null) : "Either --genome or --fasta must be provided"
LouisLeNezet marked this conversation as resolved.
Show resolved Hide resolved
assert !(params.genome == null && params.fasta == null) : "Only one of --genome or --fasta must be provided"

// Check that a steps is provided
assert params.steps, "A step must be provided"
assert params.steps : "A step must be provided"

// Check that at least one tool is provided
if (params.steps.split(',').contains("impute")) {
assert params.tools, "No tools provided"
assert params.tools : "No tools provided"
}

// Check that input is provided for all steps, except panelprep
if (params.steps.split(',').contains("all") || params.steps.split(',').contains("impute") || params.steps.split(',').contains("simulate") || params.steps.split(',').contains("validate")) {
assert params.input, "No input provided"
assert params.input : "No input provided"
}

// Check that posfile and chunks are provided when running impute only. Steps with panelprep generate those files.
if (params.steps.split(',').contains("impute") && !params.steps.split(',').find { it in ["all", "panelprep"] }) {
// Required by all tools except glimpse2
if (!params.tools.split(',').find { it in ["glimpse2"] }) {
assert params.posfile, "No --posfile provided for --steps impute"
assert params.posfile : "No --posfile provided for --steps impute"
}
// Required by all tools except STITCH
if (params.tools != "stitch") {
assert params.chunks, "No --chunks provided for --steps impute"
assert params.chunks : "No --chunks provided for --steps impute"
}
// Required by GLIMPSE1 and GLIMPSE2 only
if (params.tools.split(',').contains("glimpse")) {
assert params.panel, "No --panel provided for imputation with GLIMPSE"
assert params.panel : "No --panel provided for imputation with GLIMPSE"
}

// Check that input_truth is provided when running validate
if (params.steps.split(',').find { it in ["all", "validate"] } ) {
assert params.input_truth, "No --input_truth was provided for --steps validate"
assert params.input_truth : "No --input_truth was provided for --steps validate"
}
}

Expand Down Expand Up @@ -492,21 +492,24 @@ def checkMetaChr(chr_a, chr_b, name){
//
// Get file extension
//
import nextflow.file.http.XPath
import java.nio.file.Path

def getFileExtension(file) {
if (file instanceof Path) {
file = file.getName()
} else if (file instanceof ArrayList) {
if (file.size() == 0) {
return null
} else {
error "Type not supported: ${file} = ${file.getClass()}"
}
}
if (file instanceof CharSequence) {
return file.toString().replace(".gz", "").split("\\.").last()
def file_name = ""

if (file instanceof Path || file instanceof XPath) {
file_name = file.name
} else if (file instanceof CharSequence) {
file_name = file.toString()
} else if (file instanceof List) {
return file.collect { getFileExtension(it) }
} else {
error "Type not supported: ${file.getClass()}"
}

// Remove .gz if present and get the last part after splitting by "."
return file_name.replace(".gz", "").split("\\.").last()
}

//
Expand Down
Loading
Loading