2727# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2828# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2929
30- """Cythonized oligonucleotide functions."""
30+ from array import array
31+ from typing import Any
32+
33+ def m_reverse (sequence : array [int ]) -> Any :
34+ """Reverse a nucleotide sequence.
35+
36+ Args:
37+ sequence (uchar[]): Nucleotide sequence writeable memory view.
38+
39+ Returns:
40+ (void) Reverse a sequence in place.
41+
42+ """
3143
3244def reverse (sequence : str ) -> str :
3345 """Reverse a nucleotide sequence.
@@ -46,6 +58,18 @@ def reverse(sequence: str) -> str:
4658
4759 """
4860
61+ def m_complement (sequence : array [int ], dna : bool = ...) -> Any :
62+ """Complement a nucleotide sequence.
63+
64+ Args:
65+ sequence (uchar[]): Nucleotide sequence writeable memory view.
66+ dna (bool): Sequence is DNA, else RNA.
67+
68+ Returns:
69+ (void) Complement nucleotide sequence in place.
70+
71+ """
72+
4973def complement (sequence : str , dna : bool = ...) -> str :
5074 """Complement a nucleotide sequence.
5175
@@ -64,6 +88,18 @@ def complement(sequence: str, dna: bool = ...) -> str:
6488
6589 """
6690
91+ def m_reverse_complement (sequence : array [int ], dna : bool = ...) -> Any :
92+ """Reverse complement a nucleotide sequence.
93+
94+ Args:
95+ sequence (uchar[]): Nucleotide sequence writeable memory view.
96+ dna (bool): Sequence is DNA, else RNA.
97+
98+ Returns:
99+ (void) Reverse complement nucleotide sequence in place.
100+
101+ """
102+
67103def reverse_complement (sequence : str , dna : bool = ...) -> str :
68104 """Reverse complement a nucleotide sequence.
69105
@@ -90,31 +126,40 @@ def palindrome(sequence: str, dna: bool = ...) -> str:
90126 dna (bool): Sequence is DNA, else RNA.
91127
92128 Returns:
93- (str): longest palindromic subsequence within sequence.
129+ (str) longest palindromic subsequence within sequence.
94130
95131 Examples:
96132 .. code-block:: python
97133
98134 palindrome("ATAT") == "ATAT"
99135 palindrome("GATATG") == "ATAT"
100136 palindrome("ANT") == "ANT" # Handles degenerate bases
101- palindrome("UGCA", False) == "UGCA" # Handles RNA sequences
102137
103138 Notes:
104- * Algorithmic time complexity O(NlogN).
105139 * If a sequence contains two or more palindromic substrings of equal size, the
106140 first leftmost palindrome is prioritized.
107141
108142 """
109143
144+ def m_stretch (sequence : array [int ]) -> int :
145+ """Return the maximum length of a single letter (nucleotide) repeat in a string.
146+
147+ Args:
148+ sequence (uchar[]): Nucleotide sequence writeable memory view.
149+
150+ Returns:
151+ (int) Length of maximum run of a single letter.
152+
153+ """
154+
110155def stretch (sequence : str ) -> int :
111156 """Return the maximum length of a single letter (nucleotide) repeat in a string.
112157
113158 Args:
114159 sequence (str): Nucleotide sequence string.
115160
116161 Returns:
117- (int): Length of maximum run of a single letter.
162+ (int) Length of maximum run of a single letter.
118163
119164 Examples:
120165 .. code-block:: python
@@ -124,6 +169,22 @@ def stretch(sequence: str) -> int:
124169
125170 """
126171
172+ def m_nrepeats (sequence : array [int ], n : int ) -> int :
173+ """Calculate the maximum observed repeats of composite pattern size n characters.
174+
175+ Args:
176+ sequence (uchar[]): Nucleotide sequence string.
177+ n (int): Size of k-mers (composite pattern) to observe.
178+
179+ Returns:
180+ (int) The longest tandem run of nucleotides comprised of a composite pattern
181+ of length n characters.
182+
183+ Raises:
184+ ZeroDivisionError: if value of n is 0.
185+
186+ """
187+
127188def nrepeats (sequence : str , n : int ) -> int :
128189 """Calculate the maximum observed repeats of composite pattern size n characters.
129190
@@ -136,7 +197,7 @@ def nrepeats(sequence: str, n: int) -> int:
136197 of length n characters.
137198
138199 Raises:
139- ValueError : if value of n is less than 1 .
200+ ZeroDivisionError : if value of n is 0 .
140201
141202 Examples:
142203 .. code-block:: python
0 commit comments