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

Input workflow #2

Merged
merged 17 commits into from
Mar 20, 2024
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
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
6 changes: 3 additions & 3 deletions assets/samplesheet.csv
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
sample,fastq_1,fastq_2
SAMPLE_PAIRED_END,/path/to/fastq/files/AEG588A1_S1_L002_R1_001.fastq.gz,/path/to/fastq/files/AEG588A1_S1_L002_R2_001.fastq.gz
SAMPLE_SINGLE_END,/path/to/fastq/files/AEG588A4_S4_L003_R1_001.fastq.gz,
sample,lane,project,fastq_1,fastq_2,rundir
SAMPLE_PAIRED_END,1,P001,/path/to/fastq/files/AEG588A1_S1_L002_R1_001.fastq.gz,/path/to/fastq/files/AEG588A1_S1_L002_R2_001.fastq.gz,/path/to/rundir
SAMPLE_SINGLE_END,2,P002,/path/to/fastq/files/AEG588A4_S4_L003_R1_001.fastq.gz,,/path/to/rundir
26 changes: 24 additions & 2 deletions assets/schema_input.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,19 @@
"type": "string",
"pattern": "^\\S+$",
"errorMessage": "Sample name must be provided and cannot contain spaces",
"meta": ["id"]
"meta": ["sample"]
},
"lane": {
"type": "integer",
"pattern": "^\\d+$",
Aratz marked this conversation as resolved.
Show resolved Hide resolved
"errorMessage": "Lane ID must be a number",
"meta": ["lane"]
},
"project": {
"type": "string",
"pattern": "^\\S+$",
"errorMessage": "Project ID cannot contain spaces",
"meta": ["project"]
},
"fastq_1": {
"type": "string",
Expand All @@ -26,8 +38,18 @@
"exists": true,
"pattern": "^\\S+\\.f(ast)?q\\.gz$",
"errorMessage": "FastQ file for reads 2 cannot contain spaces and must have extension '.fq.gz' or '.fastq.gz'"
},
"rundir": {
"type": "string",
"format": "file-path",
mahesh-panchal marked this conversation as resolved.
Show resolved Hide resolved
"exists": true,
"errorMessage": "Run directory must be a path",
"meta": ["rundir"]
}
},
"required": ["sample", "fastq_1"]
"required": ["sample", "lane", "fastq_1"],
"dependentRequired": {
"fastq_2": ["fastq_1"]
}
}
}
4 changes: 2 additions & 2 deletions main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ nextflow.enable.dsl = 2
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*/

include { SEQINSPECTOR } from './workflows/seqinspector'
include { SEQINSPECTOR } from './workflows/seqinspector'
include { PIPELINE_INITIALISATION } from './subworkflows/local/utils_nfcore_seqinspector_pipeline'
include { PIPELINE_COMPLETION } from './subworkflows/local/utils_nfcore_seqinspector_pipeline'

Expand All @@ -32,7 +32,7 @@ include { getGenomeAttribute } from './subworkflows/local/utils_nfcore_seqi
// TODO nf-core: Remove this line if you don't need a FASTA file
// This is an example of how to use getGenomeAttribute() to fetch parameters
// from igenomes.config using `--genome`
params.fasta = getGenomeAttribute('fasta')
// params.fasta = getGenomeAttribute('fasta')

/*
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand Down
28 changes: 17 additions & 11 deletions subworkflows/local/utils_nfcore_seqinspector_pipeline/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ workflow PIPELINE_INITIALISATION {
pre_help_text = nfCoreLogo(monochrome_logs)
post_help_text = '\n' + workflowCitation() + '\n' + dashedLine(monochrome_logs)
def String workflow_command = "nextflow run ${workflow.manifest.name} -profile <docker/singularity/.../institute> --input samplesheet.csv --outdir <OUTDIR>"
UTILS_NFVALIDATION_PLUGIN (
UTILS_NFVALIDATION_PLUGIN ( // Validates parameters against $projectDir/nextflow_schema.json
help,
workflow_command,
pre_help_text,
Expand All @@ -75,29 +75,33 @@ workflow PIPELINE_INITIALISATION {
//
// Custom validation for pipeline parameters
//
validateInputParameters()
validateInputParameters() // Runs additional validation that is not done by $projectDir/nextflow_schema.json

//
// Create channel from input file provided through params.input
//
Channel
.fromSamplesheet("input")
.fromSamplesheet("input") // Validates samplesheet against $projectDir/assets/schema_input.json. Path to validation schema is defined by $projectDir/nextflow_schema.json
.map {
meta, fastq_1, fastq_2 ->
def id_string = "${meta.lane}_${meta.group ?: "ungrouped"}_${meta.sample}"
def updated_meta = meta + [ id: id_string ]
if (!fastq_2) {
return [ meta.id, meta + [ single_end:true ], [ fastq_1 ] ]
return [ updated_meta.id, updated_meta + [ single_end:true ], [ fastq_1 ] ]
} else {
return [ meta.id, meta + [ single_end:false ], [ fastq_1, fastq_2 ] ]
return [ updated_meta.id, updated_meta + [ single_end:false ], [ fastq_1, fastq_2 ] ]
}
}
.groupTuple()
.map {
validateInputSamplesheet(it)
}
.map {
meta, fastqs ->
return [ meta, fastqs.flatten() ]
validateInputSamplesheet(it) // Applies additional group validation checks that schema_input.json cannot do.
}
.transpose() // Replace the map below
// .map {
// meta, fastqs ->
// return [ meta, fastqs.flatten() ]
// }
.view()
.set { ch_samplesheet }

emit:
Expand Down Expand Up @@ -151,7 +155,9 @@ workflow PIPELINE_COMPLETION {
// Check and validate pipeline parameters
//
def validateInputParameters() {
genomeExistsError()
// genomeExistsError()

// TODO: Add code to further validate pipeline parameters here
}

//
Expand Down
Loading