lib/boxLump.c File Reference

#include "common.h"
#include "hash.h"
#include "boxClump.h"
#include "boxLump.h"

Include dependency graph for boxLump.c:

Go to the source code of this file.

Functions

int boxInCmpQuery (const void *va, const void *vb)
int boxInCmpTarget (const void *va, const void *vb)
boxClumplumpOneDimension (struct boxIn *boxList, boolean onQuery)
boxClumpboxLump (struct boxIn **pBoxList)


Function Documentation

int boxInCmpQuery ( const void *  va,
const void *  vb 
)

Definition at line 14 of file boxLump.c.

References boxIn::qStart.

Referenced by lumpOneDimension().

00016 {
00017 const struct boxIn *a = *((struct boxIn **)va);
00018 const struct boxIn *b = *((struct boxIn **)vb);
00019 return a->qStart - b->qStart;
00020 }

Here is the caller graph for this function:

int boxInCmpTarget ( const void *  va,
const void *  vb 
)

Definition at line 22 of file boxLump.c.

References boxIn::tStart.

Referenced by lumpOneDimension().

00024 {
00025 const struct boxIn *a = *((struct boxIn **)va);
00026 const struct boxIn *b = *((struct boxIn **)vb);
00027 return a->tStart - b->tStart;
00028 }

Here is the caller graph for this function:

struct boxClump* boxLump ( struct boxIn **  pBoxList  )  [read]

Definition at line 74 of file boxLump.c.

References boxClumpFreeList(), boxLump(), FALSE, lumpOneDimension(), slCat(), slCount(), and TRUE.

Referenced by boxLump().

00080 {
00081 struct boxClump *qClumpList = NULL, *tClumpList = NULL, 
00082         *tClump;
00083 
00084 if (*pBoxList == NULL)
00085     return NULL;
00086 tClumpList = lumpOneDimension(*pBoxList, FALSE);
00087 
00088 for (tClump = tClumpList; tClump != NULL; tClump = tClump->next)
00089     {
00090     struct boxClump *oneList = lumpOneDimension(tClump->boxList, TRUE);
00091     if (slCount(oneList) > 1)
00092         {
00093         struct boxClump *clump;
00094         for (clump = oneList; clump != NULL; clump = clump->next)
00095             {
00096             struct boxClump *subList = boxLump(&clump->boxList);
00097             qClumpList = slCat(subList, qClumpList);
00098             }
00099         boxClumpFreeList(&oneList);
00100         }
00101     else
00102         {
00103         qClumpList = slCat(oneList, qClumpList);
00104         }
00105     tClump->boxList = NULL;
00106     }
00107 
00108 boxClumpFreeList(&tClumpList);
00109 *pBoxList = NULL;
00110 return qClumpList;
00111 }

Here is the call graph for this function:

Here is the caller graph for this function:

struct boxClump* lumpOneDimension ( struct boxIn boxList,
boolean  onQuery 
) [read]

Definition at line 30 of file boxLump.c.

References AllocVar, boxClump::boxCount, boxInCmpQuery(), boxInCmpTarget(), boxClump::boxList, boxIn::next, boxIn::qEnd, boxClump::qEnd, boxClump::qStart, boxIn::qStart, slAddHead, slSort(), boxIn::tEnd, boxClump::tEnd, boxClump::tStart, and boxIn::tStart.

Referenced by boxLump().

00032 {
00033 struct boxClump *clump = NULL, *clumpList = NULL;
00034 struct boxIn *box, *nextBox;
00035 if (onQuery)
00036     slSort(&boxList, boxInCmpQuery);
00037 else
00038     slSort(&boxList, boxInCmpTarget);
00039 for (box = boxList; box != NULL; box = nextBox)
00040     {
00041     nextBox = box->next;
00042     /* Make new clump containing current box. */
00043     if (clump == NULL || 
00044         (onQuery && clump->qEnd < box->qStart) ||
00045         (!onQuery && clump->tEnd < box->tStart) )
00046         {
00047         AllocVar(clump);
00048         slAddHead(&clumpList, clump);
00049         clump->qStart = box->qStart;
00050         clump->qEnd = box->qEnd;
00051         clump->tStart = box->tStart;
00052         clump->tEnd = box->tEnd;
00053         clump->boxCount = 1;
00054         clump->boxList = box;
00055         box->next = NULL;
00056         }
00057     else
00058         {
00059         if (clump->tStart > box->tStart)
00060              clump->tStart = box->tStart;
00061         if (clump->tEnd < box->tEnd)
00062              clump->tEnd = box->tEnd;
00063         if (clump->qEnd < box->qEnd)
00064              clump->qEnd = box->qEnd;
00065         if (clump->qStart > box->qStart)
00066              clump->qStart = box->qStart;
00067         clump->boxCount += 1;
00068         slAddHead(&clump->boxList, box);
00069         }
00070     }
00071 return clumpList;
00072 }

Here is the call graph for this function:

Here is the caller graph for this function:


Generated on Tue Dec 25 19:35:49 2007 for blat by  doxygen 1.5.2