diff --git a/CHANGELOG.md b/CHANGELOG.md index 067813b..059c5b7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,11 +6,13 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [Unreleased] ### Added -- `equality` operator overload +- `__eq__` overload +- `__str__` overload - `gc_clamp` property - `single_runs` property ### Changed -- `property` deleter & setter removed +### Removed +- `property` deleter & setter ## [0.1] - 2024-11-27 ### Added - `MeltingTemperature` enum diff --git a/opr/functions.py b/opr/functions.py index e742e65..99c6a3c 100644 --- a/opr/functions.py +++ b/opr/functions.py @@ -50,6 +50,7 @@ def gc_clamp_calc(sequence): return 0 return sequence[-5:].count('G') + sequence[-5:].count('C') + def single_run_length(sequence, base): """ Calculate the maximum consecutive occurrence of a Nucleic acid (base) in a sequence. diff --git a/opr/primer.py b/opr/primer.py index b1ea9ef..8d0ccbf 100644 --- a/opr/primer.py +++ b/opr/primer.py @@ -89,6 +89,14 @@ def __mul__(self, number): return Primer(self._sequence * number) raise OPRBaseError(PRIMER_MULTIPLICATION_ERROR) + def __str__(self): + """ + Primer object string representation method. + + :return: primer sequence as str + """ + return self._sequence + def reverse(self, inplace=False): """ Reverse sequence. diff --git a/tests/test_operations.py b/tests/test_operations.py index a83dd75..ddf881e 100644 --- a/tests/test_operations.py +++ b/tests/test_operations.py @@ -57,3 +57,10 @@ def test_equality2(): oprimer_1 = Primer("ATCG") oprimer_2 = Primer("ATCGC") assert oprimer_1 != oprimer_2 + +def test_str(): + oprimer_1 = Primer("ATCG") + oprimer_2 = Primer("ATCGC") + oprimer_concat = oprimer_1 + oprimer_2 + assert str(oprimer_1) + str(oprimer_2) == oprimer_concat.sequence +