예제 #1
0
    def setUp(self):
        get_dummy_plugin()
        self.runner = CliRunner()
        self.plugin_command = RootCommand().get_command(ctx=None,
                                                        name='dummy-plugin')
        self.tempdir = tempfile.mkdtemp(prefix='qiime2-q2cli-test-temp-')

        self.input_artifact = os.path.join(self.tempdir, 'in.qza')
        Artifact.import_data(IntSequence1, [0, 42, 43],
                             list).save(self.input_artifact)
        self.output_artifact = os.path.join(self.tempdir, 'out.qza')

        self.metadata_file1 = os.path.join(self.tempdir, 'metadata1.tsv')
        with open(self.metadata_file1, 'w') as f:
            f.write('id\tcol1\n0\tfoo\nid1\tbar\n')

        self.metadata_file_alt_id_header = os.path.join(
            self.tempdir, 'metadata-alt-id-header.tsv')
        with open(self.metadata_file_alt_id_header, 'w') as f:
            f.write('#SampleID\tcol1\n0\tfoo\nid1\tbar\n')

        self.metadata_file2 = os.path.join(self.tempdir, 'metadata2.tsv')
        with open(self.metadata_file2, 'w') as f:
            f.write('id\tcol2\n0\tbaz\nid1\tbaa\n')

        self.metadata_file_mixed_types = os.path.join(
            self.tempdir, 'metadata-mixed-types.tsv')
        with open(self.metadata_file_mixed_types, 'w') as f:
            f.write('id\tnumbers\tstrings\nid1\t42\tabc\nid2\t-1.5\tdef\n')

        self.metadata_artifact = os.path.join(self.tempdir, 'metadata.qza')
        Artifact.import_data('Mapping', {
            'a': 'dog',
            'b': 'cat'
        }).save(self.metadata_artifact)
예제 #2
0
    def setUp(self):
        get_dummy_plugin()
        self.runner = CliRunner()
        self.tempdir = tempfile.mkdtemp(prefix='qiime2-q2cli-test-temp-')

        self.parser = configparser.ConfigParser()
        self.path = os.path.join(q2cli.util.get_app_dir(), 'cli-colors.theme')
예제 #3
0
    def setUp(self):
        # Ignore the returned dummy plugin object, just run this to verify the
        # plugin exists as the tests rely on it being loaded.
        get_dummy_plugin()

        # TODO standardize temporary directories created by QIIME 2
        self.test_dir = tempfile.TemporaryDirectory(prefix='qiime2-test-temp-')
        self.provenance_capture = archive.ImportProvenanceCapture()
예제 #4
0
    def setUp(self):
        # Ignore the returned dummy plugin object, just run this to verify the
        # plugin exists as the tests rely on it being loaded.
        get_dummy_plugin()

        # TODO standardize temporary directories created by QIIME 2
        self.test_dir = tempfile.TemporaryDirectory(prefix='qiime2-test-temp-')
        self.provenance_capture = archive.ImportProvenanceCapture()
예제 #5
0
    def setUp(self):
        get_dummy_plugin()
        self.runner = CliRunner()
        self.tempdir = tempfile.mkdtemp(prefix='qiime2-q2cli-test-temp-')
        self.artifact1_path = os.path.join(self.tempdir, 'a1.qza')
        self.mapping_path = os.path.join(self.tempdir, 'mapping.qza')

        artifact1 = Artifact.import_data(IntSequence1, [0, 42, 43])
        artifact1.save(self.artifact1_path)
        self.artifact1_root_dir = str(artifact1.uuid)

        mapping = Artifact.import_data('Mapping', {'foo': '42'})
        mapping.save(self.mapping_path)
예제 #6
0
파일: test_cli.py 프로젝트: jakereps/q2cli
    def setUp(self):
        get_dummy_plugin()
        self.runner = CliRunner()
        self.tempdir = tempfile.mkdtemp(prefix='qiime2-q2cli-test-temp-')
        self.artifact1_path = os.path.join(self.tempdir, 'a1.qza')
        self.mapping_path = os.path.join(self.tempdir, 'mapping.qza')

        artifact1 = Artifact.import_data(IntSequence1, [0, 42, 43])
        artifact1.save(self.artifact1_path)
        self.artifact1_root_dir = str(artifact1.uuid)

        mapping = Artifact.import_data('Mapping', {'foo': '42'})
        mapping.save(self.mapping_path)
