1.安装samtools环境
sudo apt install samtools
samtools
samtools view
(安装完成)
2. SAM格式转为BAM格式
为参考基因组建立索引,生成了prefix.fai文件
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 PCC7942_bwa.sam #(最后这个sam文件用自己目录的sam文件名)
(改为
samtools view -bhS -t GCA_000012525.1_ASM1252v1_genomic.fna.fai -o PCC7942_bwa.bam test _bwa_P7942_bwa.sam
)查看
less PCC7942_bwa.bam
为bam文件排序,sort只能为bam文件排序,而不能为sam;不同版本samtools sort命令的-o参数不同
samtools sort PCC7942_bwa.bam -o PCC7942_bwa.bam.sorted
samtools index PCC7942_bwa.bam.sorted
统计比对结果
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/014/698/905/GCA_014698905.1_ASM1469890v1/GCA_014698905.1_ASM1469890v1_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)
4. BAM2BCF
samtools mpileup -f GCA_000012525.1_ASM1252v1_genomic.fna PCC7942_bwa.bam.sorted >bcf.txt
less bcf.txt
samtools mpileup -gf GCA_000012525.1_ASM1252v1_genomic.fna PCC7942_bwa.bam.sorted>PCC7942_bwa.bcf
less PCC7942_bwa.bcf