当前位置: 首页>>代码示例>>Python>>正文


Python MafIndex.search方法代码示例

本文整理汇总了Python中Bio.AlignIO.MafIO.MafIndex.search方法的典型用法代码示例。如果您正苦于以下问题:Python MafIndex.search方法的具体用法?Python MafIndex.search怎么用?Python MafIndex.search使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Bio.AlignIO.MafIO.MafIndex的用法示例。


在下文中一共展示了MafIndex.search方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: TestSearchBadMAF

# 需要导入模块: from Bio.AlignIO.MafIO import MafIndex [as 别名]
# 或者: from Bio.AlignIO.MafIO.MafIndex import search [as 别名]
    class TestSearchBadMAF(unittest.TestCase):
        """Test index searching on an incorrectly-formatted MAF"""

        def setUp(self):
            self.idx = MafIndex("MAF/ucsc_mm9_chr10_bad.mafindex",
                                "MAF/ucsc_mm9_chr10_bad.maf", "mm9.chr10")
            self.assertEqual(len(self.idx), 48)

        def test_incorrect_bundle_coords(self):
            search = self.idx.search((3013219,), (3013319,))
            self.assertRaises(ValueError, next, search)
开发者ID:BioGeek,项目名称:biopython,代码行数:13,代码来源:test_MafIO_index.py

示例2: TestSearchGoodMAF

# 需要导入模块: from Bio.AlignIO.MafIO import MafIndex [as 别名]
# 或者: from Bio.AlignIO.MafIO.MafIndex import search [as 别名]
    class TestSearchGoodMAF(unittest.TestCase):
        """Test index searching on a properly-formatted MAF"""

        def setUp(self):
            self.idx = MafIndex("MAF/ucsc_mm9_chr10.mafindex",
                                "MAF/ucsc_mm9_chr10.maf", "mm9.chr10")
            self.assertEqual(len(self.idx), 48)

        def test_invalid_type_1(self):
            search = self.idx.search((500, 1000), ("string", 1500))
            self.assertRaises(TypeError, next, search)

        def test_invalid_type_2(self):
            search = self.idx.search((500, 1000), (750, 1500.25))
            self.assertRaises(TypeError, next, search)

        def test_invalid_exon_count(self):
            search = self.idx.search((0, 1000, 2000), (500, 1500))
            self.assertRaises(ValueError, next, search)

        def test_invalid_exon_schema(self):
            search = self.idx.search((0, 1000, 2000), (250, 500, 2500))
            self.assertRaises(ValueError, next, search)

        def test_correct_retrieval_1(self):
            search = self.idx.search((3014742, 3018161), (3015028, 3018644))
            results = [x for x in search]

            self.assertEqual(len(results), 12)

            self.assertEqual(set([len(x) for x in results]),
                             set([5, 10, 7, 6, 3, 1, 1, 1, 2, 4, 4, 9]))

            self.assertEqual(set([x.annotations["start"] for y in results
                                  for x in y]),
                             set([3018359, 16390338, 15871771, 184712,
                                  16169512, 16169976, 3014842, 1371, 7842,
                                  171548, 16389874, 15871306, 6404, 184317,
                                  14750994, 3015028, 1616, 8040, 171763,
                                  16169731, 6627, 184539, 3014689, 15870832,
                                  16389401, 6228, 184148, 1201, 3018230,
                                  15871676, 16390243, 3014778, 3018482, 3017743,
                                  3018644, 78070420, 3014742, 6283, 184202,
                                  1257, 3018161, 16390178, 15871611, 16169818,
                                  3014795, 184257, 6365, 15871286, 16389854,
                                  16169492, 171521, 7816, 1309]))

        def test_correct_retrieval_2(self):
            search = self.idx.search((3009319, 3021421), (3012566, 3021536))
            results = [x for x in search]

            self.assertEqual(len(results), 8)

            self.assertEqual(set([len(x) for x in results]),
                             set([14, 5, 2, 6, 7, 15, 6, 4]))

            self.assertEqual(set([x.annotations["start"] for y in results
                                  for x in y]),
                             set([3021421, 9910, 996, 16173434, 16393782,
                                  15875216, 11047, 175213, 3552, 677, 78072203,
                                  3590, 95587, 14757054, 3012441, 15860899,
                                  16379447, 16160646, 180525, 3009319, 11087,
                                  3012566, 15861013, 16379561, 16160760, 180626,
                                  310, 3021465, 9957, 16173483, 16393831,
                                  15875265, 78072243, 14757099, 3021275, 9741,
                                  838, 16173265, 16393613, 15875047, 10878,
                                  175057, 3382, 521, 78072035, 73556, 3422,
                                  95418, 14756885, 3021494, 16173516, 16393864,
                                  15875298, 78072287, 14757144, 3012076,
                                  16160203, 16379004, 15860456]))

        def test_correct_retrieval_3(self):
            search = self.idx.search((3012076, 3012076 + 300), (3012076 + 100, 3012076 + 400))
            results = [x for x in search]

            self.assertEqual(len(results), 2)

            self.assertEqual(set([len(x) for x in results]),
                             set([4, 5]))

            # Code formatting note:
            # Expected start coordinates are grouped by alignment blocks
            self.assertEqual(
                set([x.annotations["start"] for y in results for x in y]),
                set([
                    3012076, 16160203, 16379004, 15860456,
                    3012441, 15860899, 16379447, 16160646, 180525]))
