Princeton-LSI-ResearchComputing / tracebase

Mouse Metabolite Tracing Data Repository for the Rabinowitz Lab
MIT License
4 stars 1 forks source link

Isotope parsing fails when multiple isotopes are separated with a command and a space: e.g. [13C6, 15N3] #950

Open lparsons opened 2 months ago

lparsons commented 2 months ago

BUG DESCRIPTION

Problem

Tracers with multiple Isotopes separated with a command and space (,) instead of just a a comma with no space (,) result in and IsotopeParsingError

Steps to reproduce

  1. Attempt to load the following study sheet: col013a_tracebase_studydoc.xlsx

    python manage.py load_protocols --infile "col013a_tracebase_studydoc.xlsx"
    

Current behavior

Importing animals and samples...
Traceback (most recent call last):
  File "/var/www/tracebase/manage.py", line 22, in <module>
    main()
  File "/var/www/tracebase/manage.py", line 18, in main
    execute_from_command_line(sys.argv)
  File "/usr/local/tracebase/lib/python3.9/site-packages/django/core/management/__init__.py", line 442, in execute_from_command_line
    utility.execute()
  File "/usr/local/tracebase/lib/python3.9/site-packages/django/core/management/__init__.py", line 436, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/local/tracebase/lib/python3.9/site-packages/django/core/management/base.py", line 412, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/usr/local/tracebase/lib/python3.9/site-packages/django/core/management/base.py", line 458, in execute
    output = self.handle(*args, **options)
  File "/var/www/tracebase/DataRepo/models/maintained_model.py", line 1232, in wrapper
    fn(*args, **kwargs)
  File "/var/www/tracebase/DataRepo/management/commands/load_animals_and_samples.py", line 192, in handle
    loader.load_sample_table(
  File "/var/www/tracebase/DataRepo/models/maintained_model.py", line 1232, in wrapper
    fn(*args, **kwargs)
  File "/var/www/tracebase/DataRepo/loaders/sample_table_loader.py", line 253, in load_sample_table
    raise e
  File "/var/www/tracebase/DataRepo/loaders/sample_table_loader.py", line 237, in load_sample_table
    self._load_data(data)
  File "/var/www/tracebase/DataRepo/loaders/sample_table_loader.py", line 288, in _load_data
    infusate_rec = self.get_or_create_infusate(rownum, row)
  File "/var/www/tracebase/DataRepo/loaders/sample_table_loader.py", line 496, in get_or_create_infusate
    infusate_data_object = parse_infusate_name(infusate_str, tracer_concs)
  File "/var/www/tracebase/DataRepo/utils/infusate_name_parser.py", line 102, in parse_infusate_name
    "tracer": parse_tracer_string(tracer_string),
  File "/var/www/tracebase/DataRepo/utils/infusate_name_parser.py", line 124, in parse_tracer_string
    tracer_data["isotopes"] = parse_isotope_string(match.group("isotopes").strip())
  File "/var/www/tracebase/DataRepo/utils/infusate_name_parser.py", line 176, in parse_isotope_string
    raise IsotopeParsingError(
DataRepo.utils.infusate_name_parser.IsotopeParsingError: One or more encoded isotopes in [13C6, 15N3] could not be parsed. Only the following were parsed: [13C6,15N3].

Expected behavior

The tracer would be parsed and loaded correctly.

Suggested Change

None provided

Comment

None


ISSUE OWNER SECTION

Assumptions

  1. List of assumptions made WRT the code
  2. E.g. We will assume input is correct (explaining why there is no validation)

Limitations

  1. A list of things this work will specifically not do
  2. E.g. This feature will only handle the most frequent use case X

Affected Components

Requirements

DESIGN

GUI Change description

None provided

Code Change Description

None provided

Tests