Raises: ValueError: If the conversion table is misconfigured.
(self)
| 53 | return [bpt for bpt in self.project_bodyparts if bpt in self.table] |
| 54 | |
| 55 | def validate(self) -> None: |
| 56 | """ |
| 57 | Raises: |
| 58 | ValueError: If the conversion table is misconfigured. |
| 59 | """ |
| 60 | project_bpts = set(self.project_bodyparts) |
| 61 | sa_bpts = set(self.super_animal_bodyparts) |
| 62 | |
| 63 | mapped_sa = set(self.table.values()) |
| 64 | mapped_project = set(self.table.keys()) |
| 65 | |
| 66 | # check all mapped SuperAnimal bodyparts are in the config |
| 67 | if len(mapped_sa.difference(sa_bpts)) != 0: |
| 68 | extra_bodyparts = set(mapped_sa).difference(sa_bpts) |
| 69 | raise ValueError( |
| 70 | f"Some bodyparts in your mapping are not in the {self.super_animal} " |
| 71 | f"model: {extra_bodyparts}. Available bodyparts are {' '.join(sa_bpts)}" |
| 72 | ) |
| 73 | |
| 74 | # check all given bodyparts are in the project configuration |
| 75 | if len(mapped_project.difference(project_bpts)) != 0: |
| 76 | extra_bodyparts = mapped_project.difference(project_bpts) |
| 77 | raise ValueError( |
| 78 | "Some bodyparts in your mapping are not in your project configuration: " |
| 79 | f"{extra_bodyparts}. Defined bodyparts are {' '.join(project_bpts)}" |
| 80 | ) |
no test coverage detected