Graph makePairsGraph(const RNAProfileAliMapType &inputMapProfile, const Algebra<double,RNA_Alphabet_Profile> *alg, const Matrix<double> *score_mtrx, double threshold) {
    Graph graph;
    RNAProfileAliMapType::const_iterator it,it2;
    RNAProfileAlignment *f1=NULL,*f2=NULL;

    graph = NewGraph(score_mtrx->xDim());

    for (int i=0; i<score_mtrx->xDim(); i++) {
        Xcoord(graph,i+1) = 0;
        Ycoord(graph,i+1) = 0;
    }

    for (it=inputMapProfile.begin(); it!=inputMapProfile.end(); it++) {
        f1=it->second;
        for (it2=inputMapProfile.begin(); it2->first<it->first; it2++) {
            double score;
            f2=it2->second;

            score=score_mtrx->getAt(it->first-1,it2->first-1);
            if (alg->choice(score,threshold) != threshold) { // is it better than the threshold ?
                AddEdge (graph,it->first,it2->first,(int)(score*100.0));
            }
        }
    }


    WriteGraph (graph,(char*)"test.out");
    return graph;
}
Beispiel #2
0
void get_ab(INT q, INT x1, INT x2, INT x3, INT &a, INT &b)
{
	if (x3 == 0) {
		if (x2 == 0) {
			a = Xcoord(q);
			b = Ycoord(q);
			}
		else {
			a = Xcoord(x1);
			b = Ycoord(q);
			}
		}
	else {
		a = Xcoord(x1);
		b = Ycoord(x2);
		}
}
Beispiel #3
0
void draw_grid_(mp_graphics &G, INT q, INT f_include_line_at_infinity, INT verbose_level)
{
	INT f_v = (verbose_level >= 1);
	INT x, y, Q, a, b, c, d;
	INT *Px, *Py;
	INT u;
	//INT x1, x2, x3;
	//INT y1, y2, y3;
	//INT rad = 20;
	//INT i, j;
	
	if (f_v) {
		cout << "draw_grid_" << endl;
		}
	u = 500 / q;
	if (q == 4) {
		u = 400 / q;
		}
	
	Q = 2 * (q + 3) + 1;
	if (f_v) {
		cout << "u=" << u << endl;
		cout << "Q=" << Q << endl;
		}
	Px = NEW_INT(Q * Q);
	Py = NEW_INT(Q * Q);
	
	for (x = 0; x < Q; x++) {
		for (y = 0; y < Q; y++) {
			Px[x * Q + y] = x * u;
			Py[x * Q + y] = y * u;
			}
		}
	
		


	if (f_v) {
		cout << "drawing grid" << endl;
		}
	//G.polygon2(Px, Py, qq, n - 1);
	for (x = 0; x < q; x++) {
		a = Xcoord(x);
		b = Ycoord(0);
		c = Xcoord(x);
		d = Ycoord(q - 1);
		cout << a << "," << b << "," << c << "," << d << endl;
		G.polygon2(Px, Py, a * Q + b, c * Q + d);
		}
	for (y = 0; y < q; y++) {
		a = Xcoord(0);
		b = Ycoord(y);
		c = Xcoord(q - 1);
		d = Ycoord(y);
		cout << a << "," << b << "," << c << "," << d << endl;
		G.polygon2(Px, Py, a * Q + b, c * Q + d);
		}


	if (f_include_line_at_infinity) {
		if (f_v) {
			cout << "drawing line at infinity" << endl;
			}
		a = Xcoord(0);
		b = Ycoord(q);
		c = Xcoord(q);
		d = Ycoord(q);
		cout << a << "," << b << "," << c << "," << d << endl;
		G.polygon2(Px, Py, a * Q + b, c * Q + d);
		}


	if (f_v) {
		cout << "drawing text" << endl;
		}
	for (x = 0; x < q; x++) {
		BYTE str[1000];
		sprintf(str, "$%ld$", x);
		a = Xcoord(x);
		b = Ycoord(-1);
		G.aligned_text(Px[a * Q + b], Py[a * Q + b], "t", str);
		}
	for (y = 0; y < q; y++) {
		BYTE str[1000];
		sprintf(str, "$%ld$", y);
		a = Xcoord(-1);
		b = Ycoord(y);
		G.aligned_text(Px[a * Q + b], Py[a * Q + b], "r", str);
		}


	if (f_include_line_at_infinity) {
		BYTE str[1000];
		sprintf(str, "$\\infty$");
		a = Xcoord(-1);
		b = Ycoord(q);
		G.aligned_text(Px[a * Q + b], Py[a * Q + b], "r", str);
		}

//done:
	FREE_INT(Px);
	FREE_INT(Py);
}
Beispiel #4
0
double AI::PlayerDistance() {
	return sqrt(pow(Xcoord() - m_game_state->p1_x, 2) + pow(Ycoord() - m_game_state->p1_y, 2));
}
Beispiel #5
0
bool AI::PlayerNear() {
	std::cout << "Distance: " << sqrt((float) pow(Xcoord() - m_game_state->p1_x, 2) + (float) pow(Ycoord() - m_game_state->p1_y, 2)) << "\n";
	return PlayerDistance() < 30;
}
Beispiel #6
0
double AI::LedgeDistance() {
	return abs(abs(Xcoord()) - abs(StageLimit()));
}
Beispiel #7
0
// returns 1 for right ledge, -1 for left, 0 if not near either
int AI::NearWhatLedge() {
	if (!IsNearLedge())
		return 0;
	else
		return Xcoord()/abs(Xcoord());
}
Beispiel #8
0
bool AI::IsNearLedge() {
	return abs(abs(Xcoord()) - abs(StageLimit())) < 20;
}
Beispiel #9
0
bool AI::IsOffStage() {
    return abs(Xcoord()) > abs(StageLimit());
}
Beispiel #10
0
//0 on left side, 1 on right side
int AI::StageSide() {
    return 0.5 * (1 + GLOBAL_SIGN(Xcoord()));
}