Princeton-LSI-ResearchComputing / tracebase

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

Tracer and infusates loader #822

Open hepcat72 opened 6 months ago

hepcat72 commented 6 months ago

FEATURE REQUEST

Inspiration

The animal/sample table loader is bloated, so it makes sense to break it up. This will also standardize the loaders to have a common interface with common file types to input.

Description

Create separate sheets for the tracer and infusate data, and create separate loaders to load them.

Alternatives

None

Dependencies

Parent issue-tracking issue:

Comment

I created an example version of the Study Excel doc:

study.xlsx


ISSUE OWNER SECTION

Assumptions

None

Limitations

None

Affected Components

Requirements

Fleshed out a bit more than in #753:

^ In reference to item 1, I determined that the load order will be addressed in a separate issue (mainly because I don't want to break main, but also because it fits into a logically different effort. Items 2 & 4 conflict with items 3 & 5. The spreadsheet very well may automatically populate the names, but the scripts can easily construct them.

The requirements from #753:

  • [x] 6. New loader scripts
  • [x] 6.1. Tracers Loader
  • [x] 6.2. Infusates Loader
  • [x] 8.6. Infusates Tab
  • [x] 8.6.1. Add Columns
  • [x] 8.6.1.1. Infusate Number
  • [x] 8.6.1.2. Tracer Group Name
  • [x] 8.6.1.3. Infusate Name
  • [x] 8.6.1.4. Tracer Number
  • [x] 8.6.1.5. Tracer Concentration
  • [x] 8.7. Tracers Tab
  • [x] 8.7.1. Add Columns
  • [x] 8.7.1.1. Tracer Number
  • [x] 8.7.1.2. Compound Name
  • [x] 8.7.1.3. Element
  • [x] 8.7.1.4. Mass Number
  • [x] 8.7.1.5. Label Count
  • [x] 8.7.1.6. Label Positions
  • [x] 8.7.1.7. Tracer Name (based on Study doc, Tracers tab contents)

DESIGN

Interface Change description

2 new load scripts.

The infusate records span multiple rows. For 1 infusate, there will be a row for each unique tracer and concentration combo.

Similarly, the tracer records will span multiple rows. For 1 tracer, there will be a row for each unique labeled element.

Code Change Description

Should be fairly straightforward, using other loaders as a template. Infusate number and tracer number will be used to identify distinct infusates/tracers, but those numbers will not be loaded into the DB.

Tests

A test for each requirement

hepcat72 commented 4 months ago

Going with a unit tests strategy, though the load_tracers.py tests apply directly to the requirements.

hepcat72 commented 4 months ago

Possible improvements.

I noted that with the tracer data, these class attributes:

...could be reconfigured to support conditionally required logic, e.g. either column 1 or 2 is (or both are) required. Might be an easy change.

Also, I noted that:

...could feasibly map a single model field to multiple columns. The mapping is only used for error reporting of database errors, after all. The field types don't even have to be the same (e.g. "Tracer.compoundis a foreign key, and it can reference the "compound name" column). SoTracerLabel.name` could reference the columns "element", "count", "mass number", and "positions".

Though I will also point out that since Tracer.name and TracerLabel.name are both maintained fields that are controlled via autoupdate, they are prevented from being included in model object creations or calls to Model.objects.create(), so that is currently moot.

hepcat72 commented 3 months ago

The infusates loader class has almost exactly the same allotment of tests as the tracers loader class.

The load_infusates.py tests: