This is a test version of Biostars. For the public version, visit https://www.biostars.org.
How to extract genome from iontorent bam file?

Hi, I hope everything is fine. I have a bam file with the COVID-19 genome from the ion torrent sequencing platform. I want to assemble them and tried with spades, But there is not enough read to form a contig. In that case, I want to assemble them with having gap (NNN). Is there any tools or pipeline?

Thanks In Advance

assembly alignment genome

2 answers

No need to assemble, just map the reads on to a reference genome and extract the consensus sequence. If everyone did like this the gisaid dataset would be of much higher quality..

Thank you, can you please share the code, like align with bwa and then?

This works for me

bwa mem ref.fa output.fq.gz > alignment.sam
samtools view -bS alignment.sam > aln.bam
samtools sort -m 2G aln.bam -o aln.sorted.bam
samtools mpileup -uf ref.fa aln.sorted.bam | bcftools call -c | vcfutils.pl vcf2fq -d 2 > cons.fa

Thank you

Shaminur : You should accept @5heikki's answer as well since that gave you the original clue for how to do this. You are able to accept more than one answer if they work.

Unless you are using a very old version of samtools, you can sort the .sam file, no need to convert it. You really should pipe the output of bwa meme into samtools sort, making a .sam file is usually wasteful.

Thank you very much for your valuable succession.

Log in to answer this question.