いくつか方法があるのでまとめておく。
追記
文章修正
1、bam2fastq
公式サイトでは今後は使用非推奨で、代わりにpicardを使ってと記載されています。これまでのデータであれば問題ないと思われますが、注意して使ってください。
ダウンロード
公式サイト Genomic Services Laboratory at HudsonAlpha
ダウンロードして解凍し、解凍したディレクトリでmakeすれば使える。
make
ラン
シングルリード
bam2fastq input.bam -o input.fq
- -o Specifies the name of the FASTQ file(s) that will be generated
ペアリード
bam2fastq input.bam -o input#.fq
input_1.fqとinput_2.fqが出力される。
アンマップペアリードの出力
bam2fastq input.bam -o input#.fq --no-aligned --force --strict
- --aligned または --no-aligned Reads in the BAM that are aligned will (will not) be extracted. [Default: extract aligned reads]
- --force Create output files specified with --output, overwriting existing files.
- --strict Keep bam2fastq's processing to a minimum, assuming that the BAM strictly
2、bedtools
シングル
bedtools bamtofastq -i input.bam -fq single.fastq
ペアリード
bedtools bamtofastq -i R1R2.bam -fq R1.fastq -fq2 R2.fastq
- -fq2 FASTQ for second end. Used if BAM contains paired-end data. BAM should be sorted by query name is creating paired FASTQ.
3、picard
入力のbamと出力のfastqを指定してランする。
Picard SamToFastq INPUT=R1R2.bam F=R1.fq F2=R2.fq
4、samtools
samtools fastq input.bam > input.fq
bam/samからfastaを抽出。
samtools fasta input.bam > input.fa
他にbamtoolsでも可能だが速度は劣る。
1-4のツールがなければ、brewで導入してください。
引用
BEDTools: a flexible suite of utilities for comparing genomic features.
Quinlan AR1, Hall IM.
Bioinformatics. 2010 Mar 15;26(6):841-2. doi: 10.1093/bioinformatics/btq033. Epub 2010 Jan 28.
https://www.ncbi.nlm.nih.gov/pubmed/20110278
BCFtools/RoH: a hidden Markov model approach for detecting autozygosity from next-generation sequencing data.
Narasimhan V1, Danecek P1, Scally A2, Xue Y1, Tyler-Smith C1, Durbin R1.
Bioinformatics. 2016 Jun 1;32(11):1749-51. doi: 10.1093/bioinformatics/btw044. Epub 2016 Jan 30.
https://www.ncbi.nlm.nih.gov/pubmed/26826718
The Sequence Alignment/Map format and SAMtools.
Li H1, Handsaker B, Wysoker A, Fennell T, Ruan J, Homer N, Marth G, Abecasis G, Durbin R; 1000 Genome Project Data Processing Subgroup.
Bioinformatics. 2009 Aug 15;25(16):2078-9. doi: 10.1093/bioinformatics/btp352. Epub 2009 Jun 8.
https://www.ncbi.nlm.nih.gov/pubmed/19505943