We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 4
Name :Vishva M
Reg NO : RA2411030020267
Subject : Computational Biology
Project : Genetic AlgorithimOBJECTIVE:
create a genetic algorithm to predict the offspring of parent dogs
Process :
Using Mysql] to store the genetic details of the parent DOGs and using Python to
manipulate the genetic details and predict the offspring by selecting random breed from the
data stored
In this case we use only the three genetic details
1, Breed
2. Eye Colour
3. Height
4, Temperament
Genetic information :
ET y Coe
|
| Bella i eos cia
| Charlie y ee] a cera e
mere) k Peel | Green
| cay r iss
Accessing the above data with python to predict the offspring
PYTHON CODE :
import mysql.connector
import random
from prettytable import PrettyTable # For table formatting
# Connect to MySQL database
conn = mysql.connector.connect(
"localhost", #Replace with your host
# Replace with your username
oot", # Replace with your password
ishva" # Replace with your database name
cursor = conn.cursor(dictionary=True)
# Select a random male
cursor.execute("SELECT * FROM dog WHERE gender = 'Male' ORDER BY RAND() LIMIT
"
male_dog = cursor.fetchone()
# Select a random female
cursor.execute("SELECT * FROM dog WHERE gende!
‘Female’ ORDER BY RAND()female_dog = cursor.fetchone()
# Predict offspring traits
def predict_offspring(male, female):
# Eye color prediction (randomly choose one of the parents’ eye colors)
eye_color = random.choice({male['eye_colour’, female['eye_colour']})
# Height prediction (average of both parents’ heights)
height = round((male[height] + female['height’]) / 2, 2)
# Breed prediction (combine the breeds)
breed = male[breed’] +" x" + female['breed’]
return {
"eye_color': eye_color,
‘height’: height,
‘breed’: breed
}
# Generate offspring traits
offspring_traits = predict_offspring(male_dog, female_dog)
# Create tables for parents and offspring traits
parent_table = PrettyTable()
parent_table field_names = ["Parent”, "Name, "Breed", "Eye Color’, "Height"]
# Add parent details
parent_table.add_row(["Male", male_dog['name’], male_dog['breed’],
male_dogf'eye_colour'), male_dogf'height’)])
parent_table.add_row(["Female’, female_dog[name’], female_dog['breed’],
female_dog['eye_colour'], female_dog[height]})
# Create table for offspring traits
offspring_table = PrettyTable()
offspring_table.field_names =
[Offspring Traits", "Value"]
# Add offspring traits
offspring_table.add_row/["Eye Color’, offspring_traits['eye_color']})
offspring_table.add_row(["Height", offspring_traits(‘height']])
offspring_table.add_row({"Breed’, offspring_traits['breed']})
# Output the tables
print("=== Parent Details
print(parent_table)
")
print("\n=== Predicted Offspring Traits =
print(offspring_table)
# Close the connection
cursor.close()
anne cindyOutput :
Here we have three random output , by accessing the genetic information a
MALE and FEMALE by randomly
Output
Parent Details
| Parent | j
| Mele | Charlie | Beagle | Hazel | 50.20 |
| Female | | Poodie | Green | 40.30 |
Predicted offepring
| Offspring Traits |
1 Hazel 1
1 45.25 1
| Beagle x Poodle |
| Eye Color
1 Breed
Foxent Devaile
Fredicted
| Offspring Traits | ue
1 Eye Cozor Brown
1 Height
1 Breed
48.00
Golden Reteiever x Poodle