omics.co.in

Variables and Data Types

🐍 Downloadable Lesson Python Script 3.4 KB

ch02_data_structures.py

Implements dictionaries for genetic codon translation, sets for unique k-mer extraction, and lists of tuples for restriction enzyme motif scanning.

$ python ch02_data_structures.py --seq ATGCGATCGATCGATCGATAGCTAGCTA

Python Variables & Data Types for Genomic Analysis

Understanding native Python data structures—strings, integers, floats, lists, tuples, dictionaries, and sets—is the cornerstone of bioinformatic script development.

# 1. Strings (Genomic sequences, chromosome names)
chromosome = "chr1"
sequence = "AGCTGATCGAT"

# 2. Integers & Floats (Coordinates, p-values, coverage)
start_pos = 1450201
end_pos = 1450550
p_value = 1.45e-8
depth_coverage = 48.6

# 3. Dictionaries (Genetic code mapping)
codon_table = {
    "ATG": "Methionine (Start)",
    "TAA": "Stop",
    "TAG": "Stop",
    "TGA": "Stop"
}

# 4. Sets (Unique gene identifiers)
sample_genes = {"TP53", "EGFR", "BRCA1", "TP53"}
print("Unique genes:", len(sample_genes)) # Output: 3
← Return to Home Hub Scroll to Top ↑