1.安装samtools环境
#为参考基因组建立索引,生成了prefix.fai文件
mkdir bwa_test
cd bwa_test/
samtools faidx GCA_000012525.1_ASM1252v1_genomic.fna
less GCA_000012525.1_ASM1252v1_genomic.fna.fai
先自行下载参考基因组文件
SAM2BAM
sam文件转为bam文件
samtools view -bhS -t GCA_000012525.1_ASM1252v1_genomic.fna.fai -o PCC7942_bwa.bam test_bwa_7942.sam #(最后这个sam文件用大家自己目录的sam文件名)
less PCC7942_bwa.bam
#为bam文件排序,sort只能为bam文件排序,而不能为sam;不同版本samtools sort命令的-o参数不同
samtools sort PCC7942_bwa.bam -o PCC7942_bwa.bam.sorted
#为排序的bam文件建立索引. *.bai文件
samtools index PCC7942_bwa.bam.sorted
打开bam文件的内容
统计比对结果
samtools depth PCC7942_bwa.bam.sorted>depth.txt
less depth.txt
samtools flagstat PCC7942_bwa.bam.sorted
3.查看比对结果
(1) samtools tview
samtools tview PCC7942_bwa.bam.sorted GCA_000012525.1_ASM1252v1_genomic.fna
g, 输入:CP000100.1:1000
(2) artemis
https://ftp.ncbi.nlm.nih.gov/genomes/all/GCA/000/012/525/GCA_000012525.1_ASM1252v1/GCA_000012525.1_ASM1252v1_genomic.gff.gz
Open, GCA_000012525.1_ASM1252v1_genomic.fna文件
Read an entry, GCA_000012525.1_ASM1252v1_genomic.gff
Read Bam/vcf, PCC7942_bwa.bam.sorted (必须是排序、索引后的bam)
下载链接文件,打开artemis,进行上述操作。
4. BAM2BCF
samtools mpileup -f GCA_000012525.1_ASM1252v1_genomic.fna PCC7942_bwa.bam.sorted >bcf.txt
less bcf.tx
samtools mpileup -gf GCA_000012525.1_ASM1252v1_genomic.fna PCC7942_bwa.bam.sorted>PCC7942_bwa.bcf
less PCC7942_bwa.bcf