aaikmyz's diary

聴いた音楽とか見た映画とか行った美術館とかを記録しておきたい。

bamファイルからtophatの結果を取り出す

tophatによって生成されたbamファイルに対してsamtoolsのflagstatを使えばいろんな情報が出てくる。

$ samtools flagstat accepted_hit.bam

出力は以下のようになる。

4423480 + 0 in total (QC-passed reads + QC-failed reads)
0 + 0 duplicates
4423480 + 0 mapped (100.00%:nan%)
4423480 + 0 paired in sequencing
2295943 + 0 read1
2127537 + 0 read2
3592608 + 0 properly paired (81.22%:nan%)
3652162 + 0 with itself and mate mapped
771318 + 0 singletons (17.44%:nan%)
26412 + 0 with mate mapped to a different chr
1522 + 0 with mate mapped to a different chr (mapQ>=5)

どうやってbamファイルからこの情報を取り出しているのかは以下を参照。
http://davetang.org/wiki/tiki-index.php?page=SAMTools#Simple_stats_using_SAMTools_flagstat