inc/cda.h File Reference

#include "memgfx.h"
#include "fuzzyFind.h"

Include dependency graph for cda.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  cdaBlock
struct  cdaAli

Functions

boolean cdaCloneIsReverse (struct cdaAli *cda)
char cdaCloneStrand (struct cdaAli *cda)
char cdaDirChar (struct cdaAli *cda, char chromStrand)
char * cdaLoadString (FILE *f)
void cdaReadBlock (FILE *f, struct cdaBlock *block)
FILE * cdaOpenVerify (char *fileName)
cdaAlicdaLoadOne (FILE *f)
void cdaFixChromStartEnd (struct cdaAli *cda)
void cdaCoalesceBlocks (struct cdaAli *ca)
void cdaCoalesceFast (struct cdaAli *ca)
void cdaShowAlignmentTrack (struct memGfx *mg, int xOff, int yOff, int width, int height, Color goodColor, Color badColor, int dnaSize, int dnaOffset, struct cdaAli *cda, char repeatChar)
void cdaRcOne (struct cdaAli *cda, int dnaStart, int baseCount)
void cdaRcList (struct cdaAli *cdaList, int dnaStart, int baseCount)
void cdaFreeAli (struct cdaAli *ca)
void cdaFreeAliList (struct cdaAli **pList)
cdaAlicdaAliFromFfAli (struct ffAli *aliList, DNA *needle, int needleSize, DNA *hay, int haySize, boolean isRc)
void cdaWrite (char *fileName, struct cdaAli *cdaList)


Function Documentation

struct cdaAli* cdaAliFromFfAli ( struct ffAli aliList,
DNA needle,
int  needleSize,
DNA hay,
int  haySize,
boolean  isRc 
) [read]

Definition at line 437 of file cda.c.

References AllocVar, cdaAli::baseCount, cdaAli::blockCount, cdaAli::blocks, cdaFixChromStartEnd(), countAlis(), cdaAli::direction, dnaScoreMatch(), ffAli::hEnd, ffAli::hStart, leftGood(), needMem(), ffAli::nEnd, ffAli::nStart, cdaAli::orientation, reverseComplement(), ffAli::right, rightGood(), roundingScale(), and cdaAli::strand.

00440 {
00441 int count = countAlis(aliList);
00442 struct cdaAli *cda;
00443 struct cdaBlock *blocks;
00444 struct ffAli *fa;
00445 int score;
00446 int bases;
00447 
00448 if (isRc)
00449     reverseComplement(needle, needleSize);
00450 AllocVar(cda);
00451 cda->baseCount = needleSize;
00452 cda->strand = (isRc ? '-' : '+');
00453 cda->direction = '+';   /* Actually we don't know. */
00454 cda->orientation = (isRc ? -1 : 1);
00455 cda->blockCount = count;
00456 cda->blocks = blocks = needMem(count * sizeof(blocks[0]));
00457 
00458 for (fa = aliList; fa != NULL; fa = fa->right)
00459     {
00460     blocks->nStart = fa->nStart - needle;
00461     blocks->nEnd = fa->nEnd - needle;
00462     blocks->hStart = fa->hStart - hay;
00463     blocks->hEnd  = fa->hEnd - hay;
00464     blocks->startGood = leftGood(fa);
00465     blocks->endGood = rightGood(fa);
00466     bases = fa->nEnd - fa->nStart;
00467     score = dnaScoreMatch(fa->nStart, fa->hStart, bases);
00468     blocks->midScore = roundingScale(255, score, bases);
00469     ++blocks;
00470     }
00471 cdaFixChromStartEnd(cda);
00472 if (isRc)
00473     {
00474     reverseComplement(needle, needleSize);
00475     }
00476 return cda;
00477 }

Here is the call graph for this function:

boolean cdaCloneIsReverse ( struct cdaAli cda  ) 

Definition at line 174 of file cda.c.

References cdaAli::direction, and cdaAli::strand.

Referenced by cdaCloneStrand(), and cdaDirChar().

00176 {
00177 boolean isReverse = (cda->direction == '-');
00178 if (cda->strand == '-')
00179     isReverse = !isReverse;
00180 return isReverse;
00181 }

Here is the caller graph for this function:

char cdaCloneStrand ( struct cdaAli cda  ) 

Definition at line 183 of file cda.c.

References cdaCloneIsReverse().

00185 {
00186 return cdaCloneIsReverse(cda) ? '-' : '+';
00187 }

Here is the call graph for this function:

void cdaCoalesceBlocks ( struct cdaAli ca  ) 

Definition at line 310 of file cda.c.

References cdaCoalesceAll(), and TRUE.

00312 {
00313 cdaCoalesceAll(ca, TRUE);
00314 }

Here is the call graph for this function:

void cdaCoalesceFast ( struct cdaAli ca  ) 

Definition at line 316 of file cda.c.

References cdaCoalesceAll(), and FALSE.

00318 {
00319 cdaCoalesceAll(ca, FALSE);
00320 }

Here is the call graph for this function:

char cdaDirChar ( struct cdaAli cda,
char  chromStrand 
)

Definition at line 189 of file cda.c.

References cdaCloneIsReverse().

00192 {
00193 boolean isReverse = cdaCloneIsReverse(cda);
00194 if (chromStrand == '-')
00195     isReverse = !isReverse;
00196 return (isReverse ? '<' : '>');    
00197 }

Here is the call graph for this function:

void cdaFixChromStartEnd ( struct cdaAli cda  ) 

Definition at line 65 of file cda.c.

References cdaAli::blockCount, cdaAli::blocks, cdaAli::chromEnd, cdaAli::chromStart, cdaBlock::hEnd, and cdaBlock::hStart.

Referenced by cdaAliFromFfAli(), and cdaLoadOne().

00068 {
00069 int start = 0x7fffffff;
00070 int end = -start;
00071 int count = cda->blockCount;
00072 struct cdaBlock *block = cda->blocks;
00073 
00074 while (--count >= 0)
00075     {
00076     if (start > block->hStart)
00077         start = block->hStart;
00078     if (end < block->hEnd)
00079         end = block->hEnd;
00080     ++block;
00081     }
00082 cda->chromStart = start;
00083 cda->chromEnd = end;
00084 }

Here is the caller graph for this function:

void cdaFreeAli ( struct cdaAli ca  ) 

Definition at line 238 of file cda.c.

References cdaAli::blocks, freeMem(), and cdaAli::name.

Referenced by cdaFreeAliList().

00240 {
00241 freeMem(ca->blocks);
00242 freeMem(ca->name);
00243 freeMem(ca);
00244 }

Here is the call graph for this function:

Here is the caller graph for this function:

void cdaFreeAliList ( struct cdaAli **  pList  ) 

Definition at line 246 of file cda.c.

References cdaFreeAli(), and cdaAli::next.

00248 {
00249 struct cdaAli *ca, *next;
00250 next = *pList;
00251 while ((ca = next) != NULL)
00252     {
00253     next = ca->next;
00254     cdaFreeAli(ca);
00255     }
00256 *pList = NULL;
00257 }

Here is the call graph for this function:

struct cdaAli* cdaLoadOne ( FILE *  f  )  [read]

Definition at line 109 of file cda.c.

References AllocVar, cdaAli::baseCount, cdaAli::blockCount, cdaAli::blocks, cdaFixChromStartEnd(), cdaLoadString(), cdaReadBlock(), chromIx(), cdaAli::chromIx, cdaAli::direction, cdaAli::isEmbryonic, cdaAli::milliScore, mustReadOne, name, cdaAli::name, needMem(), cdaAli::strand, and UBYTE.

Referenced by wormCdaAlisInRange().

