obi export: made output to stdout and pipe in less possible
This commit is contained in:
@ -7,9 +7,11 @@ from obitools3.dms import DMS
|
||||
from obitools3.dms.obiseq import Nuc_Seq
|
||||
|
||||
from obitools3.apps.optiongroups import addMinimalInputOption, \
|
||||
addExportOutputOption
|
||||
addExportOutputOption, \
|
||||
addNoProgressBarOption
|
||||
|
||||
import sys
|
||||
import io
|
||||
|
||||
__title__="Export a view to a different file format"
|
||||
|
||||
@ -18,6 +20,7 @@ def addOptions(parser):
|
||||
|
||||
addMinimalInputOption(parser)
|
||||
addExportOutputOption(parser)
|
||||
addNoProgressBarOption(parser)
|
||||
|
||||
|
||||
def run(config):
|
||||
@ -46,24 +49,33 @@ def run(config):
|
||||
raise Exception("Error: the view to export in fasta or fastq format is not a NUC_SEQS view")
|
||||
|
||||
# Initialize the progress bar
|
||||
pb = ProgressBar(len(iview), config, seconde=5)
|
||||
if config['obi']['noprogressbar']:
|
||||
pb = None
|
||||
else:
|
||||
pb = ProgressBar(len(iview), config, seconde=5)
|
||||
|
||||
i=0
|
||||
for seq in iview :
|
||||
pb(i)
|
||||
if pb is not None:
|
||||
pb(i)
|
||||
try:
|
||||
writer(seq)
|
||||
except StopIteration:
|
||||
except (StopIteration, BrokenPipeError, IOError):
|
||||
break
|
||||
i+=1
|
||||
|
||||
pb(i, force=True)
|
||||
if pb is not None:
|
||||
pb(i, force=True)
|
||||
print("", file=sys.stderr)
|
||||
|
||||
# TODO save command in input dms?
|
||||
|
||||
output_object.close()
|
||||
if not BrokenPipeError and not IOError:
|
||||
output_object.close()
|
||||
iview.close()
|
||||
input[0].close()
|
||||
|
||||
logger("info", "Done.")
|
||||
|
||||
if BrokenPipeError or IOError:
|
||||
sys.stderr.close()
|
||||
|
Reference in New Issue
Block a user