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


Python Visualization._from_data_dir方法代码示例

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


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

示例1: test_load_with_archive_filepath_modified

# 需要导入模块: from qiime.sdk import Visualization [as 别名]
# 或者: from qiime.sdk.Visualization import _from_data_dir [as 别名]
    def test_load_with_archive_filepath_modified(self):
        # Save a visualization for use in the following test case.
        fp = os.path.join(self.test_dir.name, 'visualization.qza')
        Visualization._from_data_dir(self.data_dir, None).save(fp)

        # Load the visualization from a filepath then save a different
        # visualization to the same filepath. Assert that both visualizations
        # access the correct data.
        #
        # `load` used to be lazy, only extracting data when it needed to (e.g.
        # when `save` or `get_index_paths` was called). This was buggy as the
        # filepath could have been deleted, or worse, modified to contain a
        # different .qzv file. Thus, the wrong archive could be extracted on
        # demand, or the archive could be missing altogether. There isn't an
        # easy cross-platform compatible way to solve this problem, so
        # Visualization.load is no longer lazy and always extracts its data
        # immediately. The real motivation for lazy loading was for quick
        # inspection of archives without extracting/copying data, so that API
        # is now provided through Visualization.peek.
        visualization1 = Visualization.load(fp)

        new_data_dir = os.path.join(self.test_dir.name, 'viz-output2')
        os.mkdir(new_data_dir)
        most_common_viz(new_data_dir, collections.Counter(range(42)))

        Visualization._from_data_dir(new_data_dir, None).save(fp)
        visualization2 = Visualization.load(fp)

        self.assertEqual(visualization1.get_index_paths(),
                         {'html': 'data/index.html'})
        self.assertEqual(visualization2.get_index_paths(),
                         {'html': 'data/index.html', 'tsv': 'data/index.tsv'})
开发者ID:Kleptobismol,项目名称:qiime2,代码行数:34,代码来源:test_visualization.py

示例2: test_ne_same_data_different_uuid

# 需要导入模块: from qiime.sdk import Visualization [as 别名]
# 或者: from qiime.sdk.Visualization import _from_data_dir [as 别名]
    def test_ne_same_data_different_uuid(self):
        visualization1 = Visualization._from_data_dir(
            self.data_dir, self.make_provenance_capture())
        visualization2 = Visualization._from_data_dir(
            self.data_dir, self.make_provenance_capture())

        self.assertNotEqual(visualization1, visualization2)
开发者ID:qiime2,项目名称:qiime2,代码行数:9,代码来源:test_visualization.py

示例3: test_ne_different_data_different_uuid

# 需要导入模块: from qiime.sdk import Visualization [as 别名]
# 或者: from qiime.sdk.Visualization import _from_data_dir [as 别名]
    def test_ne_different_data_different_uuid(self):
        visualization1 = Visualization._from_data_dir(
            self.data_dir, self.make_provenance_capture())

        data_dir = os.path.join(self.test_dir.name, 'mc-viz-output1')
        os.mkdir(data_dir)
        most_common_viz(data_dir,
                        collections.Counter(range(42)))
        visualization2 = Visualization._from_data_dir(
            data_dir, self.make_provenance_capture())

        self.assertNotEqual(visualization1, visualization2)
开发者ID:qiime2,项目名称:qiime2,代码行数:14,代码来源:test_visualization.py

示例4: test_load_and_save

# 需要导入模块: from qiime.sdk import Visualization [as 别名]
# 或者: from qiime.sdk.Visualization import _from_data_dir [as 别名]
    def test_load_and_save(self):
        fp1 = os.path.join(self.test_dir.name, 'visualization1.qzv')
        fp2 = os.path.join(self.test_dir.name, 'visualization2.qzv')
        visualization = Visualization._from_data_dir(self.data_dir,
                                                     self.provenance)
        visualization.save(fp1)

        visualization = Visualization.load(fp1)
        # Overwriting its source file works.
        visualization.save(fp1)
        # Saving to a new file works.
        visualization.save(fp2)

        with zipfile.ZipFile(fp1, mode='r') as zf:
            fps = set(zf.namelist())
            expected = {
                'visualization1/VERSION',
                'visualization1/metadata.yaml',
                'visualization1/README.md',
                'visualization1/data/index.html',
                'visualization1/data/css/style.css'
            }
            self.assertEqual(fps, expected)

        with zipfile.ZipFile(fp2, mode='r') as zf:
            fps = set(zf.namelist())
            expected = {
                'visualization2/VERSION',
                'visualization2/metadata.yaml',
                'visualization2/README.md',
                'visualization2/data/index.html',
                'visualization2/data/css/style.css'
            }
            self.assertEqual(fps, expected)
