obi import: importing a view to a DMS now uses the C API (more efficient
and imports all metadata)
This commit is contained in:
@ -14,6 +14,7 @@ from obitools3.dms.taxo.taxo cimport Taxonomy
|
||||
|
||||
|
||||
from obitools3.utils cimport tobytes, \
|
||||
tostr, \
|
||||
get_obitype, \
|
||||
update_obitype
|
||||
|
||||
@ -25,6 +26,8 @@ from obitools3.dms.capi.obiview cimport VIEW_TYPE_NUC_SEQS, \
|
||||
COUNT_COLUMN, \
|
||||
TAXID_COLUMN
|
||||
|
||||
from obitools3.dms.capi.obidms cimport obi_import_view
|
||||
|
||||
from obitools3.dms.capi.obitypes cimport obitype_t, \
|
||||
OBI_VOID, \
|
||||
OBI_QUAL
|
||||
@ -124,7 +127,7 @@ def run(config):
|
||||
else:
|
||||
v = None
|
||||
|
||||
if config['obi']['taxdump']:
|
||||
if config['obi']['taxdump'] or isinstance(input[1], View):
|
||||
dms_only=True
|
||||
else:
|
||||
dms_only=False
|
||||
@ -134,20 +137,31 @@ def run(config):
|
||||
newviewtype=v,
|
||||
dms_only=dms_only)
|
||||
if output is None:
|
||||
raise Exception("Could not create output view")
|
||||
raise Exception("Could not open output")
|
||||
|
||||
o_dms = output[0]
|
||||
|
||||
# If importing a view between two DMS, use C API
|
||||
if isinstance(input[1], View):
|
||||
if obi_import_view(input[0].name_with_full_path, o_dms.name_with_full_path, input[1].name, tobytes((config['obi']['outputURI'].split('/'))[-1])) < 0 :
|
||||
raise Exception("Error importing a view in a DMS")
|
||||
o_dms.record_command_line(" ".join(sys.argv[1:]))
|
||||
o_dms.close()
|
||||
logger("info", "Done.")
|
||||
return
|
||||
|
||||
|
||||
# Read taxdump
|
||||
if config['obi']['taxdump']: # The input is a taxdump to import in a DMS
|
||||
# Check if taxonomy name isn't already taken
|
||||
dms = output[0]
|
||||
taxo_name = output[1]
|
||||
if Taxonomy.exists(dms, taxo_name.split(b'/')[1]):
|
||||
if Taxonomy.exists(o_dms, taxo_name.split(b'/')[1]):
|
||||
raise Exception("Taxonomy name already exists in this DMS")
|
||||
taxo = Taxonomy.open_taxdump(dms, config['obi']['inputURI'])
|
||||
taxo = Taxonomy.open_taxdump(o_dms, config['obi']['inputURI'])
|
||||
taxo.write(taxo_name)
|
||||
taxo.close()
|
||||
dms.record_command_line(" ".join(sys.argv[1:]))
|
||||
dms.close()
|
||||
o_dms.record_command_line(" ".join(sys.argv[1:]))
|
||||
o_dms.close()
|
||||
logger("info", "Done.")
|
||||
return
|
||||
|
||||
|
@ -5,7 +5,7 @@ from obitools3.apps.config import logger
|
||||
from obitools3.dms import DMS
|
||||
from obitools3.dms.taxo.taxo cimport Taxonomy
|
||||
from obitools3.apps.optiongroups import addMinimalInputOption
|
||||
from obitools3.utils cimport tostr
|
||||
from obitools3.utils cimport tostr, bytes2str_object
|
||||
|
||||
|
||||
__title__="Print a preview of a DMS, view, column...."
|
||||
@ -35,7 +35,7 @@ def run(config):
|
||||
dms = input[0]
|
||||
l = []
|
||||
for view in input[0]:
|
||||
l.append(tostr(view) + "\t(Date created: " + tostr(dms[view].comments["Date created"])+")")
|
||||
l.append(tostr(view) + "\t(Date created: " + str(bytes2str_object(dms[view].comments["Date created"]))+")")
|
||||
l.sort()
|
||||
for v in l:
|
||||
print(v)
|
||||
|
Reference in New Issue
Block a user