diff --git a/main.nf b/main.nf index 9d973c3..39af2e7 100644 --- a/main.nf +++ b/main.nf @@ -4,8 +4,8 @@ include { validateParameters; paramsHelp; paramsSummaryLog; samplesheetToList } // Print help message, supply typical command line usage for the pipeline if (params.help) { - log.info paramsHelp("nextflow run my_pipeline --input input_file.csv") - exit 0 + log.info paramsHelp("nextflow run my_pipeline --input input_file.csv") + exit 0 } // Validate input parameters @@ -18,14 +18,22 @@ log.info paramsSummaryLog(workflow) ch_input = Channel.fromList(samplesheetToList(params.input, "assets/schema_input.json")) +include { BEDTOOLS_GETFASTA } from './modules/nf-core/bedtools/getfasta' + include { PRIMER3 } from './subworkflows/primer3' workflow { - // Read in bed file(s) - // Pull raw sequences in the bed files from the reference genome - // Run primer3 on the sequences - PRIMER3 ( - Channel.of(params.targetseq), - Channel.fromPath(params.fasta), - ) + // Pull raw sequences in the bed files from the reference genome + sequences = BEDTOOLS_GETFASTA ( + ch_input, + params.fasta + ).fasta + .splitFasta( record: [id: true, seqString: true] ) + .dump() + + // Run primer3 on the sequences + PRIMER3 ( + sequences, + Channel.fromPath(params.fasta), + ) } diff --git a/modules/seqkit_fetch_target/main.nf b/modules/seqkit_fetch_target/main.nf index dcbdcdd..7ee006c 100644 --- a/modules/seqkit_fetch_target/main.nf +++ b/modules/seqkit_fetch_target/main.nf @@ -2,7 +2,7 @@ process seqkit_fetch_target { conda "seqkit" input: - val seq + tuple val(id), val(seq) path fasta output: @@ -11,20 +11,20 @@ process seqkit_fetch_target { shell: ''' - echo ">seq + echo ">!{id} !{seq} " > seq.fa - seqkit locate -i --gtf -p "!{seq}" !{fasta} > !{seq}_target.gtf + seqkit locate -i --gtf -p "!{seq}" !{fasta} > !{id}_target.gtf - seqkit subseq --gtf !{seq}_target.gtf -u 50000 -d 50000 !{fasta} > !{seq}_target.fa + seqkit subseq --gtf !{seq}_target.gtf -u 50000 -d 50000 !{fasta} > !{id}_target.fa - if [[ ! -s !{seq}_target.gtf ]] + if [[ ! -s !{id}_target.gtf ]] then exit 7 fi - seqkit stat !{seq}_target.gtf - seqkit stat !{seq}_target.fa + seqkit stat !{id}_target.gtf + seqkit stat !{id}_target.fa ''' } diff --git a/subworkflows/primer3/main.nf b/subworkflows/primer3/main.nf index 1348a7b..60337e3 100644 --- a/subworkflows/primer3/main.nf +++ b/subworkflows/primer3/main.nf @@ -6,11 +6,10 @@ include { primer3_results2fasta } from "../../modules/primer3_results2fasta/" workflow PRIMER3 { take: - seq // = Channel.of(params.targetseq) - ref // = Channel.fromPath(params.fasta) + seq // [id, sequence] + ref // fasta main: - seq.view() seqkit_fetch_target(seq,ref) target = seqkit_fetch_target.out.fasta