Skip to content

Commit

Permalink
Merge branch 'K-Johnson-Horrigan-main'
Browse files Browse the repository at this point in the history
  • Loading branch information
Anya Vostinar committed Aug 9, 2022
2 parents 79ee260 + 725081b commit 3e5292a
Show file tree
Hide file tree
Showing 10 changed files with 1,124 additions and 695 deletions.
2 changes: 1 addition & 1 deletion source/Organism.h
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ class Organism {
virtual void SetSymbionts(emp::vector<emp::Ptr<Organism>> _in) {
std::cout << "SetSymbionts called from Organism" << std::endl;
throw "Organism method called!";}
virtual void AddSymbiont(emp::Ptr<Organism> _in)
virtual int AddSymbiont(emp::Ptr<Organism> _in)
{std::cout << "AddSymbiont called from Organism" << std::endl;
throw "Organism method called!";}
virtual void AddReproSym(emp::Ptr<Organism> _in) {
Expand Down
83 changes: 83 additions & 0 deletions source/default_mode/DataNodes.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ void SymWorld::CreateDateFiles(){

SetupHostIntValFile(my_config->FILE_PATH()+"HostVals"+my_config->FILE_NAME()+file_ending).SetTimingRepeat(TIMING_REPEAT);
SetupSymIntValFile(my_config->FILE_PATH()+"SymVals"+my_config->FILE_NAME()+file_ending).SetTimingRepeat(TIMING_REPEAT);
SetUpTransmissionFile(my_config->FILE_PATH()+"TransmissionRates"+my_config->FILE_NAME()+file_ending).SetTimingRepeat(TIMING_REPEAT);

if(my_config->FREE_LIVING_SYMS() == 1){
SetUpFreeLivingSymFile(my_config->FILE_PATH()+"FreeLivingSyms_"+my_config->FILE_NAME()+file_ending).SetTimingRepeat(TIMING_REPEAT);
Expand Down Expand Up @@ -193,6 +194,36 @@ void SymWorld::WritePhylogenyFile(const std::string & filename) {
}


/**
* Input: The address of the string representing the suffixes for the files to be created.
*
* Output: None.
*
* Purpose: To setup and write to the files that track the counts of attempted
* tranmissions.
*/

emp::DataFile & SymWorld::SetUpTransmissionFile(const std::string & filename){
auto & file = SetupFile(filename);
auto & node1 = GetHorizontalTransmissionAttemptCount();
auto & node2 = GetHorizontalTransmissionSuccessCount();
auto & node3 = GetVerticalTransmissionAttemptCount();

file.AddVar(update, "update", "Update");

//horizontal transmission
file.AddTotal(node1, "attempts_horiztrans", "Total number of horizontal transmission attempts", true);
file.AddTotal(node2, "successes_horiztrans", "Total number of horizontal transmission successes", true);

//vertical transmission
file.AddTotal(node3, "attempts_verttrans", "Total number of horizontal transmission attempts", true);

file.PrintHeaderKeys();

return file;
}


/**
* Input: None
*
Expand Down Expand Up @@ -521,4 +552,56 @@ emp::DataMonitor<double,emp::data::Histogram>& SymWorld::GetHostedSymInfectChanc
data_node_hostedsyminfectchance->SetupBins(0, 1.1, 11);
return *data_node_hostedsyminfectchance;
}


/**
* Input: None
*
* Output: The DataMonitor<int>& that has the information representing
* how many attempts were made to horizontally transmit.
*
* Purpose: To retrieve the data nodes that is tracking the
* number of attempted horizontal transmissions.
*/
emp::DataMonitor<int>& SymWorld::GetHorizontalTransmissionAttemptCount() {
if (!data_node_attempts_horiztrans) {
data_node_attempts_horiztrans.New();
}
return *data_node_attempts_horiztrans;
}


/**
* Input: None
*
* Output: The DataMonitor<int>& that has the information representing
* how many successful attempts were made to horizontally transmit.
*
* Purpose: To retrieve the data nodes that is tracking the
* number of successful horizontal transmissions.
*/
emp::DataMonitor<int>& SymWorld::GetHorizontalTransmissionSuccessCount() {
if (!data_node_successes_horiztrans) {
data_node_successes_horiztrans.New();
}
return *data_node_successes_horiztrans;
}


/**
* Input: None
*
* Output: The DataMonitor<int>& that has the information representing
* how many attempts were made to vertically transmit.
*
* Purpose: To retrieve the data nodes that is tracking the
* number of attempted vertical transmissions.
*/
emp::DataMonitor<int>& SymWorld::GetVerticalTransmissionAttemptCount() {
if (!data_node_attempts_verttrans) {
data_node_attempts_verttrans.New();
}
return *data_node_attempts_verttrans;
}

#endif
7 changes: 5 additions & 2 deletions source/default_mode/Host.h
Original file line number Diff line number Diff line change
Expand Up @@ -430,17 +430,20 @@ class Host: public Organism {
/**
* Input: The pointer to the organism that is to be added to the host's symbionts.
*
* Output: None
* Output: The int describing the symbiont's position ID, or 0 if it did not successfully
* get added to the host's list of symbionts.
*
* Purpose: To add a symbionts to a host's symbionts
*/
void AddSymbiont(emp::Ptr<Organism> _in) {
int AddSymbiont(emp::Ptr<Organism> _in) {
if((int)syms.size() < my_config->SYM_LIMIT() && SymAllowedIn()){
syms.push_back(_in);
_in->SetHost(this);
_in->UponInjection();
return syms.size();
} else {
_in.Delete();
return 0;
}
}

Expand Down

0 comments on commit 3e5292a

Please sign in to comment.