1. Python Assignment
Name - Aadee Srivastava
Enrolment- A0504122193
Roll Number- 53
Section- C
Semester- 3
Program- BTech Biotech
2. Plotting codon frequency using python
• Codon frequency refers to the frequency of occurrence of
specific triplet codons in a DNA sequence.
• Codon frequency refers to the relative occurrence of specific
triplet nucleotide sequences, known as codons, within a DNA or
RNA sequence. These codons represent the basic units of the
genetic code and are responsible for encoding specific amino
acids during the process of protein synthesis. Understanding
codon frequency is crucial in various biological analyses, such
as studying genetic variations, evolutionary relationships, and
gene expression patterns.
3. In Python, to analyze codon frequency,
we would typically follow these steps:
• Data Preparation: Obtain the DNA or RNA sequence data that
you want to analyse. Ensure that the sequence is properly
formatted and accessible within your Python environment.
• Codon Generation: Break down the sequence into non-
overlapping triplets, known as codons, by using a sliding
window of size 3. This process allows you to extract all possible
codons from the sequence.
• Frequency Calculation: Utilise data structures like dictionaries
or Counter objects to keep track of the frequency of each codon
in the sequence. You can iterate through the codons and update
their respective frequencies accordingly.
4. • Visualisation (Optional): Use libraries such as Matplotlib or Seaborn to
create visual representations of the codon frequency data, which can be in
the form of bar plots, histograms, or other suitable graphical formats.
Visualisation can provide a clearer understanding of the distribution of
codons within the sequence.
• Considerations:
• When working with real genetic data, you might need to consider factors like reverse
complement sequences and different reading frames for a comprehensive analysis.
• By analysing codon frequency, researchers can gain insights into the
underlying genetic characteristics of an organism, including its evolutionary
history, functional constraints, and genetic diversity. This information is
valuable for various applications in genetics, molecular biology, and
bioinformatics, contributing to advancements in fields such as medicine,
agriculture, and biotechnology.
5. To plot codon frequency, we can use the matplotlib library in
Python. Here is a simple example of how to generate a bar plot
for codon frequency:
• import matplotlib.pyplot as p1t
• # Example data for codon frequencies
• codon_frequencies = {
• “AAA”: 0.2,
• “AAG”: 0.1,
• “AAT”: 0.3,
• “AAC”: 0.4,
• “AGA”: 0.05,
8. • Ensure that we have the matplotlib library installed. You can
install it using pip:
• Copy code
• pip install matplotlib
• We can modify the codon_frequencies dictionary with your own
data, and the script will generate a bar plot accordingly.