diff --git a/.gitignore b/.gitignore index 1d21541..49c40e4 100644 --- a/.gitignore +++ b/.gitignore @@ -2,5 +2,7 @@ nextflow .nextflow .nextflow.* pipeline_trace* -nf_pipeline -work \ No newline at end of file +nf_pipeline* +work +*.fa +*.gtf \ No newline at end of file diff --git a/cleanup.sh b/cleanup.sh new file mode 100755 index 0000000..24aa7bc --- /dev/null +++ b/cleanup.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +./nextflow main.nf -profile test +rm -rf work +rm -rf nf_pipeline +rm .nextflow.log* +rm pipeline_trace.txt* \ No newline at end of file diff --git a/conda.yml b/conda.yml index 81cc47a..457fddc 100644 --- a/conda.yml +++ b/conda.yml @@ -6,7 +6,7 @@ channels: - conda-forge dependencies: # Default bismark - - salmon - - alevin-fry - - pyroe + - bioconda::salmon>=1.8.0 + - bioconda::alevin-fry>=0.6.0 + - bioconda::pyroe - bedtools diff --git a/fastq.tar b/fastq.tar new file mode 100644 index 0000000..1edb7bd Binary files /dev/null and b/fastq.tar differ diff --git a/genomic_data/fasta/genome.fa.gz b/genomic_data/fasta/genome.fa.gz new file mode 100644 index 0000000..3ac8bb7 Binary files /dev/null and b/genomic_data/fasta/genome.fa.gz differ diff --git a/input_files/pl_sheet_toy.tsv b/input_files/pl_sheet_toy.tsv index 910d3af..120bde1 100644 --- a/input_files/pl_sheet_toy.tsv +++ b/input_files/pl_sheet_toy.tsv @@ -1,2 +1,2 @@ -reference link +chemistry link v3 https://raw.githubusercontent.com/10XGenomics/cellranger/master/lib/python/cellranger/barcodes/3M-february-2018.txt.gz diff --git a/input_files/ref_sheet.tsv b/input_files/ref_sheet.tsv index 2a2f2f7..b83aa0d 100644 --- a/input_files/ref_sheet.tsv +++ b/input_files/ref_sheet.tsv @@ -1,3 +1,3 @@ reference link human2020A https://cf.10xgenomics.com/supp/cell-exp/refdata-gex-GRCh38-2020-A.tar.gz -mm10-2020A https://cf.10xgenomics.com/supp/cell-exp/refdata-gex-mm10-2020-A.tar.gz +mm10-2020A https://cf.10xgenomics.com/supp/cell-exp/refdata-gex-mm10-2020-A.tar.gz \ No newline at end of file diff --git a/input_files/ref_sheet_toy.tsv b/input_files/ref_sheet_toy.tsv index 7768c13..f99821d 100644 --- a/input_files/ref_sheet_toy.tsv +++ b/input_files/ref_sheet_toy.tsv @@ -1,2 +1,2 @@ -reference link -human-toy https://umd.box.com/shared/static/7v6mof9emgudmuczc4lnwz4oou7xayks.gz \ No newline at end of file +reference ref_data fasta gtf +human-toy-download-ref randommeaninglessfillerstring genomic_data/fasta/genome.fa genomic_data/genes/genes.gtf diff --git a/input_files/sample_sheet_toy.tsv b/input_files/sample_sheet_toy.tsv index ac15f40..2f0a034 100644 --- a/input_files/sample_sheet_toy.tsv +++ b/input_files/sample_sheet_toy.tsv @@ -1,2 +1,2 @@ chemistry reference dataset_name dataset_url fastq_url fastq_MD5sum delete_fastq feature_barcode_csv_url multiplexing_library_csv_url -v3 human-toy toy set from 200 Sorted Cells from Human Glioblastoma Multiforme, 3' LT v3.1 https://www.10xgenomics.com/resources/datasets/200-sorted-cells-from-human-glioblastoma-multiforme-3-lt-v-3-1-3-1-low-6-0-0 https://umd.box.com/shared/static/bauvay4eq0v8xmu9e0fp0me7zj1qojnr.tar 8db8f1f92f92de0295efc9bb602a8276 1 +v3 human-toy-download-ref toy set from 200 Sorted Cells from Human Glioblastoma Multiforme, 3' LT v3.1 https://www.10xgenomics.com/resources/datasets/200-sorted-cells-from-human-glioblastoma-multiforme-3-lt-v-3-1-3-1-low-6-0-0 https://umd.box.com/shared/static/bauvay4eq0v8xmu9e0fp0me7zj1qojnr.tar 8db8f1f92f92de0295efc9bb602a8276 1 \ No newline at end of file diff --git a/main.nf b/main.nf index 98f6832..2efa5a8 100755 --- a/main.nf +++ b/main.nf @@ -25,7 +25,6 @@ workflow { // producing both the knee filtered and // unfiltered output preprocess() - // merge permit list data = preprocess.out.chem_pl.cross(data) .map(it -> tuple(it[1][1], // reference @@ -39,7 +38,6 @@ workflow { it[1][7], // feature_barcode_csv_url it[1][8] // multiplexing_library_csv_url )) - // merge t2g and salmon index data = preprocess.out.ref_t2g_index.cross(data) .map(it -> tuple( it[1][1], // chemistry @@ -55,7 +53,11 @@ workflow { it[1][2], // pl_path it[0][1] // t2g_path )) - salmon_map(data) - af(salmon_map.out, Channel.value("unfilt")) + if(!salmon_map.out[0].equals("v2") && !salmon_map.out[0].equals("v3")) { + af(salmon_map.out, Channel.value("unfilt")) + } else { + af(salmon_map.out, Channel.value("knee")) + } + af.out.view() } diff --git a/modules/af.nf b/modules/af.nf index 94764af..306357d 100644 --- a/modules/af.nf +++ b/modules/af.nf @@ -270,6 +270,10 @@ workflow af { | alevin_fry_collate \ | alevin_fry_quant \ | write_description + + emit: + write_description.out + } diff --git a/modules/preprocess.nf b/modules/preprocess.nf index 942d252..05f6e24 100644 --- a/modules/preprocess.nf +++ b/modules/preprocess.nf @@ -1,3 +1,4 @@ +import groovy.io.FileType /* * based on the provided reference and link of permit list, @@ -14,8 +15,7 @@ process get_permitlist { tuple val(chemistry), file(ofile_name), emit: chem_pl script: - ofile_name = link.getName() - + ofile_name = link.getName() if (link.getExtension() != 'txt') { ofile_name = link.getBaseName() """ @@ -32,49 +32,6 @@ process get_permitlist { // permitlist = permitlist.flatMap { ["${it[0]}" : it[1]] } - -/* -* based on the provided reference and link of cellranger references, -* download and uncompress on the fly, and make splici for them -* NOTE: -* 1. require a tsv named ref_sheet.tsv in the ${bench_dir}/input_files -* 2. only work for pre-built cellranger references, like humand2020A and mm10-2020A -* 3. if other reference needed, this process has to be expanded to -* enable cellranger to make reference -*/ -process get_splici { - tag "get_permitlist:${reference}" - // conda "bioconda::bedtools bioconda::pyroe" - - input: - tuple val(reference), val(link) - - output: - tuple val(reference), - path("splici_$reference/splici_fl${params.read_len - 5}.fa"), - path("splici_$reference/splici_fl${params.read_len - 5}_t2g_3col.tsv"), - emit: splici - - script: - """ - mkdir reference_$reference && wget -qO- ${link} | tar xzf - --strip-components=1 -C reference_$reference - pyroe make-splici reference_$reference/fasta/genome.fa reference_$reference/genes/genes.gtf ${params.read_len} splici_$reference - rm -rf reference_$reference - """ - stub: - """ - mkdir reference_$reference - mkdir reference_$reference/genes && touch reference_$reference/genes/genes.gtf - mkdir reference_$reference/fasta && touch reference_$reference/fasta/genome.fa - - mkdir splici_$reference - touch splici_$reference/splici_fl${params.read_len-5}.fa - touch splici_$reference/splici_fl${params.read_len-5}_t2g_3col.tsv - rm -rf reference_$reference - """ -} - - /* * This process takes an input sample * as defined by the columns in the sample table csv @@ -122,6 +79,292 @@ process salmon_index { """ } +/* +* Process sets up reference data based on the provided reference link or local path, +* which could contain data for both gtf and fasta files, just one, or neither if user +* provides seperate paths or remote links to both files +*/ + +process process_ref_data { + tag "ref:${reference}" + + input: + tuple val(reference), val(ref_data), val(fasta), val(gtf) + output: + tuple val(reference), path(ref_path), val(fasta), val(gtf), + emit: processed_ref_data + + script: + ref_path = "reference_${reference}/" + if (ref_data.length () > 3 && ref_data.substring(0,4).equals("http")) { //check if ref_data is https or local + """ + mkdir $ref_path + wget -qO- $ref_data | tar xzf - --strip-components=1 -C $ref_path + """ + } else if(ref_data.contains("gz") || ref_data.contains("tar")) { //if its local see if its a tarball or if its just fasta and gtf + """ + mkdir $ref_path + tar xzf $ref_data --strip-components=1 -C $ref_path + """ + } else { + ref_data_path = file(ref_data) + if(ref_data_path.exists()) { + """ + mkdir $ref_path + cp -a $ref_data/. $ref_path + """ + } else { + """ + mkdir $ref_path + """ + } + + } +} + +/* +* Process sets up gtf and fasta data based on the provided input in ref_sheet; +* if it is not a link, standardizes it to a absolute path for future use +*/ + +process standardize_files { + tag "standardize_files:$reference" + + input: + tuple val(reference), path(ref_path), val(fasta), val(gtf) + output: + tuple val(reference), path(ref_path), val(fasta), val(gtf), + emit: standardized_files_data + script: + if(fasta.length () > 3 && !fasta.substring(0,4).equals("http")) { //fasta is not a url, and is a file + if(!fasta.substring(0,1).equals("/")) { + fasta = "/" + "$fasta" + } + ref_fasta = file(ref_path.toRealPath() + "$fasta") //fasta is within given reference path + rel_fasta = file("${projectDir}${fasta}") //fasta is relative to project directory + abs_fasta = file("$fasta") //fasta is absolute path + if (ref_fasta.exists()) { //fasta exisits within given reference path + fasta = ref_fasta.toRealPath() + } else if (rel_fasta.exists()) { //fasta exists relative to project directory + fasta = rel_fasta.toRealPath() + } else if (abs_fasta.exists()) { + //fasta is an absolute path + } + } + if(gtf.length () > 3 && !gtf.substring(0,4).equals("http")) { + if(!gtf.substring(0,1).equals("/")) { + gtf = "/" + "$gtf" + } + ref_gtf = file(ref_path.toRealPath() + "$gtf") + rel_gtf = file("${projectDir}${gtf}") + abs_gtf = file("$gtf") + if (ref_gtf.exists()) { //gtf exisits within given reference path + gtf = ref_gtf.toRealPath() + } else if (rel_gtf.exists()) { //gtf exists relative to project directory + gtf = rel_gtf.toRealPath() + } else if (abs_gtf.exists()) { + //gtf is an absolute path + } + } + """ + + """ + +} + +/* +* Downloads, unzips, or moves provided fasta file in ref_sheet to +* correct location to be used in splici generation +*/ +process standard_fasta { + tag "standard_fasta:$reference" + + input: + tuple val(reference), path(ref_path), val(fasta), val(gtf) + output: + tuple val(reference), path(ref_path), val(fasta), val(gtf), + emit: processed_fasta_path + script: + fasta = fasta.toString() + abs_fasta = file("$fasta") + target = ref_path.toRealPath() + "/fasta/genome.fa" + target = target.toString() + if (fasta.length () > 3 && fasta.substring(0,4).equals("http") && fasta.contains(".tar")) { //fasta is remote tarball + //download and untar + """ + mkdir -p $ref_path/fasta/ + wget -qO- $fasta | tar xzf - --strip-components=1 -C $ref_path/fasta/genome.fa + """ + } else if (fasta.length () > 3 && fasta.substring(0,4).equals("http") && fasta.contains(".gz")) { //fasta is remote gzip + //download and unzip + """ + mkdir -p $ref_path/fasta/ + wget -qO- $fasta | gunzip -c > $ref_path/fasta/genome.fa + """ + } else if (fasta.length () > 3 && fasta.substring(0,4).equals("http")) { //fasta is remote + //download and move + """ + mkdir -p $ref_path/fasta/ + wget -qP $fasta $ref_path/fasta/genome.fa + """ + } else if (abs_fasta.exists()) { //if the path given is an absolute path to a file + if (fasta.contains(".tar")) { //tarball + //untar + """ + mkdir -p $ref_path/fasta/ + tar -xzf $fasta --strip-components=1 -C $ref_path/fasta/genome.fa + """ + } else if (fasta.contains(".gz")) { //gzip + //gunzip + """ + mkdir -p $ref_path/fasta/ + gunzip $fasta -c > $ref_path/fasta/genome.fa + """ + } else if(!fasta.equals(target)){ //.fa and its not already where it needs to be + //move file to location exisiting + """ + mkdir -p $ref_path/fasta + cp $fasta $target + """ + } else { //file exactly where it needs to be + """ + # this means something is wrong with input + """ + } + } +} + +/* +* Downloads, unzips, or moves provided gtf file in ref_sheet to +* correct location to be used in splici generation +*/ +process standard_gtf { + tag "standard_gtf:$reference" + + input: + tuple val(reference), path(ref_path), val(fasta), val(gtf) + output: + tuple val(reference), path(ref_path), val(fasta), val(gtf), + emit: processed_gtf_path + script: + gtf = gtf.toString() + abs_gtf = file("$gtf") + target = ref_path.toRealPath() + "/genes/genes.gtf" + target = target.toString() + if (gtf.length() > 3 && gtf.substring(0,4).equals("http") && gtf.contains(".tar")) { //gtf is remote tarball + //download and untar + """ + mkdir -p $ref_path/genes/ + wget -qO- $gtf | tar xzf - --strip-components=1 -C $ref_path/genes/genes.gtf + """ + } else if (gtf.length() > 3 && gtf.substring(0,4).equals("http") && gtf.contains(".gz")) { //gtf is remote gzip + //download and unzip + """ + mkdir -p $ref_path/genes/ + wget -qO- $gtf | gunzip -c > $ref_path/genes/genes.gtf + """ + } else if (gtf.length() > 3 && gtf.substring(0,4).equals("http")) { //gtf is remote + //download and move + """ + mkdir -p $ref_path/genes + wget -qP $gtf $ref_path/genes/genes.gtf + """ + } else if (abs_gtf.exists()) { //if the path given is an absolute path to a file + if (gtf.contains(".tar")) { //tarball + //untar + """ + mkdir -p $ref_path/genes/ + tar -xzf $gtf --strip-components=1 -C $ref_path/genes/genes.gtf + """ + } else if (gtf.contains(".gz")) { //gzip + //gunzip + """ + mkdir -p $ref_path/genes/ + gunzip $gtf -c > $ref_path/genes/genes.gtf + """ + } else if(!gtf.equals(target)){ //.gtf and its not already where it needs to be + //move file to location exisiting + """ + mkdir -p $ref_path/genes + cp $gtf $ref_path/genes/genes.gtf + """ + } else { //file exactly where it needs to be + """ + + """ + } + } else { + """ + # this means something is wrong with input + """ + } +} + +process prep_commands { + tag "prep_commands:${reference}" + + input: + tuple val(reference), path(ref_path), val(fasta), val(gtf) + output: + tuple val(reference), path(ref_path), val(fasta), val(gtf), val(pyroe_command_args), val(file_name) + script: + pyroe_command_args = "" + file_name = "splici" + if (!params.pyroe.filename_pref.equals("")) { + file_name = params.pyroe.filename_pref + pyroe_command_args += " --filename-prefix $params.pyroe.filename_pref" + } + if (!params.pyroe.bt_path.equals("")) { + pyroe_command_args += " --bt-path $params.pyroe.bt_path" + } + if (params.pyroe.dedup_seqs.equalsIgnoreCase("True") || params.pyroe.dedup_seqs.equalsIgnoreCase("T")) { + pyroe_command_args += " --dedup-seqs" + } + if (params.pyroe.no_flanking_merge.equalsIgnoreCase("True") || params.pyroe.no_flanking_merge.equalsIgnoreCase("T")) { + pyroe_command_args += " --no-flanking-merge" + } + """ + + """ +} + +/* +* based on the provided and processed reference sheet, and make splici for them +* NOTE: +* 1. require a tsv named ref_sheet.tsv in the ${bench_dir}/input_files +* 2. any combination of local and remote, zipped/unzipped should be accepted +*/ +process get_splici { + tag "get_splici:${reference}" + // conda "bioconda::bedtools bioconda::pyroe" + + input: + tuple val(reference), path(ref_path), path(fasta), path(gtf), val(args), val(file_name) + + output: + tuple val(reference), + path("splici_$reference/${file_name}_fl${params.pyroe.read_len - params.pyroe.trim_length}.fa"), + path("splici_$reference/${file_name}_fl${params.pyroe.read_len - params.pyroe.trim_length}_t2g_3col.tsv"), + emit: splici + + script: + """ + pyroe make-splici $ref_path/fasta/genome.fa $ref_path/genes/genes.gtf ${params.pyroe.read_len} splici_$reference${args} + rm -rf ${ref_path}/ + """ + stub: + """ + mkdir reference_$reference + mkdir reference_$reference/genes && touch reference_$reference/genes/genes.gtf + mkdir reference_$reference/fasta && touch reference_$reference/fasta/genome.fa + mkdir splici_$reference + touch splici_$reference/${file_name}${params.pyroe.read_len - params.pyroe.trim_length}.fa + touch splici_$reference/${file_name}${params.pyroe.read_len - params.pyroe.trim_length}_t2g_3col.tsv + rm -rf reference_$reference + """ +} + + /* * This workflow take a ref_sheet.tsv and a pl_sheet.tsv file * in the ${bench_dir}/input_files @@ -134,23 +377,31 @@ workflow preprocess { pl_sheet = Channel .fromPath(params.input_sheets.permitlist) .splitCsv(header:true, sep:"\t", strip: true) - .map{ row-> tuple(row.reference, + .map{ row-> tuple(row.chemistry, row.link) } get_permitlist(pl_sheet) - + ref_sheet = Channel .fromPath(params.input_sheets.reference) .splitCsv(header:true, sep:"\t", strip: true) .map{ row-> tuple(row.reference, - row.link) + row.ref_data, row.fasta, row.gtf) } - get_splici(ref_sheet) + process_ref_data(ref_sheet) + standardize_files(process_ref_data.out) + + standard_fasta(standardize_files.out) + standard_gtf(standard_fasta.out) + //prepare commands for pyroe based on user input in config sheet + prep_commands(standard_gtf.out) + + get_splici(prep_commands.out) + salmon_index(get_splici.out) chem_pl = get_permitlist.out.chem_pl ref_t2g_index = salmon_index.out.ref_t2g_index - emit: chem_pl ref_t2g_index diff --git a/modules/salmon_map.nf b/modules/salmon_map.nf index 80a2e48..7e073bf 100644 --- a/modules/salmon_map.nf +++ b/modules/salmon_map.nf @@ -3,14 +3,14 @@ workflow salmon_map { samp main: - download_fastq(samp) | salmon_map_rad + standardize_salmon_files(samp) | download_fastq | salmon_map_rad emit: salmon_map_rad.out.chemistry salmon_map_rad.out.reference salmon_map_rad.out.dataset_name salmon_map_rad.out.dataset_url - salmon_map_rad.out.fastq_url + salmon_map_rad.out.fastq_file salmon_map_rad.out.fastq_MD5sum salmon_map_rad.out.delete_fastq salmon_map_rad.out.feature_barcode_csv_url @@ -23,23 +23,16 @@ workflow salmon_map { } -/* -* This process takes an input sample -* as defined by the columns in the sample table csv -* and runs `alevin` on it to produce a RAD file. -* Currently, sketch mode is always used. -*/ - -process download_fastq { - tag "download_fastq:${fastq_MD5sum}" - label 'single_threads' - +process standardize_salmon_files { + tag "standardize_salmon_files:${dataset_name}" + errorStrategy 'terminate' + input: tuple val(chemistry), val(reference), val(dataset_name), val(dataset_url), - val(fastq_url), + val(fastq_file), val(fastq_MD5sum), val(delete_fastq), val(feature_barcode_csv_url), @@ -47,13 +40,12 @@ process download_fastq { path(index_dir_path), path(pl_path), path(t2g_path) - output: val chemistry, emit: chemistry val reference, emit: reference val dataset_name, emit: dataset_name val dataset_url, emit: dataset_url - val fastq_url, emit:fastq_url + val fastq_file, emit:fastq_file val fastq_MD5sum, emit: fastq_MD5sum val delete_fastq, emit: delete_fastq val feature_barcode_csv_url, emit: feature_barcode_csv_url @@ -61,28 +53,122 @@ process download_fastq { path index_dir_path, emit: index_dir_path path pl_path, emit: pl_path path t2g_path, emit: t2g_path - path "${fastq_MD5sum}_fastqs", emit: fastq_dir_path - """ - num_attempt=1 - wget ${fastq_url} -P ${fastq_MD5sum}_cfastqs - while [ "\$(md5sum ${fastq_MD5sum}_cfastqs/\$(ls ${fastq_MD5sum}_cfastqs) | cut -d' ' -f1)" != "${fastq_MD5sum}" ] - do - if [[ \$num_attempt -gt 3 ]] - then - echo "Three attempts were made to fetch ${fastq_url.toString().lastIndexOf('/').with {fastq_url.toString().substring(it+1, fastq_url.toString().length())}}, but the MD5sum (\$(md5sum ${fastq_MD5sum}_cfastqs/\$(ls ${fastq_MD5sum}_cfastqs) | cut -d' ' -f1)) of the downloaded file \$(ls ${fastq_MD5sum}_cfastqs) didn't match the expected MD5sum ($fastq_MD5sum). Processing of this dataset will not proceed. Please check the MD5sum and internet connectivity." - exit 1 - fi - let "num_attempt+=1" - rm -rf ${fastq_MD5sum}_cfastqs - wget ${fastq_url} -P ${fastq_MD5sum}_cfastqs - done - mkdir -p ${fastq_MD5sum}_fastqs - tar xf ${fastq_MD5sum}_cfastqs/\$(ls ${fastq_MD5sum}_cfastqs) --strip-components=1 -C ${fastq_MD5sum}_fastqs - rm -rf ${fastq_MD5sum}_cfastqs - """ + script: + //list of valid chem options, including chromiumv2 and v3 in case user types full name over v2 or v3 + valid_chems = ["dropseq", "v2", "v3", "chromiumV3", "chromium", "gemcode", + "citeseq", "celseq", "celseq2", "splitseqV1", "splitseqV2", + "quartzseq2", "sciseq3"] + if(!valid_chems.contains(chemistry)) { + error "Invalid chemistry option: " + chemistry + } + if(fastq_file.length () > 3 && !fastq_file.substring(0,4).equals("http")) { //fastq is not a url, and is a file + if(!fastq_file.substring(0,1).equals("/")) { + fastq_file = "/" + "$fastq_file" + } + rel_fastq = file("${projectDir}${fastq_file}") //fastq is relative to project directory + abs_fastq = file("$fastq_file") //fastq is absolute path + if (rel_fastq.exists()) { //fastq exists relative to project directory + fastq_file = rel_fastq.toRealPath() + } else if (!abs_fastq.exists()) { + error "Could not find referenced fastq file." + } + } + //todo csvs for multiplex and feature barcodes? + """ + + """ + +} + +/* +* This process takes an input sample +* as defined by the columns in the sample table csv +* and runs `alevin` on it to produce a RAD file. +* Currently, sketch mode is always used. +*/ + +process download_fastq { + tag "download_fastq:${fastq_MD5sum}" + label 'single_threads' + input: + val chemistry + val reference + val dataset_name + val dataset_url + val fastq_file + val fastq_MD5sum + val delete_fastq + val feature_barcode_csv_url + val multiplexing_library_csv_url + path index_dir_path + path pl_path + path t2g_path + output: + val chemistry, emit: chemistry + val reference, emit: reference + val dataset_name, emit: dataset_name + val dataset_url, emit: dataset_url + val fastq_file, emit:fastq_file + val fastq_MD5sum, emit: fastq_MD5sum + val delete_fastq, emit: delete_fastq + val feature_barcode_csv_url, emit: feature_barcode_csv_url + val multiplexing_library_csv_url, emit: multiplexing_library_csv_url + path index_dir_path, emit: index_dir_path + path pl_path, emit: pl_path + path t2g_path, emit: t2g_path + path "${fastq_MD5sum}_fastqs", emit: fastq_dir_path + + script: + fastq_file = fastq_file.toString() + abs_fastq = file("$fastq_file") + if(fastq_file.length() > 3 && fastq_file.substring(0,4).equals("http")) { //fastq is a URL + """ + num_attempt=1 + wget ${fastq_file} -P ${fastq_MD5sum}_cfastqs + while [ "\$(md5sum ${fastq_MD5sum}_cfastqs/\$(ls ${fastq_MD5sum}_cfastqs) | cut -d' ' -f1)" != "${fastq_MD5sum}" ] + do + if [[ \$num_attempt -gt 3 ]] + then + echo "Three attempts were made to fetch ${fastq_file.toString().lastIndexOf('/').with {fastq_file.toString().substring(it+1, fastq_file.toString().length())}}, but the MD5sum (\$(md5sum ${fastq_MD5sum}_cfastqs/\$(ls ${fastq_MD5sum}_cfastqs) | cut -d' ' -f1)) of the downloaded file \$(ls ${fastq_MD5sum}_cfastqs) didn't match the expected MD5sum ($fastq_MD5sum). Processing of this dataset will not proceed. Please check the MD5sum and internet connectivity." + exit 1 + fi + let "num_attempt+=1" + rm -rf ${fastq_MD5sum}_cfastqs + wget ${fastq_file} -P ${fastq_MD5sum}_cfastqs + done + mkdir -p ${fastq_MD5sum}_fastqs + tar xf ${fastq_MD5sum}_cfastqs/\$(ls ${fastq_MD5sum}_cfastqs) --strip-components=1 -C ${fastq_MD5sum}_fastqs + rm -rf ${fastq_MD5sum}_cfastqs + """ + } else if(abs_fastq.exists()) { //check that the fastq file exists locally + if (fastq_MD5sum.length() != 32) { + fastq_MD5sum = fastq_file.md5() + } + if(fastq_file.length () > 3 && fastq_file.contains(".tar") && fastq_file.contains(".gz")) { + """ + mkdir ${fastq_MD5sum}_fastqs + tar -xzf ${fastq_file} --strip-components=1 -C ${fastq_MD5sum}_fastqs + """ + } else if(fastq_file.length () > 3 && fastq_file.contains(".tar")) { + """ + mkdir ${fastq_MD5sum}_fastqs + tar -xf ${fastq_file} --strip-components=1 -C ${fastq_MD5sum}_fastqs + """ + } else if (fastq_file.length () > 3 && fastq_file.contains(".gz")) { + """ + mkdir ${fastq_MD5sum}_fastqs + gunzip ${fastq_file} -c > ${fastq_MD5sum}_fastqs + """ + } else { + """ + mkdir ${fastq_MD5sum}_fastqs + cp -a ${fastq_file} ${fastq_MD5sum}_fastqs + """ + } + } } process salmon_map_rad { @@ -95,7 +181,7 @@ process salmon_map_rad { val reference val dataset_name val dataset_url - val fastq_url + val fastq_file val fastq_MD5sum val delete_fastq val feature_barcode_csv_url @@ -110,7 +196,7 @@ process salmon_map_rad { val reference, emit: reference val dataset_name, emit: dataset_name val dataset_url, emit: dataset_url - val fastq_url, emit:fastq_url + val fastq_file, emit:fastq_file val fastq_MD5sum, emit: fastq_MD5sum val delete_fastq, emit: delete_fastq val feature_barcode_csv_url, emit: feature_barcode_csv_url diff --git a/nextflow.config b/nextflow.config index 0adc379..c213b4e 100755 --- a/nextflow.config +++ b/nextflow.config @@ -13,7 +13,6 @@ params { work_dir = "${projectDir}/nf_pipeline" output_dir = "${projectDir}/nf_pipeline/output" // delete_fastq = 1 - read_len = 90 n_threads = 16 input_sheets { @@ -23,6 +22,19 @@ params { reference = "${projectDir}/input_files/ref_sheet.tsv" sample = "${projectDir}/input_files/sample_sheet.tsv" } + pyroe { + read_len = 90 + trim_length = 5 + + filename_pref = "new_file_name" + bt_path = "" + + //the following commands can be left as "", put True or T to run pyroe with that option + + no_bt = "False" + dedup_seqs = "False" + no_flanking_merge = "False" + } } process {