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!