Cython API: when importing a file in a DMS, its length is computed
beforehand for the progress bar
This commit is contained in:
@ -20,7 +20,7 @@ from obitools3.format.fastq import FastqFormat
|
||||
from obitools3.dms.obiseq import Nuc_Seq
|
||||
from obitools3.apps.config import getConfiguration,logger
|
||||
from obitools3.apps.temp import get_temp_dms
|
||||
from obitools3.utils cimport tobytes # TODO because can't read options as bytes
|
||||
from obitools3.utils cimport tobytes, count_entries # TODO tobytes because can't read options as bytes
|
||||
|
||||
from obitools3.dms.capi.obierrno cimport obi_errno, \
|
||||
OBIVIEW_ALREADY_EXISTS_ERROR
|
||||
@ -159,6 +159,7 @@ Reads an URI and returns a tuple containing:
|
||||
(2) The opened view or iterator on the opened file or writer
|
||||
(3) The class of object returned or handled by (2)
|
||||
(4) The original URI in bytes
|
||||
(5) The number of entries (if input URI) or -1 if unavailable
|
||||
'''
|
||||
def open_uri(uri,
|
||||
bint input=True,
|
||||
@ -209,7 +210,8 @@ def open_uri(uri,
|
||||
return (dms[0],
|
||||
dms[1],
|
||||
type(dms[1]),
|
||||
urlunparse(urip))
|
||||
urlunparse(urip),
|
||||
len(dms[0]))
|
||||
try:
|
||||
resource=open_dms_element(dms[0],
|
||||
dms[1],
|
||||
@ -230,7 +232,8 @@ def open_uri(uri,
|
||||
return (resource[0],
|
||||
resource[1],
|
||||
type(resource[1]),
|
||||
urlunparse(urip))
|
||||
urlunparse(urip),
|
||||
len(resource[1]))
|
||||
except Exception as e:
|
||||
global obi_errno
|
||||
if obi_errno == OBIVIEW_ALREADY_EXISTS_ERROR:
|
||||
@ -503,19 +506,19 @@ def open_uri(uri,
|
||||
raise NotImplementedError('Output sequence file format not implemented')
|
||||
else:
|
||||
if input:
|
||||
iseq, objclass = entryIteratorFactory(file,
|
||||
skip, only,
|
||||
seqtype,
|
||||
offset,
|
||||
noquality,
|
||||
skiperror,
|
||||
header,
|
||||
sep,
|
||||
dec,
|
||||
nastring,
|
||||
stripwhite,
|
||||
blanklineskip,
|
||||
commentchar)
|
||||
iseq, objclass, format = entryIteratorFactory(file,
|
||||
skip, only,
|
||||
seqtype,
|
||||
offset,
|
||||
noquality,
|
||||
skiperror,
|
||||
header,
|
||||
sep,
|
||||
dec,
|
||||
nastring,
|
||||
stripwhite,
|
||||
blanklineskip,
|
||||
commentchar)
|
||||
else: # default export is in fasta? or tab? TODO
|
||||
objclass = Nuc_Seq # Nuc_Seq_Stored? TODO
|
||||
iseq = FastaNucWriter(FastaFormat(printNAKeys=printna, NAString=nastring),
|
||||
@ -524,7 +527,9 @@ def open_uri(uri,
|
||||
only=only)
|
||||
|
||||
#tmpdms = get_temp_dms()
|
||||
|
||||
return (file, iseq, objclass, urib)
|
||||
|
||||
|
||||
|
||||
entry_count = -1
|
||||
if input:
|
||||
entry_count = count_entries(file, format)
|
||||
|
||||
return (file, iseq, objclass, urib, entry_count)
|
||||
|
Reference in New Issue
Block a user