8a12a3b83d896da7aa531a0f41cd3a9749536fe7 kent Fri Dec 14 15:59:43 2012 -0800 More progress towards substituting in missing monomers. diff --git src/kehayden/alphaAsm/alphaAsm.c src/kehayden/alphaAsm/alphaAsm.c index 18084dc..3d44798 100644 --- src/kehayden/alphaAsm/alphaAsm.c +++ src/kehayden/alphaAsm/alphaAsm.c @@ -695,96 +695,87 @@ return refList; } int monomerRefIx(struct monomerRef *list, struct monomer *monomer) /* Return index of monomer in list. */ { int i; struct monomerRef *ref; for (i=0, ref = list; ref != NULL; ref = ref->next, ++i) { if (ref->val == monomer) return i; } errAbort("Monomer %s not on list\n", monomer->word); -return -1; // ugly +return -1; } struct monomerRef *findNeighborhoodFromReads(struct monomer *center) /* Find if possible one monomer to either side of center */ { struct slRef *readRef; struct monomerRef *before = NULL, *after = NULL; /* Loop through reads hoping to find a case where center is flanked by two monomers in * same read. As a fallback, keep track of a monomer before and a monomer after in * any read. */ -uglyf("findNeighborhood of %s from %d reads\n", center->word, slCount(center->readList)); for (readRef = center->readList; readRef != NULL; readRef = readRef->next) { struct alphaRead *read = readRef->val; int readSize = slCount(read->list); int centerIx = monomerRefIx(read->list, center); if (readSize >= 3 && centerIx > 0 && centerIx < readSize-1) { - uglyf(" Whoopie found central for %s\n", center->word); before = slElementFromIx(read->list, centerIx-1); after = slElementFromIx(read->list, centerIx+1); break; } else if (readSize >= 2) { if (centerIx == 0) - { after = slElementFromIx(read->list, centerIx+1); - uglyf(" read %s, centerIx %d, after %p\n", center->word, centerIx, after); - } else - { before = slElementFromIx(read->list, centerIx-1); - uglyf(" read %s, centerIx %d, before %p\n", center->word, centerIx, before); } } - } -uglyf("before %p, center %p, after %p\n", before, center, after); -/* Make up list. */ + +/* Make up list from end to start. */ struct monomerRef *retList = NULL, *monoRef; if (after) { AllocVar(monoRef); monoRef->val = after->val; slAddHead(&retList, monoRef); } AllocVar(monoRef); monoRef->val = center; slAddHead(&retList, monoRef); if (before) { AllocVar(monoRef); monoRef->val = before->val; slAddHead(&retList, monoRef); } -uglyf("%d in retList\n", slCount(retList)); return retList; } void subInMissing(struct alphaStore *store, struct dlList *ll) /* Go figure out missing monomers in ll, and attempt to substitute them in somewhere they would fit. */ { struct slRef *unusedList = listUnusedMonomers(store, ll); -uglyf("%d monomers, %d unused\n", slCount(store->monomerList), slCount(unusedList)); +verbose(2, "%d monomers, %d unused\n", slCount(store->monomerList), slCount(unusedList)); struct slRef *unusedRef; for (unusedRef = unusedList; unusedRef != NULL; unusedRef = unusedRef->next) { struct monomer *unused = unusedRef->val; struct monomerRef *neighborhood = findNeighborhoodFromReads(unused); uglyf("%s(%d):", unused->word, slCount(neighborhood)); { struct monomerRef *monomerRef; for (monomerRef = neighborhood; monomerRef != NULL; monomerRef = monomerRef->next) { struct monomer *monomer = monomerRef->val; uglyf(" %s", monomer->word); } uglyf("\n"); }