# Script to produce data for figures S1(a-b)
# Created by Matthew Asker 

import numpy as np
import sys
from next_reaction_method import next_reaction
import pandas as pd

a = 0.25
s = 0.1
total_sims = 1

N_th_range = [20, 40]

#index = sys.argv[1]
Nth_result = list()
K_result = list()
fix_time = list()
fix_prob = list()

for Nth in N_th_range:
    K_range = range(Nth, 4*Nth + 1)
    for K in K_range:      
        
        G = next_reaction(s, a, 0.0, 0.0, K, K, Nth, 1)
        G.run()
        
        Nth_result.append(Nth)
        K_result.append(K)
        fix_time.append(G.average_time)
        fix_prob.append(G.c_fixation_count / total_sims)
    
raw_data = {'N_th' : Nth_result,
            'K' : K_result,
            'fix_prob' : fix_prob,
            'fix_time' : fix_time}
        
filename = f'fixation probability and time'       
data = pd.DataFrame(raw_data, columns=['N_th', 'K', 'fix_prob', 'fix_time'])
data.to_csv(filename+'.csv', index=False)