From b4a1d68d2142e632a3c0ae3fd1ee4df2f3a97391 Mon Sep 17 00:00:00 2001 From: Erin McAuley Date: Thu, 3 Oct 2024 14:33:05 -0400 Subject: [PATCH] refactor: apply msto suggestions Co-authored-by: Matt Stone --- prymer/primer3/primer3_parameters.py | 9 +++++++-- tests/primer3/test_primer3_input.py | 2 +- tests/primer3/test_primer3_weights.py | 2 +- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/prymer/primer3/primer3_parameters.py b/prymer/primer3/primer3_parameters.py index e8a01a0..854ab84 100644 --- a/prymer/primer3/primer3_parameters.py +++ b/prymer/primer3/primer3_parameters.py @@ -221,8 +221,13 @@ 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_end_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]: diff --git a/tests/primer3/test_primer3_input.py b/tests/primer3/test_primer3_input.py index 1bda9a2..f0194cf 100644 --- a/tests/primer3/test_primer3_input.py +++ b/tests/primer3/test_primer3_input.py @@ -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( diff --git a/tests/primer3/test_primer3_weights.py b/tests/primer3/test_primer3_weights.py index b3a6504..5a04dc7 100644 --- a/tests/primer3/test_primer3_weights.py +++ b/tests/primer3/test_primer3_weights.py @@ -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: