Skip to content

Commit

Permalink
abolish the singleton/vector distinction for EidosValue_Float
Browse files Browse the repository at this point in the history
  • Loading branch information
bhaller committed Dec 23, 2023
1 parent af4c97b commit b85248c
Show file tree
Hide file tree
Showing 36 changed files with 497 additions and 662 deletions.
40 changes: 20 additions & 20 deletions core/chromosome.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1013,7 +1013,7 @@ MutationIndex Chromosome::DrawNewMutationExtended(std::pair<slim_position_t, Gen

if (genomic_element_type.mutation_matrix_)
{
EidosValue_Float_vector *mm = genomic_element_type.mutation_matrix_.get();
EidosValue_Float *mm = genomic_element_type.mutation_matrix_.get();
int mm_count = mm->Count();

if (mm_count == 16)
Expand Down Expand Up @@ -1615,23 +1615,23 @@ EidosValue_SP Chromosome::GetProperty(EidosGlobalStringID p_property_id)
EIDOS_TERMINATION << "ERROR (Chromosome::GetProperty): property hotspotMultipliers is only defined in nucleotide-based models." << EidosTerminate();
if (!single_mutation_map_)
EIDOS_TERMINATION << "ERROR (Chromosome::GetProperty): property hotspotMultipliers is not defined since sex-specific hotspot maps have been defined." << EidosTerminate();
return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector(hotspot_multipliers_H_));
return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(hotspot_multipliers_H_));
}
case gID_hotspotMultipliersM:
{
if (!species_.IsNucleotideBased())
EIDOS_TERMINATION << "ERROR (Chromosome::GetProperty): property hotspotMultipliersM is only defined in nucleotide-based models." << EidosTerminate();
if (single_mutation_map_)
EIDOS_TERMINATION << "ERROR (Chromosome::GetProperty): property hotspotMultipliersM is not defined since sex-specific hotspot maps have not been defined." << EidosTerminate();
return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector(hotspot_multipliers_M_));
return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(hotspot_multipliers_M_));
}
case gID_hotspotMultipliersF:
{
if (!species_.IsNucleotideBased())
EIDOS_TERMINATION << "ERROR (Chromosome::GetProperty): property hotspotMultipliersF is only defined in nucleotide-based models." << EidosTerminate();
if (single_mutation_map_)
EIDOS_TERMINATION << "ERROR (Chromosome::GetProperty): property hotspotMultipliersF is not defined since sex-specific hotspot maps have not been defined." << EidosTerminate();
return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector(hotspot_multipliers_F_));
return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(hotspot_multipliers_F_));
}

case gID_mutationEndPositions:
Expand Down Expand Up @@ -1665,23 +1665,23 @@ EidosValue_SP Chromosome::GetProperty(EidosGlobalStringID p_property_id)
EIDOS_TERMINATION << "ERROR (Chromosome::GetProperty): property mutationRates is not defined in nucleotide-based models." << EidosTerminate();
if (!single_mutation_map_)
EIDOS_TERMINATION << "ERROR (Chromosome::GetProperty): property mutationRates is not defined since sex-specific mutation rate maps have been defined." << EidosTerminate();
return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector(mutation_rates_H_));
return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(mutation_rates_H_));
}
case gID_mutationRatesM:
{
if (species_.IsNucleotideBased())
EIDOS_TERMINATION << "ERROR (Chromosome::GetProperty): property mutationRatesM is not defined in nucleotide-based models." << EidosTerminate();
if (single_mutation_map_)
EIDOS_TERMINATION << "ERROR (Chromosome::GetProperty): property mutationRatesM is not defined since sex-specific mutation rate maps have not been defined." << EidosTerminate();
return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector(mutation_rates_M_));
return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(mutation_rates_M_));
}
case gID_mutationRatesF:
{
if (species_.IsNucleotideBased())
EIDOS_TERMINATION << "ERROR (Chromosome::GetProperty): property mutationRatesF is not defined in nucleotide-based models." << EidosTerminate();
if (single_mutation_map_)
EIDOS_TERMINATION << "ERROR (Chromosome::GetProperty): property mutationRatesF is not defined since sex-specific mutation rate maps have not been defined." << EidosTerminate();
return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector(mutation_rates_F_));
return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(mutation_rates_F_));
}

case gID_overallMutationRate:
Expand All @@ -1690,42 +1690,42 @@ EidosValue_SP Chromosome::GetProperty(EidosGlobalStringID p_property_id)
EIDOS_TERMINATION << "ERROR (Chromosome::GetProperty): property overallMutationRate is not defined in nucleotide-based models." << EidosTerminate();
if (!single_mutation_map_)
EIDOS_TERMINATION << "ERROR (Chromosome::GetProperty): property overallMutationRate is not defined since sex-specific mutation rate maps have been defined." << EidosTerminate();
return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(overall_mutation_rate_H_userlevel_));
return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(overall_mutation_rate_H_userlevel_));
}
case gID_overallMutationRateM:
{
if (species_.IsNucleotideBased())
EIDOS_TERMINATION << "ERROR (Chromosome::GetProperty): property overallMutationRateM is not defined in nucleotide-based models." << EidosTerminate();
if (single_mutation_map_)
EIDOS_TERMINATION << "ERROR (Chromosome::GetProperty): property overallMutationRateM is not defined since sex-specific mutation rate maps have not been defined." << EidosTerminate();
return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(overall_mutation_rate_M_userlevel_));
return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(overall_mutation_rate_M_userlevel_));
}
case gID_overallMutationRateF:
{
if (species_.IsNucleotideBased())
EIDOS_TERMINATION << "ERROR (Chromosome::GetProperty): property overallMutationRateF is not defined in nucleotide-based models." << EidosTerminate();
if (single_mutation_map_)
EIDOS_TERMINATION << "ERROR (Chromosome::GetProperty): property overallMutationRateF is not defined since sex-specific mutation rate maps have not been defined." << EidosTerminate();
return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(overall_mutation_rate_F_userlevel_));
return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(overall_mutation_rate_F_userlevel_));
}

case gID_overallRecombinationRate:
{
if (!single_recombination_map_)
EIDOS_TERMINATION << "ERROR (Chromosome::GetProperty): property overallRecombinationRate is not defined since sex-specific recombination rate maps have been defined." << EidosTerminate();
return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(overall_recombination_rate_H_userlevel_));
return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(overall_recombination_rate_H_userlevel_));
}
case gID_overallRecombinationRateM:
{
if (single_recombination_map_)
EIDOS_TERMINATION << "ERROR (Chromosome::GetProperty): property overallRecombinationRateM is not defined since sex-specific recombination rate maps have not been defined." << EidosTerminate();
return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(overall_recombination_rate_M_userlevel_));
return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(overall_recombination_rate_M_userlevel_));
}
case gID_overallRecombinationRateF:
{
if (single_recombination_map_)
EIDOS_TERMINATION << "ERROR (Chromosome::GetProperty): property overallRecombinationRateF is not defined since sex-specific recombination rate maps have not been defined." << EidosTerminate();
return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(overall_recombination_rate_F_userlevel_));
return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(overall_recombination_rate_F_userlevel_));
}

case gID_recombinationEndPositions:
Expand All @@ -1751,19 +1751,19 @@ EidosValue_SP Chromosome::GetProperty(EidosGlobalStringID p_property_id)
{
if (!single_recombination_map_)
EIDOS_TERMINATION << "ERROR (Chromosome::GetProperty): property recombinationRates is not defined since sex-specific recombination rate maps have been defined." << EidosTerminate();
return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector(recombination_rates_H_));
return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(recombination_rates_H_));
}
case gID_recombinationRatesM:
{
if (single_recombination_map_)
EIDOS_TERMINATION << "ERROR (Chromosome::GetProperty): property recombinationRatesM is not defined since sex-specific recombination rate maps have not been defined." << EidosTerminate();
return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector(recombination_rates_M_));
return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(recombination_rates_M_));
}
case gID_recombinationRatesF:
{
if (single_recombination_map_)
EIDOS_TERMINATION << "ERROR (Chromosome::GetProperty): property recombinationRatesF is not defined since sex-specific recombination rate maps have not been defined." << EidosTerminate();
return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector(recombination_rates_F_));
return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(recombination_rates_F_));
}

