Skip to content

Commit 47f13da

Browse files
authored
Merge pull request #95 from mmore500/whole-genome-duplication
Add whole genome duplication event
2 parents f371b0f + 092e39d commit 47f13da

118 files changed

Lines changed: 240617 additions & 14 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/ci.yaml

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -38,20 +38,20 @@ jobs:
3838
# run: |
3939
# bash ./run_tests
4040

41-
tests-mac:
42-
runs-on: macos-12
43-
steps:
44-
- uses: actions/checkout@v2
45-
- name: Install dependencies
46-
run: |
47-
brew install cmake
48-
brew install python
49-
- name: Build Avida
50-
run: |
51-
./build_avida
52-
- name: Run tests
53-
run: |
54-
./run_tests
41+
# tests-mac:
42+
# runs-on: macos-12
43+
# steps:
44+
# - uses: actions/checkout@v2
45+
# - name: Install dependencies
46+
# run: |
47+
# brew install cmake
48+
# brew install python
49+
# - name: Build Avida
50+
# run: |
51+
# ./build_avida
52+
# - name: Run tests
53+
# run: |
54+
# ./run_tests
5555

5656
docker-build:
5757
name: Docker Image Build

avida-core/source/actions/PopulationActions.cc

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,77 @@ class cActionInject : public cAction
137137
}
138138
};
139139

140+
/*
141+
Replaces all population members with end-to-end duplicated versions of
142+
themselves.
143+
144+
*/
145+
class cActionInjectWholeGenomeDuplications : public cAction
146+
{
147+
148+
public:
149+
cActionInjectWholeGenomeDuplications(cWorld* world, const cString& args, Feedback&) : cAction(world, args){}
150+
151+
static const cString GetDescription() { return "No arguments"; }
152+
153+
void Process(cAvidaContext& ctx)
154+
{
155+
for (int i = 0; i < m_world->GetPopulation().GetSize(); i++)
156+
{
157+
if (!m_world->GetPopulation().GetCell(i).IsOccupied()) continue;
158+
159+
auto genome_str = m_world->GetPopulation().GetCell(i).GetOrganism()->GetGenome().AsString();
160+
auto seq_str = m_world->GetPopulation().GetCell(i).GetOrganism()->GetGenome().AsString();
161+
seq_str.Pop(',');
162+
seq_str.Pop(',');
163+
std::cout << "genome_str: " << genome_str << std::endl;
164+
std::cout << "seq_str: " << seq_str << std::endl;
165+
genome_str += seq_str;
166+
std::cout << "genome_str cat: " << genome_str << std::endl;
167+
168+
const Genome genome(genome_str);
169+
m_world->GetPopulation().Inject(genome, Systematics::Source(Systematics::DIVISION, "whole-genome duplication", true), ctx, i);
170+
}
171+
}
172+
};
173+
174+
/*
175+
Replaces all population members with end-to-end duplicated versions of
176+
themselves, with duplicated content being replaced with nop-c instructions.
177+
178+
*/
179+
class cActionInjectWholeGenomeDuplicationsNopCPrepend : public cAction
180+
{
181+
182+
public:
183+
cActionInjectWholeGenomeDuplicationsNopCPrepend(cWorld* world, const cString& args, Feedback&) : cAction(world, args){}
184+
185+
static const cString GetDescription() { return "No arguments"; }
186+
187+
void Process(cAvidaContext& ctx)
188+
{
189+
for (int i = 0; i < m_world->GetPopulation().GetSize(); i++)
190+
{
191+
if (!m_world->GetPopulation().GetCell(i).IsOccupied()) continue;
192+
193+
auto genome_str = m_world->GetPopulation().GetCell(i).GetOrganism()->GetGenome().AsString();
194+
auto seq_str = m_world->GetPopulation().GetCell(i).GetOrganism()->GetGenome().AsString();
195+
seq_str.Pop(',');
196+
seq_str.Pop(',');
197+
genome_str = genome_str.Substring(
198+
0, genome_str.GetSize() - seq_str.GetSize()
199+
);
200+
for (int j = 0; j < seq_str.GetSize(); j++) {
201+
genome_str += "c";
202+
}
203+
204+
genome_str += seq_str;
205+
206+
const Genome genome(genome_str);
207+
m_world->GetPopulation().Inject(genome, Systematics::Source(Systematics::DIVISION, "whole-genome duplication nopc prepend", true), ctx, i);
208+
}
209+
}
210+
};
140211

