Skip to content

Commit

Permalink
fixup! Add population action for whole genome duplication
Browse files Browse the repository at this point in the history
  • Loading branch information
mmore500 committed Nov 4, 2024
1 parent 92622da commit 2e31bf5
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions avida-core/source/actions/PopulationActions.cc
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,36 @@ class cActionInject : public cAction
}
};

/*
Replaces all population members with end-to-end duplicated versions of
themselves.
*/
class cActionInjectWholeGenomeDuplications : public cAction
{

public:
cActionInjectWholeGenomeDuplications(cWorld* world, const cString& args, Feedback&) : cAction(world, args){}

static const cString GetDescription() { return "No arguments"; }

void Process(cAvidaContext& ctx)
{
for (int i = 0; i < m_world->GetPopulation().GetSize(); i++)
{
if (!m_world->GetPopulation().GetCell(i).IsOccupied()) continue;

auto genome_str =m_world->GetPopulation().GetCell(i).GetOrganism()->GetGenome().AsString();
auto seq_str = m_world->GetPopulation().GetCell(i).GetOrganism()->GetGenome().AsString();
seq_str.Pop(',');
seq_str.Pop(',');
genome_str += seq_str;

const Genome genome(genome_str);
m_world->GetPopulation().Inject(genome, Systematics::Source(Systematics::DIVISION, "whole-genome duplication", true), ctx, i);
}
}
};
/*
Injects a randomly generated genome into the population.
Expand Down

0 comments on commit 2e31bf5

Please sign in to comment.