-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.py
More file actions
28 lines (23 loc) · 887 Bytes
/
utils.py
File metadata and controls
28 lines (23 loc) · 887 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# utils.py
# Utility functions used across the DNA processing GUI application
def validate_dna_sequence(dna):
"""
Validates that a given DNA sequence contains only valid bases: A, T, C, G.
Returns True if valid and not empty, False otherwise.
"""
return all(base in "ATCG" for base in dna) and len(dna) > 0
def validate_mrna_sequence(mrna):
"""
Validates that a given mRNA sequence contains only valid bases: A, U, C, G.
Returns True if valid and not empty, False otherwise.
"""
return all(base in "AUCG" for base in mrna) and len(mrna) > 0
import random
def generate_random_dna(length=100):
"""
Generates a random DNA sequence of the specified length.
Default length is 100 bases.
Returns:
A string composed of randomly selected A, T, C, G characters.
"""
return ''.join(random.choices('ATCG', k=length))