前言
GitHub - Edinburgh-Genome-Foundry/DnaChisel: :pencil2: A versatile DNA sequence optimizer
本文章主要简单讲述DNAchisel该python包方便基因操作和分析的代码使用以及原github文件库中的范例翻译,会根据博主水平持续进行更新。
同时如果需要更多关于DNAchisel包的了解,可以参考官网内容:
DNA Chisel - a versatile sequence optimizer (edinburgh-genome-foundry.github.io)
安装要求:
python 3.0以上版本
可通过pip安装
pip install dnachisel # <= minimal install without reports support
pip install 'dnachisel[reports]' # <= full install with all dependencies
文中作者解释,如果只需要python script代码部分只需要第一个命令行,如果需要report文件部分,其中包括了:matplotlib,PDF reports sequenticon等生成图像工具
The full installation using
dnachisel[reports]
downloads heavier libraries (Matplotlib, PDF reports, sequenticon) for report generation, but is highly recommended to use DNA Chisel interactively via Python scripts.
安装后可以开始实现一些功能,例如密码子优化、插入酶切位点、PCR
Core Classes
DnaOptimizationProblem
由于在实验中插入的编码序列可能因为编码基因在不同物种的中有密码子偏好性,所以需要针对不同物种进行密码子优化;抑或是做Golden Gate时候,需要考虑编码序列里不能存在BsaI、BpiI酶切位点,以下以酵母为例,选用HSP90基因序列对其进行优化:
备注:以下同时还用到biopython工具包,这是另一个强大的生物类python功能包,后面有机会会根据biopython cookbook选取做功能介绍
from Bio import SeqIO
from dnachisel import *
from Bio.Restriction import *
for index, record in enumerate(SeqIO.parse("HSP90_Raw.gbk", "genbank")):
print(
"index %i, ID = %s, length %i, with %i features"
% (index, record.id, len(record.seq), len(record.features))
)
seq = str(record.seq)
sites_constraints = [
AvoidPattern(Restriction.BsaI.site),AvoidPattern(Restriction.BbsI.site),EnforceTranslation()
]
# CREATE AN RESOLVE THE PROBLEM:
problem = DnaOptimizationProblem(
sequence=seq,
constraints=sites_constraints,
objectives=[CodonOptimize(species='e_coli',location=(0, 2184))]
)
problem.resolve_constraints()
problem.optimize()
print ("Final sequence:", problem.sequence)
此处进行解释:
DnaOptimizationProblem部分为需要解决的问题和输入的序列,sequence为HSP90基因,也就是上面的HSP90,constraints为需要输入的限制,本文中限制的条件有:去除BsaI位点,去除BbsI位点,同时保证整个序列能够翻译下去到最后的终止子(EnforceTranslation)。
objectives输入密码子优化命令:CodonOptimize,优化物种为E coli,优化位置为开始到结束。
随后resolve_constraints为解决constraints条件中内容,optimize命令为解决优化部分,如果没有输入这两行命令,则最终结果仍是原始序列。