开发者ID:Kleptobismol,项目名称:qiime2,代码行数:36,代码来源:test_visualization.py

示例5: test_get_index_paths_single_from_data_dir

# 需要导入模块: from qiime.sdk import Visualization [as 别名]
# 或者: from qiime.sdk.Visualization import _from_data_dir [as 别名]
    def test_get_index_paths_single_from_data_dir(self):
        visualization = Visualization._from_data_dir(self.data_dir,
                                                     self.provenance)

        actual = visualization.get_index_paths()
        expected = {'html': 'data/index.html'}
        self.assertEqual(actual, expected)
开发者ID:Kleptobismol,项目名称:qiime2,代码行数:9,代码来源:test_visualization.py

示例6: test_from_data_dir_with_provenance

# 需要导入模块: from qiime.sdk import Visualization [as 别名]
# 或者: from qiime.sdk.Visualization import _from_data_dir [as 别名]
    def test_from_data_dir_with_provenance(self):
        visualization = Visualization._from_data_dir(self.data_dir,
                                                     self.provenance)

        self.assertEqual(visualization.type, qiime.core.type.Visualization)
        self.assertEqual(visualization.provenance, self.provenance)
        self.assertIsInstance(visualization.uuid, uuid.UUID)
开发者ID:Kleptobismol,项目名称:qiime2,代码行数:9,代码来源:test_visualization.py

示例7: test_from_data_dir

# 需要导入模块: from qiime.sdk import Visualization [as 别名]
# 或者: from qiime.sdk.Visualization import _from_data_dir [as 别名]
    def test_from_data_dir(self):
        visualization = Visualization._from_data_dir(self.data_dir, None)

        self.assertEqual(visualization.type, qiime.core.type.Visualization)
        self.assertIsNone(visualization.provenance)
        # We don't know what the UUID is because it's generated within
        # Visualization._from_data_dir.
        self.assertIsInstance(visualization.uuid, uuid.UUID)
开发者ID:Kleptobismol,项目名称:qiime2,代码行数:10,代码来源:test_visualization.py

示例8: test_eq_same_uuid

# 需要导入模块: from qiime.sdk import Visualization [as 别名]
# 或者: from qiime.sdk.Visualization import _from_data_dir [as 别名]
    def test_eq_same_uuid(self):
        fp = os.path.join(self.test_dir.name, 'visualization.qzv')
        visualization1 = Visualization._from_data_dir(
            self.data_dir, self.make_provenance_capture())
        visualization1.save(fp)

        visualization2 = Visualization.load(fp)

        self.assertEqual(visualization1, visualization2)
开发者ID:qiime2,项目名称:qiime2,代码行数:11,代码来源:test_visualization.py

示例9: test_load

# 需要导入模块: from qiime.sdk import Visualization [as 别名]
# 或者: from qiime.sdk.Visualization import _from_data_dir [as 别名]
    def test_load(self):
        saved_visualization = Visualization._from_data_dir(self.data_dir, None)
        fp = os.path.join(self.test_dir.name, 'visualization.qzv')
        saved_visualization.save(fp)

        visualization = Visualization.load(fp)

        self.assertEqual(visualization.type, qiime.core.type.Visualization)
        self.assertIsNone(visualization.provenance)
        self.assertEqual(visualization.uuid, saved_visualization.uuid)
开发者ID:Kleptobismol,项目名称:qiime2,代码行数:12,代码来源:test_visualization.py

示例10: test_get_index_paths_multiple_html_from_data_dir

# 需要导入模块: from qiime.sdk import Visualization [as 别名]
# 或者: from qiime.sdk.Visualization import _from_data_dir [as 别名]
    def test_get_index_paths_multiple_html_from_data_dir(self):
        data_dir = os.path.join(self.test_dir.name, 'multi-html-viz2')
        os.mkdir(data_dir)
        multi_html_viz(data_dir, [1, 42])

        visualization = Visualization._from_data_dir(data_dir,
                                                     self.provenance)

        with self.assertRaises(ValueError):
            visualization.get_index_paths()
