From af420da792b6b77c046a20229bf8ae1281377b0b Mon Sep 17 00:00:00 2001 From: hamazaki1990 Date: Tue, 9 May 2017 15:39:19 +0900 Subject: [PATCH] solving #20 --- hamazaki1990/visualize.py | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/hamazaki1990/visualize.py b/hamazaki1990/visualize.py index 75a427e..1116318 100644 --- a/hamazaki1990/visualize.py +++ b/hamazaki1990/visualize.py @@ -12,27 +12,26 @@ def calculate_var(seq): return sum(sqd)/len(seq) -def change_allelewf(Population): # simulate fixation in Wrigft-Fisher model - time = 0 +def change_allelewf(Population): + fixprocess = [Population._inds] while Population.is_not_fixed(): Population.next_genwf() - Population.print_ids() - time += 1 - else: - winner_id = Population._inds[0] - return time, winner_id + fixprocess.append(Population._inds) + return fixprocess -def simulate_fixmo(Population): # simulate fixation in Moran model - time = 0 +def change_allelemo(Population): + fixprocess = [Population._inds] while Population.is_not_fixed(): Population.next_genmo() - time += 1 - else: - winner_id = Population._inds[0] - return time, winner_id + fixprocess.append(Population._inds) + return fixprocess p1 = Population(10) -data = list(change_allelewf(p1)) -data.to_csv() +data = pd.DataFrame(change_allelewf(p1)) +print(data) + +p2 = Population(10) +data = pd.DataFrame(change_allelemo(p2)) +print(data)