obi export: view type is now checked and progress bar functioning
This commit is contained in:
@ -1,5 +1,5 @@
|
|||||||
from obitools3.apps.progress cimport ProgressBar # @UnresolvedImport
|
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
|
from obitools3.utils cimport bytes2str
|
||||||
|
|
||||||
import time
|
import time
|
||||||
@ -38,7 +38,7 @@ def addOptions(parser):
|
|||||||
metavar='<FORMAT>',
|
metavar='<FORMAT>',
|
||||||
default="fasta",
|
default="fasta",
|
||||||
type=str,
|
type=str,
|
||||||
help="Export in the format <FORMAT>, 'fasta' or 'fastq'. Default: 'fasta'.")
|
help="Export in the format <FORMAT>, 'fasta' or 'fastq'. Default: 'fasta'.") # TODO export in csv
|
||||||
|
|
||||||
def run(config):
|
def run(config):
|
||||||
|
|
||||||
@ -56,12 +56,16 @@ def run(config):
|
|||||||
# Open input view
|
# Open input view
|
||||||
iview = d.open_view(config['obi']['inputview'])
|
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
|
# Initialize the progress bar
|
||||||
#pb = ProgressBar(len(iview), config, seconde=5)
|
pb = ProgressBar(len(iview), config, seconde=5)
|
||||||
|
|
||||||
i=0
|
i=0
|
||||||
for seq in iview :
|
for seq in iview :
|
||||||
#pb(i)
|
pb(i)
|
||||||
|
|
||||||
toprint = ">"+seq.get_id()+" "
|
toprint = ">"+seq.get_id()+" "
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user