开发者ID:Kleptobismol,项目名称:qiime2,代码行数:12,代码来源:test_visualization.py

示例11: test_get_index_paths_single_load

# 需要导入模块: from qiime.sdk import Visualization [as 别名]
# 或者: from qiime.sdk.Visualization import _from_data_dir [as 别名]
    def test_get_index_paths_single_load(self):
        fp = os.path.join(self.test_dir.name, 'visualization.qzv')
        visualization = Visualization._from_data_dir(self.data_dir,
                                                     self.provenance)
        visualization.save(fp)
        visualization = Visualization.load(fp)

        actual = visualization.get_index_paths()
        expected = {'html': 'data/index.html'}
        self.assertEqual(actual, expected)
开发者ID:Kleptobismol,项目名称:qiime2,代码行数:12,代码来源:test_visualization.py

示例12: test_load_visualization

# 需要导入模块: from qiime.sdk import Visualization [as 别名]
# 或者: from qiime.sdk.Visualization import _from_data_dir [as 别名]
    def test_load_visualization(self):
        saved_visualization = Visualization._from_data_dir(
             self.data_dir, self.make_provenance_capture())
        fp = os.path.join(self.test_dir.name, 'visualization.qzv')
        saved_visualization.save(fp)

        visualization = Result.load(fp)

        self.assertIsInstance(visualization, Visualization)
        self.assertEqual(visualization.type, qiime.core.type.Visualization)
        self.assertEqual(visualization.uuid, saved_visualization.uuid)
开发者ID:qiime2,项目名称:qiime2,代码行数:13,代码来源:test_result.py

示例13: test_peek

# 需要导入模块: from qiime.sdk import Visualization [as 别名]
# 或者: from qiime.sdk.Visualization import _from_data_dir [as 别名]
    def test_peek(self):
        visualization = Visualization._from_data_dir(self.data_dir, None)
        fp = os.path.join(self.test_dir.name, 'visualization.qza')
        visualization.save(fp)

        metadata = Visualization.peek(fp)

        self.assertIsInstance(metadata, ResultMetadata)
        self.assertEqual(metadata.type, qiime.core.type.Visualization)
        self.assertIsNone(metadata.provenance)
        self.assertEqual(metadata.uuid, visualization.uuid)
开发者ID:Kleptobismol,项目名称:qiime2,代码行数:13,代码来源:test_visualization.py

示例14: test_get_index_paths_multiple_from_data_dir

# 需要导入模块: from qiime.sdk import Visualization [as 别名]
# 或者: from qiime.sdk.Visualization import _from_data_dir [as 别名]
    def test_get_index_paths_multiple_from_data_dir(self):
        data_dir = os.path.join(self.test_dir.name, 'mc-viz-output2')
        os.mkdir(data_dir)
        most_common_viz(data_dir, collections.Counter(range(42)))
        visualization = Visualization._from_data_dir(data_dir,
                                                     self.provenance)

        actual = visualization.get_index_paths()
        expected = {'html': 'data/index.html',
                    'tsv': 'data/index.tsv'}
        self.assertEqual(actual, expected)
开发者ID:Kleptobismol,项目名称:qiime2,代码行数:13,代码来源:test_visualization.py

示例15: test_peek_visualization

# 需要导入模块: from qiime.sdk import Visualization [as 别名]
# 或者: from qiime.sdk.Visualization import _from_data_dir [as 别名]
    def test_peek_visualization(self):
        visualization = Visualization._from_data_dir(
             self.data_dir, self.make_provenance_capture())
        fp = os.path.join(self.test_dir.name, 'visualization.qzv')
        visualization.save(fp)

        metadata = Result.peek(fp)

        self.assertIsInstance(metadata, ResultMetadata)
        self.assertEqual(metadata.type, 'Visualization')
        self.assertEqual(metadata.uuid, str(visualization.uuid))
        self.assertIsNone(metadata.format)
开发者ID:qiime2,项目名称:qiime2,代码行数:14,代码来源:test_result.py


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