Skip to content

Commit

Permalink
Equality (#30)
Browse files Browse the repository at this point in the history
* feat : __eq__ method

* fix : tests updated

* doc : CHANGELOG.md updated
  • Loading branch information
sepandhaghighi authored Nov 29, 2024
1 parent cd7cd43 commit 09cfd0a
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [Unreleased]
### Added
- `equality` operator overload
## [0.1] - 2024-11-27
### Added
- `MeltingTemperature` enum
Expand Down
10 changes: 10 additions & 0 deletions opr/primer.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,16 @@ def __len__(self):
"""
return len(self._sequence)

def __eq__(self, other_primer):
"""
Check primers equality.
:param other_primer: another Primer
:type other_primer: Primer
:return: result as bool
"""
return self._sequence == other_primer._sequence

def __add__(self, other_primer):
"""
Concatenate the sequences of the current Primer with another one.
Expand Down
10 changes: 10 additions & 0 deletions tests/test_operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,13 @@ def test_multiply():
oprimer_1 = Primer("ATCG")
oprimer_concat = oprimer_1 * 4
assert oprimer_concat.sequence == "ATCGATCGATCGATCG"

def test_equality1():
oprimer_1 = Primer("ATCG")
oprimer_2 = Primer("ATCG")
assert oprimer_1 == oprimer_2

def test_equality2():
oprimer_1 = Primer("ATCG")
oprimer_2 = Primer("ATCGC")
assert oprimer_1 != oprimer_2

0 comments on commit 09cfd0a

Please sign in to comment.