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

__str__ #36

Merged
merged 4 commits into from
Jan 1, 2025
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
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
AHReccese marked this conversation as resolved.
Show resolved Hide resolved
- `__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