Skip to content

Commit

Permalink
refactor: Split after seqkit
Browse files Browse the repository at this point in the history
Just no reason to split it sooner
  • Loading branch information
edmundmiller committed Jul 29, 2024
1 parent c300aa3 commit 4fc68dd
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 15 deletions.
13 changes: 6 additions & 7 deletions main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,16 @@ include { BEDTOOLS_GETFASTA } from './modules/nf-core/bedtools/getfasta'
include { PRIMER3 } from './subworkflows/primer3'

workflow {
ch_fasta = channel.fromPath(params.fasta)
// Pull raw sequences in the bed files from the reference genome
sequences = BEDTOOLS_GETFASTA (
BEDTOOLS_GETFASTA (
ch_input,
params.fasta
).fasta
.splitFasta(file: true)
.dump()
ch_fasta.first()
)

// Run primer3 on the sequences
PRIMER3 (
sequences,
Channel.fromPath(params.fasta),
BEDTOOLS_GETFASTA.out.fasta,
ch_fasta.first(),
)
}
14 changes: 7 additions & 7 deletions modules/seqkit_fetch_target/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,22 @@ process seqkit_fetch_target {
path fasta

output:
path "${seq}_target.fa" , emit:fasta
path "${seq}_target.gtf" , emit:gtf
path "*_targets.fa" , emit:fasta
path "*_targets.gtf" , emit:gtf

shell:
def prefix = task.ext.prefix ?: "${meta.id}"
'''
cat !{fasta} | seqkit locate -i --gtf -f !{seq_fasta} > !{meta.id}_target.gtf
cat !{fasta} | seqkit locate -i --gtf -f !{seq_fasta} > !{meta.id}_targets.gtf
seqkit subseq --gtf !{meta.id}_target.gtf -u 50000 -d 50000 !{fasta} > !{meta.id}_target.fa
seqkit subseq --gtf !{meta.id}_targets.gtf -u 50000 -d 50000 !{fasta} > !{meta.id}_targets.fa
if [[ ! -s !{meta.id}_target.gtf ]]
if [[ ! -s !{meta.id}_targets.gtf ]]
then
exit 7
fi
seqkit stat !{meta.id}_target.gtf
seqkit stat !{meta.id}_target.fa
seqkit stat !{meta.id}_targets.gtf
seqkit stat !{meta.id}_targets.fa
'''
}
4 changes: 3 additions & 1 deletion subworkflows/primer3/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@ include { primer3_results2fasta } from "../../modules/primer3_results2fasta/"

workflow PRIMER3 {
take:
seq_fasta // [id, sequence]
seq_fasta // [meta, fasta]
ref // fasta

main:
seqkit_fetch_target(seq_fasta,ref)
target = seqkit_fetch_target.out.fasta
.splitFasta(file: true)


primer3_conf(target,ref)
primer3_index(ref)
Expand Down

0 comments on commit 4fc68dd

Please sign in to comment.