From 740d021276957ebf0382e6ab9152d9c8136e148b Mon Sep 17 00:00:00 2001 From: Celine Mercier Date: Fri, 7 Jul 2017 15:33:43 +0200 Subject: [PATCH] obi import: fixed bugs when rewriting a column: a bug with new elements names ignoring previous elements names found, a bug with the global obi_errno being reset too late, and a bug with the column dictionary used by obi import not being updated after rewriting a column --- python/obitools3/commands/import.pyx | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/python/obitools3/commands/import.pyx b/python/obitools3/commands/import.pyx index 1d064d9..b5a7de0 100644 --- a/python/obitools3/commands/import.pyx +++ b/python/obitools3/commands/import.pyx @@ -192,7 +192,7 @@ def run(config): qual_col[i] = seq['quality'] for tag in seq['tags'] : - + value = seq['tags'][tag] if tag not in dcols : @@ -234,7 +234,7 @@ def run(config): dcols[tag][0][i] = value except IndexError : - + value_type = type(value) old_column = dcols[tag][0] old_nb_elements_per_line = old_column.nb_elements_per_line @@ -248,7 +248,7 @@ def run(config): if value_type == dict : # Check dictionary keys for k in value : if k not in old_elements_names : - new_elements_names = list(value) + new_elements_names = list(set(old_elements_names+[tobytes(k) for k in value])) rewrite = True break @@ -263,18 +263,22 @@ def run(config): if new_nb_elements_per_line == 0 and new_elements_names is not None : new_nb_elements_per_line = len(new_elements_names) + # Reset obierrno + obi_errno = 0 + dcols[tag] = (view.rewrite_column_with_diff_attributes(old_column.name, new_data_type=new_type, new_nb_elements_per_line=new_nb_elements_per_line, new_elements_names=new_elements_names), value_obitype) - # Reset obierrno - obi_errno = 0 + # Update the dictionary: + for t in dcols : + dcols[t] = (view[t], dcols[t][1]) # Fill value dcols[tag][0][i] = value - + i+=1 print("\n")