本文整理汇总了Python中cogent.struct.rna2d.Pairs.toVienna方法的典型用法代码示例。如果您正苦于以下问题:Python Pairs.toVienna方法的具体用法?Python Pairs.toVienna怎么用?Python Pairs.toVienna使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cogent.struct.rna2d.Pairs
的用法示例。
在下文中一共展示了Pairs.toVienna方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_toVienna
# 需要导入模块: from cogent.struct.rna2d import Pairs [as 别名]
# 或者: from cogent.struct.rna2d.Pairs import toVienna [as 别名]
def test_toVienna(self):
"""Pairs toVienna() should return a ViennaStructure if possible"""
a = Pairs([(1,5),(3,4),(6,9),(7,8)]) #normal
b = Pairs([(0,4),(2,6)]) #pseudoknot
c = Pairs([(1,6),(3,6),(4,5)]) #conflict
d = Pairs([(1,6),(3,None)])
e = Pairs([(1,9),(8,2),(7,3)]) #not directed
f = Pairs([(1,6),(2,5),(10,15),(14,11)]) # not directed
self.assertEqual(a.toVienna(10),'.(.())(())')
self.assertEqual(a.toVienna(13,offset=3),'....(.())(())')
self.assertRaises(PairError,b.toVienna,7) #pseudoknot NOT accepted
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),'.((..))...((..))....')