dafa0da9b989d8661390ed4cfec8adcc68d5f3de
angie
Mon Oct 18 16:02:34 2010 -0700
Redmine Bug #1304 (alignment numbering wrong when "viewing parts ofalignment"): fixed bug I introduced into fuzzyShow.c back in 2007.
Also in hgc.c, trim the "Alignment of \n");
if (aliList != NULL)
{
for (leftAli = aliList; leftAli->left != NULL; leftAli = leftAli->left)
;
}
for (ali = leftAli; ali != NULL; ali = ali->right)
{
boolean utr = FALSE;
int off = ali->nStart-needle;
int count = ali->nEnd - ali->nStart;
if ((cdsE > 0) && ((cdsS-off-1) > 0))
utr = TRUE;
for (i=0; i
\n");
htmHorizontalLine(f);
}
void ffShowSideBySide(FILE *f, struct ffAli *leftAli, DNA *needle, int needleNumOffset,
DNA *haystack, int hayNumOffset, int haySize, int hayOffStart, int hayOffEnd,
int blockMaxGap, boolean rcHaystack, boolean initialNewline)
/* Print HTML side-by-side alignment of needle and haystack (no title or labels) to f.
* {hay,needle}NumOffset are the coords at which the DNA sequence begins.
* hayOff{Start,End} are the range of coords *relative to hayNumOffset* to which the
* alignment display will be clipped -- pass in {0,haySize} for no clipping. */
{
fprintf(f, "%s", initialNewline ? "\n" : "");
struct ffAli *ali, *lastAli = NULL;
struct baf baf;
/* NOTE: if rcHaystack, hayNumOffset changes here into the end, not start! */
if (rcHaystack)
hayNumOffset += haySize;
bafInit(&baf, needle, needleNumOffset, FALSE,
haystack, hayNumOffset, rcHaystack, f, 50, FALSE);
for (ali=leftAli; ali!=NULL; ali = ali->right)
{
int i;
boolean doBreak = TRUE;
if ((ali->hEnd - haystack) <= hayOffStart ||
(ali->hStart - haystack) >= hayOffEnd)
continue;
/* Decide whether to put in a line break and/or blank characters */
if (lastAli != NULL)
{
int nSkip = ali->nStart - lastAli->nEnd;
int hSkip = ali->hStart - lastAli->hEnd;
if (nSkip > 0 && nSkip <= blockMaxGap && hSkip == 0)
{
for (i=0; i
\n");
}
int ffShAliPart(FILE *f, struct ffAli *aliList,
char *needleName, DNA *needle, int needleSize, int needleNumOffset,
char *haystackName, DNA *haystack, int haySize, int hayNumOffset,
int blockMaxGap, boolean rcNeedle, boolean rcHaystack,
boolean showJumpTable,
boolean showNeedle, boolean showHaystack,
boolean showSideBySide, boolean upcMatch,
int cdsS, int cdsE, int hayPartS, int hayPartE)
/* Display parts of alignment on html page. If hayPartS..hayPartE is a
* smaller subrange of the alignment, highlight that part of the alignment
* in both needle and haystack with underline & bold, and show only that
* part of the haystack (plus padding). Returns number of blocks (after
* merging blocks separated by blockMaxGap or less). */
{
long i;
struct ffAli *ali;
struct ffAli *lastAli;
struct ffAli *leftAli = aliList;
struct ffAli *rightAli = aliList;
int maxSize = (needleSize > haySize ? needleSize : haySize);
char *colorFlags = needMem(maxSize);
int anchorCount = 0;
boolean restrictToWindow = FALSE;
int hayOffStart = 0, hayOffEnd = haySize;
int hayPaddedOffStart = 0, hayPaddedOffEnd = haySize;
int hayExtremity = rcHaystack ? (hayNumOffset + haySize) : hayNumOffset;
int nPartS=0, nPartE=0;
if (aliList != NULL)
{
while (leftAli->left != NULL) leftAli = leftAli->left;
while (rightAli->right != NULL) rightAli = rightAli->right;
}
/* If we are only showing part of the alignment, translate haystack window
* coords to needle window coords and haystack-offset window coords: */
if (hayPartS > (hayNumOffset + (leftAli->hStart - haystack)) ||
(hayPartE > 0 && hayPartE < (hayNumOffset + (rightAli->hEnd - haystack))))
{
DNA *haystackPartS;
DNA *haystackPartE;
restrictToWindow = TRUE;
if (rcHaystack)
{
haystackPartS = haystack + (haySize - (hayPartE - hayNumOffset));
haystackPartE = haystack + (haySize - (hayPartS - hayNumOffset));
}
else
{
haystackPartS = haystack + hayPartS - hayNumOffset;
haystackPartE = haystack + hayPartE - hayNumOffset;
}
boolean foundStart = FALSE;
hayOffStart = haystackPartS - haystack;
hayOffEnd = haystackPartE - haystack;
for (ali = leftAli; ali != NULL; ali = ali->right)
{
if (haystackPartS < ali->hEnd && !foundStart)
{
int offset = haystackPartS - ali->hStart;
if (offset < 0)
offset = 0;
nPartS = offset + ali->nStart - needle;
hayOffStart = offset + ali->hStart - haystack;
foundStart = TRUE;
}
if (haystackPartE > ali->hStart)
{
if (haystackPartE > ali->hEnd)
{
nPartE = ali->nEnd - needle;
hayOffEnd = ali->hEnd - haystack;
}
else
{
nPartE = haystackPartE - ali->hStart + ali->nStart - needle;
hayOffEnd = haystackPartE - haystack;
}
}
}
hayPaddedOffStart = max(0, (hayOffStart - 100));
hayPaddedOffEnd = min(haySize, (hayOffEnd + 100));
if (rcHaystack)
hayExtremity = hayNumOffset + haySize - hayPaddedOffStart;
else
- hayExtremity = hayNumOffset + hayPaddedOffEnd;
+ hayExtremity = hayNumOffset + hayPaddedOffStart;
}
if (showJumpTable)
{
fputs("
\n", f);
}
if (cdsE > 0)
{
fprintf(f, "Matching bases in coding regions of cDNA and genomic sequences are colored blue%s. ",
(upcMatch ? " and capitalized" : ""));
fprintf(f, "Matching bases in UTR regions of cDNA and genomic sequences are colored red%s. ",
(upcMatch ? " and capitalized" : ""));
fputs("Light blue (coding) or orange (UTR) bases mark the boundaries of gaps in either sequence "
"(often splice sites).\n", f);
}
else
{
fprintf(f, "Matching bases in cDNA and genomic sequences are colored blue%s. ",
(upcMatch ? " and capitalized" : ""));
fputs("Light blue bases mark the boundaries of gaps in either sequence "
"(often splice sites).\n", f);
}
if (showNeedle && restrictToWindow)
fputs("Bases that were in the selected browser region are shown in bold "
"and underlined, "
"and only the alignment for these bases is displayed in the "
"Genomic and Side by Side sections.\n", f);
if (showJumpTable)
fputs("", f);
fputs(" ", f);
if (restrictToWindow)
fputs(" ", f);
fputs(" ", f);
fputs(" ", f);
fputs(" ", f);
fputs("
\n"); zeroBytes(colorFlags, haySize); for (ali = leftAli; ali != NULL; ali = ali->right) { boolean utr = FALSE; int i; int off = ali->hStart-haystack; int count = ali->hEnd - ali->hStart; int offn = ali->nStart-needle; if ((cdsE > 0) && ((cdsS-offn-1) > 0)) utr = TRUE; for (i=0; i\n"); htmHorizontalLine(f); } if (showSideBySide) { fprintf(f, "(cdsE-offn-1)) && (cdsE > 0)) utr = TRUE; if (utr && (i == (cdsS-offn))) utr = FALSE; if (toupper(ali->hStart[i]) == toupper(ali->nStart[i])) { if (utr) colorFlags[off+i] = ((i == 0 || i == count-1) ? socOrange : socRed); else colorFlags[off+i] = ((i == 0 || i == count-1) ? socBrightBlue : socBlue); if (upcMatch) h[off+i] = toupper(h[off+i]); } if (restrictToWindow && off+i >= hayOffStart && off+i < hayOffEnd) accentFlags[off+i] = TRUE; } } ali = leftAli; lastAli = NULL; while (ali && (ali->hEnd - haystack) <= hayPaddedOffStart) ali = ali->right; for (i = hayPaddedOffStart; i < hayPaddedOffEnd; ++i) { /* Put down "anchor" on first match position in haystack * so user can hop here with a click on the needle. */ if (ali != NULL && i == ali->hStart - haystack) { if (lastAli == NULL || ali->hStart - lastAli->hEnd > blockMaxGap) { fprintf(f, "", ++anchorCount); } lastAli = ali; ali = ali->right; } cfmOutExt(cfm, h[i], seqOutColorLookup[(int)colorFlags[i]], accentFlags[i], accentFlags[i], FALSE); } cfmFree(&cfm); freeMem(h); fprintf(f, "