-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Collation of cutadapt JSON results into single JSON file * Collation of SeqKit statistics results into a single TSV file * Update version of pyQUEST to version 1.1.0 * Improved handling of 0-length reads * Ability to extract top 50 library-independent counts as FASTA
- Loading branch information
Showing
13 changed files
with
169 additions
and
10 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 |
---|---|---|
|
@@ -99,6 +99,7 @@ jobs: | |
allow-repeats: false | ||
|
||
nf-core: | ||
if: false | ||
runs-on: ubuntu-latest | ||
steps: | ||
|
||
|
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 |
---|---|---|
|
@@ -54,4 +54,8 @@ process { | |
errorStrategy = 'retry' | ||
maxRetries = 2 | ||
} | ||
|
||
withName:COLLATE_CUTADAPT_JSONS { | ||
executor = 'local' | ||
} | ||
} |
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,45 @@ | ||
// | ||
// takes channel, workflow object and name of output channel | ||
// extracts desired output channel from workflow, combines it with workflow name and appends to input channel | ||
// | ||
def add_stats_with_stage(channel, workflow, String out_channel) { | ||
return channel.mix( | ||
workflow.out.getProperty(out_channel).combine( | ||
[workflow.name.split(':').last()] | ||
) | ||
) | ||
} | ||
|
||
// | ||
// removes stage suffix from the sample name | ||
// | ||
def trim_sample_name(sample_name) { | ||
sample_name | ||
.replaceFirst(/_raw$/, "") | ||
.replaceFirst(/_primer_trimmed$/, "") | ||
.replaceFirst(/_adapter_trimmed$/, "") | ||
.replaceFirst(/_merged$/, "") | ||
.replaceFirst(/_merged_filtered$/, "") | ||
} | ||
|
||
// | ||
// each seqkit stat file prepends with two columns for sample and stage | ||
// | ||
def modify_seqkit_stats(meta, path, stage) { | ||
// TODO should be removed in the future once sample name handling in the pipeline is consistent | ||
def sample_name = trim_sample_name(meta.id) | ||
|
||
newLines = [] | ||
file(path) | ||
.readLines() | ||
.eachWithIndex { it, i -> | ||
if (i == 0) { | ||
line = "sample" + "\t" + "stage" + "\t" + it | ||
} else { | ||
line = sample_name + "\t" + stage + "\t" + it | ||
} | ||
newLines.add(line) | ||
} | ||
|
||
return newLines.join("\n") + "\n" | ||
} |
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,25 @@ | ||
import groovy.json.JsonSlurper | ||
|
||
// | ||
// takes cutadapt json filenames and stages for the sample and creates a record | ||
// | ||
def compose_cutadapt_jsons(meta, pathList, stageList) { | ||
def jsonSlurper = new JsonSlurper() | ||
def record = [:] | ||
|
||
[pathList, stageList].transpose().each() { path, stage -> | ||
def object = jsonSlurper.parse(path) | ||
|
||
object["read_counts"]["read1_with_adapter_percent"] = 100 * object["read_counts"]["read1_with_adapter"] / object["read_counts"]["input"] | ||
if (object["read_counts"]["read2_with_adapter"]){ | ||
object["read_counts"]["read2_with_adapter_percent"] = 100 * object["read_counts"]["read2_with_adapter"] / object["read_counts"]["input"] | ||
} else { | ||
object["read_counts"]["read2_with_adapter_percent"] = null | ||
} | ||
|
||
record[stage] = object | ||
} | ||
|
||
record = [(meta.id): record] | ||
return record | ||
} |
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,33 @@ | ||
import groovy.json.JsonOutput | ||
|
||
// Import generic module functions | ||
include { compose_cutadapt_jsons } from './functions' | ||
|
||
process COLLATE_CUTADAPT_JSONS { | ||
label 'process_low' | ||
publishDir "${params.outdir}/cutadapt", mode: params.publish_dir_mode | ||
|
||
input: | ||
val inputList // list of tuples [meta, [list of jsons], [list of stages]] | ||
|
||
output: | ||
path 'cutadapt.json', emit: json | ||
|
||
exec: | ||
String filename = [task.workDir, 'cutadapt.json'].join(File.separator) | ||
|
||
new File(filename).withWriter { writer -> | ||
writer.writeLine('{') | ||
|
||
inputList.eachWithIndex { e, index -> | ||
def (meta, pathList, stageList) = e | ||
def record = compose_cutadapt_jsons(meta, pathList, stageList) | ||
String record_string = JsonOutput.toJson(record) | ||
String comma = index + 1 < inputList.size() ? ',' : '' | ||
String output_string = ' ' + record_string[1..-2] + comma | ||
writer.writeLine(output_string) | ||
} | ||
|
||
writer.writeLine('}') | ||
} | ||
} |
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,17 @@ | ||
name: cutadapt_json_collation | ||
description: Collate all cutadapt output jsons into one file | ||
keywords: | ||
- cutadapt | ||
input: | ||
- inputList: | ||
type: list | ||
description: | | ||
Groovy list containing tuples of three objects: | ||
meta, list of cutadapt jsons, list of stages | ||
output: | ||
- json: | ||
type: file | ||
description: collated cutadapt json file for all samples | ||
pattern: "cutadapt.json" | ||
authors: | ||
- "@y-popov" |
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
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
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