diff --git a/python/obitools3/commands/import.pyx b/python/obitools3/commands/import.pyx index 377ad0a..f2fe2a5 100755 --- a/python/obitools3/commands/import.pyx +++ b/python/obitools3/commands/import.pyx @@ -25,7 +25,8 @@ from obitools3.dms.capi.obiview cimport VIEW_TYPE_NUC_SEQS, \ DEFINITION_COLUMN, \ QUALITY_COLUMN, \ COUNT_COLUMN, \ - TAXID_COLUMN + TAXID_COLUMN, \ + MERGED_PREFIX from obitools3.dms.capi.obidms cimport obi_import_view @@ -163,7 +164,7 @@ def run(config): taxo.write(taxo_name) taxo.close() o_dms.record_command_line(" ".join(sys.argv[1:])) - o_dms.close() + o_dms.close(force=True) logger("info", "Done.") return @@ -217,11 +218,14 @@ def run(config): logger("info", "Read %d entries", i) for tag in entry : + newtag = tag + if tag[:7] == b"merged_": + newtag = MERGED_PREFIX+tag[7:] if type(entry[tag]) == dict : if tag in dict_dict: - dict_dict[tag][0].update(entry[tag].keys()) + dict_dict[newtag][0].update(entry[tag].keys()) else: - dict_dict[tag] = [set(entry[tag].keys()), get_obitype(entry[tag])] + dict_dict[newtag] = [set(entry[tag].keys()), get_obitype(entry[tag])] i+=1 if pb is not None: @@ -288,6 +292,8 @@ def run(config): tag = TAXID_COLUMN if tag == b"count": tag = COUNT_COLUMN + if tag[:7] == b"merged_": + tag = MERGED_PREFIX+tag[7:] if tag not in dcols : @@ -328,8 +334,8 @@ def run(config): try: # Check that it's not the case where the first entry contained a dict of length 1 and now there is a new key if type(value) == dict and \ - dcols[tag][0].nb_elements_per_line == 1 and len(value.keys()) == 1 \ - and dcols[tag][0].elements_names[0] != list(value.keys())[0] : + dcols[tag][0].nb_elements_per_line == 1 \ + and set(dcols[tag][0].elements_names) != set(value.keys()) : raise IndexError # trigger column rewrite # Fill value @@ -402,7 +408,7 @@ def run(config): except AttributeError: pass try: - output[0].close() + output[0].close(force=True) except AttributeError: pass