Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Equality #30

Merged
merged 3 commits into from
Nov 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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