Mercurial > repos > shellac > guppy_basecaller
diff env/lib/python3.7/site-packages/gxformat2/_labels.py @ 2:6af9afd405e9 draft
"planemo upload commit 0a63dd5f4d38a1f6944587f52a8cd79874177fc1"
author | shellac |
---|---|
date | Thu, 14 May 2020 14:56:58 -0400 (2020-05-14) |
parents | 26e78fe6e8c4 |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/env/lib/python3.7/site-packages/gxformat2/_labels.py Thu May 14 14:56:58 2020 -0400 @@ -0,0 +1,27 @@ +"""Utilities for handling unlabelled objects when translating workflow formats.""" + + +class Labels(object): + """Track labels assigned and generate anonymous ones.""" + + def __init__(self): + """Initialize labels that have been encountered or generated.""" + self.seen_labels = set() + self.anonymous_labels = 0 + + def ensure_new_output_label(self, label): + """Ensure supplied label has value or generate an anonymous one.""" + if label is None: + self.anonymous_labels += 1 + label = "_anonymous_output_%d" % self.anonymous_labels + assert label not in self.seen_labels + self.seen_labels.add(label) + return label + + @staticmethod + def is_anonymous_output_label(label): + """Predicate determining if supplied label was generated for anonymous output.""" + # label likely can't be null according to the schema definition - but we've got a test + # in Galaxy that doesn't define a label in order to great a .ga file without output + # labels (which is completely normal). + return not label or label.startswith("_anonymous_output_")