Пример #1
0
void
NDalign::realignForward(bool verbose, bool displayAlign) {
  Match_Node_t  match;

  match.Start  = abgn();    //  Begin position in a
  match.Offset = bbgn();    //  Begin position in b
  match.Len    = 0;
  match.Next   = 0;         //  Not used here

  int32  aLo=0, aHi=0;
  int32  bLo=0, bHi=0;

  if (displayAlign)
    fprintf(stderr, "NDalign::realignForward()--\n");

  pedOverlapType  olapType = _editDist->Extend_Alignment(&match,         //  Initial exact match, relative to start of string
                                                         _aStr, _aLen,
                                                         _bStr, _bLen,
                                                         aLo,   aHi,    //  Output: Regions which the match extends
                                                         bLo,   bHi);

  aHi++;  //  Add one to the end point because Extend_Alignment returns the base-based coordinate.
  bHi++;

  //  Is this a better overlap than what we have?

  if (((score() <  _editDist->score())) ||
      ((score() <= _editDist->score()) && (length() > ((aHi - aLo) + (bHi - bLo) + _editDist->Left_Delta_Len) / 2))) {
    if (displayAlign)
      fprintf(stderr, "NDalign::realignForward()-- Save better alignment - OLD length %u erate %f score %u (%d-%d %d-%d)\n",
              length(), erate(), score(), abgn(), aend(), bbgn(), bend());

    _bestResult.save(aLo, aHi, bLo, bHi, _editDist->score(), olapType, _editDist->Left_Delta_Len, _editDist->Left_Delta);

    display("NDalign::realignForward()-- ", false);

    _bestResult.setErate(1.0 - (double)(_matches + _gapmatches) / (length() - _freegaps));

    if (displayAlign)
      fprintf(stderr, "NDalign::realignForward()-- Save better alignment - NEW length %u erate %f score %u (%d-%d %d-%d)\n",
              length(), erate(), score(), abgn(), aend(), bbgn(), bend());

  }

  else if (displayAlign) {
    fprintf(stderr, "NDalign::realignForward()-- Alignment no better   - OLD length %u erate %f score %u (%d-%d %d-%d)\n",
            length(), erate(), score(), abgn(), aend(), bbgn(), bend());
    fprintf(stderr, "NDalign::realignForward()-- Alignment no better   - NEW length %u erate %f score %u (%d-%d %d-%d)\n",
            ((aHi - aLo) + (bHi - bLo) + _editDist->Left_Delta_Len) / 2, 0.0, _editDist->score(), aLo, aHi, bLo, bHi);
    //display("NDalign::realignForward(NB)--", aLo, aHi, bLo, bHi, _editDist->Left_Delta, _editDist->Left_Delta_Len, true, false);
  }
}
Пример #2
0
void cholesky (double **orig, double **chol, int tr, int dept)
{
   int i, j, k;

   FILE *error;
start:
   for (i = 0; i < tr; i++) {
      chol[i][i] = orig[i][i];
      for (k = 0; k < i; k++)
         chol[i][i] -= chol[k][i]*chol[k][i];
      if (chol[i][i] <= 0) {
         bend(orig, orig, tr);
         error = fopen("./std.error.txt", "a");
         fprintf(error, "\nERROR: non-positive definite matrix!\n");
         dept++;
         fprintf(error, "\nproblem from %d %f %d\n", i, chol[i][i], dept);
         fclose(error);
         goto start;
      }
      chol[i][i] = sqrt(chol[i][i]);

      for (j = i+1; j < tr; j++) {
         chol[i][j] = orig[i][j];
         for (k = 0; k < i; k++)
            chol[i][j] -= chol[k][i]*chol[k][j];
         chol[i][j] /= chol[i][i];
         chol[j][i] = chol[i][j];
      }
   }
}
Пример #3
0
	forall_edges(e,G)
	{
		const BendString &bs1 = bend(e->adjSource());
		const BendString &bs2 = bend(e->adjTarget());

		if (bs1.size() != bs2.size()) {
			error.sprintf(
				"Size of corresponding bend strings at edge %d differ!",
				e->index());
			return false;
		}

		size_t i = 0, j = bs2.size()-1;
		while(i < bs1.size()) {
			if (bs1[i] != flip(bs2[j])) {
				error.sprintf(
					"Corresponding bend strings at edge %d not consistent!",
					e->index());
				return false;
			}
			++i; --j;
		}
	}
