This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Convert BAM format file to FASTA format

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.

next-gen software error

but I did not get the fasta format

what did you get ?

You could use reformat.sh from BBMap suite: reformat.sh in=your.bam out=seq.fa or reformat.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 use repair.sh to fix the order of reads in output files.

0 answers

No answers yet.

Log in to answer this question.