obi import: fixed the import of old obitools files with premerged
informations, and other minor improvements
This commit is contained in:
@ -25,7 +25,8 @@ from obitools3.dms.capi.obiview cimport VIEW_TYPE_NUC_SEQS, \
|
|||||||
DEFINITION_COLUMN, \
|
DEFINITION_COLUMN, \
|
||||||
QUALITY_COLUMN, \
|
QUALITY_COLUMN, \
|
||||||
COUNT_COLUMN, \
|
COUNT_COLUMN, \
|
||||||
TAXID_COLUMN
|
TAXID_COLUMN, \
|
||||||
|
MERGED_PREFIX
|
||||||
|
|
||||||
from obitools3.dms.capi.obidms cimport obi_import_view
|
from obitools3.dms.capi.obidms cimport obi_import_view
|
||||||
|
|
||||||
@ -163,7 +164,7 @@ def run(config):
|
|||||||
taxo.write(taxo_name)
|
taxo.write(taxo_name)
|
||||||
taxo.close()
|
taxo.close()
|
||||||
o_dms.record_command_line(" ".join(sys.argv[1:]))
|
o_dms.record_command_line(" ".join(sys.argv[1:]))
|
||||||
o_dms.close()
|
o_dms.close(force=True)
|
||||||
logger("info", "Done.")
|
logger("info", "Done.")
|
||||||
return
|
return
|
||||||
|
|
||||||
@ -217,11 +218,14 @@ def run(config):
|
|||||||
logger("info", "Read %d entries", i)
|
logger("info", "Read %d entries", i)
|
||||||
|
|
||||||
for tag in entry :
|
for tag in entry :
|
||||||
|
newtag = tag
|
||||||
|
if tag[:7] == b"merged_":
|
||||||
|
newtag = MERGED_PREFIX+tag[7:]
|
||||||
if type(entry[tag]) == dict :
|
if type(entry[tag]) == dict :
|
||||||
if tag in dict_dict:
|
if tag in dict_dict:
|
||||||
dict_dict[tag][0].update(entry[tag].keys())
|
dict_dict[newtag][0].update(entry[tag].keys())
|
||||||
else:
|
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
|
i+=1
|
||||||
|
|
||||||
if pb is not None:
|
if pb is not None:
|
||||||
@ -288,6 +292,8 @@ def run(config):
|
|||||||
tag = TAXID_COLUMN
|
tag = TAXID_COLUMN
|
||||||
if tag == b"count":
|
if tag == b"count":
|
||||||
tag = COUNT_COLUMN
|
tag = COUNT_COLUMN
|
||||||
|
if tag[:7] == b"merged_":
|
||||||
|
tag = MERGED_PREFIX+tag[7:]
|
||||||
|
|
||||||
if tag not in dcols :
|
if tag not in dcols :
|
||||||
|
|
||||||
@ -328,8 +334,8 @@ def run(config):
|
|||||||
try:
|
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
|
# 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 \
|
if type(value) == dict and \
|
||||||
dcols[tag][0].nb_elements_per_line == 1 and len(value.keys()) == 1 \
|
dcols[tag][0].nb_elements_per_line == 1 \
|
||||||
and dcols[tag][0].elements_names[0] != list(value.keys())[0] :
|
and set(dcols[tag][0].elements_names) != set(value.keys()) :
|
||||||
raise IndexError # trigger column rewrite
|
raise IndexError # trigger column rewrite
|
||||||
|
|
||||||
# Fill value
|
# Fill value
|
||||||
@ -402,7 +408,7 @@ def run(config):
|
|||||||
except AttributeError:
|
except AttributeError:
|
||||||
pass
|
pass
|
||||||
try:
|
try:
|
||||||
output[0].close()
|
output[0].close(force=True)
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user