From 219c0d6fdc15669116b1a75b53bf511079817dca Mon Sep 17 00:00:00 2001 From: Celine Mercier Date: Wed, 12 Feb 2020 14:21:39 +0100 Subject: [PATCH] obi cat: Fixed the handling when concatenating views with dictionaries having different key sets --- python/obitools3/commands/cat.pyx | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/python/obitools3/commands/cat.pyx b/python/obitools3/commands/cat.pyx index dee708c..6797edd 100755 --- a/python/obitools3/commands/cat.pyx +++ b/python/obitools3/commands/cat.pyx @@ -86,7 +86,24 @@ def run(config): if not remove_rev_qual: Column.new_column(o_view, REVERSE_SEQUENCE_COLUMN, OBI_SEQ) Column.new_column(o_view, REVERSE_QUALITY_COLUMN, OBI_QUAL, associated_column_name=REVERSE_SEQUENCE_COLUMN, associated_column_version=o_view[REVERSE_SEQUENCE_COLUMN].version) - + + # Initialize multiple elements columns + dict_cols = {} + for v in iview_list: + for coln in v.keys(): + if v[coln].nb_elements_per_line > 1: + if coln not in dict_cols: + dict_cols[coln] = {} + dict_cols[coln]['eltnames'] = set(v[coln].elements_names) + dict_cols[coln]['nbelts'] = v[coln].nb_elements_per_line + dict_cols[coln]['obitype'] = v[coln].data_type_int + else: + dict_cols[coln]['eltnames'] = set(v[coln].elements_names + list(dict_cols[coln]['eltnames'])) + dict_cols[coln]['nbelts'] = len(dict_cols[coln]['eltnames']) + for coln in dict_cols: + Column.new_column(o_view, coln, dict_cols[coln]['obitype'], + nb_elements_per_line=dict_cols[coln]['nbelts'], elements_names=list(dict_cols[coln]['eltnames'])) + # Initialize the progress bar pb = ProgressBar(total_len, config, seconde=5)