thehyve / tmtk

tranSMART Arborist ETL toolkit
https://pypi.org/project/tmtk/
GNU Lesser General Public License v3.0
6 stars 4 forks source link

If wordmap file is empty call_boris() returns an error #9

Closed wibo-pipping closed 8 years ago

wibo-pipping commented 8 years ago

StopIteration Traceback (most recent call last) /Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pandas/io/parsers.py in read(self, nrows) 1196 try: -> 1197 data = self._reader.read(nrows) 1198 except StopIteration:

pandas/parser.pyx in pandas.parser.TextReader.read (pandas/parser.c:7988)()

pandas/parser.pyx in pandas.parser.TextReader._read_low_memory (pandas/parser.c:8629)()

StopIteration:

During handling of the above exception, another exception occurred:

AttributeError Traceback (most recent call last)

in () ----> 1 zero_study.call_boris() /Users/wibopipping/tools/tmtk/tmtk/study.py in call_boris(self) 137 138 def call_boris(self): --> 139 arborist.call_boris(self) 140 141 @property /Users/wibopipping/tools/tmtk/tmtk/arborist/common.py in call_boris(to_be_shuffled) 51 raise utils.ClassError(type(to_be_shuffled, 'pd.DataFrame, tmtk.Clinical or tmtk.Study')) 52 ---> 53 json_data = create_concept_tree(to_be_shuffled) 54 55 json_data = launch_arborist_gui(json_data) # Returns modified json_data /Users/wibopipping/tools/tmtk/tmtk/arborist/jstreecontrol.py in create_concept_tree(column_object) 25 """ 26 if isinstance(column_object, tmtk.Study): ---> 27 concept_tree = create_tree_from_study(column_object) 28 29 elif isinstance(column_object, pd.DataFrame): /Users/wibopipping/tools/tmtk/tmtk/arborist/jstreecontrol.py in create_tree_from_study(study_object, concept_tree) 49 concept_tree = ConceptTree() 50 ---> 51 concept_tree = create_tree_from_clinical(study_object.Clinical, concept_tree) 52 53 for map_file in study_object.subject_sample_mappings: /Users/wibopipping/tools/tmtk/tmtk/arborist/jstreecontrol.py in create_tree_from_clinical(clinical_object, concept_tree) 80 data_args = variable.column_map_data 81 concept_path = variable.concept_path ---> 82 categories = variable.word_map_dict if not variable.is_numeric else {} 83 84 # Add filename to SUBJ_ID, this is a work around for unique path constraint. /Users/wibopipping/tools/tmtk/tmtk/clinical/Variable.py in is_numeric(self) 58 @property 59 def is_numeric(self): ---> 60 return utils.is_numeric(self.mapped_values) 61 62 @property /Users/wibopipping/tools/tmtk/tmtk/clinical/Variable.py in mapped_values(self) 93 @property 94 def mapped_values(self): ---> 95 return [v for k, v in self.word_map_dict.items()] 96 97 def validate(self, verbosity=2): /Users/wibopipping/tools/tmtk/tmtk/clinical/Variable.py in word_map_dict(self) 88 :return: dict 89 """ ---> 90 word_map = self.parent.WordMapping.get_word_map(self.id_) 91 return {v: word_map.get(v, v) for v in self.unique_values} 92 /Users/wibopipping/tools/tmtk/tmtk/clinical/WordMapping.py in get_word_map(self, var_id) 34 35 filename, column = var_id.rsplit('__', 1) ---> 36 f = self.df.ix[:, 0].astype(str) == filename 37 c = self.df.ix[:, 1].astype(str) == column 38 if sum(f & c): /Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/Werkzeug-0.11.9-py3.5.egg/werkzeug/utils.py in **get**(self, obj, type) 71 value = obj.**dict**.get(self.**name**, _missing) 72 if value is _missing: ---> 73 value = self.func(obj) 74 obj.__dict__[self.**name**] = value 75 return value /Users/wibopipping/tools/tmtk/tmtk/utils/filebase.py in df(self) 13 def df(self): 14 if self.path and os.path.exists(self.path): ---> 15 df, self._hash_init = file2df(self.path, hashed=True) 16 else: 17 CPrint.warn("No dataframe found on disk for {}, creating.".format(self)) /Users/wibopipping/tools/tmtk/tmtk/utils/Generic.py in file2df(path, hashed) 58 df = pd.read_table(path, 59 sep='\t', ---> 60 dtype=object) 61 if hashed: 62 hash_value = hash(df.**bytes**()) /Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pandas/io/parsers.py in parser_f(filepath_or_buffer, sep, dialect, compression, doublequote, escapechar, quotechar, quoting, skipinitialspace, lineterminator, header, index_col, names, prefix, skiprows, skipfooter, skip_footer, na_values, true_values, false_values, delimiter, converters, dtype, usecols, engine, delim_whitespace, as_recarray, na_filter, compact_ints, use_unsigned, low_memory, buffer_lines, warn_bad_lines, error_bad_lines, keep_default_na, thousands, comment, decimal, parse_dates, keep_date_col, dayfirst, date_parser, memory_map, float_precision, nrows, iterator, chunksize, verbose, encoding, squeeze, mangle_dupe_cols, tupleize_cols, infer_datetime_format, skip_blank_lines) 496 skip_blank_lines=skip_blank_lines) 497 --> 498 return _read(filepath_or_buffer, kwds) 499 500 parser_f.__name__ = name /Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pandas/io/parsers.py in _read(filepath_or_buffer, kwds) 283 return parser 284 --> 285 return parser.read() 286 287 _parser_defaults = { /Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pandas/io/parsers.py in read(self, nrows) 745 raise ValueError('skip_footer not supported for iteration') 746 --> 747 ret = self._engine.read(nrows) 748 749 if self.options.get('as_recarray'): /Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pandas/io/parsers.py in read(self, nrows) 1202 self.index_col, 1203 self.index_names, -> 1204 dtype=self.kwds.get('dtype')) 1205 else: 1206 raise /Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pandas/io/parsers.py in _get_empty_meta(columns, index_col, index_names, dtype) 2257 # Convert column indexes to column names. 2258 dtype = dict((columns[k] if com.is_integer(k) else k, v) -> 2259 for k, v in compat.iteritems(dtype)) 2260 2261 if index_col is None or index_col is False: /Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pandas/compat/**init**.py in iteritems(obj, **kwargs) 132 func = getattr(obj, "iteritems", None) 133 if not func: --> 134 func = obj.items 135 return func(**kwargs) 136 AttributeError: type object 'object' has no attribute 'items'
jochemb commented 8 years ago

Thanks, this should be fixed for the following cases: