本文整理汇总了Python中skbio.Alignment.is_valid方法的典型用法代码示例。如果您正苦于以下问题:Python Alignment.is_valid方法的具体用法?Python Alignment.is_valid怎么用?Python Alignment.is_valid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类skbio.Alignment
的用法示例。
在下文中一共展示了Alignment.is_valid方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: AlignmentTests
# 需要导入模块: from skbio import Alignment [as 别名]
# 或者: from skbio.Alignment import is_valid [as 别名]
#.........这里部分代码省略.........
d2 = DNASequence('TCGGT-GGCC', id="d2")
expected = Alignment([d2])
self.assertEqual(actual, expected)
def test_subalignment_filter_out_everything(self):
exp = Alignment([])
# no sequences
obs = self.a1.subalignment(seqs_to_keep=None, invert_seqs_to_keep=True)
self.assertEqual(obs, exp)
# no positions
obs = self.a1.subalignment(positions_to_keep=None,
invert_positions_to_keep=True)
self.assertEqual(obs, exp)
def test_init_validate(self):
"""initialization with validation functions as expected
"""
Alignment(self.seqs1, validate=True)
# invalid DNA character
invalid_seqs1 = [self.d1, self.d2, self.d3,
DNASequence('.-ACC-GTXGC--', id="i1")]
self.assertRaises(SequenceCollectionError, Alignment,
invalid_seqs1, validate=True)
# invalid lengths (they're not all equal)
invalid_seqs2 = [self.d1, self.d2, self.d3,
DNASequence('.-ACC-GTGC--', id="i2")]
self.assertRaises(SequenceCollectionError, Alignment,
invalid_seqs2, validate=True)
def test_is_valid(self):
"""is_valid functions as expected
"""
self.assertTrue(self.a1.is_valid())
self.assertTrue(self.a2.is_valid())
self.assertTrue(self.empty.is_valid())
# invalid because of length mismatch
d1 = DNASequence('..ACC-GTTGG..', id="d1")
d2 = DNASequence('TTACCGGT-GGC', id="d2")
self.assertFalse(Alignment([d1, d2]).is_valid())
# invalid because of invalid charaters
d1 = DNASequence('..ACC-GTXGG..', id="d1")
d2 = DNASequence('TTACCGGT-GGCC', id="d2")
self.assertFalse(Alignment([d1, d2]).is_valid())
def test_iter_positions(self):
"""iter_positions functions as expected
"""
actual = list(self.a2.iter_positions())
expected = [[RNASequence(j) for j in i] for i in
['UA', 'UC', 'AG', 'UU', '-U']]
self.seqs2_t = [('r1', 'UUAU-'), ('r2', 'ACGUU')]
self.assertEqual(actual, expected)
actual = list(self.a2.iter_positions(constructor=str))
expected = [list('UA'),
list('UC'),
list('AG'),
list('UU'),
list('-U')]
self.seqs2_t = [('r1', 'UUAU-'), ('r2', 'ACGUU')]