本文整理汇总了Python中RNA.energy_of_struct方法的典型用法代码示例。如果您正苦于以下问题:Python RNA.energy_of_struct方法的具体用法?Python RNA.energy_of_struct怎么用?Python RNA.energy_of_struct使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RNA
的用法示例。
在下文中一共展示了RNA.energy_of_struct方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: add
# 需要导入模块: import RNA [as 别名]
# 或者: from RNA import energy_of_struct [as 别名]
def add(self, seq):
def bp_pr(i, j):
if i > j:
i, j = j, i
return bppm[iindx[i + 1] - (j + 1)]
def pos_bp_pr_iter():
"""Yield probability for base i being paired in each structure."""
struct_0, struct_1 = target_structs
for i in xrange(len(seq)):
a = struct_0.basepairs[i]
b = struct_1.basepairs[i]
if a is not None:
if b is not None:
yield bp_pr(i, a), bp_pr(i, b)
else:
sum_ = sum((bp_pr(i, j) for j in xrange(size)))
yield bp_pr(i, a), 1 - sum_
elif b is not None:
sum_ = sum((bp_pr(i, j) for j in xrange(size)))
yield 1 - sum_, bp_pr(i, b)
else:
sum_ = 1 - sum((bp_pr(i, j) for j in xrange(size)))
yield sum_, sum_
seq_str = str(seq)
if seq_str in self.container:
return
size = len(seq)
self.container[seq_str] = {}
# with LOCK_VIENNA_RNA:
energy_ensemble = vienna_rna.pf_fold_par(seq_str, None, None, 1, 0,
0)
bppm = vienna_rna.doubleArray_frompointer(vienna_rna.export_bppm())
i = vienna_rna.get_iindx(len(seq_str))
iindx = vienna_rna.intArray_frompointer(i)
energy_structs = (
vienna_rna.energy_of_struct(seq_str, str(target_structs[0])),
vienna_rna.energy_of_struct(seq_str, str(target_structs[1])))
struct_mfe = " " * len(seq_str)
energy_mfe = vienna_rna.fold_par(seq_str, struct_mfe, None, 0, 0)
self.container[seq_str]["pos_bp_pr"] = list(pos_bp_pr_iter())
self.container[seq_str]["energy_ensemble"] = energy_ensemble
self.container[seq_str]["energy_mfe"] = energy_mfe
self.container[seq_str]["struct_mfe"] = struct_mfe
self.container[seq_str]["seq_pr"] = (
math.exp((energy_ensemble - energy_structs[0]) / kT),
math.exp((energy_ensemble - energy_structs[1]) / kT))