Skip to content

Commit

Permalink
chore: tiny fixups
Browse files Browse the repository at this point in the history
  • Loading branch information
clintval committed Dec 29, 2024
1 parent 619b147 commit 914379d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
10 changes: 5 additions & 5 deletions fgpyo/sam/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1319,13 +1319,13 @@ class SecondaryAlignment:
def __post_init__(self) -> None:
"""Perform post-initialization validation on this dataclass."""
if self.reference_start < 0:
raise ValueError(f"Start cannot be less zero! Found: {self.reference_start}")
raise ValueError(f"Start cannot be <0! Found: {self.reference_start}")
if self.edit_distance < 0:
raise ValueError(f"Edit distance cannot be less zero! Found: {self.edit_distance}")
raise ValueError(f"Edit distance cannot be <0! Found: {self.edit_distance}")
if self.alignment_score is not None and self.alignment_score < 0:
raise ValueError(f"Alignment score cannot be less zero! Found: {self.alignment_score}")
raise ValueError(f"Alignment score cannot be <0! Found: {self.alignment_score}")
if self.mapq is not None and self.mapq < 0:
raise ValueError(f"Mapping quality cannot be less zero! Found: {self.mapq}")
raise ValueError(f"Mapping quality cannot be <0! Found: {self.mapq}")

@classmethod
def from_tag_part(cls, part: str) -> "SecondaryAlignment":
Expand Down Expand Up @@ -1365,7 +1365,7 @@ def many_from_tag(cls, value: str) -> list["SecondaryAlignment"]:
Args:
value: A single `XA` or `XB` tag value.
"""
return list(map(cls.from_tag_part, value.rstrip(";").split(";")))
return [cls.from_tag_part(part) for part in value.rstrip(";").split(";")]

@classmethod
def many_from_rec(cls, rec: AlignedSegment) -> list["SecondaryAlignment"]:
Expand Down
8 changes: 4 additions & 4 deletions tests/fgpyo/sam/test_secondary_alignment.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"alignment_score": 0,
"mapq": 30,
},
"Start cannot be less zero! Found: -1",
"Start cannot be <0! Found: -1",
),
(
{
Expand All @@ -36,7 +36,7 @@
"alignment_score": 0,
"mapq": 30,
},
"Edit distance cannot be less zero! Found: -1",
"Edit distance cannot be <0! Found: -1",
),
(
{
Expand All @@ -48,7 +48,7 @@
"alignment_score": -1,
"mapq": 30,
},
"Alignment score cannot be less zero! Found: -1",
"Alignment score cannot be <0! Found: -1",
),
(
{
Expand All @@ -60,7 +60,7 @@
"alignment_score": 4,
"mapq": -1,
},
"Mapping quality cannot be less zero! Found: -1",
"Mapping quality cannot be <0! Found: -1",
),
],
)
Expand Down

0 comments on commit 914379d

Please sign in to comment.