Error with registering a semantic type

Im not sure if this is the right place to do this, but Im not sure how else to ping people, so…

I’m trying to put together a new semantic type format for a file I need. I’ve got my defination (adapted from the dada2 plugin)

from qiime2.plugin import SemanticType, model
from q2_types.feature_data import FeatureData

KmerMap = SemanticType('KmerMap', variant_of=FeatureData.field['type'])

So, then I go to register the new semantic type in my plugin

from qiime2.plugin import Plugin
from q2_types.feature_data import (FeatureData,
                                   Sequence) 
from q2_sidle.import KmerMap, KmerMapFormat, KmerMapDirFrmt

plugin = Plugin(
    name='sidle',
    ...
    )
plugin.register_semantic_types(KmerMap)

When I go to update with qiime dev refresh-cache, I get a value error:

ValueError: Duplicate semantic type ('FeatureData') defined in plugins: 'sidle' and 'types'

Im not sure how to get my KmerMap semantic type registered and would love some help!

Best,
Justine

2 Likes

Hey @jwdebelius!

Any chance you’ve just missed an accidental registration of FeatureData somewhere in your plugin? If you have the source somewhere I would be happy to take a look. The code you have presented here works as expected:

from qiime2.plugin import SemanticType
from q2_types.feature_data import FeatureData, DifferentialDirectoryFormat
from qiime2.plugin import Plugin
from qiime2.sdk import PluginManager

plugin = Plugin(name='sidle', version='foo', website='bar')
KmerMap = SemanticType('KmerMap', variant_of=FeatureData.field['type'])

# this part is necessary, but I am doing it so that we can show the complete
# registration, below
plugin.register_semantic_type_to_format(
    FeatureData[KmerMap],
    artifact_format=DifferentialDirectoryFormat)
plugin.register_semantic_types(KmerMap)

# This part is because I am testing this in an interactive python session
pm = PluginManager(add_plugins=False)
pm.add_plugin(plugin, package='sidle', project_name='sidle')
from q2_types.plugin_setup import plugin as types_plugin
pm.add_plugin(types_plugin, project_name='types')

# confirm new semantic type
print(pm.get_semantic_types()['FeatureData[KmerMap]'])

this should yield:

SemanticTypeRecord(semantic_type=FeatureData[KmerMap], plugin=<qiime2.plugin.plugin.Plugin object at 0x10ceece10>)

You can see an example “in the wild” here:

Maybe do a global search in your code to look for all of the registration you are performing?

:qiime2:

1 Like

@thermokarst,

Thank you! I found a super stupid mistake on my part based on your global search suggestion. Totally an error between :keyboard: and :chair:.

I appreciate your help checking and going through the code.

Best,
Justine

2 Likes