--
SLiM forward genetic simulation: http://messerlab.org/slim/
---
You received this message because you are subscribed to the Google Groups "slim-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to slim-discuss...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/slim-discuss/380a0448-cdb3-439c-bfdc-1ca72c984ebcn%40googlegroups.com.
Hiya Ben and João,
If you don’t mind me saying so, I was also quite keen to give my subpopulations names besides p1, p2, etc. My workaround was to define a global Dictionary object mapping the pN SLiM names to names of my choice:
defineGlobal("SLIM2POPNAMES", Dictionary());
defineGlobal("POP2SLIMNAMES", Dictionary());
I can set values like this
SLIM2POPNAMES.setValue("p0", "Te Hauturu-o-Toi");
POP2SLIMNAMES.setValue("Te Hauturu-o-Toi", "p0");
Then I can do things like
function (object)getSubpopByName(string$ name) {
for (pop in sim.subpopulations) {
if (pop.name == name) {
return pop;
}
}
return NULL;
}
function (object)getSubpopByMeaningfulName(string$ name) {
result = getSubpopByName(POP2SLIMNAMES.getValue(name));
if (isNULL(result)) {
// if there is no name set, return the SLiM pNum name
return name;
}
return result;
}
This is useful in particular if I have other functions that have actions depending on which population is sent to it
function (void)applyCarryingCapacity(string$ name) {
subpop = getSubpopByName(name);
meaningfulName = SLIM2POPNAMES.getValue(name);
K = CARRYINGCAPACITY.getValue(meaningfulName);
//catn("setting K for " + name + " to " + K);
subpop.fitnessScaling = K / subpop.individualCount;
}
Hope this helps!
Eirian
To view this discussion on the web visit https://groups.google.com/d/msgid/slim-discuss/f7ec6c43-74f1-0163-f35c-f01ec86f2842%40mac.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/slim-discuss/f912303d-9d08-56de-41fc-da41545dfc1f%40mac.com.