void processOneGraph(struct txGraph *txg, struct hash *weightHash, double threshold,
                     char *outType, FILE *f)
/* Write out edges for one graph. */
{
    struct txEdge *edge;
    struct txEdgeBed e;
    ZeroVar(&e);
    e.chrom = txg->tName;
    for (edge = txg->edgeList; edge != NULL; edge = edge->next)
    {
        double weight = weightOfEvidence(txg, edge->evList, weightHash);
        if (weight >= threshold)
        {
            struct txVertex *start = &txg->vertices[edge->startIx];
            struct txVertex *end = &txg->vertices[edge->endIx];
            e.chromStart = start->position;
            e.chromEnd = end->position;
            e.name = outType;
            e.score = edge->evCount;
            e.strand[0] = txg->strand[0];
            e.startType[0] = ggVertexTypeAsString(start->type)[0];
            e.type = edge->type;
            e.endType[0] = ggVertexTypeAsString(end->type)[0];
            txEdgeBedTabOut(&e, f);
        }
    }
}
Ejemplo n.º 2
0
void writeOverlappingEdges(
	enum ggEdgeType edgeType, struct txGraph *inGraph,
	int inStart, int mappedStart, enum ggVertexType startType, boolean startMappedExact, 
	int inEnd, int mappedEnd, enum ggVertexType endType, boolean endMappedExact, 
	struct txGraph *orthoGraph, boolean orthoRev, int mappedCoverage, FILE *f)
/* Write edges of graph that overlap correctly to f */
{
if (startType == ggSoftStart || startType == ggSoftEnd || startMappedExact)
    {
    if (endType == ggSoftStart || endType == ggSoftEnd || endMappedExact)
	{
	struct txEdge *edge;
	for (edge = orthoGraph->edgeList; edge != NULL; edge = edge->next)
	    {
	    if (edge->type == edgeType)
		{
		int orthoStartIx = edge->startIx;
		int orthoStart = orthoGraph->vertices[orthoStartIx].position;
		enum ggVertexType orthoStartType = orthoGraph->vertices[orthoStartIx].type;
		int orthoEndIx = edge->endIx;
		int orthoEnd = orthoGraph->vertices[orthoEndIx].position;
		enum ggVertexType orthoEndType = orthoGraph->vertices[orthoEndIx].type;
		int overlap = rangeIntersection(mappedStart, mappedEnd, orthoStart, orthoEnd);
		if (overlap > 0)
		    {
		    enum ggVertexType rStartType = startType, rEndType = endType;
		    if (orthoRev)
		        {
			rStartType = endType;
			rEndType = startType;
			}
		    if (rStartType == ggSoftStart || rStartType == ggSoftEnd || mappedStart == orthoStart)
			{
			if (rEndType == ggSoftStart || rEndType == ggSoftEnd || mappedEnd == orthoEnd)
			    {
			    /* Compute score that depends on how much start/end have wobbled. */
			    int mappedOverlapScore = 1000 * overlap/(mappedEnd - mappedStart);
			    int orthoOverlapScore = 1000 * overlap/(orthoEnd - orthoStart);
			    int overlapScore = min(mappedOverlapScore, orthoOverlapScore);
			    int coverageScore = 1000 * mappedCoverage/(inEnd - inStart);

			    /* Write out bed fields. */
			    fprintf(f, "%s\t%d\t%d\t", inGraph->tName, inStart, inEnd);
			    fprintf(f, "%s\t", orthoGraph->name);
			    fprintf(f, "%d\t", coverageScore);
			    fprintf(f, "%s\t", inGraph->strand);

			    /* Write out edge and vertex type info. */
			    fprintf(f, "%s\t", ggVertexTypeAsString(startType));
			    fprintf(f, "%s\t", (edgeType == ggExon ? "exon" : "intron"));
			    fprintf(f, "%s\t", ggVertexTypeAsString(endType));

			    /* Write out mouse info. */
			    fprintf(f, "%s\t%d\t%d\t", orthoGraph->tName, mappedStart, mappedEnd);
			    fprintf(f, "%s\t", inGraph->name);
			    fprintf(f, "%d\t", overlapScore);
			    fprintf(f, "%s\t", orthoGraph->strand);
			    fprintf(f, "%s\t", ggVertexTypeAsString(orthoStartType));
			    fprintf(f, "%s\t", ggVertexTypeAsString(orthoEndType));
			    fprintf(f, "%d\t", orthoStart);
			    fprintf(f, "%d\n", orthoEnd);
			    }
			}
		    }
		}
	    }
	}
    }
}