Skip to content

Commit

Permalink
refactor: apply msto suggestions
Browse files Browse the repository at this point in the history
Co-authored-by: Matt Stone <[email protected]>
  • Loading branch information
emmcauley and msto authored Oct 3, 2024
1 parent 2393014 commit 8a22df3
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
5 changes: 3 additions & 2 deletions prymer/primer3/primer3_parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,9 @@ def __post_init__(self) -> None:
if self.probe_max_dinuc_bases % 2 == 1:
raise ValueError("Max threshold for dinucleotide bases must be an even number of bases")
default_thermo_max: float = self.probe_tms.min - 10.0
for field in fields(self): # if *_thermo fields are None, set to default
if field.type is Optional[float] and getattr(self, field.name) is None:
thermo_max_fields = ["probe_max_self_any_thermo", "probe_max_self_any_thermo", "probe_max_hairpin_thermo"]
for field in fields(self):
if field.name in thermo_max_fields and getattr(self, field.name) is None:
object.__setattr__(self, field.name, default_thermo_max)

def to_input_tags(self) -> dict[Primer3InputTag, Any]:
Expand Down
2 changes: 1 addition & 1 deletion tests/primer3/test_primer3_input.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def test_probe_design_only_valid(
)
mapped_dict = test_input.to_input_tags(design_region=test_design_region)
assert mapped_dict[Primer3InputTag.PRIMER_PICK_INTERNAL_OLIGO] == 1
assert len(mapped_dict.keys()) == 27
assert len(mapped_dict) == 27

# test instantiation of default `ProbeWeights` when they are not provided
altered_input = Primer3Input(
Expand Down
2 changes: 1 addition & 1 deletion tests/primer3/test_primer3_weights.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def test_probe_weights_valid() -> None:
assert test_dict[Primer3InputTag.PRIMER_INTERNAL_WT_SELF_ANY_TH] == 1.0
assert test_dict[Primer3InputTag.PRIMER_INTERNAL_WT_SELF_END_TH] == 1.0
assert test_dict[Primer3InputTag.PRIMER_INTERNAL_WT_HAIRPIN_TH] == 1.0
assert len((test_dict.values())) == 9
assert len(test_dict) == 9


def test_primer_weights_to_input_tags() -> None:
Expand Down

0 comments on commit 8a22df3

Please sign in to comment.