00111 {
00112 struct cdaAli *ca;
00113 struct cdaBlock *blocks;
00114 int count;
00115 int i;
00116 char *name;
00117 UBYTE chromIx;
00118 
00119 if ((name = cdaLoadString(f)) == NULL)
00120     return NULL;
00121 AllocVar(ca);
00122 ca->name = name;
00123 mustReadOne(f, ca->isEmbryonic);
00124 mustReadOne(f, ca->baseCount);
00125 mustReadOne(f, ca->milliScore);
00126 mustReadOne(f, chromIx);
00127 ca->chromIx = chromIx;
00128 mustReadOne(f, ca->strand);
00129 mustReadOne(f, ca->direction);
00130 mustReadOne(f, ca->blockCount);
00131 count = ca->blockCount;
00132 ca->blocks = blocks = needMem(count * sizeof(blocks[0]));
00133 for (i=0; i<count; ++i)
00134     cdaReadBlock(f, &blocks[i]);
00135 cdaFixChromStartEnd(ca);
00136 return ca;
00137 }

Here is the call graph for this function:

Here is the caller graph for this function:

char* cdaLoadString ( FILE *  f  ) 

Definition at line 16 of file cda.c.

References mustRead(), needMem(), readOne, and UBYTE.

Referenced by cdaLoadOne().

00018 {
00019 UBYTE size;
00020 char *s;
00021 if (!readOne(f, size))
00022     return NULL;
00023 s = needMem(size+1);
00024 mustRead(f, s, size);
00025 return s;
00026 }

Here is the call graph for this function:

Here is the caller graph for this function:

FILE* cdaOpenVerify ( char *  fileName  ) 

Definition at line 86 of file cda.c.

References aliSig, bits32, errAbort(), mustOpen(), and mustReadOne.

Referenced by flyOpenGoodAli(), and wormOpenGoodAli().

00089 {
00090 FILE *aliFile;
00091 bits32 sig;
00092 
00093 aliFile = mustOpen(fileName, "rb");
00094 mustReadOne(aliFile, sig);
00095 if (sig != aliSig)
00096     errAbort("Bad signature %x on %s", sig, fileName);
00097 return aliFile;
00098 }

Here is the call graph for this function:

Here is the caller graph for this function:

void cdaRcList ( struct cdaAli cdaList,
int  dnaStart,
int  baseCount 
)

Definition at line 229 of file cda.c.

References cdaRcOne(), and cdaAli::next.

00231 {
00232 struct cdaAli *cda;
00233 for (cda = cdaList; cda != NULL; cda = cda->next)
00234     cdaRcOne(cda, dnaStart, baseCount);
00235 }

Here is the call graph for this function:

void cdaRcOne ( struct cdaAli cda,
int  dnaStart,
int  baseCount 
)

Definition at line 199 of file cda.c.

References cdaAli::baseCount, cdaAli::blockCount, cdaAli::blocks, cdaBlock::endGood, cdaBlock::hEnd, cdaBlock::hStart, cdaBlock::nEnd, cdaBlock::nStart, reverseOffset(), cdaBlock::startGood, and UBYTE.

Referenced by cdaRcList().

00201 {
00202 struct cdaBlock *block, *endBlock;
00203 
00204 for (block = cda->blocks, endBlock = block+cda->blockCount; block < endBlock; ++block)
00205     {
00206     int temp;
00207     UBYTE uc;
00208     temp = reverseOffset(block->hStart-dnaStart, baseCount) + dnaStart + 1;
00209     block->hStart = reverseOffset(block->hEnd-dnaStart, baseCount) + dnaStart + 1;
00210     block->hEnd = temp;
00211     temp = reverseOffset(block->nStart, cda->baseCount);
00212     block->nStart = reverseOffset(block->nEnd, cda->baseCount);
00213     block->nEnd = temp;
00214     uc = block->startGood;
00215     block->startGood = block->endGood;
00216     block->endGood = uc;
00217     }
00218 block = cda->blocks;
00219 endBlock -= 1;
00220 for (;block < endBlock; ++block, --endBlock)
00221     {
00222     struct cdaBlock temp;
00223     temp = *block;
00224     *block = *endBlock;
00225     *endBlock = temp;
00226     }
00227 }

Here is the call graph for this function:

Here is the caller graph for this function:

void cdaReadBlock ( FILE *  f,
struct cdaBlock block 
)

Definition at line 42 of file cda.c.

References cdaBlock::endGood, cdaBlock::hEnd, cdaBlock::hStart, cdaBlock::midScore, mustReadOne, cdaBlock::nEnd, cdaBlock::nStart, and cdaBlock::startGood.

