# Path: q2_types/ordination/_format.py
# class OrdinationFormat(model.TextFileFormat):
#     def sniff(self):
#         sniffer = skbio.io.io_registry.get_sniffer('ordination')
#         return sniffer(str(self))[0]
# 
# class ProcrustesStatisticsFmt(model.TextFileFormat):
#     METADATA_COLUMNS = {
#         'true M^2 value',
#         'p-value for true M^2 value',
#         'number of Monte Carlo permutations',
#     }
# 
#     def validate(self, level):
#         try:
#             md = qiime2.Metadata.load(str(self))
#         except qiime2.metadata.MetadataFileError as md_exc:
#             raise ValidationError(md_exc) from md_exc
# 
#         for column in sorted(self.METADATA_COLUMNS):
#             try:
#                 md.get_column(column)
#             except ValueError as md_exc:
#                 raise ValidationError(md_exc) from md_exc


import unittest
import skbio
import pandas as pd
import pandas.testing as pdt
import qiime2
from q2_types.ordination import OrdinationFormat, ProcrustesStatisticsFmt
from qiime2.plugin.testing import TestPluginBase
#
# The full license is in the file LICENSE, distributed with this software.
# ----------------------------------------------------------------------------





class TestTransformers(TestPluginBase):
    package = 'q2_types.ordination.tests'

    def test_skbio_ordination_results_to_ordination_format(self):
        filenames = ('pcoa-results-1x1.txt', 'pcoa-results-2x2.txt',
                     'pcoa-results-NxN.txt')
        for filename in filenames:
            filepath = self.get_data_path(filename)
            transformer = self.get_transformer(skbio.OrdinationResults,
                                               OrdinationFormat)
            input = skbio.OrdinationResults.read(filepath)

            obs = transformer(input)
            self.assertIsInstance(obs, OrdinationFormat)
            obs = skbio.OrdinationResults.read(str(obs))

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

    def test_ordination_format_to_skbio_ordination_results(self):
        filenames = ('pcoa-results-1x1.txt', 'pcoa-results-2x2.txt',
                     'pcoa-results-NxN.txt')
        for filename in filenames:

# Path: q2_types/ordination/_format.py
# class OrdinationFormat(model.TextFileFormat):
#     def sniff(self):
#         sniffer = skbio.io.io_registry.get_sniffer('ordination')
#         return sniffer(str(self))[0]
# 
# class ProcrustesStatisticsFmt(model.TextFileFormat):
#     METADATA_COLUMNS = {
#         'true M^2 value',
#         'p-value for true M^2 value',
#         'number of Monte Carlo permutations',
#     }
# 
#     def validate(self, level):
#         try:
#             md = qiime2.Metadata.load(str(self))
#         except qiime2.metadata.MetadataFileError as md_exc:
#             raise ValidationError(md_exc) from md_exc
# 
#         for column in sorted(self.METADATA_COLUMNS):
#             try:
#                 md.get_column(column)
#             except ValueError as md_exc:
#                 raise ValidationError(md_exc) from md_exc


# Path: q2_types/ordination/tests/test_transformer.py
import unittest
import skbio
import pandas as pd
import pandas.testing as pdt
import qiime2
from q2_types.ordination import OrdinationFormat, ProcrustesStatisticsFmt
from qiime2.plugin.testing import TestPluginBase

#
# The full license is in the file LICENSE, distributed with this software.
# ----------------------------------------------------------------------------





class TestTransformers(TestPluginBase):
    package = 'q2_types.ordination.tests'

    def test_skbio_ordination_results_to_ordination_format(self):
        filenames = ('pcoa-results-1x1.txt', 'pcoa-results-2x2.txt',
                     'pcoa-results-NxN.txt')
        for filename in filenames:
            filepath = self.get_data_path(filename)
            transformer = self.get_transformer(skbio.OrdinationResults,
                                               OrdinationFormat)
            input = skbio.OrdinationResults.read(filepath)

            obs = transformer(input)
            self.assertIsInstance(obs, OrdinationFormat)
            obs = skbio.OrdinationResults.read(str(obs))

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

    def test_ordination_format_to_skbio_ordination_results(self):
        filenames = ('pcoa-results-1x1.txt', 'pcoa-results-2x2.txt',
                     'pcoa-results-NxN.txt')
        for filename in filenames:

            input, obs = self.transform_format(OrdinationFormat,