This is a test version of Biostars. For the public version, visit https://www.biostars.org.
How to generate a consensus sequence from BAM file with bcftools?

Hello, I have aligned some files against a reference genome with BMA-MEM, deduplicated and sorted with sambamba to generate a AlnSrtDedSrt.bam file.

The question is: how can I generate a consensus fasta file?

I have this fragment of code:

$ bcftools mpileup -Ou -f {ref}.fa AlnSrtDedSrt.bam | bcftools call -Ou -mv | bcftools norm -f {ref}.fa -Oz -o {input}.vcf.gz
$ tabix {input}.vcf.gz
$ bcftools consensus -f {ref}.fa {input}.vcf.gz > {out}.fa

where {ref}.fa is the reference file.

Is the code correct? The main problem is how to make the {input}.vcf.gz file. Any tips?

Thank you

bam bcftools consensus

0 answers

No answers yet.

Log in to answer this question.