本文整理匯總了Python中cogent.struct.rna2d.Pairs.hasPseudoknots方法的典型用法代碼示例。如果您正苦於以下問題:Python Pairs.hasPseudoknots方法的具體用法?Python Pairs.hasPseudoknots怎麽用?Python Pairs.hasPseudoknots使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類cogent.struct.rna2d.Pairs
的用法示例。
在下文中一共展示了Pairs.hasPseudoknots方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: PairsTests
# 需要導入模塊: from cogent.struct.rna2d import Pairs [as 別名]
# 或者: from cogent.struct.rna2d.Pairs import hasPseudoknots [as 別名]
#.........這裏部分代碼省略.........
self.assertRaises(Exception,b.toVienna,7) #old test for exception
self.assertRaises(ValueError,c.toVienna,7)
#pairs containging None are being skipped
self.assertEquals(d.toVienna(7),'.(....)')
#raises error when trying to insert at non-existing indices
self.assertRaises(IndexError,a.toVienna,3)
self.assertEqual(Pairs().toVienna(3),'...')
#test when parsing in the sequence
self.assertEqual(a.toVienna('ACGUAGCUAG'),'.(.())(())')
self.assertEqual(a.toVienna(Rna('AACCGGUUAGCUA'), offset=3),\
'....(.())(())')
self.assertEqual(e.toVienna(10),'.(((...)))')
self.assertEqual(f.toVienna(20),'.((..))...((..))....')
def test_tuples(self):
"""Pairs tuples() should transform the elements of list to tuples"""
x = Pairs([])
x.tuples()
assert x == []
x = Pairs([[1,2],[3,4]])
x.tuples()
assert x == [(1,2),(3,4)]
x = Pairs([(1,2),(3,4)])
x.tuples()
assert x == [(1,2),(3,4)]
assert x != [[1,2],[3,4]]
def test_unique(self):
"""Pairs unique() should remove double occurences of certain tuples"""
self.assertEqual(self.Empty.unique(),[])
self.assertEqual(self.MoreTuples.unique(),self.MoreTuples)
self.assertEqual(self.Doubles.unique(),Pairs([(1,2),(2,3),(1,3)]))
def test_directed(self):
"""Pairs directed() should change all pairs so that a<b in (a,b)"""
self.assertEqual(self.Empty.directed(),[])
res = self.Undirected.directed()
res.sort()
self.assertEqual(res,Pairs([(1,2),(1,7),(3,8),(4,6)]))
res = self.UndirectedNone.directed()
self.assertEqual(res,Pairs([]))
res = self.UndirectedDouble.directed()
self.assertEqual(res,Pairs([(1,2)]))
def test_symmetric(self):
"""Pairs symmetric() should add (down,up) for each (up,down)"""
self.assertEqual(self.Empty.symmetric(),[])
self.assertEqualItems(self.OneTuple.symmetric(),[(2,1),(1,2)])
self.assertEqualItems(Pairs([(1,2),(1,2)]).symmetric(),[(1,2),(2,1)])
self.assertEqualItems(Pairs([(1,2),(3,4)]).symmetric(),\
[(1,2),(2,1),(3,4),(4,3)])
self.assertEqualItems(Pairs([(1,None)]).symmetric(),[])
def test_paired(self):
"""Pairs paired() should omit all pairs containing None"""
self.assertEqual(self.Empty.paired(),[])
self.assertEqual(Pairs([(1,2),(2,None),(None,3),(None,None)]).paired()\
,[(1,2)])
def test_hasConflicts(self):
"""Pairs hasConflicts() should return True if there are conflicts"""
assert not self.Empty.hasConflicts()
assert not Pairs([(1,2),(3,4)]).hasConflicts()
assert Pairs([(1,2),(2,3)]).hasConflicts()
assert Pairs([(1,2),(2,None)]).hasConflicts()
def test_mismatches(self):
"""Pairs mismatches() should return #pairs that can't be formed"""
# with plain string
self.assertEqual(Pairs([(0,1)]).mismatches('AC',{}),1)
self.assertEqual(Pairs([(0,1)]).mismatches('AC',{('A','C'):None}),0)
self.assertEqual(Pairs([(0,1)]).mismatches('AC',{('A','G'):None}),1)
self.assertEqual(Pairs([(0,1),(2,3),(3,1)]).\
mismatches('ACGU',{('A','U'):None}),3)
# using sequence with alphabet
sequence = Rna('ACGUA')
self.assertEqual(Pairs([(0,1),(0,4),(0,3)]).mismatches(sequence),2)
def test_hasPseudoknots(self):
"""Pairs hasPseudoknots() should return True if there's a pseudoknot"""
assert not self.NoPseudo.hasPseudoknots()
assert not self.NoPseudo2.hasPseudoknots()
#add tests for ((.))() etc
assert self.p0.hasPseudoknots()
assert self.p1.hasPseudoknots()
assert self.p2.hasPseudoknots()
assert self.p3.hasPseudoknots()
assert self.p4.hasPseudoknots()
assert self.p5.hasPseudoknots()
assert self.p6.hasPseudoknots()
assert self.p7.hasPseudoknots()