Skip to content

Commit

Permalink
Merge branch 'dev' into add/feature
Browse files Browse the repository at this point in the history
  • Loading branch information
AHReccese authored Jan 16, 2025
2 parents 1b9a842 + adce824 commit 0513dc7
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
### Added
- `double_runs` property
- `repeats` method
- `name` property
### Changed
- Test system modified
## [0.2] - 2025-01-09
### Added
- `__eq__` overload
Expand Down
2 changes: 2 additions & 0 deletions opr/params.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
G_WEIGHT = 329.21
ANHYDROUS_MOLECULAR_WEIGHT_CONSTANT = 61.96

DEFAULT_PRIMER_NAME = "unknown"

PRIMER_SEQUENCE_TYPE_ERROR = "Primer sequence should be a string variable."
PRIMER_SEQUENCE_LENGTH_WARNING = "The recommended range for primer length is between 18 and 30."
PRIMER_SEQUENCE_VALID_BASES_ERROR = "Primer sequence should only contain the nucleotide bases A, T, C, and G."
Expand Down
16 changes: 14 additions & 2 deletions opr/primer.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from enum import Enum
from warnings import warn
from .errors import OPRBaseError
from .params import VALID_BASES
from .params import DEFAULT_PRIMER_NAME, VALID_BASES
from .params import PRIMER_SEQUENCE_TYPE_ERROR, PRIMER_SEQUENCE_LENGTH_WARNING, PRIMER_SEQUENCE_VALID_BASES_ERROR, PRIMER_SEQUENCE_VALID_GC_CONTENT_RANGE_WARNING
from .params import PRIMER_LOWER_LENGTH, PRIMER_HIGHEST_LENGTH, PRIMER_LOWEST_GC_RANGE, PRIMER_HIGHEST_GC_RANGE
from .params import DNA_COMPLEMENT_MAP
Expand All @@ -30,15 +30,18 @@ class Primer:
>>> oprimer.molecular_weight
"""

def __init__(self, sequence):
def __init__(self, sequence, name=DEFAULT_PRIMER_NAME):
"""
Initialize the Primer instance.
:param sequence: primer nucleotides sequence
:type sequence: str
:param name: primer name
:type name: str
:return: an instance of the Primer class
"""
self._sequence = Primer.validate_primer(sequence)
self._name = name
self._molecular_weight = None
self._gc_content = None
self._gc_clamp = None
Expand Down Expand Up @@ -159,6 +162,15 @@ def sequence(self):
"""
return self._sequence

@property
def name(self):
"""
Return the primer name.
:return: primer name
"""
return self._name

@property
def molecular_weight(self):
"""
Expand Down
13 changes: 13 additions & 0 deletions tests/test_property.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from opr import Primer

TEST_CASE_NAME = "Property tests"


def test_sequence():
oprimer = Primer("ATCGATCGATCGATCGAT")
assert oprimer.sequence== "ATCGATCGATCGATCGAT"


def test_name():
oprimer = Primer("ATCGATCGATCGATCGAT", "primer1")
assert oprimer.name == "primer1"

0 comments on commit 0513dc7

Please sign in to comment.