예제 #7
0
    def setUp(self):
        # Ignore the returned dummy plugin object, just run this to verify the
        # plugin exists as the tests rely on it being loaded.
        get_dummy_plugin()

        # TODO standardize temporary directories created by QIIME 2
        self.test_dir = tempfile.TemporaryDirectory(prefix='qiime2-test-temp-')

        self.data_dir = os.path.join(self.test_dir.name, 'viz-output')
        os.mkdir(self.data_dir)
        mapping_viz(self.data_dir,
                    {'abc': 'foo', 'def': 'bar'},
                    {'ghi': 'baz', 'jkl': 'bazz'},
                    key_label='Key', value_label='Value')
예제 #8
0
    def setUp(self):
        get_dummy_plugin()

        self.runner = CliRunner()
        self.plugin_command = RootCommand().get_command(ctx=None,
                                                        name='dummy-plugin')
        self.tempdir = tempfile.mkdtemp(prefix='qiime2-q2cli-test-temp-')

        self.ints1 = os.path.join(self.tempdir, 'ints1.qza')
        Artifact.import_data(IntSequence1, [0, 42, 43], list).save(self.ints1)
        self.ints2 = os.path.join(self.tempdir, 'ints2.qza')
        Artifact.import_data(IntSequence1, [99, -22], list).save(self.ints2)
        self.ints3 = os.path.join(self.tempdir, 'ints3.qza')
        Artifact.import_data(IntSequence2, [43, 43], list).save(self.ints3)
        self.output = os.path.join(self.tempdir, 'output.qza')
예제 #9
0
    def setUp(self):
        dummy_plugin = get_dummy_plugin()

        self.runner = CliRunner()
        self.tempdir = tempfile.mkdtemp(prefix='qiime2-q2cli-test-temp-')

        self.metadata_file_mixed_types = os.path.join(
                self.tempdir, 'metadata-mixed-types.tsv')
        with open(self.metadata_file_mixed_types, 'w') as f:
            f.write('id\tnumbers\tstrings\n0\t42\tabc\n1\t-1.5\tdef\n')

        self.bad_metadata_file = os.path.join(
                self.tempdir, 'bad-metadata.tsv')
        with open(self.bad_metadata_file, 'w') as f:
            f.write('wrong\tnumbers\tstrings\nid1\t42\tabc\nid2\t-1.5\tdef\n')

        self.metadata_artifact = os.path.join(self.tempdir, 'metadata.qza')
        Artifact.import_data(
            'Mapping', {'a': 'dog', 'b': 'cat'}).save(self.metadata_artifact)

        self.ints1 = os.path.join(self.tempdir, 'ints1.qza')
        ints1 = Artifact.import_data(
            'IntSequence1', [0, 42, 43], list)
        ints1.save(self.ints1)

        self.ints2 = os.path.join(self.tempdir, 'ints')
        ints1.export_data(self.ints2)

        self.viz = os.path.join(self.tempdir, 'viz.qzv')
        most_common_viz = dummy_plugin.actions['most_common_viz']
        self.viz = most_common_viz(ints1).visualization.save(self.viz)
예제 #10
0
    def setUp(self):
        dummy_plugin = get_dummy_plugin()

        self.runner = CliRunner()
        self.tempdir = tempfile.mkdtemp(prefix='qiime2-q2cli-test-temp-')

        self.metadata_file_mixed_types = os.path.join(
            self.tempdir, 'metadata-mixed-types.tsv')
        with open(self.metadata_file_mixed_types, 'w') as f:
            f.write('id\tnumbers\tstrings\n0\t42\tabc\n1\t-1.5\tdef\n')

        self.bad_metadata_file = os.path.join(self.tempdir, 'bad-metadata.tsv')
        with open(self.bad_metadata_file, 'w') as f:
            f.write('wrong\tnumbers\tstrings\nid1\t42\tabc\nid2\t-1.5\tdef\n')

        self.metadata_artifact = os.path.join(self.tempdir, 'metadata.qza')
        Artifact.import_data('Mapping', {
            'a': 'dog',
            'b': 'cat'
        }).save(self.metadata_artifact)

        self.ints1 = os.path.join(self.tempdir, 'ints1.qza')
        ints1 = Artifact.import_data('IntSequence1', [0, 42, 43], list)
        ints1.save(self.ints1)

        self.ints2 = os.path.join(self.tempdir, 'ints')
        ints1.export_data(self.ints2)

        self.viz = os.path.join(self.tempdir, 'viz.qzv')
        most_common_viz = dummy_plugin.actions['most_common_viz']
        self.viz = most_common_viz(ints1).visualization.save(self.viz)
