Skip to content
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 16 additions & 10 deletions src/pixelator/pna/config/config_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,16 +93,23 @@ def load_panel_file(self, path: PathType) -> None:
def add_panel(self, panel: PNAAntibodyPanel) -> None:
"""Register a panel and its lookup keys in the config.

The panel is indexed by panel name (or filename fallback), optional product,
and aliases.
The panel is indexed by panel name, optional product, and aliases.
Only a single-source panel can be registered. Panel CSV files are
one source.

Args:
panel: Panel object to add.

Raises:
ValueError: If ``panel`` has more or fewer than one source.
PanelException: If an alias already maps to a different panel key.
"""
key = panel.name if panel.name is not None else str(panel.filename)
if len(panel.sources) != 1:
raise ValueError(
"Only a single-source panel can be added to the config. "
f"Got {len(panel.sources)} sources."
)
key = panel.name
self.panels[key].append(panel)

# allow to also get panel by product name if provided in the panel file
Expand Down Expand Up @@ -279,18 +286,17 @@ def get_panel(
+ "alias to disambiguate.",
)

def keyfunc(p):
def keyfunc(p: PNAAntibodyPanel):
"""Keyfunc.

Args:
p: p.
p: PNAAntibodyPanel.

Returns:
Parsed semantic version of the panel.
"""
version = p.version
if version is None:
v = semver.Version.parse("0.0.0")

v = semver.Version.parse(version)
return v
return semver.Version.parse(version)

panels_with_key = sorted(panels_with_key, key=keyfunc, reverse=True)
return panels_with_key[0]
Expand Down
2 changes: 2 additions & 0 deletions src/pixelator/pna/config/panel/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"""

from pixelator.pna.config.panel.antibody_panel import (
PanelSource,
PNAAntibodyPanel,
load_antibody_panel,
)
Expand All @@ -17,6 +18,7 @@
__all__ = [
"PNAAntibodyPanel",
"PNAAntibodyPanelDiff",
"PanelSource",
"collapsed_hashing_marker_id",
"load_antibody_panel",
"sample_hashing_mask",
Expand Down
Loading
Loading