Miscellaneous Utilities¶
Plugins¶
- qiime2.plugins.available_plugins()¶
Utilities¶
- qiime2.util.duplicate(src, dst)¶
Alternative to shutil.copyfile, this will use os.link when possible.
See shutil.copyfile for documention. Only src and dst are supported. Unlike copyfile, this will not overwrite the destination if it exists.
- qiime2.util.redirected_stdio(stdout=None, stderr=None)¶
Testing¶
- class qiime2.plugin.testing.TestPluginBase(methodName='runTest')¶
Test harness for simplifying testing QIIME 2 plugins.
TestPluginBase
extendsunittest.TestCase
, with a few extra helpers and assertions.- package¶
The name of the plugin package to be tested.
- Type:
str
- test_dir_prefix¶
The prefix for the temporary testing dir created by the harness.
- Type:
str
- assertRegisteredSemanticType(semantic_type)¶
Test assertion for ensuring a plugin’s semantic type is registered.
Fails if the semantic type requested is not found in the Plugin Manager.
- Parameters:
semantic_type (A Semantic Type) – The Semantic Type to test the presence of.
- assertSemanticTypeRegisteredToFormat(semantic_type, exp_format)¶
- Test assertion for ensuring a semantic type is registered to a
format.
Fails if the semantic type requested is not registered to the format specified with
exp_format
. Also fails if the semantic type isn’t registered to any format.- Parameters:
semantic_type (A Semantic Type) – The Semantic Type to check for.
exp_format (A Format) – The Format to check that the Semantic Type is registed on.
- get_data_path(filename)¶
Convenience method for getting a data asset while testing.
Test data stored in the
data/
dir local to the running test can be accessed via this method.- Parameters:
filename (str) – The name of the file to look up.
- Returns:
filepath – The materialized filepath to the requested test data.
- Return type:
str
- get_transformer(from_type, to_type)¶
Convenience method for getting a registered transformer.
This helper deliberately side-steps the framework’s validation machinery, so that it is possible for plugin developers to test failing conditions.
- setUp()¶
Test runner setup hook.
If overriding this hook in a test, call
__super__
to invoke this method in the overridden hook, otherwise the harness might not work as expected.
- tearDown()¶
Test runner teardown hook.
If overriding this hook in a test, call
__super__
to invoke this method in the overridden hook, otherwise the harness might not work as expected.
- transform_format(source_format, target, filename=None, filenames=None)¶
Helper utility for loading data and transforming it.
Combines several other utilities in this class, will load files from
data/
, assource_format
, then transform to thetarget
view.This helper deliberately side-steps the framework’s validation machinery, so that it is possible for plugin developers to test failing conditions.
- Parameters:
source_format (A Format) – The Format to load the data as.
target (A View Type) – The View Type to transform the data to.
filename (str) – The name of the file to load from
data
. Use this for formats that use a single file in their format definition. Mutually exclusive with thefilenames
parameter.filenames (list[str]) – The names of the files to load from
data
. Use this for formats that use multiple files in their format definition. Mutually exclusive with thefilename
parameter.
- Returns:
input (A Format) – The data loaded from
data
as the specifiedsource_format
.obs (A View Type) – The loaded data, transformed to the specified
target
view type.