Referenced by cdaLoadOne().

00044 {
00045 mustReadOne(f, block->nStart);
00046 mustReadOne(f, block->nEnd);
00047 mustReadOne(f, block->hStart);
00048 block->hEnd = block->hStart + (block->nEnd - block->nStart);
00049 mustReadOne(f, block->startGood);
00050 mustReadOne(f, block->endGood);
00051 mustReadOne(f, block->midScore);
00052 }

Here is the caller graph for this function:

void cdaShowAlignmentTrack ( struct memGfx mg,
int  xOff,
int  yOff,
int  width,
int  height,
Color  goodColor,
Color  badColor,
int  dnaSize,
int  dnaOffset,
struct cdaAli cda,
char  repeatChar 
)

Definition at line 323 of file cda.c.

References cdaAli::blockCount, cdaAli::blocks, cdaBlock::endGood, cdaBlock::hEnd, cdaBlock::hStart, MG_WHITE, mgDrawBox(), mgFontCharWidth(), mgSmallFont(), mgTextCentered(), cdaBlock::midScore, cdaBlock::nEnd, cdaBlock::nStart, roundingScale(), and cdaBlock::startGood.

00327 {
00328 struct cdaBlock *block = cda->blocks;
00329 int count = cda->blockCount;
00330 int blockIx;
00331 int scaledHeight = roundingScale(height, dnaSize, width);
00332 MgFont *font = NULL;
00333 int repeatCharWidth = 0;
00334 
00335 if (repeatChar)
00336     {
00337     font = mgSmallFont();
00338     repeatCharWidth = mgFontCharWidth(font, repeatChar);
00339     }
00340 
00341 for (blockIx = 0; blockIx < count; ++blockIx)
00342     {
00343     int x[4];
00344     int b[4];
00345     Color c[3];
00346     int quarterWid;
00347     int i;
00348     int w;
00349 
00350     b[0] = block->hStart;
00351     b[3] = block->hEnd;
00352     quarterWid = (b[3]-b[0]+2)>>2;
00353     if (quarterWid > scaledHeight)
00354         quarterWid = scaledHeight;
00355     b[1] = b[0] + quarterWid;
00356     b[2] = b[3] - quarterWid;
00357 
00358     c[0] = ((block->startGood >= 4 && (blockIx == 0 || block[-1].nEnd == block[0].nStart)) 
00359         ? goodColor : badColor);
00360     c[1] = ((block->midScore > 229) ? goodColor : badColor);
00361     c[2] = ((block->endGood >= 4 && (blockIx == count-1 || block[0].nEnd == block[1].nStart))
00362         ? goodColor : badColor);
00363 
00364     for (i=0; i<4; ++i)
00365         x[i] = roundingScale(b[i]-dnaOffset, width, dnaSize) + xOff;
00366     for (i=0; i<3; ++i)
00367         {
00368         if ((w = x[i+1] - x[i]) > 0)
00369             mgDrawBox(mg, x[i], yOff, w, height, c[i]);
00370         }
00371     
00372     if (repeatChar)
00373         {
00374         char buf[256];
00375         int charCount;
00376         w = x[3] - x[0];
00377         charCount = w/repeatCharWidth;
00378         if (charCount >= sizeof(buf))
00379             charCount = sizeof(buf)-1;
00380         memset(buf, repeatChar, charCount);
00381         buf[charCount] = 0;
00382         mgTextCentered(mg, x[0], yOff, w, height, MG_WHITE, font, buf);
00383         }
00384     ++block;
00385     }
00386 }

Here is the call graph for this function:

void cdaWrite ( char *  fileName,
struct cdaAli cdaList 
)

Definition at line 164 of file cda.c.

References cdaCreate(), cdaWriteOne(), and cdaAli::next.

00166 {
00167 FILE *f = cdaCreate(fileName);
00168 struct cdaAli *ca;
00169 for (ca = cdaList; ca != NULL; ca = ca->next)
00170     cdaWriteOne(f, ca);
00171 fclose(f);
00172 }

Here is the call graph for this function:


Generated on Tue Dec 25 18:43:32 2007 for blat by  doxygen 1.5.2