From ced9a268a1fb0538fa590cb6e620a2d561d588a2 Mon Sep 17 00:00:00 2001 From: Celine Mercier Date: Tue, 11 Jul 2017 12:10:33 +0200 Subject: [PATCH] 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) --- python/obitools3/commands/import.pyx | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/python/obitools3/commands/import.pyx b/python/obitools3/commands/import.pyx index 1c66471..15c8625 100644 --- a/python/obitools3/commands/import.pyx +++ b/python/obitools3/commands/import.pyx @@ -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='', + 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