Commit 1130103c authored by Pierre LINDENBAUM's avatar Pierre LINDENBAUM
Browse files

nextflow

parent 3c56c752
all: bin/nextflow nextflow.nf
bin/nextflow run -resume nextflow.nf --datadir ../../DATA
bin/nextflow:
mkdir -p bin && cd bin && wget -O - -q "https://get.nextflow.io" | bash && ./nextflow
datain = Channel.from("child","father","mother").
map{ S->[S,file("${params.datadir}/"+S+".R1.fq.gz"),file("${params.datadir}/"+S+".R2.fq.gz")] }
process dowmnloadref {
output:
file("ref.fa") into ref
file("ref.fa.*") into ref_idx
script:
"""
export PATH="/usr/local/opt/sam_vcf_htslib/bin:${PATH}"
wget -O - -q "http://hgdownload.cse.ucsc.edu/goldenPath/hg19/chromosomes/chr22.fa.gz" | gunzip -c > ref.fa
wget -O - -q "http://hgdownload.cse.ucsc.edu/goldenPath/hg19/chromosomes/chrM.fa.gz" | gunzip -c >> ref.fa
samtools faidx ref.fa
bwa index ref.fa
"""
}
process map {
tag "map ${sample}"
input:
set sample,R1,R2 from datain
file ref from ref
file refidx from ref_idx
output:
set sample,file("${sample}.sam") into sams
script:
"""
export PATH="/usr/local/opt/sam_vcf_htslib/bin:${PATH}"
bwa mem -R '@RG\\tID:${sample}\\tSM:${sample}' "${ref}" "${R1}" "${R2}" > "${sample}.sam"
"""
}
process sam2bam {
tag "sam2bam for ${sample}"
input:
set sample,sam from sams
output:
set sample,file("${sample}.unsorted.bam") into unsorted
script:
"""
export PATH="/usr/local/opt/sam_vcf_htslib/bin:${PATH}"
samtools view -b -S "${sam}" > "${sample}.unsorted.bam"
"""
}
process sortbam {
tag "sort ${sample}"
input:
set sample,bam from unsorted
output:
set sample,file("${sample}.bam") into sorted
file("${sample}.bam.bai")
script:
"""
export PATH="/usr/local/opt/sam_vcf_htslib/bin:${PATH}"
samtools sort -T ${sample}.tmp -o "${sample}.bam" ${bam}
samtools index ${sample}.bam
"""
}
process callvariants {
input:
val bams from sorted.map{T->T[1]}.collect()
file ref from ref
file refidx from ref_idx
output:
file("variants.vcf.gz") into vcf
script:
"""
export PATH="/usr/local/opt/sam_vcf_htslib/bin:${PATH}"
samtools mpileup -g --output-tags DP --fasta-ref "${ref}" --output variants.bcf ${bams.join(" ")}
bcftools call --multiallelic-caller --variants-only --output-type z -o variants.vcf.gz --format-fields GQ,GP variants.bcf
"""
}
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