Cython: added possibility to output in tabular format
This commit is contained in:
@ -115,9 +115,9 @@ def __addImportInputOption(optionManager):
|
|||||||
type=str,
|
type=str,
|
||||||
help="String associated with Non Available (NA) values in the input")
|
help="String associated with Non Available (NA) values in the input")
|
||||||
|
|
||||||
|
|
||||||
def __addTabularInputOption(optionManager):
|
def __addTabularOption(optionManager):
|
||||||
group = optionManager.add_argument_group("Input format options for tabular files")
|
group = optionManager.add_argument_group("Input and output format options for tabular files")
|
||||||
|
|
||||||
group.add_argument('--header',
|
group.add_argument('--header',
|
||||||
action="store_true", dest="obi:header",
|
action="store_true", dest="obi:header",
|
||||||
@ -126,9 +126,15 @@ def __addTabularInputOption(optionManager):
|
|||||||
|
|
||||||
group.add_argument('--sep',
|
group.add_argument('--sep',
|
||||||
action="store", dest="obi:sep",
|
action="store", dest="obi:sep",
|
||||||
default=None,
|
default="\t",
|
||||||
type=str,
|
type=str,
|
||||||
help="Column separator")
|
help="Column separator")
|
||||||
|
|
||||||
|
|
||||||
|
def __addTabularInputOption(optionManager):
|
||||||
|
group = optionManager.add_argument_group("Input format options for tabular files")
|
||||||
|
|
||||||
|
__addTabularOption(optionManager)
|
||||||
|
|
||||||
group.add_argument('--dec',
|
group.add_argument('--dec',
|
||||||
action="store", dest="obi:dec",
|
action="store", dest="obi:dec",
|
||||||
@ -244,6 +250,12 @@ def __addExportOutputOption(optionManager):
|
|||||||
const=b'fastq',
|
const=b'fastq',
|
||||||
help="Output file is in fastq format")
|
help="Output file is in fastq format")
|
||||||
|
|
||||||
|
group.add_argument('--tab-output',
|
||||||
|
action="store_const", dest="obi:outputformat",
|
||||||
|
default=None,
|
||||||
|
const=b'tabular',
|
||||||
|
help="Output file is in tabular format")
|
||||||
|
|
||||||
group.add_argument('--print-na',
|
group.add_argument('--print-na',
|
||||||
action="store_true", dest="obi:printna",
|
action="store_true", dest="obi:printna",
|
||||||
default=False,
|
default=False,
|
||||||
@ -260,13 +272,20 @@ def addMinimalOutputOption(optionManager):
|
|||||||
__addOutputOption(optionManager)
|
__addOutputOption(optionManager)
|
||||||
__addDMSOutputOption(optionManager)
|
__addDMSOutputOption(optionManager)
|
||||||
|
|
||||||
|
|
||||||
|
def addTabularOutputOption(optionManager):
|
||||||
|
__addTabularOption(optionManager)
|
||||||
|
|
||||||
|
|
||||||
def addExportOutputOption(optionManager):
|
def addExportOutputOption(optionManager):
|
||||||
__addOutputOption(optionManager)
|
__addOutputOption(optionManager)
|
||||||
__addExportOutputOption(optionManager)
|
__addExportOutputOption(optionManager)
|
||||||
|
__addTabularOption(optionManager)
|
||||||
|
|
||||||
|
|
||||||
def addAllOutputOption(optionManager):
|
def addAllOutputOption(optionManager):
|
||||||
__addOutputOption(optionManager)
|
__addOutputOption(optionManager)
|
||||||
__addDMSOutputOption(optionManager)
|
__addDMSOutputOption(optionManager)
|
||||||
__addExportOutputOption(optionManager)
|
__addExportOutputOption(optionManager)
|
||||||
|
__addTabularOption(optionManager)
|
||||||
|
|
||||||
|
@ -15,14 +15,18 @@ from obitools3.parsers.universal import entryIteratorFactory
|
|||||||
|
|
||||||
from obitools3.writers.fasta import FastaNucWriter
|
from obitools3.writers.fasta import FastaNucWriter
|
||||||
from obitools3.writers.fastq import FastqWriter
|
from obitools3.writers.fastq import FastqWriter
|
||||||
|
from obitools3.writers.tab import TabWriter
|
||||||
from obitools3.format.fasta import FastaFormat
|
from obitools3.format.fasta import FastaFormat
|
||||||
from obitools3.format.fastq import FastqFormat
|
from obitools3.format.fastq import FastqFormat
|
||||||
|
from obitools3.format.tab import TabFormat
|
||||||
|
|
||||||
from obitools3.dms.obiseq import Nuc_Seq
|
from obitools3.dms.obiseq import Nuc_Seq
|
||||||
from obitools3.apps.config import getConfiguration,logger
|
from obitools3.apps.config import getConfiguration,logger
|
||||||
from obitools3.apps.temp import get_temp_dms
|
from obitools3.apps.temp import get_temp_dms
|
||||||
from obitools3.utils cimport tobytes, count_entries # TODO tobytes 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.files.universalopener cimport uopen
|
||||||
|
|
||||||
from obitools3.dms.capi.obierrno cimport obi_errno, \
|
from obitools3.dms.capi.obierrno cimport obi_errno, \
|
||||||
OBIVIEW_ALREADY_EXISTS_ERROR
|
OBIVIEW_ALREADY_EXISTS_ERROR
|
||||||
|
|
||||||
@ -283,17 +287,18 @@ def open_uri(uri,
|
|||||||
format=config["obi"][formatkey]
|
format=config["obi"][formatkey]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
format=None
|
format=None
|
||||||
|
|
||||||
if b'seqtype' in qualifiers:
|
if b'seqtype' in qualifiers:
|
||||||
seqtype=qualifiers[b'seqtype'][0]
|
seqtype=qualifiers[b'seqtype'][0]
|
||||||
else:
|
else:
|
||||||
if format == b"ngsfilter": # TODO discuss
|
if format == b"ngsfilter" or format == b"tabular": # TODO discuss
|
||||||
seqtype=None
|
seqtype=None
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
seqtype=config["obi"]["seqtype"]
|
seqtype=config["obi"]["seqtype"]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
seqtype=b"nuc"
|
seqtype=b"nuc"
|
||||||
|
config["obi"]["seqtype"] = seqtype
|
||||||
|
|
||||||
if b'skip' in qualifiers:
|
if b'skip' in qualifiers:
|
||||||
skip=int(qualifiers[b"skip"][0])
|
skip=int(qualifiers[b"skip"][0])
|
||||||
@ -504,7 +509,11 @@ def open_uri(uri,
|
|||||||
skip = skip,
|
skip = skip,
|
||||||
only = only)
|
only = only)
|
||||||
else:
|
else:
|
||||||
raise NotImplementedError('Output sequence file format not implemented')
|
iseq = TabWriter(TabFormat(header=header, NAString=nastring, sep=sep),
|
||||||
|
file,
|
||||||
|
skip=skip,
|
||||||
|
only=only,
|
||||||
|
header=header)
|
||||||
elif format==b"ngsfilter":
|
elif format==b"ngsfilter":
|
||||||
objclass = dict
|
objclass = dict
|
||||||
if input:
|
if input:
|
||||||
|
Reference in New Issue
Block a user