Commit 5abaf10d authored by amunoz's avatar amunoz
Browse files

Merge

parents 3d20b78c 8d50ef42
#!/usr/bin/env nextflow
nextflow.enable.dsl = 2
/*
......@@ -75,7 +77,6 @@ params.read_group = "@RG\\tID:SRR709972\\tSM:NA19206\\tPL:ILLUMINA\\tCN:CBRA\\tL
* Include subworkflows
*/
include { SUB_BWA_INDEX } from './subworkflows/bwa_index'
include { SUB_BUNDLE_FILES } from './subworkflows/bundle_files'
include { SUB_TRIMMED_FASTQ } from './subworkflows/trimmed_fastq'
include { SUB_BWA_MEM } from './subworkflows/bwa_mem'
include { SUB_SAMTOOLS_VIEW_SAM2BAM } from './subworkflows/samtools_view_sam2bam'
......@@ -91,19 +92,18 @@ include { SUB_CNV_CODEX } from './subworkflows/cnv_codex'
include { SUB_FINAL_FILTERING } from './subworkflows/final_filtering'
workflow{
indexFiles = []
if( params.generate_bwa_indexes )
indexFiles = SUB_BWA_INDEX(reference_fasta)
else
indexFiles = SUB_BUNDLE_FILES(reference_fasta)
if( params.generate_bwa_indexes ) {
output_bwa_index = SUB_BWA_INDEX(reference_fasta)
indexFiles = output_bwa_index.indexs.combine(output_bwa_index.fai).collect()
}
else {
indexChr = Channel.fromPath(params.reference_fasta_indexs)
indexFiles = indexChr.collect()
}
SUB_TRIMMED_FASTQ(fastq)
indexReads = SUB_TRIMMED_FASTQ.out.reads.combine(indexFiles)
SUB_BWA_MEM(
indexReads
)
SUB_BWA_MEM(SUB_TRIMMED_FASTQ.out.reads, indexFiles)
SUB_SAMTOOLS_VIEW_SAM2BAM(
SUB_BWA_MEM.out.output_paired,
......
process BUNDLE_INDEXFILES{
tag "bundle indexfiles"
input:
path reference_amb
path reference_ann
path reference_bwt
path reference_pac
path reference_sa
output:
tuple path(reference_amb),
path(reference_ann),
path(reference_bwt),
path(reference_pac),
path(reference_sa)
script:
"""
"""
}
\ No newline at end of file
process BUNDLE_SECONDARYFILES{
tag "bundle_secondaryfiles"
input:
path index_files
path reference_fai
path reference_fasta
output:
tuple path(index_files), path(reference_fai), path(reference_fasta)
script:
"""
"""
}
\ No newline at end of file
......@@ -6,19 +6,16 @@ process BWA_INDEX {
path input
output:
tuple path( "${input.simpleName}.fa" ),
path( "*.{amb,ann,bwt,pac,sa}" )
path "${input.simpleName}.fa", emit: reference_fasta
path "*.{amb,ann,bwt,pac,sa}", emit: indexs
script:
def algoType = params.algoType ? "-a $params.algoType" : ""
"""
ext=${input.extension}
if ["\$ext" == "gz"];then
if [ "${input.extension}" == "gz" ];then
gunzip -c $input >> ${input.simpleName}.fa
bwa index $algoType ${input.simpleName}.fa
else
bwa index $algoType $input
fi
bwa index $algoType ${input.simpleName}.fa
"""
}
}
\ No newline at end of file
process BWA_MEM_PAIRED {
tag "bwa mem paired"
tag { "bwa-mem paired" }
container 'quay.io/biocontainers/bwa:0.7.17--h84994c4_5'
input:
val srr_id
path paired1
path paired2
path reference_genome
path index
path indexs
output:
path "*.R1R2.sam"
......@@ -16,6 +15,12 @@ process BWA_MEM_PAIRED {
def threadsArgument = params.threads_bwa_mem ? "-t $params.threads_bwa_mem" : ""
def read_group = params.read_group ? "-R $read_group" : ""
"""
bwa mem $threadsArgument $read_group $reference_genome $paired1 $paired2 >> ${srr_id}.R1R2.sam
INDEX=`find -L ./ -name "*.amb" | sed 's/.amb//'`
bwa mem \\
$threadsArgument \\
\$INDEX \\
$paired1 $paired2 \\
$read_group >> ${srr_id}.R1R2.sam
"""
}
}
process BWA_MEM_UNPAIRED {
tag "bwa mem unpaired"
tag { "bwa-mem unpaired" }
container 'quay.io/biocontainers/bwa:0.7.17--h84994c4_5'
input:
val srr_id
path unpaired
path reference_genome
path index
path indexs
output:
path "*.sam", emit: output_unpaired
path "*.sam"
script:
def threadsArgument = params.threads_bwa_mem ? "-t $params.threads_bwa_mem" : ""
def read_group = params.read_group ? "-R $read_group" : ""
"""
INDEX=`find -L ./ -name "*.amb" | sed 's/.amb//'`
nameReplaced=\$(echo ${unpaired.simpleName} | sed 's/_/.R/g')
bwa mem $threadsArgument $read_group $reference_genome $unpaired >> \$nameReplaced.sam
bwa mem \\
$threadsArgument \\
\$INDEX \\
$unpaired \\
$read_group >> \$nameReplaced.sam
"""
}
......@@ -15,11 +15,15 @@ process FASTP {
val length_required
output:
tuple val(srr_id),
path("${fastq1.simpleName}.trimmed.fastq"),
path("${fastq2.simpleName}.trimmed.fastq"), emit: paired_fastq
tuple val(srr_id),
path("${fastq1.simpleName}.trimmed.fastq"),
path("${fastq2.simpleName}.trimmed.fastq"),
path("${fastq1.simpleName}.unpaired.trimmed.fastq"),
path("${fastq2.simpleName}.unpaired.trimmed.fastq")
path("${fastq2.simpleName}.unpaired.trimmed.fastq"), emit: reads
path "*.html"
path "*.json"
......
process SAMTOOLS_FAIDX {
tag "samtools faidx"
tag { "samtools faidx" }
container 'quay.io/biocontainers/samtools:1.5--2'
input:
tuple path(reference_genome), path(index_files)
path reference_genome
output:
tuple path(reference_genome), path(index_files), path("*.fai"), emit: output_samtools_faidx
path "*.fai", emit: fai
script:
script:
"""
samtools faidx $reference_genome
"""
......
......@@ -10,16 +10,9 @@
params {
//Files
fastq = [ "data/fastq_simple/SRR081254_{1,2}.fastq.gz", "data/fastq_simple/SRR078847_{1,2}.fastq.gz" ]
generate_bwa_indexes = false
reference_amb = "data/hs37d5.fa.amb"
reference_ann = "data/hs37d5.fa.ann"
reference_bwt = "data/hs37d5.fa.bwt"
reference_pac = "data/hs37d5.fa.pac"
reference_sa = "data/hs37d5.fa.sa"
reference_fai = "data/hs37d5.fa.fai"
generate_bwa_indexes = false
reference_fasta = "data/hs37d5.fa"
reference_fasta_indexs = [ "data/hs37d5.fa.{amb,ann,bwt,pac,sa,fai}" ]
samples = "data/samples_test.txt"
bed = "data/gencode.v19.genes.v7_model.patched_contigs.gtf.bed.*"
blacklist = "data/hg19-blacklist.v2.num.bed.gz"
......@@ -37,14 +30,12 @@ params {
merge_all_script = "templates/merge_all.sh"
//params
threads_fastqc = 2
threads_fastp = 12
//threads_fastqc = 2
//threads_fastp = 12
//threads_bwa_mem = 24
threads_bwa_mem = 1
threads_samtools = 8
threads_gridss = 8
//threads_bwa_mem = 1
//threads_samtools = 8
//threads_gridss = 8
cut_right = true
cut_right_window_size = 5
cut_right_mean_quality = 24
......@@ -93,8 +84,8 @@ profiles {
}
manifest {
name = 'StructuralVariants Workflow'
author = 'Adrián Muñoz-Civico, Laura Rodríguez-Navas'
name = 'CNV_pipeline'
author = 'Adrián Muñoz-Civico, Laura Rodríguez-Navas, Daniel López-López'
homePage = 'https://gitlab.bsc.es/lrodrig1/structuralvariants_poc/-/tree/master/structuralvariants/nextflow'
defaultBranch = 'master'
mainScript = 'main.nf'
......
/*
* Includes for bundle_files
*/
include {
BUNDLE_SECONDARYFILES
} from "../modules/bundle_secondaryfiles"
include {
BUNDLE_INDEXFILES
} from "../modules/bundle_indexfiles"
/*
* Subworkflow bundle_files
*/
workflow SUB_BUNDLE_FILES {
take:
reference_fasta
main:
BUNDLE_INDEXFILES(params.reference_amb,
params.reference_ann,
params.reference_bwt,
params.reference_pac,
params.reference_sa,
)
BUNDLE_SECONDARYFILES(BUNDLE_INDEXFILES.out,
params.reference_fai,
reference_fasta)
emit:
output = BUNDLE_SECONDARYFILES.out
}
\ No newline at end of file
/*
* Includes for bwa_index
*/
include {
SAMTOOLS_FAIDX
} from "../modules/samtools_faidx"
include {
BWA_INDEX
} from "../modules/bwa_index"
include {
SAMTOOLS_FAIDX
} from "../modules/samtools_faidx"
/*
* Subworkflow bwa_index
......@@ -17,9 +16,11 @@ workflow SUB_BWA_INDEX {
reference_fasta
main:
// TODO gunzip
SAMTOOLS_FAIDX(reference_fasta)
BWA_INDEX(reference_fasta)
SAMTOOLS_FAIDX(reference_fasta, BWA_INDEX.out)
emit:
output = SAMTOOLS_FAIDX.out
}
\ No newline at end of file
fai = SAMTOOLS_FAIDX.out
indexs = BWA_INDEX.out
}
/*
* Include for bwa_mem
* Include for bwa_mem
*/
include {
BWA_MEM_PAIRED as BWA_MEM_READS
......@@ -17,23 +17,22 @@ include {
workflow SUB_BWA_MEM {
take:
reads
indexFiles
main:
srr_id = reads.map{it[0]}
paired1 = reads.map{it[1]}
paired2 = reads.map{it[2]}
unpaired1 = reads.map{it[3]}
unpaired2 = reads.map{it[4]}
reference_genome = reads.map{it[5]}
index = reads.map{it[6]}
BWA_MEM_READS(srr_id, paired1, paired2, reference_genome, index)
BWA_MEM_UNPAIRED1(srr_id, unpaired1, reference_genome, index)
BWA_MEM_UNPAIRED2(srr_id, unpaired2, reference_genome, index)
BWA_MEM_READS(srr_id, paired1, paired2, indexFiles)
BWA_MEM_UNPAIRED1(srr_id, unpaired1, indexFiles)
BWA_MEM_UNPAIRED2(srr_id, unpaired2, indexFiles)
emit:
output_paired = BWA_MEM_READS.out
output_unpairedR1 = BWA_MEM_UNPAIRED1.out
output_unpairedR2 = BWA_MEM_UNPAIRED2.out
}
\ No newline at end of file
}
......@@ -18,7 +18,7 @@ include {
workflow SUB_TRIMMED_FASTQ {
take:
fastq
main:
FASTQC_RAW_DATA(fastq,
params.threads_fastqc)
......@@ -35,6 +35,4 @@ workflow SUB_TRIMMED_FASTQ {
emit:
reads = FASTP.out.reads
html_report = FASTP.out.html_report
json_report = FASTP.out.json_report
}
\ No newline at end of file
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment