obi import: added an option to specify the NA value in the input file

(default is 'NA', same as in R's read.table function)
This commit is contained in:
Celine Mercier
2017-07-11 12:10:33 +02:00
parent df2ad41150
commit ced9a268a1

View File

@ -104,9 +104,15 @@ def addOptions(parser):
const='pep',
help="Input file contains protein sequences")
group.add_argument('--NA',
action="store", dest="import:NA",
metavar='<NA_value>',
default='NA',
type=str,
help="Character string for Not Available values in the input file "
"(default: 'NA'")
# TODO: Handling of NA values. Check None. Specify in doc? None or NA? Possiblity to specify in option?
# look in R read.table option to specify NA value
def run(config):
cdef int i
@ -192,6 +198,10 @@ def run(config):
value = seq['tags'][tag]
# Check NA value
if value == config['import']['NA'] :
value = None
if tag not in dcols :
value_type = type(value)
@ -209,7 +219,7 @@ def run(config):
if value_obitype != OBI_VOID :
dcols[tag] = (Column.new_column(view, tag, value_obitype, nb_elements_per_line=nb_elts, elements_names=elt_names), value_obitype)
# Fill value
dcols[tag][0][i] = value