Exemplo n.º 1
0
struct evidence *evidenceForEdge(struct altGraphX *ag, int v1, int v2)
/* Return the evidence associated with this edge. */
{
int edgeNum = altGraphXGetEdgeNum(ag, v1, v2);
struct evidence *ev = slElementFromIx(ag->evidence, edgeNum);
return ev;
}
Exemplo n.º 2
0
int agxEvCount(struct altGraphX *ag, int v1, int v2)
/* Return the number of ESTs supporting this edge. */
{
int edgeNum = altGraphXGetEdgeNum(ag, v1, v2);
struct evidence *ev = slElementFromIx(ag->evidence, edgeNum);
return ev->evCount;
}
Exemplo n.º 3
0
void outputControlExonBeds(struct altGraphX *ag, int v1, int v2)
{
int *vPos = ag->vPositions;
struct bed bedUp, bedDown, bedAlt;
struct evidence *ev = slElementFromIx(ag->evidence, altGraphXGetEdgeNum(ag, v1, v2));

/* Make sure that this edge has enough support 
   that we believe it. */
if(ev->evCount >= minControlConf)
    {
    /* Initialize some beds for reporting. */
    bedUp.chrom = bedDown.chrom = bedAlt.chrom = ag->tName;
    bedUp.name = bedDown.name = bedAlt.name = ag->name;
    bedUp.score = bedDown.score = bedAlt.score = altControl;
    safef(bedUp.strand, sizeof(bedUp.strand), "%s", ag->strand);
    safef(bedDown.strand, sizeof(bedDown.strand), "%s", ag->strand);
    safef(bedAlt.strand, sizeof(bedDown.strand), "%s", ag->strand);
    /* Alt spliced region. */
    bedAlt.chromStart = vPos[v1];
    bedAlt.chromEnd = vPos[v2];
    
    /* Upstream/down stream */
    if(sameString(ag->strand, "+"))
	{
	bedUp.chromStart = vPos[v1] - flankingSize;
	bedUp.chromEnd = vPos[v1];
	bedDown.chromStart = vPos[v2];
	bedDown.chromEnd = vPos[v2] + flankingSize;
	}
    else 
	{
	bedDown.chromStart = vPos[v1] - flankingSize;
	bedDown.chromEnd = vPos[v1];
	bedUp.chromStart = vPos[v2];
	bedUp.chromEnd = vPos[v2] + flankingSize;
	}
    bedOutputN(&bedAlt, 6, altRegion, '\t','\n');
    bedOutputN(&bedUp, 6, upStream100, '\t', '\n');
    bedOutputN(&bedDown, 6, downStream100, '\t', '\n');
    }
}
Exemplo n.º 4
0
boolean isRetainIntron(struct altGraphX *ag, bool **em,  int vs, int ve1, int ve2,
		       int *altBpStart, int *altBpEnd)
/* return TRUE if retained intron. 
   Looking for pattern:
   hs-->he---->hs--->he
    \---------------/

   Use edgesInArea() to investigate that encompasses the common hard
   end and common hard start. Should only be 4 edges in area defined by
   splicing.
   eseses 
   012345 
  0  
  1  + +
  2   + 
  3    +
  4   
  5
*/
{
unsigned char *vTypes = ag->vTypes;
int i=0;
int numAltVerts = 4;

/* Quick check. */
if(vTypes[vs] != ggHardStart || vTypes[ve1] != ggHardEnd || vTypes[ve2] != ggHardEnd)
    return FALSE;
if(em[vs][ve1] && em[vs][ve2]) 
    {
    /* Try to find a hard start that connects ve1 and ve2. */
    for(i=0; i<ag->vertexCount; i++)
	{
	if(vTypes[i] == ggHardStart && em[ve1][i] && em[i][ve2] &&
	edgesInArea(ag,em,ve2-1,vs+1) == numAltVerts)
	    {
	    int *vPos = ag->vPositions;
	    struct bed bedAlt;
	    /* Initialize some beds for reporting. */
	    bedAlt.chrom = ag->tName;
	    bedAlt.name = ag->name;
	    bedAlt.score = altRetInt;
	    safef(bedAlt.strand, sizeof(bedAlt.strand), "%s", ag->strand);
	    /* Alt spliced region. */
	    bedAlt.chromStart = vPos[ve1];
	    bedAlt.chromEnd = vPos[i];
	    if(optionExists("printRetIntAccs"))
		{
		int incEdge = altGraphXGetEdgeNum(ag, vs, ve2);
		int exEdge = altGraphXGetEdgeNum(ag, ve1, i);
		struct evidence *ev= slElementFromIx(ag->evidence, incEdge);
		int i;
		fprintf(stdout, "RETINT\t%s\t%d\t", ag->name,ev->evCount);
		for(i = 0; i < ev->evCount; i++)
		    {
		    fprintf(stdout, "%s,", ag->mrnaRefs[ev->mrnaIds[i]]);
		    }
		fprintf(stdout, "\t");
		ev= slElementFromIx(ag->evidence, exEdge);
		fprintf(stdout, "%d\t", ev->evCount);
		for(i = 0; i < ev->evCount; i++)
		    {
		    fprintf(stdout, "%s,", ag->mrnaRefs[ev->mrnaIds[i]]);
		    }
		fprintf(stdout, "\n");
		}
	    /* Upstream/down stream */
	    if(altRegion != NULL)
		{
		bedOutputN(&bedAlt, 6, altRegion, '\t','\n');
		}
	    *altBpStart = ve1;
	    *altBpEnd = i;
	    return TRUE;
	    }
	}
    }
return FALSE;
}	    
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;
}