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

Additional checks of sample sheet #623

Merged
merged 5 commits into from
Jul 8, 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
23 changes: 23 additions & 0 deletions workflows/sarek.nf
Original file line number Diff line number Diff line change
Expand Up @@ -1005,6 +1005,29 @@ def extract_csv(csv_file) {
}
}

// check that the sample sheet doesn't contain
// 1. multiple rows with the same combination of patient, sample and lane, and
// 2. same sample for different patients
def patient_sample_lane_combinations_in_samplesheet = []
def sample2patient = [:]

Channel.from(csv_file).splitCsv(header: true)
.map{ row ->
def patient_sample_lane = [row.patient.toString(), row.sample.toString(), row.lane.toString()]
if (patient_sample_lane in patient_sample_lane_combinations_in_samplesheet) {
log.error "The patient-sample-lane combination (${row.patient.toString()}, ${row.sample.toString()}, ${row.lane.toString()}) present multiple times in the samplesheet."
System.exit(1)
} else {
patient_sample_lane_combinations_in_samplesheet.add(patient_sample_lane)
}
if (!sample2patient.containsKey(row.sample.toString())) {
sample2patient[row.sample.toString()] = row.patient.toString()
} else if (sample2patient[row.sample.toString()] !== row.patient.toString()) {
log.error "The sample ${row.sample.toString()} is registered in samplesheet for both patient ${row.patient.toString()} and ${sample2patient[row.sample.toString()]}."
System.exit(1)
}
}

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 ->
Expand Down