添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

I was wondering if there is an good way of converting an aligned bam into a consensus fasta file. I was following the solution on Questions Regarding Consensus Sequence Calling With Samtools / Bcftools / Vcfutils.Pl but the discuss has me a little worried. In addition, the first step takes a long time and my runs keep failing without any errors. Any suggestions would be most appreciated.

Thanks in advance.

pipe this command with awk to obatin fasta file.

samtools view file.bam | awk '{print ">"$1"\n"$10}' > output.fasta

$1 is the header and $10 is the sequence in bam file separated by tab delimeter.

Well here's one way:

samtools view aligned.bam | awk 'BEGIN {FS="\t"} {print ">" $1 "\n" $10}' > aligned.fa

If you wanted BAM to fastq:

samtools view aligned.bam | awk 'BEGIN {FS="\t"} {print "@" $1 "\n" $10 "\n+\n" $11}' > aligned.fq

You could also use this http://bedtools.readthedocs.org/en/latest/content/tools/bamtofastq.html