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; }
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(¬AltList, 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); }
struct bed *bedForEdge(struct altGraphX *ag, bool **em, int v1, int v2, int edgeCount) { int i; char buff[256]; int *vPos = ag->vPositions; int vCount = ag->vertexCount; int pos1=0, pos2=BIGNUM; int ev1=0, ev2=0; struct bed *bed = NULL; boolean found1 = FALSE, found2 = FALSE; /* Find first exon. */ for(i=0; i<vCount; i++) { if(em[i][v1] && altGraphXEdgeVertexType(ag, i, v1) == ggExon) { int edgeNum = altGraphXGetEdgeNum(ag, i, v1); struct evidence *ev = slElementFromIx(ag->evidence, edgeNum); if(ev->evCount > ev1) { found1 = TRUE; ev1 = ev->evCount; pos1 = vPos[i]; } } } /* Find second exon. */ for(i=0; i<vCount; i++) { if(em[v2][i] && altGraphXEdgeVertexType(ag, v2, i) == ggExon) { int edgeNum = altGraphXGetEdgeNum(ag, v2, i); struct evidence *ev = slElementFromIx(ag->evidence, edgeNum); if(ev->evCount > ev2) { found2 = TRUE; ev2 = ev->evCount; pos2 = vPos[i]; } } } if(found1 && found2) { AllocVar(bed); safef(buff, sizeof(buff), "%s.%d", ag->name, edgeCount); bed->name = cloneString(buff); safef(bed->strand, sizeof(bed->strand), "%s", ag->strand); bed->chrom = cloneString(ag->tName); bed->chromStart = bed->thickStart = pos1; bed->chromEnd = bed->thickEnd = pos2; bed->score = (ev1 + ev2)/2; AllocArray(bed->chromStarts, 2); AllocArray(bed->blockSizes, 2); bed->blockCount = 2; bed->chromStarts[0] = pos1 - bed->chromStart; bed->chromStarts[1] = vPos[v2] - bed->chromStart; bed->blockSizes[0] = vPos[v1] - pos1; bed->blockSizes[1] = pos2 - vPos[v2]; } return bed; }