Skip to content
Snippets Groups Projects
Verified Commit 67c4ff01 authored by Laurent Modolo's avatar Laurent Modolo
Browse files

SAMtools: update nf structure

parent eab4cb6b
No related branches found
No related tags found
No related merge requests found
......@@ -3,15 +3,6 @@ profiles {
docker.temp = 'auto'
docker.enabled = true
process {
$sort_bam {
container = "samtools:1.7"
}
$index_bam {
container = "samtools:1.7"
}
$split_bam {
container = "samtools:1.7"
}
$filter_bam {
container = "samtools:1.7"
}
......@@ -19,15 +10,6 @@ profiles {
}
sge {
process{
$sort_bam {
beforeScript = "module purge; module load SAMtools/1.7"
}
$index_bam {
beforeScript = "module purge; module load SAMtools/1.7"
}
$split_bam {
beforeScript = "module purge; module load SAMtools/1.7"
}
$filter_bam {
beforeScript = "module purge; module load SAMtools/1.7"
}
......
......@@ -7,6 +7,7 @@ log.info "bed file : ${params.bed}"
Channel
.fromPath( params.bam )
.ifEmpty { error "Cannot find any bam files matching: ${params.bam}" }
.map { it -> [(it.baseName =~ /([^\.]*)/)[0][1], it]}
.set { bam_files }
Channel
.fromPath( params.bed )
......@@ -14,18 +15,18 @@ Channel
.set { bed_files }
process filter_bam {
tag "$bam.baseName"
tag "$file_id"
cpus 4
input:
file bam from bam_files
set file_id, file(bam) from bam_files
file bed from bed_files
output:
file "*_filtered.bam*" into filtered_bam_files
set file_id, "*_filtered.bam*" into filtered_bam_files
script:
"""
samtools view -@ ${task.cpus} -hb ${bam} -L ${bed} > ${bam.baseName}_filtered.bam
samtools view -@ ${task.cpus} -hb ${bam} -L ${bed} > ${file_id}_filtered.bam
"""
}
......
profiles {
docker {
docker.temp = 'auto'
docker.enabled = true
process {
$index_bam {
container = "samtools:1.7"
}
}
}
sge {
process{
$index_bam {
beforeScript = "module purge; module load SAMtools/1.7"
}
}
}
}
......@@ -5,14 +5,18 @@ log.info "bams files : ${params.bam}"
Channel
.fromPath( params.bam )
.ifEmpty { error "Cannot find any bam files matching: ${params.bam}" }
.map { it -> [(it.baseName =~ /([^\.]*)/)[0][1], it]}
.set { bam_files }
process index_bam {
tag "$bam.baseName"
tag "$file_id"
input:
file bam from bam_files
set file_id, file(bam) from bam_files
output:
file "*bam*" into indexed_bam_file
set file_id, "*.bam*" into indexed_bam_file
script:
"""
samtools index ${bam}
......
/*
* SAMtools :
* Imputs : bam files
* Output : bam files
*/
/* bams sorting */
params.bam = "$baseDir/data/bam/*.bam"
log.info "bams files : ${params.bam}"
Channel
.fromPath( params.bam )
.ifEmpty { error "Cannot find any bam files matching: ${params.bam}" }
.set { bam_files }
process sort_bam {
tag "$bam.baseName"
cpus 4
input:
file bam from bam_files
output:
file "*_sorted.bam" into sorted_bam_files
script:
"""
samtools sort -@ ${task.cpus} -O BAM -o ${bam.baseName}_sorted.bam ${bam}
"""
}
/* bams indexing */
params.bam = "$baseDir/data/bam/*.bam"
log.info "bams files : ${params.bam}"
Channel
.fromPath( params.bam )
.ifEmpty { error "Cannot find any bam files matching: ${params.bam}" }
.set { bam_files }
process index_bam {
tag "$bam.baseName"
input:
file bam from bam_files
output:
file "*bam*" into indexed_bam_file
script:
"""
samtools index ${bam}
"""
}
/* bams spliting */
params.bam = "$baseDir/data/bam/*.bam"
log.info "bams files : ${params.bam}"
Channel
.fromPath( params.bam )
.ifEmpty { error "Cannot find any bam files matching: ${params.bam}" }
.set { bam_files }
process split_bam {
tag "$bam.baseName"
cpus 2
input:
file bam from bam_files
output:
file "*_forward.bam*" into forward_bam_files
file "*_reverse.bam*" into reverse_bam_files
script:
"""
samtools view -hb -F 0x10 ${bam} > ${bam}_forward.bam &
samtools view -hb -f 0x10 ${bam} > ${bam}_reverse.bam
"""
}
/* bams filtering */
params.bam = "$baseDir/data/bam/*.bam"
params.bed = "$baseDir/data/bam/*.bed"
log.info "bams files : ${params.bam}"
log.info "bed file : ${params.bed}"
Channel
.fromPath( params.bam )
.ifEmpty { error "Cannot find any bam files matching: ${params.bam}" }
.set { bam_files }
Channel
.fromPath( params.bed )
.ifEmpty { error "Cannot find any bed file matching: ${params.bed}" }
.set { bed_files }
process filter_bam {
tag "$bam.baseName"
cpus 4
input:
file bam from bam_files
file bed from bed_files
output:
file "*_filtered.bam*" into filtered_bam_files
script:
"""
samtools view -@ ${task.cpus} -hb ${bam} -L ${bed} > ${bam.baseName}_filtered.bam
"""
}
profiles {
docker {
docker.temp = 'auto'
docker.enabled = true
process {
$sort_bam {
container = "samtools:1.7"
}
}
}
sge {
process{
$sort_bam {
beforeScript = "module purge; module load SAMtools/1.7"
}
}
}
}
......@@ -5,21 +5,22 @@ log.info "bams files : ${params.bam}"
Channel
.fromPath( params.bam )
.ifEmpty { error "Cannot find any bam files matching: ${params.bam}" }
.map { it -> [(it.baseName =~ /([^\.]*)/)[0][1], it]}
.set { bam_files }
process sort_bam {
tag "$bams.baseName"
tag "$file_id"
cpus 4
input:
file bam from bam_files
set file_id, file(bam) from bam_files
output:
file "*_sorted.bam" into sorted_bam_files
set file_id, "*_sorted.bam" into sorted_bam_files
script:
"""
samtools sort -@ ${task.cpus} -O BAM -o ${bam.baseName}_sorted.bam ${bam}
samtools sort -@ ${task.cpus} -O BAM -o ${file_id}_sorted.bam ${bam}
"""
}
profiles {
docker {
docker.temp = 'auto'
docker.enabled = true
process {
$split_bam {
container = "samtools:1.7"
}
}
}
sge {
process{
$split_bam {
beforeScript = "module purge; module load SAMtools/1.7"
}
}
}
}
......@@ -5,22 +5,23 @@ log.info "bams files : ${params.bam}"
Channel
.fromPath( params.bam )
.ifEmpty { error "Cannot find any bam files matching: ${params.bam}" }
.map { it -> [(it.baseName =~ /([^\.]*)/)[0][1], it]}
.set { bam_files }
process split_bam {
tag "$bam.baseName"
tag "$file_id"
cpus 2
input:
file bam from bam_files
set file_id, file(bam) from bam_files
output:
file "*_forward.bam*" into forward_bam_files
file "*_reverse.bam*" into reverse_bam_files
set file_id, "*_forward.bam*" into forward_bam_files
set file_id, "*_reverse.bam*" into reverse_bam_files
script:
"""
samtools view -hb -F 0x10 ${bam} > ${bam}_forward.bam &
samtools view -hb -f 0x10 ${bam} > ${bam}_reverse.bam
samtools view -hb -F 0x10 ${bam} > ${file_id}_forward.bam &
samtools view -hb -f 0x10 ${bam} > ${file_id}_reverse.bam
"""
}
nextflow src/nf_modules/SAMtools/tests/sort_bams.nf \
-c src/nf_modules/SAMtools/samtools.config \
nextflow src/nf_modules/SAMtools/sort_bams.nf \
-c src/nf_modules/SAMtools/sort_bams.config \
-profile docker \
--bam "data/tiny_dataset/map/tiny_v2.bam"
nextflow src/nf_modules/SAMtools/tests/index_bams.nf \
-c src/nf_modules/SAMtools/samtools.config \
nextflow src/nf_modules/SAMtools/index_bams.nf \
-c src/nf_modules/SAMtools/index_bams.config \
-profile docker \
--bam "data/tiny_dataset/map/tiny_v2.sort.bam"
nextflow src/nf_modules/SAMtools/tests/split_bams.nf \
-c src/nf_modules/SAMtools/samtools.config \
nextflow src/nf_modules/SAMtools/split_bams.nf \
-c src/nf_modules/SAMtools/split_bams.config \
-profile docker \
--bam "data/tiny_dataset/map/tiny_v2.bam"
nextflow src/nf_modules/SAMtools/tests/filter_bams.nf \
-c src/nf_modules/SAMtools/samtools.config \
nextflow src/nf_modules/SAMtools/filter_bams.nf \
-c src/nf_modules/SAMtools/filter_bams.config \
-profile docker \
--bam "data/tiny_dataset/map/tiny_v2.bam" \
--bed "data/tiny_dataset/OLD/2genes.bed"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment