Python: URI decoding: added metabaR output
This commit is contained in:
@ -277,7 +277,12 @@ def open_uri(uri,
|
||||
iseq = urib
|
||||
objclass = bytes
|
||||
else: # TODO update uopen to be able to write?
|
||||
if not urip.path or urip.path == b'-':
|
||||
if config['obi']['outputformat'] == b'metabaR':
|
||||
if 'metabarprefix' not in config['obi']:
|
||||
raise Exception("Prefix needed when exporting for metabaR (--metabaR-prefix option)")
|
||||
else:
|
||||
file = open(config['obi']['metabarprefix']+'.tab', 'wb')
|
||||
elif not urip.path or urip.path == b'-':
|
||||
file = sys.stdout.buffer
|
||||
else:
|
||||
file = open(urip.path, 'wb')
|
||||
@ -303,7 +308,7 @@ def open_uri(uri,
|
||||
if b'seqtype' in qualifiers:
|
||||
seqtype=qualifiers[b'seqtype'][0]
|
||||
else:
|
||||
if format == b"ngsfilter" or format == b"tabular": # TODO discuss
|
||||
if format == b"ngsfilter" or format == b"tabular" or format == b"metabaR": # TODO discuss
|
||||
seqtype=None
|
||||
else:
|
||||
try:
|
||||
@ -437,7 +442,7 @@ def open_uri(uri,
|
||||
try:
|
||||
na_int_to_0=config["obi"]["na_int_to_0"]
|
||||
except KeyError:
|
||||
if format==b"tabular":
|
||||
if format==b"tabular" or format==b"metabaR":
|
||||
na_int_to_0=True
|
||||
else:
|
||||
na_int_to_0=False
|
||||
@ -487,6 +492,13 @@ def open_uri(uri,
|
||||
except KeyError:
|
||||
only_keys=[]
|
||||
|
||||
if b"metabaR_prefix" in qualifiers:
|
||||
metabaR_prefix = tobytes(qualifiers[b"metabaR_prefix"][0][0])
|
||||
else:
|
||||
try:
|
||||
metabaR_prefix = tobytes(config["obi"]["metabarprefix"])
|
||||
except KeyError:
|
||||
metabaR_prefix=None
|
||||
|
||||
if format is not None:
|
||||
if seqtype==b"nuc":
|
||||
@ -552,6 +564,17 @@ def open_uri(uri,
|
||||
skip=skip,
|
||||
only=only,
|
||||
header=header)
|
||||
elif format==b"metabaR":
|
||||
print(file)
|
||||
objclass = dict
|
||||
if input:
|
||||
raise NotImplementedError('Input data file format not implemented')
|
||||
else:
|
||||
iseq = TabWriter(TabFormat(tags=only_keys, header=header, NAString=nastring, sep=sep, NAIntTo0=na_int_to_0, metabaR=True),
|
||||
file,
|
||||
skip=skip,
|
||||
only=only,
|
||||
header=header)
|
||||
elif format==b"ngsfilter":
|
||||
objclass = dict
|
||||
if input:
|
||||
@ -565,7 +588,7 @@ def open_uri(uri,
|
||||
skip = skip,
|
||||
only = only)
|
||||
else:
|
||||
raise NotImplementedError('Output sequence file format not implemented')
|
||||
raise NotImplementedError('Output data file format not implemented')
|
||||
else:
|
||||
if input:
|
||||
iseq, objclass, format = entryIteratorFactory(file,
|
||||
|
Reference in New Issue
Block a user