本文整理匯總了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)