Example #1
0
cutVector HedgeCutter::getCuts(int arrX, int arrY){
	while (!curCuts.empty()){
		curCuts.pop_back();
	}
	int tempReach = mReach;
	mBaseTile[0] = { arrX};
	mBaseTile[1] = { arrY };
	if (tempReach > 0){
		calcCuts(mBaseTile, tempReach);
	}
	
	for (cutVector::size_type i = 0; i < curCuts.size(); i++){
		
	}
	return curCuts;
}
Example #2
0
void outputPicks(struct scoredWindow *winList,  char *database,
	struct hash *chromLimitHash, struct stats *stats, FILE *f)
/* Output picked regions. */
{
struct scoredWindow *strata[strataCount][strataCount];
double geneCuts[strataCount], consCuts[strataCount];
struct scoredWindow *win, *next;
int geneIx, consIx, pickIx;
FILE *html = NULL;
struct region *avoidList = NULL, *avoid;

/* Get list of regions to avoid */
if (avoidFile != NULL)
    avoidList = loadRegionFile(database, avoidFile);

if (htmlOutput != NULL)
    {
    html = mustOpen(htmlOutput, "w");
    htmStart(html, "Random Regions for 1% Project");
    }
fprintf(f, "Cuts at:\n");
calcCuts(stats->consCounts, histSize, 
	stats->totalConsCount, 1.0, consCuts, strataCount);
uglyf("cons %f %f %f\n", consCuts[0], consCuts[1], consCuts[2]);
fprintf(f, "cons %f %f %f\n", consCuts[0], consCuts[1], consCuts[2]);
calcCuts(stats->geneCounts, histSize, 
	stats->totalGeneCount, 1.0/geneScale, geneCuts, strataCount);
uglyf("gene %f %f %f\n", geneCuts[0], geneCuts[1], geneCuts[2]);
uglyf("gene %f %f %f\n", geneCuts[0], geneCuts[1], geneCuts[2]);
fprintf(f, "\n");


/* Move winList to strata. */
zeroBytes(strata, sizeof(strata));
for (win = winList; win != NULL; win = next)
    {
    /* Calculate appropriate strata and move. */
    next = win->next;
    consIx = cutIx(consCuts, strataCount, win->consRatio);
    geneIx = cutIx(geneCuts, strataCount, win->geneRatio);
    slAddHead(&strata[consIx][geneIx], win);
    }

/* Shuffle strata and output first picks in each. */
srand(randSeed);
for (consIx=strataCount-1; consIx>=0; --consIx)
    {
    for (geneIx=strataCount-1; geneIx>=0; --geneIx)
        {
	int cs=0, gs=0;
	if (geneIx>0)
	    gs = round(100*genoCuts[geneIx-1]);
	if (consIx>0)
	    cs = round(100*genoCuts[consIx-1]);
	fprintf(f, "consNonTx %d%%-%d%%, gene %d%%-%d%%\n", 
		cs, round(100*genoCuts[consIx]),
		gs, round(100*genoCuts[geneIx]));
	if (html)
	    {
	    fprintf(html, "<H2>consNonTx %d%% - %d%%, gene %d%% - %d%%</H3>\n", 
		cs, round(100*genoCuts[consIx]),
		gs, round(100*genoCuts[geneIx]));
	    }
	shuffleList(&strata[consIx][geneIx]);
	pickIx = 0;
	for (win = strata[consIx][geneIx]; win != NULL; win = win->next)
	    {
	    int end = win->start + bigWinSize;
	    if (!hitsRegions(win->chrom, win->start, end, avoidList))
		{
		if (withinChromLimits(chromLimitHash, win->chrom))
		    {
		    AllocVar(avoid);
		    avoid->chrom = cloneString(win->chrom);
		    avoid->start = win->start;
		    avoid->end = end;
		    slAddHead(&avoidList, avoid);
		    fprintf(f, "%s:%d-%d\t", win->chrom, win->start+1, end);
		    fprintf(f, "consNonTx %4.1f%%, gene %4.1f%%\n",
			    100*win->consRatio, 100*win->geneRatio);
		    if (html)
			{
			fprintf(html, "<A HREF=\"http://genome.ucsc.edu/cgi-bin/");
			fprintf(html, "hgTracks?db=%s&position=%s:%d-%d\">",
				database, win->chrom, win->start+1, end);
			fprintf(html, "%s:%d-%d</A>", win->chrom, win->start+1, end);
			fprintf(html, "\tconsNonTx %4.1f%%, gene %4.1f%%<BR>\n",
				100*win->consRatio, 100*win->geneRatio);
			}
		    if (++pickIx >= picksPer)
			break;
		    }
		}
	    }
	fprintf(f, "\n");
	}
    }
if (html)
    {
    htmEnd(html);
    carefulClose(&html);
    }
}
Example #3
0
void HedgeCutter::calcCuts(coords base, int temp){
	temp--;
	//Get backup so we don't lose the original value
	coords baseBackup = base;
	for (int i = 0; i < 4; i++){
		//reset the base to the backup every loop so we get the right coordinates
		base = baseBackup;
		switch (i){
		case 0:
			//Set the coordinates to be cut
			base[0]--;
			//Make sure the coordinate isn't cut already
			if (std::find(curCuts.begin(), curCuts.end(), base) != curCuts.end()) {
			}
			else {
				//Make sure it doesn't reach too far out in any direction
				if (mBaseTile[0] - base[0] < -mMaxDistance ||
					mBaseTile[0] - base[0] > mMaxDistance ||
					mBaseTile[1] - base[1] < -mMaxDistance ||
					mBaseTile[1] - base[1] > mMaxDistance){
				}
				else {
					//if it checks out, add it to the cutVector
					curCuts.push_back(base);
				}
			}
			//If we haven't reached max range yet, keep looping
			if (temp > 0){
				calcCuts(base, temp);
			}
			break;
		case 1:
			//Set the coordinates to be cut
			base[1]--;
			//Make sure the coordinate isn't cut already
			if (std::find(curCuts.begin(), curCuts.end(), base) != curCuts.end()) {
			}
			else {
				//Make sure it doesn't reach too far out in any direction
				if (mBaseTile[0] - base[0] < -mMaxDistance ||
					mBaseTile[0] - base[0] > mMaxDistance ||
					mBaseTile[1] - base[1] < -mMaxDistance ||
					mBaseTile[1] - base[1] > mMaxDistance){
				}
				else {
					//if it checks out, add it to the cutVector
					curCuts.push_back(base);
				}
			}
			//If we haven't reached max range yet, keep looping
			if (temp > 0){
				calcCuts(base, temp);
			}
			break;
		case 2:
			//Set the coordinates to be cut
			base[0]++;
			//Make sure the coordinate isn't cut already
			if (std::find(curCuts.begin(), curCuts.end(), base) != curCuts.end()) {
			}
			else {
				//Make sure it doesn't reach too far out in any direction
				if (mBaseTile[0] - base[0] < -mMaxDistance ||
					mBaseTile[0] - base[0] > mMaxDistance ||
					mBaseTile[1] - base[1] < -mMaxDistance ||
					mBaseTile[1] - base[1] > mMaxDistance){
				}
				else {
					//if it checks out, add it to the cutVector
					curCuts.push_back(base);
				}
			}
			//If we haven't reached max range yet, keep looping
			if (temp > 0){
				calcCuts(base, temp);
			}
			break;
		case 3:
			//Set the coordinates to be cut
			base[1]++;
			//Make sure the coordinate isn't cut already
			if (std::find(curCuts.begin(), curCuts.end(), base) != curCuts.end()) {
			}
			else {
				//Make sure it doesn't reach too far out in any direction
				if (mBaseTile[0] - base[0] < -mMaxDistance ||
					mBaseTile[0] - base[0] > mMaxDistance ||
					mBaseTile[1] - base[1] < -mMaxDistance ||
					mBaseTile[1] - base[1] > mMaxDistance){
				}
				else {
					//if it checks out, add it to the cutVector
					curCuts.push_back(base);
				}
			}
			//If we haven't reached max range yet, keep looping
			if (temp > 0){
				calcCuts(base, temp);
			}
			break;
		}
	}
}