def clean_category(self): category_name = self.cleaned_data['category'] if not category_name: del self.cleaned_data['category'] return if category_name not in CATEGORIES.keys() + CRYSPER_CATEGORIES.keys(): raise ValidationError('You must choose a valid category') return category_name
def _get_category_name(category): if category[0] in SPECIAL_SEARCH_CATEGORIES: return category[0] for name, category_def in CATEGORIES.items(): if category == category_def: return name for name, category_def in CRYSPER_CATEGORIES.items(): if category == category_def: return name return '{0}: {1}'.format(category[0], ','.join(category)) raise ValueError('The given category not in the CATEGORY dictionary')
def gb_category(self): if (self.level != LEVEL_0 or self.type.name == VECTOR_TYPE_NAME or self.type.name == OTHER_TYPE_NAME): return self.type.name type_ = self.type.name prefix = self.prefix suffix = self.suffix for category, values in CATEGORIES.items(): if values == (type_, prefix, suffix): return category.strip() for category, values in CRYSPER_CATEGORIES.items(): if values == (type_, prefix, suffix): return category.strip()
def _check_category(type_name, prefix, suffix, vector): if type_name in (OTHER_TYPE_NAME, VECTOR_TYPE_NAME): return True for values in CATEGORIES.values(): if values == (type_name, prefix, suffix): return True for values in CRYSPER_CATEGORIES.values(): if values == (type_name, prefix, suffix): return True if (type_name, prefix, suffix) in ((TU_TYPE_NAME, 'GGAG', 'GTCA'), (TU_TYPE_NAME, 'GTCA', 'CGCT'), (MODULE_TYPE_NAME, 'GGAG', 'GTCA'), (MODULE_TYPE_NAME, 'GTCA', 'CGCT')): return True return False