Commands: updated for JSON formatted comments with history

This commit is contained in:
Celine Mercier
2018-10-07 19:10:34 +02:00
parent 35cf2962cc
commit e9a41c5b97
11 changed files with 144 additions and 34 deletions

View File

@ -1,6 +1,7 @@
#cython: language_level=3
import sys
import os
from obitools3.apps.progress cimport ProgressBar # @UnresolvedImport
from obitools3.dms.view.view cimport View
@ -89,7 +90,7 @@ def run(config):
logger("info", "obi import : imports file into a DMS")
if not config['obi']['taxdump']: # TODO discuss
if not config['obi']['taxdump']:
input = open_uri(config['obi']['inputURI'])
if input is None: # TODO check for bytes instead now?
raise Exception("Could not open input URI")
@ -108,12 +109,13 @@ def run(config):
#quality=get_quality) # TODO
if output is None:
raise Exception("Could not create output view")
# Read taxdump
if config['obi']['taxdump']: # The input is a taxdump to import in a DMS
taxo = Taxonomy.open_taxdump(output[0], config['obi']['inputURI'])
taxo.write(output[1])
taxo.close()
output[0].record_command_line(" ".join(sys.argv[1:]))
output[0].close()
return
@ -132,16 +134,16 @@ def run(config):
raise NotImplementedError()
# Save basic columns in variables for optimization
if NUC_SEQS_view :
if NUC_SEQS_view :
id_col = view[b"ID"] # TODO use macros or globals for column names
def_col = view[b"DEFINITION"]
seq_col = view[b"NUC_SEQ"]
dcols = {}
i = 0
for entry in entries :
pb(i)
if NUC_SEQS_view :
@ -258,6 +260,11 @@ def run(config):
i+=1
# Save command config in View and DMS comments
command_line = " ".join(sys.argv[1:])
view.write_config(config, "import", command_line, input_str=[os.path.abspath(config['obi']['inputURI'])])
output[0].record_command_line(command_line)
print("\n")
print(view.__repr__())