RECETOX / RIAssigner

RIAssigner is a python tool for retention index (RI) computation for GC-MS data.
MIT License
4 stars 6 forks source link

catch the rt_index being None #93

Closed martenson closed 5 months ago

martenson commented 2 years ago

As defined in the method here the value returned can be None which will throw an uncaught ValueError when passed as _rt_index here: https://github.com/RECETOX/RIAssigner/blob/main/RIAssigner/data/PandasData.py#L48

Traceback (most recent call last):
  File "/usr/local/lib/python3.8/runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/local/lib/python3.8/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/usr/local/lib/python3.8/site-packages/RIAssigner/__main__.py", line 62, in <module>
    main(sys.argv[1:])
  File "/usr/local/lib/python3.8/site-packages/RIAssigner/__main__.py", line 48, in main
    args = parser.parse_args(argv)
  File "/usr/local/lib/python3.8/argparse.py", line 1768, in parse_args
    args, argv = self.parse_known_args(args, namespace)
  File "/usr/local/lib/python3.8/argparse.py", line 1800, in parse_known_args
    namespace, args = self._parse_known_args(args, namespace)
  File "/usr/local/lib/python3.8/argparse.py", line 2006, in _parse_known_args
    start_index = consume_optional(start_index)
  File "/usr/local/lib/python3.8/argparse.py", line 1946, in consume_optional
    take_action(action, args, option_string)
  File "/usr/local/lib/python3.8/argparse.py", line 1874, in take_action
    action(self, namespace, argument_values, option_string)
  File "/usr/local/lib/python3.8/site-packages/RIAssigner/cli/LoadDataAction.py", line 34, in __call__
    data = PandasData(filename, filetype, rt_unit)
  File "/usr/local/lib/python3.8/site-packages/RIAssigner/data/PandasData.py", line 15, in __init__
    self._read()
  File "/usr/local/lib/python3.8/site-packages/RIAssigner/data/PandasData.py", line 22, in _read
    self._init_rt_column_info()
  File "/usr/local/lib/python3.8/site-packages/RIAssigner/data/PandasData.py", line 47, in _init_rt_column_info
    self._rt_position = self._data.columns.tolist().index(self._rt_index)
ValueError: None is not in list
hechth commented 2 years ago

True - there should be a better explanation if no RT column is found.

hechth commented 6 months ago

We should allow reading data that has no retention time or retention index because we only need it for some operations. We need to check where the software currently actually fails if no retention index or retention time information is present. We need to define which functions should trigger an exception in which situation and implement unit tests for this.

Basically the tool should:

hechth commented 6 months ago

There is a good course on exception handling: https://app.pluralsight.com/library/courses/core-python-robust-resource-error-handling/table-of-contents