Exemple #1
0
struct psl *filterPsls(struct psl *pslList, int chromStart, int chromEnd)
/** Filter pslList to get only "good" ones. */
{
struct psl *goodList = NULL, *psl = NULL, *pslNext = NULL;
for(psl = pslList; psl != NULL; psl = pslNext)
    {
    boolean notTooBig = FALSE;
    pslNext = psl->next;

    /* Figure out chromStart/chromEnd put us in the middle of a big
     * intron or the like inside of another gene.  If so ignore alignments
     * from enclosing genes by setting notTooBig. */
    int endFirstExon = psl->tStarts[0] + psl->blockSizes[0];
    int startLastExon = psl->tStarts[psl->blockCount-1];
    int pad=100;   
    notTooBig = (endFirstExon + pad >= chromStart && startLastExon -pad <= chromEnd);
#ifdef AFFYSPLICE
    notTooBig = TRUE;
#endif
    if(passFilters(psl) && notTooBig)
	{
	slSafeAddHead(&goodList, psl);
	}
    else
	{
	if(!useChromKeeper)
	    pslFree(&psl);
	}
    }
slReverse(&goodList);
return goodList;
}
Exemple #2
0
static void condSelectReply(fr_t *fr, aobj *akey, void *rrow, long *card) {
    uchar hit = 0;
    if (fr->nowc) hit = 1;
    else          hit = passFilters(fr->btr, akey, rrow, 
                                    fr->w->flist, fr->w->tmatch);

    if (hit) {
        *card = *card + 1;
        if (fr->cstar) return; /* just counting */
        robj *r = outputRow(fr->btr, rrow, fr->qcols, fr->cmatchs,
                            akey, fr->w->tmatch, 0);
        if (fr->q->qed) addRow2OBList(fr->ll, fr->w, fr->btr, r, fr->ofree,
                                      rrow, akey);
        else            addReplyBulk(fr->c, r);
        decrRefCount(r);
    }
}
Exemple #3
0
void processBestSingle(char *acc, struct psl *pslList, FILE *bestFile, FILE *repFile)
/* Find single best psl in list. */
{
struct psl *bestPsl = NULL, *psl;
int bestScore = 0, score, threshold;

for (psl = pslList; psl != NULL; psl = psl->next)
    {
    score = pslScore(psl);
    if (score > bestScore)
        {
	bestScore = score;
	bestPsl = psl;
	}
    }
threshold = round((1.0 - nearTop)*bestScore);
for (psl = pslList; psl != NULL; psl = psl->next)
    {
    if (pslScore(psl) >= threshold && passFilters(psl, NULL))
        pslTabOut(psl, bestFile);
    }
}
Exemple #4
0
void processBestMulti(char *acc, struct psl *pslList, FILE *bestFile, FILE *repFile)
/* Find psl's that are best anywhere along their length. */
{
struct psl *psl;
int qSize;
int *repTrack = NULL;
int *scoreTrack = NULL;
int milliScore;
int goodAliCount = 0;
int bestAliCount = 0;
int milliMin = 1000*minAli;


if (pslList == NULL)
    return;
qSize = pslList->qSize;
AllocArray(repTrack, qSize+1);
AllocArray(scoreTrack, qSize+1);

for (psl = pslList; psl != NULL; psl = psl->next)
    {
    int blockIx;
    char strand = psl->strand[0];
    milliScore = calcMilliScore(psl);
    if (milliScore >= milliMin)
	{
	++goodAliCount;
	milliScore += sizeFactor(psl);
	for (blockIx = 0; blockIx < psl->blockCount; ++blockIx)
	    {
	    int start = psl->qStarts[blockIx];
	    int size = psl->blockSizes[blockIx];
	    int end = start+size;
	    int i;
	    if (strand == '-')
	        reverseIntRange(&start, &end, psl->qSize);
	    if (start < 0 || end > qSize)
		{
		warn("Odd: qName %s tName %s qSize %d psl->qSize %d start %d end %d",
		    psl->qName, psl->tName, qSize, psl->qSize, start, end);
		if (start < 0)
		    start = 0;
		if (end > qSize)
		    end = qSize;
		}
	    for (i=start; i<end; ++i)
		{
		repTrack[i] += 1;
		if (milliScore > scoreTrack[i])
		    scoreTrack[i] = milliScore;
		}
	    }
	}
    }
/* Print out any alignments that are within 2% of top score. */
for (psl = pslList; psl != NULL; psl = psl->next)
    {
    if(passFilters(psl, scoreTrack))
	{
	pslTabOut(psl, bestFile);
	++bestAliCount;
	}
    }


/* Print out run-length-encoded repeat info.  */
    {
    int runVal = repTrack[0];
    int curVal;
    int runSize = 1;
    int packetCount = 0;
    int *packetSize = NULL;
    int *packetVal = NULL;
    int i;

    AllocArray(packetSize, qSize);
    AllocArray(packetVal, qSize);

    repTrack[qSize] = -1;	/* Sentinal value to simplify RLC loop. */
    fprintf(repFile, "%s\t%d\t%d\t", acc, bestAliCount, goodAliCount);

    for (i=1; i<=qSize; ++i)
	{
	if ((curVal = repTrack[i]) != runVal)
	    {
	    packetSize[packetCount] = runSize;
	    packetVal[packetCount] = runVal;
	    ++packetCount;
	    runSize = 1;
	    runVal = curVal;
	    }
	else
	    {
	    ++runSize;
	    }
	}
    fprintf(repFile, "%d\t", packetCount);
    for (i=0; i<packetCount; ++i)
	fprintf(repFile, "%d,", packetSize[i]);
    fprintf(repFile, "\t");
    for (i=0; i<packetCount; ++i)
	fprintf(repFile, "%d,", packetVal[i]);
    fprintf(repFile, "\n");

    freeMem(packetSize);
    freeMem(packetVal);
    }

freeMem(repTrack);
freeMem(scoreTrack);
}