This is a test version of Biostars. For the public version, visit https://www.biostars.org.
What is the best way to re-align a .bam file?

I need to know exactly what reference genome was used to align a file, so I am looking for a way to de-align and re-align an existing .bam.

Could you suggest a correct way to do this? Is my original approach of going from .bam -> .fastq -> .sam -> .bam feasible?

Is there any loss of information?

P.S. At the moment I am using samtools bam2fq.

bam fasta fastq samtools

I used ngs-bits BamToFastq, but bedtools bamToFastq should work just as good for .bam -> .fastq.

I would not expect a loss of information unless you've filtered out unmapped reads from your bam files. Also hard clipping can create a problem - but more knowledgable people may answer better.

1 answer

Bazam has been developed precisely for this purpose.

Just tested bazam and it works great. Thanks a lot!

Log in to answer this question.