1. Samtools faidx
利用 samtools 的 faidx 工具,方法如下:
首先用 faidx 生成 fasta 序列文件索引
samtools faidx hg19.fa
samtools faidx hg19.fa chr13:1000000:10006666
2.bedtools getfasta
BEDTools是可用于genomic features的比較,相關(guān)操作及進(jìn)行注釋的工具。而其中g(shù)etfasta的功能就是根據(jù)坐標(biāo)信息提取序列信息。
-fi:參考基因組fasta文件;
-bed:需要提取的序列的位置信息;
-fo:輸出文件。
bedtools getfasta [OPTIONS] -fi <input FASTA> -bed <BED/GFF/VCF>
3.pysam fetch
name_file = pysam.AlignmentFile(input_filename, "rb")
for line in name_file.fetch(contig="chr21", start=xx, end=xx):
print(line)
提取參考基因組某個(gè)位置的堿基 - 簡(jiǎn)書(shū) (jianshu.com)
4. biopython
genome_dict= {}
for line in SeqIO.parse("ref.fa", format="fasta"):
print(record)
genome_dict[line.id] = record.seq.upper()
genome_dict["chr1"][1:100000]
5.R Biostrings
library(Biostrings) ;
s = readDNAStringSet("ref.fasta")
s$chr1[1:100]