464c616e3d16e7ba8cdcc37c89a7a3016a9eb602 kent Wed Jan 30 18:06:08 2013 -0800 Making random seed default to 0 rather than time to make results more reproducible. Adding in a NULL check to avoid a seg fault. diff --git src/kehayden/alphaAsm/alphaAsm.c src/kehayden/alphaAsm/alphaAsm.c index 0c47c2d..d1d92ee 100644 --- src/kehayden/alphaAsm/alphaAsm.c +++ src/kehayden/alphaAsm/alphaAsm.c @@ -926,30 +926,35 @@ struct monomer *monomer = ref->val; if (monomer->subbedOutCount > commonCount) { commonCount = monomer->subbedOutCount; common = monomer; } } return common; } boolean subIntoFirstMostCommonOfType(struct alphaStore *store, struct monomer *unused, struct dlList *ll) /* Substitute unused for first occurence of most common monomer of same type. */ { struct monomer *common = mostCommonInType(unused->type); +if (common == NULL) + { + verbose(2, "No monomers of type %s used at all!\n", unused->type->name); + return FALSE; + } if (common->subbedOutCount < 2) { verbose(2, "Trying to sub in %s, but there's no monomers of type %s that are used more than once.\n", unused->word, unused->type->name); return FALSE; } struct dlNode *node; for (node = ll->head; !dlEnd(node); node = node->next) { struct monomer *monomer = node->val; if (monomer == common) { verbose(2, "Subbing %s for %s of type %s\n", unused->word, monomer->word, unused->type->name); node->val = unused; unused->subbedOutCount += 1; @@ -1629,20 +1634,20 @@ char *fileName = optionVal("afterChain", NULL); wordTreeWrite(wt, store->maxChainSize, fileName); } } int main(int argc, char *argv[]) /* Process command line. */ { optionInit(&argc, argv, options); if (argc != 4) usage(); maxChainSize = optionInt("size", maxChainSize); outSize = optionInt("outSize", outSize); fullOnly = optionExists("fullOnly"); pseudoCount = optionInt("pseudoCount", pseudoCount); -int seed = optionInt("seed", (int)time(0)); +int seed = optionInt("seed", 0); srand(seed); alphaAsm(argv[1], argv[2], argv[3]); return 0; }