struct bed *bedIntronsFromAgx(struct altGraphX *ag)
/* Produce an intron bed for every intron in the altGraphx. */
{
struct bed *bed = NULL, *bedList = NULL;
int i,j;
int count =0;
int vCount = ag->vertexCount;
bool **em  = altGraphXCreateEdgeMatrix(ag);
for(i=0; i<vCount; i++)
    {
    for(j=0; j<vCount; j++)
	{
	if(em[i][j] && altGraphXEdgeVertexType(ag, i, j) == ggSJ)
	    {
	    bed = bedForEdge(ag, em, i, j, count++);
	    if(bed != NULL)
		slAddHead(&bedList, bed);
	    }
	}
    }
altGraphXFreeEdgeMatrix(&em, vCount);
slReverse(&bedList);
return bedList;
}
Ejemplo n.º 2
0
void lookForAltSplicing(char *db, struct altGraphX *ag, struct altSpliceSite **aSpliceList, 
			int *altSpliceSites, int *altSpliceLoci, int *totalSpliceSites)
/* Walk throught the altGraphX graph and look for evidence of altSplicing. */
{
struct altSpliceSite *notAlt = NULL, *notAltList = NULL;
bool **em = altGraphXCreateEdgeMatrix(ag);
int vCount = ag->vertexCount;
unsigned char *vTypes = ag->vTypes;
int altSpliceSitesOrig = *altSpliceSites;
int i,j,k;
int altCount = 0;
occassionalDot();
totalLoci++;
for(i=0; i<vCount; i++)
    {
    struct altSpliceSite *aSplice = NULL;
    for(j=0; j<vCount; j++)
	{
	if(em[i][j] && areConsSplice(em, vCount, vTypes,i,j) && 
	   (agxEvCount(ag, i,j) >= minConfidence)) 
	    {
	    for(k=j+1; k<vCount; k++)
		{
		if(em[i][k] && areConsSplice(em, vCount, vTypes, i, k) &&
		   (agxEvCount(ag, i,k) >= minConfidence)) 
		    {
		    totalSplices++;
		    if(aSplice == NULL)
			{
			splicedLoci++;
			aSplice = initASplice(ag, em, i, j, k);

			(*altSpliceSites)++;
			}
		    else
			addSpliceSite(ag, em, aSplice, k);
		    }
		}
	    }
	/* Only want non alt-spliced exons for our controls.  Some of
	 these checks are historical and probably redundant....*/
	if(em[i][j] && 
	   rowSum(em[i], ag->vTypes, ag->vertexCount) == 1 &&
	   rowSum(em[j], ag->vTypes, ag->vertexCount) == 1 &&
	   colSum(em, ag->vTypes, ag->vertexCount, j) == 1 &&
	   colSum(em, ag->vTypes, ag->vertexCount, j) == 1 &&
	   altGraphXEdgeVertexType(ag, i, j) == ggExon &&
	   areHard(ag, i, j) && 
	   areConstitutive(ag, em, i, j))
	    {
	    notAlt = initASplice(ag, em, i, j, j);
	    if(altRegion != NULL) 
		outputControlExonBeds(ag, i, j);
	    slAddHead(&notAltList, notAlt);
	    } 
	}
    if(aSplice != NULL) 
	{
	if(altLogFile)
	    fprintf(altLogFile, "%s\n", ag->name);
	slAddHead(aSpliceList, aSplice);
	}
    /* If we have a simple splice classfy it and log it. */
    if(aSplice != NULL && aSplice->altCount == 2)
	{
	altTotalCount++;	
	fixOtherStrand(aSplice);
	logSpliceType(aSplice->spliceTypes[1], abs(aSplice->altBpEnds[1] - aSplice->altBpStarts[1]));
	if(aSplice->spliceTypes[1] == alt3Prime && (aSplice->altBpEnds[1] - aSplice->altBpStarts[1] == 3))
	    reportThreeBpBed(aSplice);
	if(doSScores)
	    fillInSscores(db, aSplice, 1);
	if(RData != NULL)
	    {
	    outputForR(aSplice, 1, RData);
	    }
	}
    /* Otherwise log it as altOther. Start at 1 as 0->1 is the first
     * splice, 1->2 is the first alt spliced.*/
    else if(aSplice != NULL)
	{
	for(altCount=1; altCount<aSplice->altCount; altCount++)
	    {
	    altTotalCount++;
	    altOtherCount++;
	    }
	}
    }
for(notAlt = notAltList; notAlt != NULL; notAlt = notAlt->next)
    {
    if(doSScores)
	fillInSscores(db, notAlt, 1);
    if(RData != NULL)
	{
	fixOtherStrand(notAlt);
	outputForR(notAlt, 1, RDataCont);
	}
    }
if(*altSpliceSites != altSpliceSitesOrig)
    (*altSpliceLoci)++;
altGraphXFreeEdgeMatrix(&em, vCount);
}