开发者ID:BioGeek,项目名称:biopython,代码行数:89,代码来源:test_MafIO_index.py

示例3: TestSearchGoodMAF

# 需要导入模块: from Bio.AlignIO.MafIO import MafIndex [as 别名]
# 或者: from Bio.AlignIO.MafIO.MafIndex import search [as 别名]
    class TestSearchGoodMAF(unittest.TestCase):
        """Test index searching on a properly-formatted MAF."""

        def setUp(self):
            self.idx = MafIndex("MAF/ucsc_mm9_chr10.mafindex",
                                "MAF/ucsc_mm9_chr10.maf", "mm9.chr10")
            self.assertEqual(len(self.idx), 48)

        def test_invalid_type_1(self):
            search = self.idx.search((500, 1000), ("string", 1500))
            self.assertRaises(TypeError, next, search)

        def test_invalid_type_2(self):
            search = self.idx.search((500, 1000), (750, 1500.25))
            self.assertRaises(TypeError, next, search)

        def test_invalid_exon_count(self):
            search = self.idx.search((0, 1000, 2000), (500, 1500))
            self.assertRaises(ValueError, next, search)

        def test_invalid_exon_schema(self):
            search = self.idx.search((0, 1000, 2000), (250, 500, 2500))
            self.assertRaises(ValueError, next, search)

        def test_correct_retrieval_1(self):
            """Correct retrieval of Cnksr3 in mouse."""

            search = self.idx.search((3014742, 3018161), (3015028, 3018644))
            results = [x for x in search]

            self.assertEqual(len(results), 4 + 4)

            self.assertEqual(set([len(x) for x in results]),
                             set([4, 1, 9, 10, 4, 3, 5, 1]))

            # Code formatting note:
            # Expected start coordinates are grouped by alignment blocks
            self.assertEqual(
                set([x.annotations["start"] for y in results for x in y]),
                set([
                    3014742, 6283, 184202, 1257,
                    3014778,
                    3014795, 184257, 6365, 15871286, 16389854, 16169492, 171521, 7816, 1309,
                    3014842, 1371, 7842, 171548, 16169512, 16389874, 15871306, 6404, 184317, 14750994,
                    3018161, 16390178, 15871611, 16169818,
                    3018230, 15871676, 16390243,
                    3018359, 16390338, 15871771, 184712, 16169976, 3018482]))

        def test_correct_retrieval_2(self):
            search = self.idx.search((3009319, 3021421), (3012566, 3021536))
            results = [x for x in search]

            self.assertEqual(len(results), 6)

            self.assertEqual(set([len(x) for x in results]),
                             set([2, 4, 5, 14, 7, 6]))

            # Code formatting note:
            # Expected start coordinates are grouped by alignment blocks
            self.assertEqual(
                set([x.annotations["start"] for y in results for x in y]),
                set([
                    3009319, 11087,
                    3012076, 16160203, 16379004, 15860456,
                    3012441, 15860899, 16379447, 16160646, 180525,
                    3021421, 9910, 996, 16173434, 16393782, 15875216, 11047, 175213, 3552, 677, 78072203, 3590, 95587, 14757054,
                    3021465, 9957, 16173483, 16393831, 15875265, 78072243, 14757099,
                    3021494, 16173516, 16393864, 15875298, 78072287, 14757144]))

        def test_correct_retrieval_3(self):
            """Following issue 1083.

            https://github.com/biopython/biopython/issues/1083
            """
            search = self.idx.search((3012076, 3012076 + 300), (3012076 + 100, 3012076 + 400))
            results = [x for x in search]

            self.assertEqual(len(results), 2)

            self.assertEqual(set([len(x) for x in results]),
                             set([4, 5]))

            # Code formatting note:
            # Expected start coordinates are grouped by alignment blocks
            self.assertEqual(
                set([x.annotations["start"] for y in results for x in y]),
                set([
                    3012076, 16160203, 16379004, 15860456,
                    3012441, 15860899, 16379447, 16160646, 180525]))

        def test_correct_block_boundary(self):
            """Following issues 504 and 1086.

            https://github.com/biopython/biopython/pull/504
            https://github.com/biopython/biopython/pull/1086#issuecomment-285080702

            We test what happens at the boundary between these two MAF blocks:

            a score=19159.000000
            s mm9.chr10                         3014644 45 + 129993255 CCTGTACC---CTTTGGTGAGAATTTTTGTTTCAGTGTTAAAAGTTTG
#.........这里部分代码省略.........
开发者ID:andrewguy,项目名称:biopython,代码行数:103,代码来源:test_MafIO_index.py


注:本文中的Bio.AlignIO.MafIO.MafIndex.search方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。