This is a test version of Biostars. For the public version, visit https://www.biostars.org.
export alignment from BAM file

Dear all,

I'd like to export an alignment in a fasta (or similar) format from a bam file.

I know there are tools to extract the reads that cover a certain region, for example by doing:

samtools view -b -h bam_file.bam "chr1:2000-3000" > reads_bam_file.bam    
samtools fasta reads_bam_file.bam > reads_bam_file.fasta

But this doesn't result in an alignment.

The reason I'd like to avoid repeat the alignment is that I might have several hundreds of reads, which make a de novo alignment not sustainable.

I haven't found so far a tool for doing this and I was wondering if anybody has suggestions

Thank you in advance!

bam samtools

1 answer

See if this answer helps: https://support.bioconductor.org/p/64748/#64755

Exactly what I was looking for! Thanks

Please accept GenoMax's answer to mark the post resolved.

upvote_bookmark_accept

Log in to answer this question.