Skip to content

Commit

Permalink
feat: Use getfasta to create fastas
Browse files Browse the repository at this point in the history
  • Loading branch information
edmundmiller committed Jul 29, 2024
1 parent e71c2f9 commit 87e5567
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 19 deletions.
26 changes: 17 additions & 9 deletions main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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),
)
}
14 changes: 7 additions & 7 deletions modules/seqkit_fetch_target/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ process seqkit_fetch_target {
conda "seqkit"

input:
val seq
tuple val(id), val(seq)
path fasta

output:
Expand All @@ -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
'''
}
5 changes: 2 additions & 3 deletions subworkflows/primer3/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 87e5567

Please sign in to comment.