Skip to content

Commit

Permalink
add check for sample IDs
Browse files Browse the repository at this point in the history
  • Loading branch information
cdiener committed Aug 2, 2024
1 parent 42d7ceb commit 8669cda
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ Limit logger default change to workflows only.

Make some attempts to clean the taxon name in interactions.

Workflows accepting per sample media will now raise an error if the medium is missing
samples.

### 0.36.1

Fixes a crash in the `minimal_media` workflow when growth rates are infeasible.
Expand Down
5 changes: 5 additions & 0 deletions micom/workflows/media.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ def process_medium(medium, samples):
m["sample_id"] = s
meds.append(m)
medium = pd.concat(meds, axis=0)
elif not all(s in medium.sample_id.unique() for s in samples):
missing = [s for s in samples if s not in medium.sample_id.unique()]
raise ValueError(
"The medium is missing samples from the manifest: {', '.join(missing)}."
)
return medium.drop_duplicates(subset=["reaction", "sample_id"])


Expand Down

0 comments on commit 8669cda

Please sign in to comment.