From 735231baaee6ee348d0038792eb2ce7d83880232 Mon Sep 17 00:00:00 2001 From: Jacques Dainat Date: Mon, 15 Oct 2018 14:53:03 +0200 Subject: [PATCH] fix #22 --- EMBLmyGFF3/modules/feature.py | 4 ++++ EMBLmyGFF3/modules/qualifier.py | 11 +++++------ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/EMBLmyGFF3/modules/feature.py b/EMBLmyGFF3/modules/feature.py index d385d43..f4f9f2e 100755 --- a/EMBLmyGFF3/modules/feature.py +++ b/EMBLmyGFF3/modules/feature.py @@ -475,10 +475,14 @@ def add_qualifier(self, gff_qualifier, value): for val in value: if val not in self.qualifiers[qualifier].value: self.qualifiers[qualifier].add_value(val) + else: + logging.debug('val %s alredy exist (list case)' % val) # Scalar case else: if value not in self.qualifiers[qualifier].value: self.qualifiers[qualifier].add_value(value) + else: + logging.debug('val %s alredy exist (scalar case)' % val) def combine(self, other): """ diff --git a/EMBLmyGFF3/modules/qualifier.py b/EMBLmyGFF3/modules/qualifier.py index 713ee89..c117202 100755 --- a/EMBLmyGFF3/modules/qualifier.py +++ b/EMBLmyGFF3/modules/qualifier.py @@ -76,10 +76,10 @@ def _by_value_format(self, value): elif self.value_format.startswith("\"\""): # Handle dbxref's self._load_legal_dbxref( LEGAL_DBXREF_FILE ) value = value if type(value) == type([]) else [value] - new_value=[] + for val in value: if val.split(':')[0].lower() in [v.lower() for v in self.legal_dbxref]: - new_value.append(val) + new_value = val else: msg = "Unknown db_xref '%s' - removing." % (val.split(':')[0]) if msg not in Qualifier.PREVIOUS_ERRORS: @@ -153,11 +153,10 @@ def add_value(self, value): Qualifier wihtout value is possible. e.g environmental_sample """ self.value = [self.value] if type(self.value) != type([]) else self.value - value = [value] if type(value) != type([]) else value - new_values = [self._by_value_format(v) for v in value] - logging.debug("%s - Changing value: '%s' to '%s'" % (self.name, value, new_values)) - self.value += new_values + new_value = self._by_value_format(value) + logging.debug("%s - Changing value: '%s' to '%s'" % (self.name, value, new_value)) + self.value.append(new_value) logging.debug("%s - Current value: '%s'" % (self.name, self.value)) def set_value(self, value):