Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1376 from nakib103/nextflow_split_opt
- Loading branch information
Showing
8 changed files
with
78 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
#!/usr/bin/env nextflow | ||
|
||
/* | ||
* Script to split a multi-chromosome VCF into single-chromosome VCFs | ||
*/ | ||
|
||
nextflow.enable.dsl=2 | ||
|
||
// defaults | ||
prefix = "out" | ||
params.outdir = "" | ||
params.cpus = 1 | ||
|
||
process splitVCF { | ||
/* | ||
Function to split a multi-chromosome VCF into single chromosome VCF | ||
Returns | ||
------- | ||
Returns 2 files per chromosome: | ||
1) A VCF format file for each splitted chromosome | ||
2) A tabix index for that VCF | ||
*/ | ||
cpus params.cpus | ||
container "${params.singularity_dir}/bcftools.sif" | ||
|
||
input: | ||
val(chr) | ||
path(vcf) | ||
path(vcf_index) | ||
val(bin_size) | ||
|
||
output: | ||
tuple path("${prefix}.${chr}.*vcf.gz"), path("${prefix}.${chr}.*vcf.gz.tbi"), emit: files | ||
|
||
script: | ||
""" | ||
bcftools view --no-version -r ${chr} ${vcf} -o ${prefix}.${chr}.vcf.gz -O z | ||
bcftools index -t ${prefix}.${chr}.vcf.gz | ||
if [[ ${bin_size} ]]; then | ||
bcftools query -f'%CHROM\t%POS\n' ${prefix}.${chr}.vcf.gz | split -l ${bin_size} | ||
for file in x*; do | ||
bcftools view --no-version -T \${file} -Oz ${prefix}.${chr}.vcf.gz > ${prefix}.${chr}.\${file}.vcf.gz | ||
bcftools index -t ${prefix}.${chr}.\${file}.vcf.gz | ||
done | ||
rm ${prefix}.${chr}.vcf.gz | ||
rm ${prefix}.${chr}.vcf.gz.tbi | ||
rm x* | ||
fi | ||
""" | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters