def initiate_infection(cls, poi): genomes = [] for _ in range(poi): genome = Genome.from_reference() genome.genome = genome.genome + _ genome.id = _ genomes.append(genome) return genomes
def distribution_simulation(cls, poi, strain_differential, n_events=5, backcross=False): genome_pool = Infection.initiate_infection(poi) parental_genome = genome_pool[0] unrelated_genome = Genome.from_reference() unrelated_genome.genome = unrelated_genome.genome - 1. unrelated_genome.id = -1 print 'parental_genomeID ', parental_genome.id host = Infection(genome_pool) data = [] for _ in range(n_events): print 'event ' + str(_ + 1) n_oocysts = sample_n_oocysts_function() n_ihepatocytes = sample_n_hepatocytes_function() weights = obtain_dirichlet_exponential_strain_proportions( strain_differential, len(host.unique_genome_pool)) transmission = Infection.mosquito_transmission( host.unique_genome_pool, n_oocysts, n_ihepatocytes, weights) #transmission.interpret_ihep_relationships() transmission.calculate_observable_relatedness() #transmission.calculate_ibd_stats() data.append(transmission.return_stats()) if backcross: if backcross == 1: transmission.add_strain(parental_genome) elif backcross == 2: if _ > 0: print 'adding unrelated_gnome' transmission.add_strain(unrelated_genome) host = transmission return data