def get_from_parent_and_environment(self): # parental inheritance and environmental acquisition parental_contribution = [] for i in range(self.number_of_host_in_population): # select parent for next generation rnd = random.randint(0, self.number_of_environmental_species - 1) parental_contribution.append( self.composition_of_individual[rnd].microbiome / float(self.number_of_microbes_in_host)) self.composition_of_individual[rnd].microbiome *= 2 environmental_contribution = addition_of_arrays( self.percentage_of_pooled_environmental_component, 1 - self.percentage_of_pooled_environmental_component, self.microbiome_sum, self.environment) # mix pooled and fixed env for i in range(self.number_of_host_in_population): # mix environmental and parental contribution mixed_contribution = addition_of_arrays( 1 - self.percentage_of_environmental_acquisition, self.percentage_of_environmental_acquisition, parental_contribution[i], environmental_contribution) self.composition_of_individual[i].microbiome = numpy.random.multinomial( self.number_of_microbes_in_host, mixed_contribution / sum(mixed_contribution))
def sum_species(self): self.microbiome_sum = numpy.array([]) for individual in self.composition_of_individual: self.microbiome_sum = addition_of_arrays(1, 1, self.microbiome_sum, individual.microbiome) self.microbiome_sum = self.microbiome_sum / float(sum(self.microbiome_sum)) # composition of the microbiomes within the population in terms of genome self.species_community = self.microbiome_sum # composition of the microbiomes within the population in terms of species marker