Hi
I have a BAM file(s) which are reads aligned to reference genome.I'd like to know how can convert a BAM file to the full sequence in fasta format, using the reads in the BAM file.I searched Biostars for BAM/SAM to FASTA conversion method, and found the two command could do this (Convert Bam File To Fasta File).
1- samtools view filename.bam | awk '{OFS="\t"; print ">"$1"\n"$10}' - > filename.fasta
2-samtools bam2fq input.bam | seqtk seq -A > output.fa
but I did not get the fasta format. because i have this error(Too many arguments, bam2fq: unrecognized option --'A'
Is there a solution that would help?
I am impatiens for your answer.
You could use
reformat.sh
from BBMap suite:reformat.sh in=your.bam out=seq.fa
orreformat.sh in=your.bam out1=seq_R1.fa out2=seq_R2.fa
. Consider a caveat though. If your bam file does not contain both reads then you may need to userepair.sh
to fix the order of reads in output files.what did you get ?