summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathan Fargo <32229490+ntfargo@users.noreply.github.com>2024-06-18 16:53:17 +0200
committerNathan Fargo <32229490+ntfargo@users.noreply.github.com>2024-06-18 16:53:17 +0200
commit046f10d7a389a0c6d27ac80a993497894999dbcd (patch)
tree42c0ce388499ee62eecb3cc7a4c22fefe89aeea1
parent4234d64541a022096eb08519fdd4e5d7c2f3c04c (diff)
Documentation.
-rw-r--r--GenoFusion/utils/dna_utils.py13
-rw-r--r--SequenceViewer/app/sequence_tools.py9
2 files changed, 14 insertions, 8 deletions
diff --git a/GenoFusion/utils/dna_utils.py b/GenoFusion/utils/dna_utils.py
index 8e2285c..c519e80 100644
--- a/GenoFusion/utils/dna_utils.py
+++ b/GenoFusion/utils/dna_utils.py
@@ -1,3 +1,16 @@
+"""
+This module provides utility functions for DNA sequence analysis.
+
+Functions:
+- calculate_nucleotide_composition(sequence): Calculates the count of each nucleotide (A, T, G, C) in the given DNA sequence.
+- calculate_nucleotide_percentage(sequence): Calculates the percentage of each nucleotide (A, T, G, C) in the given DNA sequence.
+- calculate_gc_content(sequence): Calculates the GC content (percentage of G and C nucleotides) in the given DNA sequence.
+- reverse_sequence(sequence): Reverses the given DNA sequence.
+- complement_sequence(sequence): Generates the complement sequence of the given DNA sequence.
+- reverse_complement_sequence(sequence): Generates the reverse complement sequence of the given DNA sequence.
+- get_sequence_properties(sequence): Returns a dictionary containing various properties of the given DNA sequence, including length, nucleotide composition, nucleotide percentage, GC content, reverse sequence, complement sequence, and reverse complement sequence.
+"""
+
def calculate_nucleotide_composition(sequence):
sequence = sequence.upper()
composition = {
diff --git a/SequenceViewer/app/sequence_tools.py b/SequenceViewer/app/sequence_tools.py
index e44625d..1fcd5a8 100644
--- a/SequenceViewer/app/sequence_tools.py
+++ b/SequenceViewer/app/sequence_tools.py
@@ -23,7 +23,6 @@ def is_nicking(enzyme):
"""Check if an enzyme is a nicking endonuclease."""
return "Nicking" in enzyme.__class__.__name__
-# Group enzymes based on properties
enzyme_groups = {
"All Commercial": CommOnly,
"Nonredundant Commercial": CommOnly, # This should be updated with a proper list if available
@@ -38,7 +37,6 @@ enzyme_groups = {
"Nicking Endonucleases": [enzyme for enzyme in AllEnzymes if is_nicking(enzyme)]
}
-# Define colors for enzyme highlighting
colors = [
"red", "green", "blue", "yellow", "orange", "purple", "cyan", "magenta", "lime", "pink",
"teal", "lavender", "brown", "beige", "maroon", "mint", "olive", "coral", "navy", "grey"
@@ -47,13 +45,11 @@ colors = [
enzyme_colors = {}
def get_color_for_enzyme(enzyme_name):
- """Assign a random color to each enzyme for highlighting."""
if enzyme_name not in enzyme_colors:
enzyme_colors[enzyme_name] = random.choice(colors)
return enzyme_colors[enzyme_name]
def get_enzyme_sites(sequence, enzymes):
- """Find enzyme recognition sites in a given DNA sequence."""
enzyme_sites = []
for enzyme in enzymes:
for site in enzyme.search(sequence):
@@ -62,16 +58,14 @@ def get_enzyme_sites(sequence, enzymes):
return enzyme_sites
def translate_sequence(nucleotide_sequence):
- """Translate a nucleotide sequence into a protein sequence."""
sequence = Seq(nucleotide_sequence)
return str(sequence.translate())
def find_enzyme_sites(sequence_str, selected_group):
- """Highlight enzyme recognition sites in a DNA sequence."""
if selected_group in enzyme_groups:
enzymes = enzyme_groups[selected_group]
else:
- enzymes = AllEnzymes # Default to all enzymes if group not found
+ enzymes = AllEnzymes
enzyme_sites = get_enzyme_sites(Seq(sequence_str), enzymes)
highlighted_sequence = ""
@@ -87,7 +81,6 @@ def find_enzyme_sites(sequence_str, selected_group):
return highlighted_sequence, enzyme_sites
def get_sequence_properties(sequence_str):
- """Calculate basic properties of a DNA sequence."""
sequence = Seq(sequence_str)
gc_content = (sequence.count("G") + sequence.count("C")) / len(sequence) * 100
return {