Cython API: when importing a file in a DMS, its length is computed

beforehand for the progress bar
This commit is contained in:
Celine Mercier
2019-03-13 18:35:32 +01:00
parent 50e7cd61a6
commit d88390c6d8
5 changed files with 97 additions and 48 deletions

View File

@ -87,14 +87,19 @@ def run(config):
DMS.obi_atexit()
logger("info", "obi import : imports file into a DMS")
logger("info", "obi import: imports an object (file(s), obiview, taxonomy...) into a DMS")
entry_count = -1
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")
# TODO uuuuh
entry_count = input[4]
logger("info", "Importing %d entries", entry_count)
# TODO a bit dirty
if input[2]==Nuc_Seq:
v = View_NUC_SEQS
else:
@ -117,7 +122,7 @@ def run(config):
output[0].close()
return
pb = ProgressBar(10000000, config, seconde=5) # TODO should be number of records in file
pb = ProgressBar(entry_count, config, seconde=5)
entries = input[1]
@ -250,14 +255,17 @@ def run(config):
i+=1
pb(i, force=True)
print("", file=sys.stderr)
# 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__())
#print("\n\nOutput view:\n````````````", file=sys.stderr)
#print(repr(view), file=sys.stderr)
try:
input[0].close()
except AttributeError:
@ -267,3 +275,4 @@ def run(config):
except AttributeError:
pass
logger("info", "Done.")