19 #ifndef GO_FISH_API_H_ 20 #define GO_FISH_API_H_ 21 #include <cuda_runtime.h> 22 #include "../3P/_outside_libraries/helper_math.h" 23 #include "../3P/go_fish_data_struct.h" 37 template <
typename Functor_demography,
typename Functor_inbreeding>
38 inline selection_constant(
float gamma, Functor_demography demography, Functor_inbreeding F,
int forward_generation_shift = 0);
39 __device__ __forceinline__
float operator()(
const int population,
const int generation,
const float freq)
const;
49 template <
typename Functor_demography,
typename Functor_inbreeding>
51 __device__ __forceinline__
float operator()(
const int population,
const int generation,
const float freq)
const;
64 inline selection_sine_wave(
float A,
float pi,
float D,
float rho = 0,
int generation_shift = 0);
65 template <
typename Functor_demography,
typename Functor_inbreeding>
66 inline selection_sine_wave(
float gamma_A,
float pi,
float gamma_D, Functor_demography demography, Functor_inbreeding F,
float rho = 0,
int generation_shift = 0,
int forward_generation_shift = 0);
67 __device__ __forceinline__
float operator()(
const int population,
const int generation,
const float freq)
const;
71 template <
typename Functor_sel,
typename Functor_sel_pop>
80 __device__ __forceinline__
float operator()(
const int population,
const int generation,
const float freq)
const;
84 template <
typename Functor_sel1,
typename Functor_sel2>
92 inline selection_piecewise(Functor_sel1 s1_in, Functor_sel2 s2_in,
int inflection_point,
int generation_shift = 0);
93 __device__ __forceinline__
float operator()(
const int population,
const int generation,
const float freq)
const;
106 __host__ __forceinline__
float operator()(
const int population,
const int generation)
const;
119 inline F_mu_h_sine_wave(
float A,
float pi,
float D,
float rho = 0,
int generation_shift = 0);
120 __host__ __forceinline__
float operator()(
const int population,
const int generation)
const;
124 template <
typename Functor_p,
typename Functor_p_pop>
133 __host__ __forceinline__
float operator()(
const int population,
const int generation)
const;
137 template <
typename Functor_p1,
typename Functor_p2>
145 inline F_mu_h_piecewise(Functor_p1 p1_in, Functor_p2 p2_in,
int inflection_point,
int generation_shift = 0);
146 __host__ __forceinline__
float operator()(
const int population,
const int generation)
const;
159 __host__ __device__ __forceinline__
int operator()(
const int population,
const int generation)
const;
173 __host__ __device__ __forceinline__
int operator()(
const int population,
const int generation)
const;
185 __host__ __device__ __forceinline__
int operator()(
const int population,
const int generation)
const;
198 __host__ __device__ __forceinline__
int operator()(
const int population,
const int generation)
const;
202 template <
typename Functor_d,
typename Functor_d_pop>
211 __host__ __device__ __forceinline__
int operator()(
const int population,
const int generation)
const;
215 template <
typename Functor_d1,
typename Functor_d2>
223 inline demography_piecewise(Functor_d1 d1_in, Functor_d2 d2_in,
int inflection_point,
int generation_shift = 0);
224 __host__ __device__ __forceinline__
int operator()(
const int population,
const int generation)
const;
238 __host__ __device__ __forceinline__
float operator()(
const int pop_FROM,
const int pop_TO,
const int generation)
const;
242 template <
typename Functor_m1>
251 __host__ __device__ __forceinline__
float operator()(
const int pop_FROM,
const int pop_TO,
const int generation)
const;
255 template <
typename Functor_m1,
typename Functor_m2>
263 inline migration_piecewise(Functor_m1 m1_in, Functor_m2 m2_in,
int inflection_point,
int generation_shift = 0);
264 __host__ __device__ __forceinline__
float operator()(
const int pop_FROM,
const int pop_TO,
const int generation)
const;
273 __host__ __forceinline__
bool operator()(
const int generation)
const;
278 __host__ __forceinline__
bool operator()(
const int generation)
const;
297 template <
typename Functor_default,
typename Functor_action>
304 bool_pulse(
int pulse,
int generation_shift = 0);
305 bool_pulse(Functor_default f_default_in, Functor_action f_action,
int pulse,
int generation_shift = 0);
306 __host__ __forceinline__
bool operator()(
const int generation)
const;
310 template <
typename Functor_first,
typename Functor_second>
317 inline bool_piecewise(
int inflection_point,
int generation_shift = 0);
318 inline bool_piecewise(Functor_first f1_in, Functor_second f2_in,
int inflection_point,
int generation_shift = 0);
319 __host__ __forceinline__
bool operator()(
const int generation)
const;
330 template <
typename Functor_mutation,
typename Functor_demography,
typename Functor_migration,
typename Functor_selection,
typename Functor_inbreeding,
typename Functor_dominance,
typename Functor_preserve,
typename Functor_timesample>
331 __host__
void run_sim(
allele_trajectories & all_results,
const Functor_mutation mu_rate,
const Functor_demography demography,
const Functor_migration mig_prop,
const Functor_selection sel_coeff,
const Functor_inbreeding FI,
const Functor_dominance dominance,
const Functor_preserve preserve_mutations,
const Functor_timesample take_sample);
333 template <
typename Functor_mutation,
typename Functor_demography,
typename Functor_migration,
typename Functor_selection,
typename Functor_inbreeding,
typename Functor_dominance,
typename Functor_preserve,
typename Functor_timesample>
334 __host__
void run_sim(
allele_trajectories & all_results,
const Functor_mutation mu_rate,
const Functor_demography demography,
const Functor_migration mig_prop,
const Functor_selection sel_coeff,
const Functor_inbreeding FI,
const Functor_dominance dominance,
const Functor_preserve preserve_mutations,
const Functor_timesample take_sample,
const allele_trajectories & prev_sim);
340 #include "../3P/_internal/template_inline_simulation_functors.cuh" 344 #include "../3P/_internal/go_fish_impl.cuh" functor: models population size (individuals) as a sine wave through time
functor: models selection coefficient s as a constant across populations and over time ...
int initial_population_size
initial population size
int num_pop
number of population participating in equal migration
int N
population size (individuals) constant
Functor_m2 m2
second migration function
float D
Offset of sine wave.
float rate
logistic growth rate
float m
migration rate from pop i to pop j =/= i
functor: migration function changes from m1 to m2 at generation inflection_point
functor: turns sampling and preserving off (for every generation except the final one which is always...
functor: parameter function changes from p1 to p2 at generation inflection_point
control and output data structure for GO_Fish simulation
int inflection_point
generation in which the Demographic function switches from d1 to d2
functor: single, constant population size (N individuals) across populations and over time ...
float pi
Frequency of sine wave.
float A
Amplitude of sine wave.
int generation_shift
number of generations to shift function backwards
float A
Amplitude of sine wave.
float rho
Phase of sine wave.
functor: migration flows at rate m from pop1 to pop2 and function rest for all other migration rates ...
Functor_sel_pop s_pop
population specific selection function for pop
functor: one population, pop, has a different, selection function, s_pop, all other have function s ...
int generation_shift
number of generations to shift function backwards
float pi
Frequency of sine wave.
int pop
population with specific demography function
Namespace of functions for controlling GO_Fish simulations.
__device__ __forceinline__ float operator()(const int population, const int generation, const float freq) const
selection operator, returns selection coefficient, s, for a given population, generation, freq
Functor_sel s
selection function applied to all other populations
float p
parameter constant
int generation_shift
number of generations to shift function backwards
float D
Offset of sine wave.
Functor_d2 d2
second demographic function
functor: models logistic growth of population size (individuals) over time
Functor_d1 d1
first demographic function
functor: one population, pop, has a different, parameter function, p_pop, all others have function p ...
float slope
slope of selection coefficient's linear dependence on frequency
Functor_d d
demographic function applied to all other populations
int generation_shift
number of generations to shift function backwards
Functor_p1 p1
first parameter function
int inflection_point
generation in which the migration function switches from m1 to m2
int generation_shift
number of generations to shift function backwards
functor: models parameter as a sine wave through time
int generation_shift
number of generations to shift function backwards
functor: one population, pop, has a different, demography function, d_pop, all others have function...
int generation_shift
number of generations to shift function backwards
int pulse
generation in which the boolean pulse f_action is emitted
int inflection_point
generation in which the boolean function switches from f1 to f2
float A
Amplitude of sine wave.
Functor_m1 rest
migration function specifying migration in remaining migration directions
Functor_p p
parameter function applied to all other populations
Functor_d_pop d_pop
population specific demographic function for pop
int generation_shift
number of generations to shift function backwards
int inflection_point
generation in which the selection function switches from s1 to s2
Functor_m1 m1
first migration function
Functor_sel1 s1
first selection function
float m
migration rate from pop1 to pop2
Functor_p2 p2
second parameter function
selection_constant()
default constructor
functor: selection function changes from s1 to s2 at generation inflection_point
float D
Offset of sine wave.
__host__ void run_sim(allele_trajectories &all_results, const Functor_mutation mu_rate, const Functor_demography demography, const Functor_migration mig_prop, const Functor_selection sel_coeff, const Functor_inbreeding FI, const Functor_dominance dominance, const Functor_preserve preserve_mutations, const Functor_timesample take_sample, const allele_trajectories &prev_sim)
runs a single-locus Wright-Fisher simulation specified by the given simulation functions and sim_cons...
int generation_shift
number of generations to shift function backwards
int generation_shift
number of generations to shift function backwards
functor: models selection coefficient as linearly dependent on frequency
Functor_second f2
second boolean function
float rho
Phase of sine wave.
int generation_shift
number of generations to shift function backwards
functor: returns the result of function f1 until generation inflection_point, then returns the result...
functor: models parameter p as a constant across populations and over time
functor: migration flows at rate m from pop i to pop j =/= i and 1-(num_pop-1)*m for i == j ...
functor: turns sampling and preserving on (for every generation except the final one which is always ...
float pi
Frequency of sine wave.
functor: models exponential growth of population size (individuals) over time
float intercept
selection coefficient's intercept with frequency 0
int generation_shift
number of generations to shift function backwards
Functor_sel2 s2
second selection function
Functor_first f1
first boolean function
functor: models selection as a sine wave through time
Functor_p_pop p_pop
population specific parameter function for pop
int inflection_point
generation in which the Inbreeding/Mutation/Dominance function switches from p1 to p2 ...
float rate
exponential growth rate
float rho
Phase of sine wave.
int pop
population with specific selection function
int carrying_capacity
carrying capacity
Namespace for single-locus, forward, Monte-Carlo Wright-Fisher simulation and output data structures...
functor: returns the result of function f_default except at generation pulse returns the result of fu...
Functor_default f_default
default boolean function
int initial_population_size
initial population size
Functor_action f_action
boolean function emitted at generation pulse
int generation_shift
number of generations to shift function backwards
float s
selection coefficient
int generation_shift
number of generations to shift function backwards
int pop
population with specific parameter function
functor: demography function changes from d1 to d2 at generation inflection_point ...