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