Skip to content

Commit 50378b8

Browse files
committed
added check to Reference.plate_map to raise exception if the plate name is not found in the reference
1 parent bdea4d1 commit 50378b8

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/alhambra_mixes/references.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,15 +81,22 @@ def plate_map(
8181
:return:
8282
a :class:`PlateMap` consisting of all strands in this Reference object from plate named
8383
`name`. Currently always makes a 96-well plate.
84+
:raises ValueError:
85+
If the `name` is not the name of a plate in the reference.
8486
"""
8587
well_to_strand_name = {}
88+
found_plate_name = False
8689
for row in self.df.itertuples():
8790
if row.Plate == name: # type: ignore
91+
found_plate_name = True
8892
well = row.Well # type: ignore
8993
sequence = row.Sequence # type: ignore
9094
strand = Strand(name=row.Name, sequence=sequence) # type: ignore
9195
well_to_strand_name[well] = strand.name
9296

97+
if not found_plate_name:
98+
raise ValueError(f'Plate "{name}" not found in reference file.')
99+
93100
plate_map = PlateMap(
94101
plate_name=name,
95102
plate_type=plate_type,

0 commit comments

Comments
 (0)