Пример #4
0
void mouseMove(int x, int y){
    
    // this will only be true when the left button is down
    if (xOrigin >= 0) {
        
		// update deltaAngle
		deltaAnglex = (x - xOrigin) * 0.0005f;
        deltaAngley = (y - yOrigin) * 0.0001f;
        
        // bend that shit
        for (int i = 0; i < numballs; i++) {
            balls[i].tempvelocity = balls[i].oldvelocity;
        }
        bend();
	}
}
Пример #5
0
void Box::transformVertex(QVector3D v, float animationFrame)
{
    switch (m_globalDefMode)
    {
        case Pinch:
            pinch(v, 1.0f - animationFrame);
            break;
        case Mold:
            mold(v, 1.0f - animationFrame);
            break;
        case Twist:
            twist(v, animationFrame*360.0f);
            break;
        case Bend:
            bend(v, animationFrame*90.0f);
            break;
        default:
            glVertex3fv(&v[0]);
    }
}
/* makeStraightEdge:
 *
 * FIX: handle ports on boundary?
 */
void 
makeStraightEdge(graph_t * g, edge_t * e, int et, splineInfo* sinfo)
{
    pointf dumb[4];
    node_t *n = agtail(e);
    node_t *head = aghead(e);
    int e_cnt = ED_count(e);
    int curved = (et == ET_CURVED);
    pointf perp;
    pointf del;
    edge_t *e0;
    int i, j, xstep, dx;
    double l_perp;
    pointf dumber[4];
    pointf p, q;

    p = dumb[1] = dumb[0] = add_pointf(ND_coord(n), ED_tail_port(e).p);
    q = dumb[2] = dumb[3] = add_pointf(ND_coord(head), ED_head_port(e).p);
    if ((e_cnt == 1) || Concentrate) {
	if (curved) bend(dumb,get_centroid(g));
	clip_and_install(e, aghead(e), dumb, 4, sinfo);
	addEdgeLabels(g, e, p, q);
	return;
    }

    e0 = e;
    if (APPROXEQPT(dumb[0], dumb[3], MILLIPOINT)) {
	/* degenerate case */
	dumb[1] = dumb[0];
	dumb[2] = dumb[3];
	del.x = 0;
	del.y = 0;
    }
    else {
        perp.x = dumb[0].y - dumb[3].y;
        perp.y = dumb[3].x - dumb[0].x;
	l_perp = LEN(perp.x, perp.y);
	xstep = GD_nodesep(g->root);
	dx = xstep * (e_cnt - 1) / 2;
	dumb[1].x = dumb[0].x + (dx * perp.x) / l_perp;
	dumb[1].y = dumb[0].y + (dx * perp.y) / l_perp;
	dumb[2].x = dumb[3].x + (dx * perp.x) / l_perp;
	dumb[2].y = dumb[3].y + (dx * perp.y) / l_perp;
	del.x = -xstep * perp.x / l_perp;
	del.y = -xstep * perp.y / l_perp;
    }

    for (i = 0; i < e_cnt; i++) {
	if (aghead(e0) == head) {
	    p = dumb[0];
	    q = dumb[3];
	    for (j = 0; j < 4; j++) {
		dumber[j] = dumb[j];
	    }
	} else {
	    p = dumb[3];
	    q = dumb[0];
	    for (j = 0; j < 4; j++) {
		dumber[3 - j] = dumb[j];
	    }
	}
	if (et == ET_PLINE) {
	    Ppoint_t pts[4];
	    Ppolyline_t spl, line;

	    line.pn = 4;
	    line.ps = pts;
	    for (j=0; j < 4; j++) {
		pts[j] = dumber[j];
	    }
	    make_polyline (line, &spl);
	    clip_and_install(e0, aghead(e0), spl.ps, spl.pn, sinfo);
	}
	else
	    clip_and_install(e0, aghead(e0), dumber, 4, sinfo);

	addEdgeLabels(g, e0, p, q);
	e0 = ED_to_virt(e0);
	dumb[1].x += del.x;
	dumb[1].y += del.y;
	dumb[2].x += del.x;
	dumb[2].y += del.y;
    }
}
Пример #7
0
bool
NDalign::processHits(void) {

  //  If the first time here, set the hit iterator to zero, otherwise move to the next one.
  //  And then return if there are no more hits to iterate over.

  if (_hitr == UINT32_MAX)
    _hitr = 0;
  else
    _hitr++;

  if (_hitr >= _hits.size())
    return(false);

  //  While hits, process them.
  //
  //  If a good hit is found, return, leaving hitr as is.  The next time we enter this function,
  //  we'll increment hitr and process the next hit.  If no good hit is found, we iterate the loop
  //  until a good one is found, or we run out of hits.

  for (; _hitr < _hits.size(); _hitr++) {
    Match_Node_t  match;

    match.Start  = _hits[_hitr].aBgn;    //  Begin position in a
    match.Offset = _hits[_hitr].bBgn;    //  Begin position in b
    match.Len    = _hits[_hitr].tLen;    //  tLen can include mismatches if alternate scoring is used!
    match.Next   = 0;                 //  Not used here


#ifdef SEED_NON_OVERLAPPING
    match.Offset = _merSize;  //  Really should track this in the hits, oh well.
#endif

#ifdef DEBUG_ALGORITHM
    fprintf(stderr, "\n");
    fprintf(stderr, "NDalign::processHits()-- Extend_Alignment Astart %d Bstart %d length %d\n", match.Start, match.Offset, match.Len);
#endif

    int32  aLo=0, aHi=0;
    int32  bLo=0, bHi=0;

    pedOverlapType  olapType = _editDist->Extend_Alignment(&match,         //  Initial exact match, relative to start of string
                                                           _aStr, _aLen,
                                                           _bStr, _bLen,
                                                           aLo,   aHi,    //  Output: Regions which the match extends
                                                           bLo,   bHi);

    aHi++;  //  Add one to the end point because Extend_Alignment returns the base-based coordinate.
    bHi++;

    //  Is this a better overlap than what we have?  Save it and update statistics.

    if (((score() <  _editDist->score())) ||
        ((score() <= _editDist->score()) && (length() > ((aHi - aLo) + (bHi - bLo) + _editDist->Left_Delta_Len) / 2))) {

#ifdef DEBUG_ALGORITHM
      fprintf(stderr, "NDalign::processHits()-- Save better alignment - OLD length %u erate %f score %u (%d-%d %d-%d) ",
              length(), erate(), score(), abgn(), aend(), bbgn(), bend());
#endif

      _bestResult.save(aLo, aHi, bLo, bHi, _editDist->score(), olapType, _editDist->Left_Delta_Len, _editDist->Left_Delta);

      display("NDalign::processHits()-- ", false);

      _bestResult.setErate(1.0 - (double)(_matches + _gapmatches) / (length() - _freegaps));

#ifdef DEBUG_ALGORITHM
      fprintf(stderr, "NDalign::processHits()-- NEW length %u erate %f score %u (%d-%d %d-%d)\n",
              length(), erate(), score(), abgn(), aend(), bbgn(), bend());
#endif

    } else {
      olapType = pedBothBranch;

#ifdef DEBUG_ALGORITHM
      fprintf(stderr, "NDalign::processHits()-- DON'T save alignment - OLD length %u erate %f score %u (%d-%d %d-%d) ",
              length(), erate(), score(), abgn(), aend(), bbgn(), bend());
      fprintf(stderr, "NDalign::processHits()--  NEW length %u score %u coords %u-%u %u-%u\n",
              ((aHi - aLo) + (bHi - bLo) + _editDist->Left_Delta_Len) / 2,
              _editDist->score(),
              aLo, aHi, bLo, bHi);
#endif
    }

    //  If a dovetail, we're done.  Let the client figure out if the quality is good.

    if (olapType == pedDovetail)
      return(true);

  }  //  Over all seeds.

  //  No more seeds to align.  Did we save an alignment?

  return(score() > 0);
}
Пример #8
0
std::shared_ptr<Model> Deserno2005ModelFactory::create() const {
    auto model = std::make_shared<Model>(num_lipid * 3);

    std::shared_ptr<FENEBondPotential> head_tail_bond(
        new FENEBondPotential(
            /* r0= */1.5*sigma,
            /* k = */30*epsilon/sigma/sigma,
            /* b = */0.95*sigma,
            /* e = */epsilon));
    for (std::size_t i(0); i < num_lipid; ++i)
        head_tail_bond->add_bond(std::make_pair(i*3, i*3+1));
    model->add_potential(head_tail_bond);

    std::shared_ptr<FENEBondPotential> tail_tail_bond(
        new FENEBondPotential(
            /* r0= */1.5*sigma,
            /* k = */30*epsilon/sigma/sigma,
            /* b = */sigma,
            /* e = */epsilon));
    for (std::size_t i(0); i < num_lipid; ++i)
        tail_tail_bond->add_bond(std::make_pair(i*3+1, i*3+2));
    model->add_potential(tail_tail_bond);

    std::shared_ptr<LowestOrderHarmonicBendPotential> bend(
        new LowestOrderHarmonicBendPotential(
            /* r0= */4*sigma,
            /* k = */10*epsilon/sigma/sigma));
    for (std::size_t i(0); i < num_lipid; ++i)
        bend->add_pair(std::make_pair(i*3, i*3+2));
    model->add_potential(bend);

    std::shared_ptr<WeeksChandlerAndersonPotential> head_head_replusion(
        new WeeksChandlerAndersonPotential(
            /* s= */0.95*sigma,
            /* e= */epsilon));
    head_head_replusion->set_pair("LH", "LH");
    model->add_potential(head_head_replusion);

    std::shared_ptr<WeeksChandlerAndersonPotential> head_tail_replusion(
        new WeeksChandlerAndersonPotential(
            /* s= */0.95*sigma,
            /* e= */epsilon));
    head_tail_replusion->set_pair("LH", "LT");
    model->add_potential(head_tail_replusion);

    std::shared_ptr<WeeksChandlerAndersonPotential> tail_tail_replusion(
        new WeeksChandlerAndersonPotential(
            /* s= */sigma,
            /* e= */epsilon));
    tail_tail_replusion->set_pair("LT", "LT");
    model->add_potential(tail_tail_replusion);

    std::shared_ptr<TailsAttractionPotential> tails_attraction(
        new TailsAttractionPotential(
            /* r_c= */pow(2,1.0/6.0)*sigma,
            /* w_c= */w_c,
            /* e =  */epsilon));
    tails_attraction->set_pair("LT", "LT");
    model->add_potential(tails_attraction);

    return model;
}
Пример #9
0
   void dogde()
   {   int i,j,ran;
	   char ch,menu;
   loading();

   cleardevice();

   setbkcolor(YELLOW);
   setcolor(BLUE);
    h:
    outtextxy(100,100,"Press I to read instructions.");
    outtextxy(100,200,"Press S to start the game.");
    outtextxy(100,300,"Press E to exit.");

    menu=getchar();
    clrscr();
    toupper(menu);
    switch(menu)
   { case 'S' : break;
     case 's' : break;
     case 'I' : instructions();
		goto h;
     case 'i' : instructions();
		goto h;
     case 'E' : exit(0);
     case 'e' : exit(0);
     default : goto h;
   }

   setviewport(0,170,639,310,1);

  start:

   setbkcolor(YELLOW);
   randomize();
   ran=random(2);


  if(ran==0)
{

  for(i=0;i<639;i++)

  {  draw_man();

       setcolor(RED);
       rectangle(635-i,120,639-i,140);
       setcolor(BLACK);
       rectangle(637-i,120,641-i,140);

       man.top_y=90;
       man.top_x=55;
       man.bottom_x=55;
       man.bottom_y=140;

       obstacle.x=635-i;
       obstacle.y=120;

     if(kbhit())
     { ch=getch();

	  if(ch=='y'||ch=='Y')
	  {  i=jump(i,ran);
	     draw_man();

	     if(man.bottom_x>obstacle.x)
	       {  score++;
		  goto start; }

	 else if(man.bottom_y >=obstacle.y && man.bottom_x==obstacle.x)
	    {

	      gameover();
	    }




	  }

	else if(ch=='h'||ch=='H')
	{     i=bend(i,ran);
	     draw_man();


	     if(man.bottom_x>obstacle.x)
	       {  score++;
		  goto start; }

	 else if(man.bottom_y >=obstacle.y && man.bottom_x==obstacle.x)
	    {

	      gameover();
	    }

	 }
      }
  delay(10);
  }

}


else  if(ran==1)
{

  for(i=0;i<639;i++)

  {  draw_man();
      setcolor(RED);
      rectangle(635-i,20,639-i,80);
      setcolor(BLACK);
      rectangle(637-i,20,641-i,80);

       obstacle.x=635-i;
       obstacle.y=60;

     if(kbhit())
     { ch=getch();



	 if(ch=='y'||ch=='Y')
	  {  i=jump(i,ran);

	    draw_man();


	     if(man.bottom_x>obstacle.x)
	       {  score++;
		  goto start; }



	    else if(man.top_y<=obstacle.y && man.bottom_x==obstacle.x)

	    {

	      gameover();
	    }

	  }

	else if(ch=='h'||ch=='H')
	{     i=bend(i,ran);

	  draw_man();


	     if(man.bottom_x>obstacle.x)
	       {  score++;
		  goto start; }

	 else if(man.bottom_y >=obstacle.y && man.bottom_x==obstacle.x)
	    {

	      gameover();
	    }

	 }
      }
    delay(10);
  }

}
  gameover();
  closegraph();
}