Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Extend your answer from question 3. Write a second function, generate_population(fA, N), which will generate a population of size N. You will generate a genotype

Extend your answer from question 3. Write a second function, generate_population(fA, N), which will generate a population of size N. You will generate a genotype for each individual, and count how many individuals are in each genotype by using three variables, AA_count, Aa_count, and aa_count. Your function will return these three counts. Finally, calculate the new frequency of the A allele. The frequency will be the number of A alleles out of the total number of alleles: (2*AA_count + Aa_count) / (2 * N). [Each AA individual has two copies of the A allele, so we count each individual twice, while each Aa individual has one copy of the A allele. There are N individuals with 2 alleles each, so we divide by 2N.]

import random

def draw_alleles(fA): # copy your function from question 3 here

#here it is

import random def draw_alleles(fA): genotype='' rand_1=random.random() rand_2=random.random() if (rand_1fA) and (rand_2>fA): genotype='aa' else: if (rand_1

def main(): fA=0.3 for _ in range(10): print(draw_alleles(fA))

if __name__=='__main__': main()

return genotype

def generate_population(fA, N): # function to generate a population consisting of N genotypes, given the initial frequency of A return AA_counter, Aa_counter, aa_counter

def main(): fA = 0.3 N = 10 AA_ct, Aa_ct, aa_ct = generate_population(fA, N) # Calculate a new frequency for the A allele and print it.

main()

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Refactoring Databases Evolutionary Database Design

Authors: Scott Ambler, Pramod Sadalage

1st Edition

0321774515, 978-0321774514

More Books

Students also viewed these Databases questions

Question

What are their resources?

Answered: 1 week ago

Question

4. What advice would you give to Carol Sullivan-Diaz?

Answered: 1 week ago