本文整理汇总了Python中cogent.struct.rna2d.Pairs.remove方法的典型用法代码示例。如果您正苦于以下问题:Python Pairs.remove方法的具体用法?Python Pairs.remove怎么用?Python Pairs.remove使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cogent.struct.rna2d.Pairs
的用法示例。
在下文中一共展示了Pairs.remove方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: compare_pairs_mapping
# 需要导入模块: from cogent.struct.rna2d import Pairs [as 别名]
# 或者: from cogent.struct.rna2d.Pairs import remove [as 别名]
def compare_pairs_mapping(one, other, one_to_other):
"""Returns intersection/union given a mapping from the first pairs to second
Use in case the numbering of the two Pairs object don't correspond.
Sort of aligning two ungapped sequences and comparing their Pairs
object via a mapping.
one: list of tuples or Pairs object
other: list of tuples or Pairs object
one_to_other: mapping of positions in first pairs object to positions
in second pairs object.
For example:
# pos in first seq, base, pos in second seq
#1 U 0
#2 C 1
#3 G 2
#4 A 3
# A 4
#5 C 5
#6 C 6
#7 U
#8 G 7
mapping = {1:0, 2:1, 3:2, 4:3, 5:5, 6:6, 7:None, 8:7}
"""
if not one and not other:
return 1.0
just_in_first = 0
just_in_second = 0
in_both = 0
pairs1 = Pairs(one).directed() #removes duplicates
pairs2 = Pairs(other).directed()
for x,y in pairs1:
other_match = (one_to_other[x],one_to_other[y])
if other_match in pairs2:
in_both += 1
pairs2.remove(other_match)
else:
just_in_first += 1
just_in_second += len(pairs2)
return in_both/(just_in_first + in_both + just_in_second)