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

More checks of sample-sheet #629

Merged
merged 5 commits into from
Jul 12, 2022
Merged
Changes from 1 commit
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
34 changes: 34 additions & 0 deletions workflows/sarek.nf
Original file line number Diff line number Diff line change
Expand Up @@ -1034,9 +1034,14 @@ def extract_csv(csv_file) {
}
}

numberOfSamples = 0
numberOfNormalSamples = 0
numberOfTumorSamples = 0
asp8200 marked this conversation as resolved.
Show resolved Hide resolved

Channel.from(csv_file).splitCsv(header: true)
//Retrieves number of lanes by grouping together by patient and sample and counting how many entries there are for this combination
.map{ row ->
numberOfSamples++
if (!(row.patient && row.sample)){
log.error "Missing field in csv file header. The csv file must have fields named 'patient' and 'sample'."
System.exit(1)
Expand All @@ -1048,6 +1053,7 @@ def extract_csv(csv_file) {
[rows, size]
}.transpose()
.map{ row, numLanes -> //from here do the usual thing for csv parsing

def meta = [:]

// Meta data to identify samplesheet
Expand All @@ -1066,6 +1072,34 @@ def extract_csv(csv_file) {
if (row.status) meta.status = row.status.toInteger()
else meta.status = 0

if (meta.status == 0) numberOfNormalSamples++
else numberOfTumorSamples++

// Two checks for ensuring that the pipeline stops with a meaningful error message if
// 1. the sample-sheet only contains normal-samples, but some of the requested tools require tumor-samples, and
// 2. the sample-sheet only contains tumor-samples, but some of the requested tools require normal/germline-samples.
if ((numberOfNormalSamples == numberOfSamples) && params.tools) { // In this case, the sample-sheet contains no tumor-samples
def tools_requiring_tumor_samples = ['ascat', 'controlfreec', 'mutect2', 'msisensorpro']
def requested_tools_requiring_tumor_samples = []
tools_requiring_tumor_samples.each{ tool_requiring_tumor_samples ->
if (params.tools.contains(tool_requiring_tumor_samples)) requested_tools_requiring_tumor_samples.add(tool_requiring_tumor_samples)
}
if (!requested_tools_requiring_tumor_samples.isEmpty()) {
log.error('The sample-sheet only contains normal-samples, but the following tools, which were requested by the option "tools", expect at least one tumor-sample : ' + requested_tools_requiring_tumor_samples.join(", "))
System.exit(1)
}
asp8200 marked this conversation as resolved.
Show resolved Hide resolved
asp8200 marked this conversation as resolved.
Show resolved Hide resolved
} else if ((numberOfTumorSamples == numberOfSamples) && params.tools) { // In this case, the sample-sheet contains no normal/germline-samples
def tools_requiring_normal_samples = ['ascat', 'deepvariant', 'haplotypecaller']
asp8200 marked this conversation as resolved.
Show resolved Hide resolved
def requested_tools_requiring_normal_samples = []
tools_requiring_normal_samples.each{ tool_requiring_normal_samples ->
if (params.tools.contains(tool_requiring_normal_samples)) requested_tools_requiring_normal_samples.add(tool_requiring_normal_samples)
}
if (!requested_tools_requiring_normal_samples.isEmpty()) {
log.error('The sample-sheet only contains tumor-samples, but the following tools, which were requested by the option "tools", expect at least one normal-sample : ' + requested_tools_requiring_normal_samples.join(", "))
System.exit(1)
}
}

// mapping with fastq
if (row.lane && row.fastq_2) {
meta.id = "${row.sample}-${row.lane}".toString()
Expand Down