예제 #11
0
    def setUp(self):
        self.plugin = get_dummy_plugin()

        self.concatenate_ints_sig = MethodSignature(
            concatenate_ints,
            inputs={
                'ints1': IntSequence1 | IntSequence2,
                'ints2': IntSequence1,
                'ints3': IntSequence2
            },
            parameters={
                'int1': qiime2.plugin.Int,
                'int2': qiime2.plugin.Int
            },
            outputs=[
                ('concatenated_ints', IntSequence1)
            ]
        )

        self.split_ints_sig = MethodSignature(
            split_ints,
            inputs={
                'ints': IntSequence1
            },
            parameters={},
            outputs=[
                ('left', IntSequence1),
                ('right', IntSequence1)
            ]
        )
예제 #12
0
    def setUp(self):
        self.plugin = get_dummy_plugin()

        # TODO standardize temporary directories created by QIIME 2
        # create a temporary data_dir for sample Visualizations
        self.test_dir = tempfile.TemporaryDirectory(prefix='qiime2-test-temp-')
        self.data_dir = os.path.join(self.test_dir.name, 'viz-output')
        os.mkdir(self.data_dir)
예제 #13
0
파일: test_cli.py 프로젝트: jakereps/q2cli
    def setUp(self):
        get_dummy_plugin()
        self.runner = CliRunner()
        self.plugin_command = RootCommand().get_command(
            ctx=None, name='dummy-plugin')
        self.tempdir = tempfile.mkdtemp(prefix='qiime2-q2cli-test-temp-')

        self.input_artifact = os.path.join(self.tempdir, 'in.qza')
        Artifact.import_data(
            IntSequence1, [0, 42, 43], list).save(self.input_artifact)
        self.output_artifact = os.path.join(self.tempdir, 'out.qza')

        self.metadata_file1 = os.path.join(self.tempdir, 'metadata1.tsv')
        with open(self.metadata_file1, 'w') as f:
            f.write('id\tcol1\n0\tfoo\nid1\tbar\n')

        self.metadata_file_alt_id_header = os.path.join(
                self.tempdir, 'metadata-alt-id-header.tsv')
        with open(self.metadata_file_alt_id_header, 'w') as f:
            f.write('#SampleID\tcol1\n0\tfoo\nid1\tbar\n')

        self.metadata_file2 = os.path.join(self.tempdir, 'metadata2.tsv')
        with open(self.metadata_file2, 'w') as f:
            f.write('id\tcol2\n0\tbaz\nid1\tbaa\n')

        self.metadata_file_mixed_types = os.path.join(
                self.tempdir, 'metadata-mixed-types.tsv')
        with open(self.metadata_file_mixed_types, 'w') as f:
            f.write('id\tnumbers\tstrings\nid1\t42\tabc\nid2\t-1.5\tdef\n')

        self.metadata_artifact = os.path.join(self.tempdir, 'metadata.qza')
        Artifact.import_data(
            'Mapping', {'a': 'dog', 'b': 'cat'}).save(self.metadata_artifact)

        self.cmd_config = os.path.join(self.tempdir, 'conf.ini')
        with open(self.cmd_config, 'w') as f:
            f.write('[dummy-plugin.identity-with-metadata]\n'
                    'm-metadata-file=%s\n' % self.metadata_file1)
            f.write('[dummy-plugin.identity-with-optional-metadata]\n'
                    'm-metadata-file=%s\n' % self.metadata_file1)
            f.write('[dummy-plugin.identity-with-metadata-column]\n'
                    'm-metadata-file=%s\n'
                    'm-metadata-column=col1\n' % self.metadata_file1)
            f.write('[dummy-plugin.identity-with-optional-metadata-column]\n'
                    'm-metadata-file=%s\n'
                    'm-metadata-column=col1\n' % self.metadata_file1)