141212
/*
142213
Injects a randomly generated genome into the population.
@@ -6133,6 +6204,8 @@ void RegisterPopulationActions(cActionLibrary* action_lib)
61336204
{
61346205
action_lib->Register<cActionInject>("Inject");
61356206
action_lib->Register<cActionInjectRandom>("InjectRandom");
6207+
action_lib->Register<cActionInjectWholeGenomeDuplications>("InjectWholeGenomeDuplications");
6208+
action_lib->Register<cActionInjectWholeGenomeDuplicationsNopCPrepend>("InjectWholeGenomeDuplicationsNopCPrepend");
61366209
action_lib->Register<cActionInjectAllRandomRepro>("InjectAllRandomRepro");
61376210
action_lib->Register<cActionInjectAll>("InjectAll");
61386211
action_lib->Register<cActionInjectRange>("InjectRange");
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
VERSION_ID 2.12.0
2+
3+
WORLD_GEOMETRY 2 # 2 = Torus
4+
RANDOM_SEED 101
5+
6+
EVENT_FILE events.cfg # File containing list of events during run
7+
ENVIRONMENT_FILE environment.cfg # File that describes the environment
8+
9+
INST_SET_LOAD_LEGACY 0
10+
11+
INSTSET heads_default:hw_type=0
12+
INST nop-A
13+
INST nop-B
14+
INST nop-C
15+
INST if-n-equ
16+
INST if-less
17+
INST pop
18+
INST push
19+
INST swap-stk
20+
INST swap
21+
INST shift-r
22+
INST shift-l
23+
INST inc
24+
INST dec
25+
INST add
26+
INST sub
27+
INST nand
28+
INST IO
29+
INST h-alloc
30+
INST h-divide
31+
INST h-copy
32+
INST h-search
33+
INST mov-head
34+
INST jmp-head
35+
INST get-head
36+
INST if-label
37+
INST set-flow
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
h-alloc # Allocate space for child
2+
h-search # Locate the end of the organism
3+
nop-C #
4+
nop-A #
5+
mov-head # Place write-head at beginning of offspring.
6+
nop-C #
7+
nop-C #
8+
nop-C #
9+
nop-C #
10+
nop-C #
11+
h-search # Mark the beginning of the copy loop
12+
h-copy # Do the copy
13+
if-label # If we're done copying....
14+
nop-C #
15+
nop-A #
16+
h-divide # ...divide!
17+
mov-head # Otherwise, loop back to the beginning of the copy loop.
18+
nop-A # End label.
19+
nop-B #
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
REACTION NOT not process:value=1.0:type=pow requisite:max_count=1
2+
REACTION NAND nand process:value=1.0:type=pow requisite:max_count=1
3+
REACTION AND and process:value=2.0:type=pow requisite:max_count=1
4+
REACTION ORN orn process:value=2.0:type=pow requisite:max_count=1
5+
REACTION OR or process:value=3.0:type=pow requisite:max_count=1
6+
REACTION ANDN andn process:value=3.0:type=pow requisite:max_count=1
7+
REACTION NOR nor process:value=4.0:type=pow requisite:max_count=1
8+
REACTION XOR xor process:value=4.0:type=pow requisite:max_count=1
9+
REACTION EQU equ process:value=5.0:type=pow requisite:max_count=1
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
u begin Inject default-classic.org
2+
3+
# Print all of the standard data files...
4+
u 0:10:end PrintAverageData # Save info about they average genotypes
5+
6+
# Setup the exit time and full population data collection.
7+
u 0:10:end SavePopulation
8+
9+
u 99 InjectWholeGenomeDuplications
10+
11+
u 500 Exit # exit

avida-core/tests/whole_genome_duplication/expected/.gitignore

Whitespace-only changes.
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# Avida Average Data
2+
# Sun Nov 3 20:35:15 2024
3+
# 1: Update
4+
# 2: Merit
5+
# 3: Gestation Time
6+
# 4: Fitness
7+
# 5: Repro Rate?
8+
# 6: (deprecated) Size
9+
# 7: Copied Size
10+
# 8: Executed Size
11+
# 9: (deprecated) Abundance
12+
# 10: Proportion of organisms that gave birth in this update
13+
# 11: Proportion of Breed True Organisms
14+
# 12: (deprecated) Genotype Depth
15+
# 13: Generation
16+
# 14: Neutral Metric
17+
# 15: Lineage Label
18+
# 16: True Replication Rate (based on births/update, time-averaged)
19+
20+
0 16 65 0 0 0 19 16 0 1 1 0 0 0 0 0
21+
10 16 65 0.246154 0 0 19 16 0 0.2 0.2 0 3.93333 0.779251 0 0
22+
20 15.573 63.7753 0.243426 0 0 18.6404 15.573 0 0.168539 0.146067 0 8.03371 1.45069 0 0
23+
30 15.7576 64.1515 0.245311 0 0 18.7424 15.7576 0 0.242424 0.181818 0 12.6894 1.93131 0 0
24+
40 15.7563 63.7329 0.246933 0 0 18.6862 15.7563 0 0.259259 0.181287 0 17.2476 2.2828 0 0
25+
50 15.7725 63.9512 0.246373 0 0 18.6848 15.7725 0 0.289678 0.234184 0 21.9501 2.97972 0 0
26+
60 15.8077 63.8665 0.247322 0 0 18.7475 15.8077 0 0.246734 0.189405 0 26.6379 2.88236 0 0
27+
70 15.8563 64.3477 0.246562 0 0 18.788 15.8563 0 0.277328 0.203947 0 31.4686 3.19316 0 0
28+
80 15.8771 64.2914 0.246868 0 0 18.8335 15.8771 0 0.274812 0.206015 0 36.1383 2.84073 0 0
29+
90 15.9991 64.8297 0.246646 0 0 18.9429 15.9991 0 0.293478 0.222222 0 40.878 2.24124 0 0
30+
100 19.7562 57.2447 0 0 0 38.6572 19.7562 0 0 0 0 0 0 0 0
31+
110 16.5183 65.3103 0.243985 0 0 20.4803 16.5183 0 0.205278 0.135278 0 3.96528 0.0115889 0 0
32+
120 16.3907 66.0997 0.248073 0 0 19.2837 16.3912 0 0.300639 0.22534 0 8.68436 -0.00972108 0 0
33+
130 16.4701 66.3394 0.248873 0 0 19.3492 16.4726 0 0.299138 0.221018 0 13.387 0.00674033 0 0
34+
140 16.5258 66.1006 0.250796 0 0 19.3822 16.5294 0 0.288889 0.226389 0 18.1133 0.0585448 0 0
35+
150 16.7952 66.4422 0.253586 0 0 19.6145 16.7957 0 0.291551 0.220956 0 22.9405 0.115293 0 0
36+
160 16.92 66.8869 0.254127 0 0 19.706 16.9214 0 0.288136 0.212003 0 27.7066 0.25028 0 0
37+
170 17.0906 66.7487 0.257248 0 0 19.8577 17.0914 0 0.284047 0.208727 0 32.6676 0.23917 0 0
38+
180 17.6174 67.549 0.261213 0 0 20.3576 17.6174 0 0.277577 0.209225 0 37.7549 0.016051 0 0
39+
190 18.1045 68.5654 0.265543 0 0 20.8372 18.105 0 0.282023 0.208947 0 42.9114 -0.24512 0 0
40+
200 18.3968 68.3668 0.269041 0 0 21.1986 18.3968 0 0.267798 0.195495 0 48.0003 0.219401 0 0
41+
210 18.4747 67.7281 0.273427 0 0 21.3219 18.4753 0 0.277222 0.208333 0 53.3544 0.186011 0 0
42+
220 18.948 68.4396 0.277368 0 0 21.7997 18.948 0 0.278689 0.195332 0 58.7369 0.238729 0 0
43+
230 19.3168 68.9578 0.282429 0 0 22.2335 19.3205 0 0.270984 0.199555 0 64.4252 -0.235457 0 0
44+
240 19.8136 70.2242 0.286648 0 0 22.7155 19.8463 0 0.255904 0.185885 0 69.788 -0.24973 0 0
45+
250 20.3997 70.3722 0.293529 0 0 23.3396 20.4234 0 0.256467 0.188039 0 75.7508 -0.144379 0 0
46+
260 20.7512 69.7832 0.301026 0 0 23.6439 20.7751 0 0.262997 0.202669 0 81.712 0.216172 0 0
47+
270 21.3595 70.8413 0.306906 0 0 24.2209 21.3651 0 0.270909 0.18783 0 87.9203 0.675043 0 0
48+
280 21.6804 71.085 0.311666 0 0 24.5356 21.6898 0 0.26876 0.193163 0 93.955 0.883239 0 0
49+
290 21.6151 70.2518 0.315118 0 0 24.5523 21.6398 0 0.259311 0.192607 0 99.6109 0.955468 0 0
50+
300 21.5688 68.6819 0.321713 0 0 24.4868 21.5696 0 0.272576 0.19172 0 105.649 0.606747 0 0
51+
310 21.8231 68.2739 0.325618 0 0 24.6583 21.8239 0 0.273056 0.203611 0 111.133 0.618987 0 0
52+
320 21.761 67.6949 0.330179 0 0 24.576 21.7635 0 0.293137 0.212837 0 117.265 0.692737 0 0
53+
330 21.345 65.4869 0.334408 0 0 24.1422 21.3472 0 0.295556 0.217222 0 123.538 -0.202152 0 0
54+
340 21.3204 65.3659 0.337257 0 0 24.1095 21.3212 0 0.289247 0.218116 0 129.792 -0.0288514 0 0
55+
350 21.307 64.7338 0.340769 0 0 24.1164 21.3215 0 0.292026 0.206724 0 136.063 0.131069 0 0
56+
360 21.3907 63.973 0.346287 0 0 24.249 21.3912 0 0.296749 0.220339 0 142.431 0.169888 0 0
57+
370 21.5521 64.3551 0.349896 0 0 24.3882 21.5529 0 0.308975 0.220061 0 148.896 0.0482889 0 0
58+
380 21.1928 62.1081 0.355021 0 0 24.0247 21.1933 0 0.311667 0.223889 0 155.375 0.0160717 0 0
59+
390 20.5309 59.7968 0.359692 0 0 23.3243 20.5314 0 0.33463 0.243469 0 162.42 0.253333 0 0
60+
400 20.6019 59.0108 0.361598 0 0 23.3858 20.6025 0 0.33 0.2375 0 168.779 -0.121841 0 0
61+
410 20.5675 57.8769 0.364893 0 0 23.2839 20.5681 0 0.324167 0.238611 0 175.279 0.0679735 0 0
62+
420 19.9244 55.8144 0.368565 0 0 22.5964 19.9247 0 0.323333 0.239167 0 182.22 0.284736 0 0
63+
430 19.8033 55.0345 0.371051 0 0 22.4398 19.8033 0 0.342317 0.261184 0 188.834 -0.0896306 0 0
64+
440 19.7773 54.5385 0.372602 0 0 22.4618 19.7773 0 0.348068 0.263831 0 195.243 -0.329435 0 0
65+
450 19.5428 53.5539 0.376048 0 0 22.1772 19.5428 0 0.357222 0.269167 0 202.097 0.443936 0 0
66+
460 19.5251 53.0864 0.377587 0 0 22.1331 19.5251 0 0.353987 0.272298 0 208.666 0.785116 0 0
67+
470 19.6179 53.0167 0.379735 0 0 22.2573 19.6185 0 0.354821 0.266185 0 215.423 0.867064 0 0
68+
480 19.6134 52.8835 0.382005 0 0 22.2829 19.6134 0 0.359922 0.269594 0 222.16 2.51841 0 0
69+
490 19.4023 51.8225 0.386416 0 0 21.9722 19.4023 0 0.346485 0.26424 0 229.421 2.61261 0 0
70+
500 19.2374 51.4389 0.386223 0 0 21.858 19.2374 0 0.371317 0.288494 0 236.2 3.26682 0 0.185777
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#filetype genotype_data
2+
#format id src src_args parents num_units total_units length merit gest_time fitness gen_born update_born update_deactivated depth hw_type inst_set sequence cells gest_offset lineage
3+
# Structured Population Save
4+
# Sun Nov 3 20:35:15 2024
5+
# 1: ID
6+
# 2: Source
7+
# 3: Source Args
8+
# 4: Parent ID(s)
9+
# 5: Number of currently living organisms
10+
# 6: Total number of organisms that ever existed
11+
# 7: Genome Length
12+
# 8: Average Merit
13+
# 9: Average Gestation Time
14+
# 10: Average Fitness
15+
# 11: Generation Born
16+
# 12: Update Born
17+
# 13: Update Deactivated
18+
# 14: Phylogenetic Depth
19+
# 15: Hardware Type ID
20+
# 16: Inst Set Name
21+
# 17: Genome Sequence
22+
# 18: Occupied Cell IDs
23+
# 19: Gestation (CPU) Cycle Offsets
24+
# 20: Lineage Label
25+
26+
1 div:ext (none) (none) 1 1 19 0 0 0 0 -1 -1 0 0 heads_default rucavcccccutycasvab 0 33 0
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#filetype genotype_data
2+
#format id src src_args parents num_units total_units length merit gest_time fitness gen_born update_born update_deactivated depth hw_type inst_set sequence cells gest_offset lineage
3+
# Structured Population Save
4+
# Sun Nov 3 20:35:15 2024
5+
# 1: ID
6+
# 2: Source
7+
# 3: Source Args
8+
# 4: Parent ID(s)
9+
# 5: Number of currently living organisms
10+
# 6: Total number of organisms that ever existed
11+
# 7: Genome Length
12+
# 8: Average Merit
13+
# 9: Average Gestation Time
14+
# 10: Average Fitness
15+
# 11: Generation Born
16+
# 12: Update Born
17+
# 13: Update Deactivated
18+
# 14: Phylogenetic Depth
19+
# 15: Hardware Type ID
20+
# 16: Inst Set Name
21+
# 17: Genome Sequence
22+
# 18: Occupied Cell IDs
23+
# 19: Gestation (CPU) Cycle Offsets
24+
# 20: Lineage Label
25+
26+
1 div:ext (none) (none) 13 13 19 16 65 0.246154 0 -1 -1 0 0 heads_default rucavcccccutycasvab 0,59,60,61,119,179,3480,3481,3482,3483,3540,3541,3542 64,32,32,64,32,33,33,64,32,33,64,32,64 0,0,0,0,0,0,0,0,0,0,0,0,0
27+
2 div:int (none) 1 1 1 19 0 0 0 3 7 -1 1 0 heads_default rucavcccccutycasvar 3422 99 0
28+
3 div:int (none) 1 1 1 20 0 0 0 4 9 -1 1 0 heads_default rucavcccciutycastvab 118 66 0

0 commit comments

Comments
 (0)