# Path: q2_types/tree/_format.py
# class NewickFormat(model.TextFileFormat):
#     def sniff(self):
#         sniffer = skbio.io.io_registry.get_sniffer('newick')
#         return sniffer(str(self))[0]


import unittest
import skbio
from q2_types.tree import NewickFormat
from qiime2.plugin.testing import TestPluginBase
# ----------------------------------------------------------------------------
# Copyright (c) 2016-2021, QIIME 2 development team.
#
# Distributed under the terms of the Modified BSD License.
#
# The full license is in the file LICENSE, distributed with this software.
# ----------------------------------------------------------------------------





class TestTransformers(TestPluginBase):
    package = "q2_types.tree.tests"

    def test_skbio_tree_node_to_newick_format(self):
        filepath = self.get_data_path('tree.nwk')
        transformer = self.get_transformer(skbio.TreeNode, NewickFormat)
        input = skbio.TreeNode.read(filepath)

        obs = transformer(input)
        obs = skbio.TreeNode.read(str(obs))

        self.assertEqual(str(input), str(obs))

    def test_newick_format_to_skbio_tree_node(self):
        filename = 'tree.nwk'

# Path: q2_types/tree/_format.py
# class NewickFormat(model.TextFileFormat):
#     def sniff(self):
#         sniffer = skbio.io.io_registry.get_sniffer('newick')
#         return sniffer(str(self))[0]


# Path: q2_types/tree/tests/test_transformer.py
import unittest
import skbio
from q2_types.tree import NewickFormat
from qiime2.plugin.testing import TestPluginBase

# ----------------------------------------------------------------------------
# Copyright (c) 2016-2021, QIIME 2 development team.
#
# Distributed under the terms of the Modified BSD License.
#
# The full license is in the file LICENSE, distributed with this software.
# ----------------------------------------------------------------------------





class TestTransformers(TestPluginBase):
    package = "q2_types.tree.tests"

    def test_skbio_tree_node_to_newick_format(self):
        filepath = self.get_data_path('tree.nwk')
        transformer = self.get_transformer(skbio.TreeNode, NewickFormat)
        input = skbio.TreeNode.read(filepath)

        obs = transformer(input)
        obs = skbio.TreeNode.read(str(obs))

        self.assertEqual(str(input), str(obs))

    def test_newick_format_to_skbio_tree_node(self):
        filename = 'tree.nwk'

        input, obs = self.transform_format(NewickFormat, skbio.TreeNode,