예제 #14
0
파일: test_cli.py 프로젝트: jakereps/q2cli
    def setUp(self):
        get_dummy_plugin()

        self.runner = CliRunner()
        self.plugin_command = RootCommand().get_command(
            ctx=None, name='dummy-plugin')
        self.tempdir = tempfile.mkdtemp(prefix='qiime2-q2cli-test-temp-')

        self.ints1 = os.path.join(self.tempdir, 'ints1.qza')
        Artifact.import_data(
            IntSequence1, [0, 42, 43], list).save(self.ints1)
        self.ints2 = os.path.join(self.tempdir, 'ints2.qza')
        Artifact.import_data(
            IntSequence1, [99, -22], list).save(self.ints2)
        self.ints3 = os.path.join(self.tempdir, 'ints3.qza')
        Artifact.import_data(
            IntSequence2, [43, 43], list).save(self.ints3)
        self.output = os.path.join(self.tempdir, 'output.qza')
예제 #15
0
    def setUp(self):
        # Ignore the returned dummy plugin object, just run this to verify the
        # plugin exists as the tests rely on it being loaded.
        get_dummy_plugin()

        # TODO standardize temporary directories created by QIIME 2
        self.test_dir = tempfile.TemporaryDirectory(prefix='qiime2-test-temp-')

        self.data_dir = os.path.join(self.test_dir.name, 'viz-output')
        os.mkdir(self.data_dir)
        mapping_viz(self.data_dir, {
            'abc': 'foo',
            'def': 'bar'
        }, {
            'ghi': 'baz',
            'jkl': 'bazz'
        },
                    key_label='Key',
                    value_label='Value')
예제 #16
0
def get_rt_tests():
    tests = []
    try:
        plugin = get_dummy_plugin()
    except RuntimeError:
        return tests

    for action in plugin.actions.values():
        for name in action.examples:
            tests.append((action, name))

    return tests
예제 #17
0
    def setUp(self):
        get_dummy_plugin()
        self.parser = configparser.ConfigParser()
        self.runner = CliRunner(mix_stderr=False)
        self.tempdir = tempfile.mkdtemp(prefix='qiime2-q2cli-test-temp-')
        self.generated_config = os.path.join(self.tempdir, 'generated-theme')

        self.tempdir = tempfile.mkdtemp(prefix='qiime2-q2cli-test-temp-')
        self.artifact1_path = os.path.join(self.tempdir, 'a1.qza')
        self.mapping_path = os.path.join(self.tempdir, 'mapping.qza')

        artifact1 = Artifact.import_data(IntSequence1, [0, 42, 43])
        artifact1.save(self.artifact1_path)
        self.artifact1_root_dir = str(artifact1.uuid)

        mapping = Artifact.import_data('Mapping', {'foo': '42'})
        mapping.save(self.mapping_path)

        self.config = os.path.join(self.tempdir, 'good-config.ini')
        self.parser['type'] = {'underline': 't'}
        with open(self.config, 'w') as fh:
            self.parser.write(fh)
