Skip to content

Commit 53ef3a9

Browse files
committed
Extract instrument name from instrument collection
Note that in the future we might want to make instrument a fully fledged model in our database.
1 parent 60a6eae commit 53ef3a9

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

nmdc_server/ingest/omics_processing.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,13 @@ def load_omics_processing(db: Session, obj: Dict[str, Any], mongodb: Database, l
114114
obj["analyte_category"] = omics_types[obj["analyte_category"].lower()]
115115
obj["omics_type"] = omics_types[obj["analyte_category"].lower()]
116116

117+
# Get instrument name
118+
instrument_id = obj.pop("instrument_used", [])
119+
if instrument_id:
120+
instrument = mongodb["instrument_set"].find_one({"id": instrument_id[0]})
121+
if instrument:
122+
obj["instrument_name"] = instrument["name"]
123+
117124
omics_processing = models.OmicsProcessing(**OmicsProcessing(**obj).dict())
118125
for biosample_object in biosample_input_objects:
119126
# mypy thinks that omics_processing.biosample_inputs is of type Biosample

0 commit comments

Comments
 (0)