]> pd.if.org Git - afpopgen/commitdiff
add options hash to json output
authorNathan Wagner <nw@hydaspes.if.org>
Thu, 19 Mar 2015 20:21:16 +0000 (20:21 +0000)
committerNathan Wagner <nw@hydaspes.if.org>
Thu, 19 Mar 2015 20:28:42 +0000 (20:28 +0000)
add warning for uneven allele count

sim/sim.c

index 7919300933f8ec045c7deacd6d78cd7d44b22e5e..31a78c76bcee832020f25d297f55cceff971d77f 100644 (file)
--- a/sim/sim.c
+++ b/sim/sim.c
@@ -15,11 +15,17 @@ void hexlistjson(struct afrhex *map);
 static void setpop(struct afrhex *map, int hexid, int *pop) {
        struct afrhex *hex;
        int i;
 static void setpop(struct afrhex *map, int hexid, int *pop) {
        struct afrhex *hex;
        int i;
+       int sum = 0;
 
        hex = find_hex(map, hexid);
        for (i=0; i < 2; i++) {
                hex->freq[i] = pop[i];
 
        hex = find_hex(map, hexid);
        for (i=0; i < 2; i++) {
                hex->freq[i] = pop[i];
+               sum += pop[i];
        }
        }
+       if (sum % 2) {
+               fprintf(stderr, "allele frequency for hex %d not even\n", hexid);
+       }
+       hex->pop = sum/2;
 }
 
 static void setpopstr(struct afrhex *map, char *spec) {
 }
 
 static void setpopstr(struct afrhex *map, char *spec) {
@@ -123,6 +129,7 @@ int main (int ac, char *av[]) {
 
        printf("{");
        printf(" \"run\": %d, \"seed\": %d, \"gens\": %d", run, seed, gens);
 
        printf("{");
        printf(" \"run\": %d, \"seed\": %d, \"gens\": %d", run, seed, gens);
+       printf(",\n\"options\": { \"capfactor\": %f }", capfactor);
        printf(",\n\"gendata\": [\n");
 
        dumpgenjson(map, 0, year);
        printf(",\n\"gendata\": [\n");
 
        dumpgenjson(map, 0, year);