From 2d3c99c639bd5cc8af1003b5bd474be0eeb00122 Mon Sep 17 00:00:00 2001 From: Laurent Modolo <laurent.modolo@ens-lyon.fr> Date: Tue, 19 Oct 2021 17:38:10 +0200 Subject: [PATCH] src/example_chipseq.nf: work in progress of chip-seq example --- src/example_chipseq.nf | 123 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 123 insertions(+) create mode 100644 src/example_chipseq.nf diff --git a/src/example_chipseq.nf b/src/example_chipseq.nf new file mode 100644 index 00000000..454617c9 --- /dev/null +++ b/src/example_chipseq.nf @@ -0,0 +1,123 @@ + +nextflow.enable.dsl=2 + +include { + fastp +} from './nf_modules/fastp/main' + +workflow csv_parsing { + if (params.csv_path.size() > 0) { + log.info "loading local csv files" + Channel + .fromPath(params.csv_path, checkIfExists: true) + .ifEmpty { error + log.error """ + ============================================================= + WARNING! No csv input file precised. + Use '--csv_path <file.csv>' + Or '--help' for more informations + ============================================================= + """ + } + .splitCsv(header: true, sep: ";", strip: true) + .flatMap{ + it -> [ + [(it.IP + it.WCE).md5(), "IP", "w", file(it.IP)], + [(it.IP + it.WCE).md5(), "WCE", "w", file(it.WCE)] + ] + } + .map{ it -> + if (it[1] instanceof List){ + it + } else { + [it[0], [it[1]], it[2], it[3], [it[4]]] + } + } + .map{ + it -> + if (it[1].size() == 2){ // if data are paired_end + [ + "index": it[0], + "group": ref_order(it), + "ip": it[2], + "type": it[3], + "id": read_order(it)[0], + "file": read_order(it) + ] + } else { + [ + "index": it[0], + "group": it[1].simpleName, + "ip": it[2], + "type": it[3], + "id": it[4].simpleName, + "file": [it[4].simpleName, it[4]] + ] + } + } + .set{input_csv} + } else { + log.info "loading remotes SRA csv files" + Channel + .fromPath(params.csv_sra, checkIfExists: true) + .ifEmpty { error + log.error """ + ============================================================= + WARNING! No csv input file precised. + Use '--csv_path <file.csv>' or + Use '--csv_SRA <file.csv>' + Or '--help' for more informations + ============================================================= + """ + } + .splitCsv(header: true, sep: ";", strip: true) + .flatMap{ + it -> [ + [[it.IP_w + it.WCE_w + it.IP_m + it.WCE_m], t.IP_w, "IP", "w", it.IP_w], + [[it.IP_w + it.WCE_w + it.IP_m + it.WCE_m], it.IP_w, "WCE", "w", it.WCE_w], + [[it.IP_w + it.WCE_w + it.IP_m + it.WCE_m], it.IP_w, "IP", "m", it.IP_m], + [[it.IP_w + it.WCE_w + it.IP_m + it.WCE_m], it.IP_w, "WCE", "m", it.WCE_m] + ] + } + .map{ + it -> + if (it[1].size() == 2){ // if data are paired_end + [ + "index": ( + it[0][0][0].simpleName + + it[0][0][1].simpleName + + it[0][0][2].simpleName + + it[0][0][3].simpleName + ).md5(), + "group": it[1][0].simpleName, + "ip": it[2], + "type": it[3], + "id": it[4][0].simpleName[0..-4], + "file": [it[4][0].simpleName[0..-4], it[4]] + ] + } else { + [ + "index": ( + it[0][0].simpleName + + it[0][1].simpleName + + it[0][2].simpleName + + it[0][3].simpleName + ).md5(), + "group": it[1].simpleName, + "ip": it[2], + "type": it[3], + "id": it[4].simpleName, + "file": [it[4].simpleName, it[4]] + ] + } + } + .set{input_csv} + } + emit: + input_csv +} + + +workflow { + +} \ No newline at end of file -- GitLab