From 022d61464dbeb259b5cf92017cf776b4d72ff992 Mon Sep 17 00:00:00 2001 From: Sepand Haghighi Date: Thu, 10 Oct 2024 17:23:29 +0330 Subject: [PATCH] Minor edits (#21) * fix : primer_sequence --> sequence * doc : CHANGELOG.md updated * fix : new_seq --> new_sequence --- CHANGELOG.md | 2 +- opr/primer.py | 38 +++++++++++++++++++------------------- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 84ba67d..1673157 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,7 +9,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ### Changed ## [0.1] - 2024-06-05 ### Added -- MeltingTemperature enum +- `MeltingTemperature` enum - Basic melting temperature calculation - `addition` and `multipication` operators overload - `len` magic overload diff --git a/opr/primer.py b/opr/primer.py index 4e3c1f1..929ac8b 100644 --- a/opr/primer.py +++ b/opr/primer.py @@ -29,15 +29,15 @@ class Primer: >>> oprimer.molecular_weight """ - def __init__(self, primer_sequence): + def __init__(self, sequence): """ Initialize the Primer instance. - :param primer_sequence: primer nucleotides sequence - :type primer_sequence: str + :param sequence: primer nucleotides sequence + :type sequence: str :return: an instance of the Primer class """ - self._sequence = Primer.validate_primer(primer_sequence) + self._sequence = Primer.validate_primer(sequence) self._molecular_weight = None self._gc_content = None self._melting_temperature = { @@ -86,11 +86,11 @@ def reverse(self, inplace=False): :type inplace: bool :return: new Primer object or None """ - new_seq = self._sequence[::-1] + new_sequence = self._sequence[::-1] if inplace: - self._sequence = new_seq + self._sequence = new_sequence else: - return Primer(primer_sequence=new_seq) + return Primer(sequence=new_sequence) def complement(self, inplace=False): """ @@ -100,33 +100,33 @@ def complement(self, inplace=False): :type inplace: bool :return: new Primer object or None """ - new_seq = "" + new_sequence = "" for item in self._sequence: - new_seq += DNA_COMPLEMENT_MAP[item] + new_sequence += DNA_COMPLEMENT_MAP[item] if inplace: - self._sequence = new_seq + self._sequence = new_sequence else: - return Primer(primer_sequence=new_seq) + return Primer(sequence=new_sequence) @staticmethod - def validate_primer(primer_sequence): + def validate_primer(sequence): """ Validate the given primer sequence. - :param primer_sequence: primer nucleotides sequence - :type primer_sequence: any + :param sequence: primer nucleotides sequence + :type sequence: any :return: an uppercased primer sequence """ - if not isinstance(primer_sequence, str): + if not isinstance(sequence, str): raise OPRBaseError(PRIMER_SEQUENCE_TYPE_ERROR) - primer_sequence = primer_sequence.upper() + sequence = sequence.upper() - if len(primer_sequence) < PRIMER_LOWER_LENGTH or len(primer_sequence) > PRIMER_HIGHEST_LENGTH: + if len(sequence) < PRIMER_LOWER_LENGTH or len(sequence) > PRIMER_HIGHEST_LENGTH: warn(PRIMER_SEQUENCE_LENGTH_WARNING, RuntimeWarning) - if not all(base in VALID_BASES for base in primer_sequence): + if not all(base in VALID_BASES for base in sequence): raise OPRBaseError(PRIMER_SEQUENCE_VALID_BASES_ERROR) - return primer_sequence + return sequence @property def sequence(self):