예제 #18
0
    def setUp(self):
        get_dummy_plugin()
        self.runner = CliRunner()
        self.plugin_command = RootCommand().get_command(ctx=None,
                                                        name='dummy-plugin')
        self.tempdir = tempfile.mkdtemp(prefix='qiime2-q2cli-test-temp-')

        self.input_artifact = os.path.join(self.tempdir, 'in.qza')
        Artifact.import_data(IntSequence1, [0, 42, 43],
                             list).save(self.input_artifact)
        self.output_artifact = os.path.join(self.tempdir, 'out.qza')

        self.metadata_file1 = os.path.join(self.tempdir, 'metadata1.tsv')
        with open(self.metadata_file1, 'w') as f:
            f.write('id\tcol1\n0\tfoo\nid1\tbar\n')

        self.metadata_file2 = os.path.join(self.tempdir, 'metadata2.tsv')
        with open(self.metadata_file2, 'w') as f:
            f.write('id\tcol2\n0\tbaz\nid1\tbaa\n')

        self.metadata_artifact = os.path.join(self.tempdir, 'metadata.qza')
        Artifact.import_data('Mapping', {
            'a': 'dog',
            'b': 'cat'
        }).save(self.metadata_artifact)

        self.cmd_config = os.path.join(self.tempdir, 'conf.ini')
        with open(self.cmd_config, 'w') as f:
            f.write('[dummy-plugin.identity-with-metadata]\n'
                    'm-metadata-file=%s\n' % self.metadata_file1)
            f.write('[dummy-plugin.identity-with-optional-metadata]\n'
                    'm-metadata-file=%s\n' % self.metadata_file1)
            f.write('[dummy-plugin.identity-with-metadata-category]\n'
                    'm-metadata-file=%s\n'
                    'm-metadata-category=col1\n' % self.metadata_file1)
            f.write('[dummy-plugin.identity-with-optional-metadata-category]\n'
                    'm-metadata-file=%s\n'
                    'm-metadata-category=col1\n' % self.metadata_file1)
예제 #19
0
    def setUp(self):
        get_dummy_plugin()
        self.runner = CliRunner()
        self.plugin_command = RootCommand().get_command(
            ctx=None, name='dummy-plugin')
        self.tempdir = tempfile.mkdtemp(prefix='qiime2-q2cli-test-temp-')

        self.input_artifact = os.path.join(self.tempdir, 'in.qza')
        Artifact.import_data(
            IntSequence1, [0, 42, 43], list).save(self.input_artifact)
        self.output_artifact = os.path.join(self.tempdir, 'out.qza')

        self.metadata_file1 = os.path.join(self.tempdir, 'metadata1.tsv')
        with open(self.metadata_file1, 'w') as f:
            f.write('id\tcol1\n0\tfoo\nid1\tbar\n')

        self.metadata_file2 = os.path.join(self.tempdir, 'metadata2.tsv')
        with open(self.metadata_file2, 'w') as f:
            f.write('id\tcol2\n0\tbaz\nid1\tbaa\n')

        self.metadata_artifact = os.path.join(self.tempdir, 'metadata.qza')
        Artifact.import_data(
            'Mapping', {'a': 'dog', 'b': 'cat'}).save(self.metadata_artifact)

        self.cmd_config = os.path.join(self.tempdir, 'conf.ini')
        with open(self.cmd_config, 'w') as f:
            f.write('[dummy-plugin.identity-with-metadata]\n'
                    'm-metadata-file=%s\n' % self.metadata_file1)
            f.write('[dummy-plugin.identity-with-optional-metadata]\n'
                    'm-metadata-file=%s\n' % self.metadata_file1)
            f.write('[dummy-plugin.identity-with-metadata-category]\n'
                    'm-metadata-file=%s\n'
                    'm-metadata-category=col1\n' % self.metadata_file1)
            f.write('[dummy-plugin.identity-with-optional-metadata-category]\n'
                    'm-metadata-file=%s\n'
                    'm-metadata-category=col1\n' % self.metadata_file1)
예제 #20
0
    def test_assert_result_type_visualization_success(self):
        dummy_plugin = get_dummy_plugin()

        self.viz_path = os.path.join(self.tempdir, 'viz.qzv')
        most_common_viz = dummy_plugin.actions['most_common_viz']
        viz = most_common_viz(Artifact.load(self.artifact1_path))
        viz.visualization.save(self.viz_path)

        result = self.runner.invoke(dev, [
            'assert-result-type', self.viz_path, '--qiime-type',
            'Visualization'
        ])

        expected_regex = r'The input file \(.*viz\.qzv\) type and the'\
                         r' expected type \(Visualization\) match'

        self.assertEqual(result.exit_code, 0)
        self.assertRegex(result.stdout, expected_regex)
