Skip to content

Commit

Permalink
__str__ (#36)
Browse files Browse the repository at this point in the history
* feat : __str__ overload

* fix : test_operations.py updated

* doc : CHANGELOG.md updated

* fix : autopep8
  • Loading branch information
sepandhaghighi authored Jan 1, 2025
1 parent b44f560 commit 062eaa8
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 2 deletions.
6 changes: 4 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions opr/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
8 changes: 8 additions & 0 deletions opr/primer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
7 changes: 7 additions & 0 deletions tests/test_operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 062eaa8

Please sign in to comment.