Variables and Data Types
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