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


Python DissimilarityMatrix.from_file方法代码示例

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


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

示例1: test_round_trip_read_write

# 需要导入模块: from skbio.core.distance import DissimilarityMatrix [as 别名]
# 或者: from skbio.core.distance.DissimilarityMatrix import from_file [as 别名]
    def test_round_trip_read_write(self):
        """Test reading, writing, and reading again works as expected."""
        for dm_f in self.dm_fs:
            # Read.
            dm1 = DissimilarityMatrix.from_file(dm_f)

            # Write.
            out_f = StringIO()
            dm1.to_file(out_f)
            out_f.seek(0)

            # Read.
            dm2 = DissimilarityMatrix.from_file(out_f)
            self.assertEqual(dm1, dm2)
开发者ID:charudatta-navare,项目名称:scikit-bio,代码行数:16,代码来源:test_distance.py

示例2: test_from_file_with_file_path

# 需要导入模块: from skbio.core.distance import DissimilarityMatrix [as 别名]
# 或者: from skbio.core.distance.DissimilarityMatrix import from_file [as 别名]
    def test_from_file_with_file_path(self):
        """Should identify the filepath correctly and parse from it."""

        # should fail with the expected exception
        with self.assertRaises(DissimilarityMatrixFormatError):
            DissimilarityMatrix.from_file(self.bad_dm_fp)

        obs = DissimilarityMatrix.from_file(self.dm_2x2_asym_fp)
        self.assertEqual(self.dm_2x2_asym, obs)
        self.assertTrue(isinstance(obs, DissimilarityMatrix))

        obs = DissimilarityMatrix.from_file(self.dm_3x3_fp)
        self.assertEqual(self.dm_3x3, obs)
        self.assertTrue(isinstance(obs, DissimilarityMatrix))
开发者ID:charudatta-navare,项目名称:scikit-bio,代码行数:16,代码来源:test_distance.py

示例3: test_from_file_real_file

# 需要导入模块: from skbio.core.distance import DissimilarityMatrix [as 别名]
# 或者: from skbio.core.distance.DissimilarityMatrix import from_file [as 别名]
    def test_from_file_real_file(self):
        """Should correctly parse a real on-disk file."""
        self.tmp_f.write('\n'.join(DM_3x3_WHITESPACE_F))
        self.tmp_f.seek(0)

        obs = DissimilarityMatrix.from_file(self.tmp_f)
        self.assertEqual(obs, self.dm_3x3)
开发者ID:Jorge-C,项目名称:bipy,代码行数:9,代码来源:test_distance.py

示例4: test_from_file_invalid_input

# 需要导入模块: from skbio.core.distance import DissimilarityMatrix [as 别名]
# 或者: from skbio.core.distance.DissimilarityMatrix import from_file [as 别名]
    def test_from_file_invalid_input(self):
        """Raises error on ill-formatted dissimilarity matrix file."""
        # Empty dm.
        with self.assertRaises(DissimilarityMatrixFormatError):
            _ = DissimilarityMatrix.from_file([])

        # Number of values don't match number of IDs.
        with self.assertRaises(DissimilarityMatrixFormatError):
            _ = DissimilarityMatrix.from_file(self.bad_dm_f1)

        # Mismatched IDs.
        with self.assertRaises(DissimilarityMatrixFormatError):
            _ = DissimilarityMatrix.from_file(self.bad_dm_f2)

        # Extra data at end.
        with self.assertRaises(DissimilarityMatrixFormatError):
            _ = DissimilarityMatrix.from_file(self.bad_dm_f3)

        # Missing data.
        with self.assertRaises(DissimilarityMatrixFormatError):
            _ = DissimilarityMatrix.from_file(self.bad_dm_f4)

        # Header, but no data.
        with self.assertRaises(DissimilarityMatrixFormatError):
            _ = DissimilarityMatrix.from_file(self.bad_dm_f5)

        # Non-hollow.
        with self.assertRaises(DissimilarityMatrixError):
            _ = DissimilarityMatrix.from_file(self.bad_dm_f6)
开发者ID:Jorge-C,项目名称:bipy,代码行数:31,代码来源:test_distance.py

示例5: test_from_file_real_file

# 需要导入模块: from skbio.core.distance import DissimilarityMatrix [as 别名]
# 或者: from skbio.core.distance.DissimilarityMatrix import from_file [as 别名]
    def test_from_file_real_file(self):
        """Should correctly parse a real on-disk file."""
        with tempfile.TemporaryFile(mode='r+',
                                    prefix='skbio.core.tests.test_distance',
                                    suffix='.txt') as fh:
            fh.write('\n'.join(DM_3x3_WHITESPACE_F))
            fh.seek(0)

            obs = DissimilarityMatrix.from_file(fh)
        self.assertEqual(obs, self.dm_3x3)
开发者ID:charudatta-navare,项目名称:scikit-bio,代码行数:12,代码来源:test_distance.py

示例6: test_from_file_list_of_strings

# 需要导入模块: from skbio.core.distance import DissimilarityMatrix [as 别名]
# 或者: from skbio.core.distance.DissimilarityMatrix import from_file [as 别名]
 def test_from_file_list_of_strings(self):
     """Should correctly parse a list of strings."""
     obs = DissimilarityMatrix.from_file(DM_3x3_WHITESPACE_F)
     self.assertEqual(obs, self.dm_3x3)
开发者ID:charudatta-navare,项目名称:scikit-bio,代码行数:6,代码来源:test_distance.py

示例7: test_from_file_extra_junk

# 需要导入模块: from skbio.core.distance import DissimilarityMatrix [as 别名]
# 或者: from skbio.core.distance.DissimilarityMatrix import from_file [as 别名]
 def test_from_file_extra_junk(self):
     """Should correctly parse a file with extra whitespace and comments."""
     obs = DissimilarityMatrix.from_file(self.dm_3x3_whitespace_f)
     self.assertEqual(obs, self.dm_3x3)
开发者ID:charudatta-navare,项目名称:scikit-bio,代码行数:6,代码来源:test_distance.py

示例8: test_from_file

# 需要导入模块: from skbio.core.distance import DissimilarityMatrix [as 别名]
# 或者: from skbio.core.distance.DissimilarityMatrix import from_file [as 别名]
 def test_from_file(self):
     """Should parse and return a valid DissimilarityMatrix given a file."""
     for dm_f, dm in zip(self.dm_fs, self.dms):
         obs = DissimilarityMatrix.from_file(dm_f)
         self.assertEqual(obs, dm)
开发者ID:charudatta-navare,项目名称:scikit-bio,代码行数:7,代码来源:test_distance.py


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