From 4bc19c3e49835acdf797ee758ddb982809cbb425 Mon Sep 17 00:00:00 2001 From: Celine Mercier Date: Tue, 8 Nov 2016 11:17:20 +0100 Subject: [PATCH] obi export: view type is now checked and progress bar functioning --- python/obitools3/commands/export.pyx | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/python/obitools3/commands/export.pyx b/python/obitools3/commands/export.pyx index 79348e4..cabcd82 100644 --- a/python/obitools3/commands/export.pyx +++ b/python/obitools3/commands/export.pyx @@ -1,5 +1,5 @@ from obitools3.apps.progress cimport ProgressBar # @UnresolvedImport -from obitools3.obidms._obidms import OBIDMS # TODO cimport doesn't work +from obitools3.obidms._obidms import OBIDMS, OBIView_NUC_SEQS # TODO cimport doesn't work from obitools3.utils cimport bytes2str import time @@ -38,7 +38,7 @@ def addOptions(parser): metavar='', default="fasta", type=str, - help="Export in the format , 'fasta' or 'fastq'. Default: 'fasta'.") + help="Export in the format , 'fasta' or 'fastq'. Default: 'fasta'.") # TODO export in csv def run(config): @@ -56,12 +56,16 @@ def run(config): # Open input view iview = d.open_view(config['obi']['inputview']) + # TODO check that the view has the type NUC_SEQS + if ((config['export']['format'] == "fasta") or (config['export']['format'] == "fastq")) and (isinstance(iview, OBIView_NUC_SEQS) == False) : + 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) + pb = ProgressBar(len(iview), config, seconde=5) i=0 for seq in iview : - #pb(i) + pb(i) toprint = ">"+seq.get_id()+" "