虚拟机的安装
主要参考网易云课堂 Linux生信分析环境搭建Bio-linux课程
设置共享文件夹需要的命令
sudo mount -t vboxsf share /home/student/share
fastq文件转化为fasta(使用seqtk)
seqtk seq -a input.fastq > output.fasta
使用到的软件
wgsim (模拟生成fastq文件)
bowtie2
samtools
bedtools
IGV
原文地址 [http://biobits.org/samtools_primer.html]()
第一步:模拟生成双末端fastq文件
wgsim -N 4000 -1 150 -2 150 NC_008253.fna reads_1.fastq reads_2.fastq
-N 参数用来指定reads的数量
-1, -2 用来指定双端reads的长度
还有其他参数可以空运行命令来查看
第二步:使用bowtie2将reads比对到参考基因组
bowtie2-build NC_008253.fna Ecoli
bowtie2 -x Ecoli -1 reads_1.fastq -2 reads_2.fastq -S Ecoli.sam
第一个文件 NC_008253.fna 是参考序列的文件名
第二个 Ecoli 是为构建的索引起一个名字,下一步bowtie2比对时 -x 参数后接的就是这个名字
(比对完输出到屏幕的结果还是不明白)
第三步:使用samtools将sam格式转换为bam格式并且把bam格式sorted(这个sorted起什么作用自己还不太明白)
samtools view -b - S -o Ecoli.bam Ecoli.sam
samtools sort Ecoli.bam -o Ecoli.sorted.bam
第四步
提取基因组重测序数据中可能属于叶绿体的reads
使用bowtie2比对(双末端测序数据)
bowtie2-build Malus_baccata.fasta Malus_baccata
bowtie2 -x Malus_baccata -1 reads_1.fastq -2 reads_2.fastq -S eg2.sam
samtools view -b -S -o eg2.bam eg2.sam
-b指定输出格式为BAM(indicates that the output is BAM)-S指定输入格式为SAM(indicates that the input is SAM)-o指定输出文件名(specifies the name of the output file)
samtools sort eg2.bam -o eg2.sorted.bam
samtools index eg2.sorted.bam
#过滤没有比对到参考基因组的reads
samtools view -F 4 eg2.sorted.bam > eg2.aligned.sam
#根据fasta文件将header添加到sam文件中
samtools view -T reference_genome.fasta -h eg2.aligned.sam > eg2.aligned.header.sam
#SMA转BAM
samtools view -b -S -o eg2.aligned.header.bam eg2.aligned.header.sam
#BAM转换fastq
bam2fastq --aligned -o aligned.fastq eg2.aligned.header.sam
samtools 常用操作
#没有比对到参考基因组上reads的数量
samtools view -c -f -4 aligned.sorted.bam
#sam转bam
samtools view -b -S -o A.bam A.sam
#排序
samtools sort A.bam -o A.sorted.bam
#索引
samtools index A.soretd.bam
samtools fastq
samtools stats
samtools flags
参考文献
1、samtools使用大全 【CSDN】
2、https://bedtools.readthedocs.io/en/latest/content/tools/bamtofastq.html
3、http://www.htslib.org/doc/samtools.html
4、http://seqome.com/convert-bam-file-fastq/
5、https://www.jianshu.com/p/368b9471656e
6、https://wikis.utexas.edu/display/CoreNGSTools/Samtools%3A+viewing,+counting+and+sorting+your+alignment+data

