I’m currently using the following line to get tags of datasets to the underlying tool:
#set tags = ','.join(str(t.value) for t in $dataset.tags)
This however this does not return the original tags, they get truncated (losing #
and the name:
), converted to lowercase and special characters are removed. Is there a better way to get access to tags in the tool xml?
1 Like
You need to get t.name
and t.value
. .name
is the first part before the :
1 Like
Thanks @mvdbeek, can the tool also get access to unsanitized or at least preserved casing of tag values? e.g. #hello:YoU
vs #hello:you
There’s no sanitization anywhere, but tags are linked via lowercase, so maybe you’d need to use
user_tname
and user_value
1 Like
Thanks @mvdbeek that works, although not that easy(or I might also just be doing something wrong) and I guess the cheetah templating is then still sanitizing characters like $
?
Anyway the following snippet works for me to get both the named:tags
and simpletags
:
#for $t in $dataset.tags:
#if $t.user_tname == 'name':
#set taglist = taglist + [t.user_value]
#else:
#set taglist = taglist + [t.user_tname]
#end if
#end for
1 Like
The way you’re looping you don’t maintain the tags as they are stored in Galaxy.
I think the correct way would be
#set tags = ','.join(["%s:%s" % (t.user_tname, t.user_value) if t.user_tname else str(t.user_value) for t in $dataset.tags])
1 Like
And we could also make that the __str__
method of the ItemTagAssociation
class so that you only have to do $set tags = ",".join($dataset.tags)
1 Like