本文整理汇总了Python中RNA.bp_distance方法的典型用法代码示例。如果您正苦于以下问题:Python RNA.bp_distance方法的具体用法?Python RNA.bp_distance怎么用?Python RNA.bp_distance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RNA
的用法示例。
在下文中一共展示了RNA.bp_distance方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: mfe_bp_distance
# 需要导入模块: import RNA [as 别名]
# 或者: from RNA import bp_distance [as 别名]
def mfe_bp_distance(S, G, masked=None):
"""This function takes an RNA sequence S, a secondary structure G,
and returns de base pairs distance between the mfe structure (a mask
for the folding can be provided as an optional argument) of S
and G
"""
Sec_struct = RNA.fold(S)[0]
return RNA.bp_distance(Sec_struct, G)
示例2: expand
# 需要导入模块: import RNA [as 别名]
# 或者: from RNA import bp_distance [as 别名]
def expand(self, extend=1, exp_mode='default', mfree=6, p_min=None, warning=False):
"""Find new secondary structures and add them to :obj:`TrafoLandscape()`
The function supports two move-sets: 1) The mfe structure for the current
sequence length is connected to all present structures, 2) The conformation
graph is expanded using helix-breathing.
Args:
extend (int, optional): number of nucleotide extensions before graph
expansion (updates the global variable transcript length). Defaults to 1.
exp_mode (str, optional): choose from "mfe-only": only use current mfe
structure as potential new neighbor. "breathing-only": only use breathing
neighborhood. "default": do both mfe and breathing.
mfree (int, optional): minimum number of freed bases during a
helix-opening step. Defaults to 6.
p_min (flt, optional): Minimum probability of a structure for neighbor
generation. Defaults to None: using global TrafoLandscape parameter.
warning (bool, optional): When using 'breathing-only' search mode,
print a warning if MFE structure is not part of the ensemble. Be
aware that calculating the MFE structure just for this warning is not
recommended for large systems!
Returns:
int: Number of new nodes
"""
if p_min is None:
p_min = self._p_min
fseq = self.full_sequence
self._transcript_length += extend
if self._transcript_length > len(fseq):
self._transcript_length = len(fseq)
seq = self.transcript
csid = self._nodeid
md = self._model_details
fc_full = self._fold_compound
if exp_mode not in ['default', 'mfe-only', 'breathing-only']:
raise TrafoUsageError('unknown expansion mode')
# Calculate MFE of current transcript
if exp_mode == 'default' or exp_mode == 'mfe-only' or len(self) == 0 or warning:
fc_tmp = RNA.fold_compound(seq, md)
ss, mfe = fc_tmp.mfe()
future = '.' * (len(fseq) - len(seq))
ss = ss + future
# If there is no node because we are in the beginning, add the node,
# otherwise, try to add transition edges from every node to MFE.
if len(self) == 0:
en = round(fc_full.eval_structure(ss), 2)
self.add_node(ss, energy=en, occupancy=1.0,
identity=self._nodeid, active=True, last_seen=0)
self._nodeid += 1
elif exp_mode == 'default' or exp_mode == 'mfe-only':
# Try to connect MFE to every existing state
fpathE = 9999
for ni in sorted(self.nodes(), key=lambda x: RNA.bp_distance(ss, x)):
if ni == ss:
continue
if self.node[ni]['active'] == False:
continue
if self.has_edge(ni, ss):
# in case it was there but inactive
self.node[ss]['active'] = True
self.node[ss]['last_seen'] = 0
assert self.get_saddle(ss, ni) is not None
fpathE = self.get_saddle(ss, ni) \
if self.get_saddle(ss, ni) < fpathE else fpathE
continue
if self.has_node(ss): # from a previous iteration
if self.add_transition_edge(ni, ss, fpathE=fpathE+1.00, call='mfe'):
# in case it was there but inactive
self.node[ss]['active'] = True
self.node[ss]['last_seen'] = 0
elif self.add_transition_edge(ni, ss, fpathE=fpathE+1.00, call='mfe'):
en = round(fc_full.eval_structure(ss), 2)
self.node[ss]['active'] = True
self.node[ss]['last_seen'] = 0
self.node[ss]['energy'] = en
self.node[ss]['occupancy'] = 0.0
self.node[ss]['identity'] = self._nodeid
self._nodeid += 1
if self.get_saddle(ss, ni) is not None:
fpathE = self.get_saddle(ss, ni) \
if self.get_saddle(ss, ni) < fpathE else fpathE
if exp_mode == 'default' or exp_mode == 'breathing-only':
# Do the helix breathing graph expansion
# Initialize a dictionary to store the feature expansion during each
# graph expansion round: ext_moves[ext_seq] = [set((con,paren),...),
# structure] where ext_seq = exterior-loop sequence with ((xxx))
#.........这里部分代码省略.........