case gID_species:
Expand All @@ -1780,25 +1780,25 @@ EidosValue_SP Chromosome::GetProperty(EidosGlobalStringID p_property_id)
{
if (!using_DSB_model_)
EIDOS_TERMINATION << "ERROR (Chromosome::GetProperty): property geneConversionGCBias is not defined since the DSB recombination model is not being used." << EidosTerminate();
return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(mismatch_repair_bias_));
return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(mismatch_repair_bias_));
}
case gID_geneConversionNonCrossoverFraction:
{
if (!using_DSB_model_)
EIDOS_TERMINATION << "ERROR (Chromosome::GetProperty): property geneConversionNonCrossoverFraction is not defined since the DSB recombination model is not being used." << EidosTerminate();
return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(non_crossover_fraction_));
return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(non_crossover_fraction_));
}
case gID_geneConversionMeanLength:
{
if (!using_DSB_model_)
EIDOS_TERMINATION << "ERROR (Chromosome::GetProperty): property geneConversionMeanLength is not defined since the DSB recombination model is not being used." << EidosTerminate();
return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(gene_conversion_avg_length_));
return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(gene_conversion_avg_length_));
}
case gID_geneConversionSimpleConversionFraction:
{
if (!using_DSB_model_)
EIDOS_TERMINATION << "ERROR (Chromosome::GetProperty): property geneConversionSimpleConversionFraction is not defined since the DSB recombination model is not being used." << EidosTerminate();
return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(simple_conversion_fraction_));
return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(simple_conversion_fraction_));
}
case gID_tag:
{
Expand Down
2 changes: 1 addition & 1 deletion core/community_eidos.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1412,7 +1412,7 @@ EidosValue_SP Community::ExecuteMethod_usage(EidosGlobalStringID p_method_id, co

size_t usage = usage_community.totalMemoryUsage + usage_all_species.totalMemoryUsage;
double usage_MB = usage / (1024.0 * 1024.0);
EidosValue_SP result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(usage_MB));
EidosValue_SP result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(usage_MB));

return result_SP;
}
Expand Down
2 changes: 1 addition & 1 deletion core/genome.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1282,7 +1282,7 @@ EidosValue_SP Genome::ExecuteMethod_sumOfMutationsOfType(EidosGlobalStringID p_m
}
}

return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_singleton(selcoeff_sum));
return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(selcoeff_sum));
}

// print the sample represented by genomes, using SLiM's own format
Expand Down
6 changes: 3 additions & 3 deletions core/genomic_element_type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ MutationType *GenomicElementType::DrawMutationType(void) const
return mutation_type_ptrs_[gsl_ran_discrete(rng, lookup_mutation_type_)];
}

void GenomicElementType::SetNucleotideMutationMatrix(const EidosValue_Float_vector_SP &p_mutation_matrix)
void GenomicElementType::SetNucleotideMutationMatrix(const EidosValue_Float_SP &p_mutation_matrix)
{
mutation_matrix_ = p_mutation_matrix;

Expand Down Expand Up @@ -269,7 +269,7 @@ EidosValue_SP GenomicElementType::GetProperty(EidosGlobalStringID p_property_id)
}
case gID_mutationFractions:
{
return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float_vector(mutation_fractions_));
return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(mutation_fractions_));
}
case gID_mutationMatrix:
{
Expand Down Expand Up @@ -432,7 +432,7 @@ EidosValue_SP GenomicElementType::ExecuteMethod_setMutationMatrix(EidosGlobalStr

EidosValue *mutationMatrix_value = p_arguments[0].get();

SetNucleotideMutationMatrix(EidosValue_Float_vector_SP((EidosValue_Float_vector *)(mutationMatrix_value)));
SetNucleotideMutationMatrix(EidosValue_Float_SP((EidosValue_Float *)(mutationMatrix_value)));

// the change to the mutation matrix means everything downstream has to be recached
species_.CacheNucleotideMatrices();
Expand Down
4 changes: 2 additions & 2 deletions core/genomic_element_type.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class GenomicElementType : public EidosDictionaryUnretained

slim_usertag_t tag_value_ = SLIM_TAG_UNSET_VALUE; // a user-defined tag value

EidosValue_Float_vector_SP mutation_matrix_; // in nucleotide-based models only, the 4x4 or 64x4 float mutation matrix
EidosValue_Float_SP mutation_matrix_; // in nucleotide-based models only, the 4x4 or 64x4 float mutation matrix
double *mm_thresholds = nullptr; // mutation matrix threshold values for determining derived nucleotides; cached in CacheNucleotideMatrices()

GenomicElementType(const GenomicElementType&) = delete; // no copying
Expand All @@ -83,7 +83,7 @@ class GenomicElementType : public EidosDictionaryUnretained
void InitializeDraws(void); // reinitialize our mutation-type lookup after changing our mutation type or proportions
MutationType *DrawMutationType(void) const; // draw a mutation type from the distribution for this genomic element type

void SetNucleotideMutationMatrix(const EidosValue_Float_vector_SP &p_mutation_matrix);
void SetNucleotideMutationMatrix(const EidosValue_Float_SP &p_mutation_matrix);


//
Expand Down
Loading

0 comments on commit b85248c

Please sign in to comment.