-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* FEAT: Add falco. * Fix output and adjust formatting * Add test for permissions * FEAT: Add multiqc. * Cleanup code. * Update file parsing * Refactor into different workflows * Remove debbuging view() * Add test for multiqc * Autodetect SampleSheet from input directory * Fix InterOp statistics.
- Loading branch information
1 parent
4cfd291
commit fb98dc5
Showing
12 changed files
with
376 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,4 +3,5 @@ testData | |
|
||
# Nextflow related files | ||
.nextflow | ||
.nextflow.log* | ||
work |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
name: combine_samples | ||
namespace: dataflow | ||
description: Combine fastq files from across samples into one event with a list of fastq files per orientation. | ||
argument_groups: | ||
- name: Input arguments | ||
arguments: | ||
- name: "--id" | ||
description: "ID of the new event" | ||
type: string | ||
required: true | ||
- name: --forward_input | ||
type: file | ||
required: true | ||
- name: --reverse_input | ||
type: file | ||
required: false | ||
- name: Output arguments | ||
arguments: | ||
- name: --output_forward | ||
type: file | ||
direction: output | ||
multiple: true | ||
required: true | ||
- name: --output_reverse | ||
type: file | ||
direction: output | ||
multiple: true | ||
required: false | ||
resources: | ||
- type: nextflow_script | ||
path: main.nf | ||
entrypoint: run_wf | ||
|
||
runners: | ||
- type: nextflow | ||
|
||
engines: | ||
- type: native |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
workflow run_wf { | ||
take: | ||
input_ch | ||
|
||
main: | ||
output_ch = input_ch | ||
| map { id, state -> | ||
def newEvent = [state.id, state + ["_meta": ["join_id": id]]] | ||
newEvent | ||
} | ||
| groupTuple(by: 0, sort: "hash") | ||
| map {run_id, states -> | ||
// Gather the following state for all samples | ||
def forward_fastqs = states.collect{it.forward_input} | ||
def reverse_fastqs = states.collect{it.reverse_input}.findAll{it != null} | ||
|
||
def resultState = [ | ||
"output_forward": forward_fastqs, | ||
"output_reverse": reverse_fastqs, | ||
// The join ID is the same across all samples from the same run | ||
"_meta": ["join_id": states[0]._meta.join_id] | ||
] | ||
return [run_id, resultState] | ||
} | ||
|
||
emit: | ||
output_ch | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
name: gather_fastqs_and_validate | ||
namespace: dataflow | ||
description: | | ||
From a directory containing fastq files, gather the files per sample | ||
and validate according to the contents of the sample sheet. | ||
argument_groups: | ||
- name: Input arguments | ||
arguments: | ||
- name: --input | ||
description: Directory containing .fastq files | ||
type: file | ||
required: true | ||
- name: --sample_sheet | ||
description: Sample sheet | ||
type: file | ||
required: true | ||
- name: Output arguments | ||
arguments: | ||
- name: --fastq_forward | ||
type: file | ||
direction: output | ||
required: true | ||
- name: "--fastq_reverse" | ||
type: file | ||
direction: output | ||
required: false | ||
resources: | ||
- type: nextflow_script | ||
path: main.nf | ||
entrypoint: run_wf | ||
|
||
runners: | ||
- type: nextflow | ||
|
||
engines: | ||
- type: native |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
workflow run_wf { | ||
take: | ||
input_ch | ||
|
||
main: | ||
output_ch = input_ch | ||
// Gather input files from BCL convert output folder | ||
| flatMap { id, state -> | ||
println "Processing sample sheet: $state.sample_sheet" | ||
def sample_sheet = state.sample_sheet | ||
def start_parsing = false | ||
def sample_id_column_index = null | ||
def samples = ["Undetermined"] | ||
def original_id = id | ||
|
||
// Parse sample sheet for sample IDs | ||
csv_lines = sample_sheet.splitCsv(header: false, sep: ',') | ||
csv_lines.any { csv_items -> | ||
if (csv_items.isEmpty()) { | ||
return | ||
} | ||
def possible_header = csv_items[0] | ||
def header = possible_header.find(/\[(.*)\]/){fullmatch, header_name -> header_name} | ||
if (header) { | ||
if (start_parsing) { | ||
// Stop parsing when encountering the next header | ||
return true | ||
} | ||
if (header == "Data") { | ||
start_parsing = true | ||
} | ||
} | ||
if (start_parsing) { | ||
if ( !sample_id_column_index ) { | ||
sample_id_column_index = csv_items.findIndexValues{it == "Sample_ID"} | ||
assert sample_id_column_index != -1: | ||
"Could not find column 'Sample_ID' in sample sheet!" | ||
return | ||
} | ||
samples += csv_items[sample_id_column_index] | ||
} | ||
} | ||
println "Looking for fastq files in ${state.input}." | ||
def allfastqs = state.input.listFiles().findAll{it.isFile() && it.name ==~ /^.+\.fastq.gz$/} | ||
println "Found ${allfastqs.size()} fastq files, matching them to the following samples: ${samples}." | ||
processed_samples = samples.collect { sample_id -> | ||
def forward_regex = ~/^${sample_id}_S(\d+)_(L(\d+)_)?R1_(\d+)\.fastq\.gz$/ | ||
def reverse_regex = ~/^${sample_id}_S(\d+)_(L(\d+)_)?R2_(\d+)\.fastq\.gz$/ | ||
def forward_fastq = state.input.listFiles().findAll{it.isFile() && it.name ==~ forward_regex} | ||
def reverse_fastq = state.input.listFiles().findAll{it.isFile() && it.name ==~ reverse_regex} | ||
assert forward_fastq : "No forward fastq files were found for sample ${sample_id}" | ||
assert forward_fastq.size() < 2: | ||
"Found multiple forward fastq files corresponding to sample ${sample_id}: ${forward_fastq}" | ||
assert reverse_fastq.size() < 2: | ||
"Found multiple reverse fastq files corresponding to sample ${sample_id}: ${reverse_fastq}." | ||
assert !forward_fastq.isEmpty(): | ||
"Expected a forward fastq file to have been created correspondig to sample ${sample_id}." | ||
// TODO: if one sample had reverse reads, the others must as well. | ||
reverse_fastq = !reverse_fastq.isEmpty() ? reverse_fastq[0] : null | ||
def fastqs_state = [ | ||
"fastq_forward": forward_fastq[0], | ||
"fastq_reverse": reverse_fastq, | ||
"_meta": [ "join_id": original_id ], | ||
] | ||
[sample_id, fastqs_state] | ||
} | ||
println "Finished processing sample sheet." | ||
return processed_samples | ||
} | ||
|
||
emit: | ||
output_ch | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.