예제 #21
0
    def setUp(self):
        self.plugin = get_dummy_plugin()

        self.concatenate_ints_sig = MethodSignature(
            concatenate_ints,
            inputs={
                'ints1': IntSequence1 | IntSequence2,
                'ints2': IntSequence1,
                'ints3': IntSequence2
            },
            parameters={
                'int1': qiime2.plugin.Int,
                'int2': qiime2.plugin.Int
            },
            outputs=[('concatenated_ints', IntSequence1)])

        self.split_ints_sig = MethodSignature(split_ints,
                                              inputs={'ints': IntSequence1},
                                              parameters={},
                                              outputs=[('left', IntSequence1),
                                                       ('right', IntSequence1)
                                                       ])
예제 #22
0
파일: test_core.py 프로젝트: qiime2/q2cli
 def setUp(self):
     get_dummy_plugin()
     self.runner = CliRunner()
     self.tempdir = tempfile.mkdtemp(prefix='qiime2-q2cli-test-temp-')
예제 #23
0
 def setUp(self):
     self.plugin = get_dummy_plugin()
     self.single_int = qiime2.Artifact.import_data(SingleInt, -1)
     self.int_sequence = qiime2.Artifact.import_data(IntSequence1,
                                                     [1, 2, 3])
     self.mapping = qiime2.Artifact.import_data(Mapping, {'foo': '42'})
예제 #24
0
 def setUp(self):
     plugin = get_dummy_plugin()
     self.action = plugin.actions[self.ACTION]
예제 #25
0
 def setUp(self):
     self.plugin = get_dummy_plugin()
     self.method = self.plugin.methods['deprecated_method']
예제 #26
0
 def setUp(self):
     self.plugin = get_dummy_plugin()
     # PluginManager is a singleton so there's no issue creating it again.
     self.pm = qiime2.sdk.PluginManager()
예제 #27
0
    def setUp(self):
        self.plugin = get_dummy_plugin()

        # TODO standardize temporary directories created by QIIME 2
        # create a temporary data_dir for sample Visualizations
        self.test_dir = tempfile.TemporaryDirectory(prefix='qiime2-test-temp-')
예제 #28
0
 def setUp(self):
     self.plugin = get_dummy_plugin()
예제 #29
0
 def setUp(self):
     self.plugin = get_dummy_plugin()
     # PluginManager is a singleton so there's no issue creating it again.
     self.pm = qiime2.sdk.PluginManager()
예제 #30
0
 def setUp(self):
     # TODO standardize temporary directories created by QIIME 2
     self.test_dir = tempfile.TemporaryDirectory(prefix='qiime2-test-temp-')
     self.plugin = get_dummy_plugin()
예제 #31
0
 def setUp(self):
     self.test_dir = tempfile.TemporaryDirectory(prefix='qiime2-test-temp-')
     self.plugin = get_dummy_plugin()
예제 #32
0
 def setUp(self):
     self._sys_modules = sys.modules.copy()
     # Ignore the returned dummy plugin object, just run this to verify the
     # plugin exists as the tests rely on it being loaded.
     get_dummy_plugin()
예제 #33
0
 def setUp(self):
     get_dummy_plugin()
     self.runner = CliRunner()
     self.tempdir = tempfile.mkdtemp(prefix='qiime2-q2cli-test-temp-')
예제 #34
0
 def setUp(self):
     get_dummy_plugin()
예제 #35
0
def dummy_plugin(monkeypatch):
    monkeypatch.setenv('QIIMETEST', '')
    return get_dummy_plugin()
예제 #36
0
 def setUp(self):
     self.plugin = get_dummy_plugin()
예제 #37
0
 def setUp(self):
     get_dummy_plugin()
예제 #38
0
 def setUp(self):
     # TODO standardize temporary directories created by QIIME 2
     self.test_dir = tempfile.TemporaryDirectory(prefix='qiime2-test-temp-')
     self.plugin = get_dummy_plugin()
예제 #39
0
 def setUp(self):
     self._sys_modules = sys.modules.copy()
     # Ignore the returned dummy plugin object, just run this to verify the
     # plugin exists as the tests rely on it being loaded.
     get_dummy_plugin()
예제 #40
0
 def setUp(self):
     self.plugin = get_dummy_plugin()
     self.single_int = qiime2.Artifact.import_data(SingleInt, -1)
     self.int_sequence = qiime2.Artifact.import_data(
         IntSequence1, [1, 2, 3])
     self.mapping = qiime2.Artifact.import_data(Mapping, {'foo': '42'})