예제 #1
0
// Action_MultiVector::DoAction()
Action::RetType Action_MultiVector::DoAction(int frameNum, ActionFrame& frm) {
  for (unsigned int nv = 0; nv < CrdIdx1_.size(); ++nv) {
    Vec3 CXYZ( frm.Frm().CRD( CrdIdx1_[nv] ) );
    Vec3 VXYZ( frm.Frm().CRD( CrdIdx2_[nv] ) );
    VXYZ -= CXYZ;
    data_[nv]->AddVxyz(VXYZ, CXYZ);
  }

  return Action::OK;
}
예제 #2
0
// Action_MultiVector::DoAction()
Action::RetType Action_MultiVector::DoAction(int frameNum, Frame* currentFrame, 
                                               Frame** frameAddress)
{
  for (unsigned int nv = 0; nv < CrdIdx1_.size(); ++nv) {
    Vec3 CXYZ( currentFrame->CRD( CrdIdx1_[nv] ) );
    Vec3 VXYZ( currentFrame->CRD( CrdIdx2_[nv] ) );
    VXYZ -= CXYZ;
    data_[nv]->AddVxyz(VXYZ, CXYZ);
  }

  return Action::OK;
}
예제 #3
0
void Action_Vector::Dipole(Frame const& currentFrame) {
  Vec3 VXYZ(0.0, 0.0, 0.0);
  Vec3 CXYZ(0.0, 0.0, 0.0);
  double total_mass = 0;
  for (AtomMask::const_iterator atom = mask_.begin();
                                atom != mask_.end(); ++atom)
  {
    double mass = (*CurrentParm_)[*atom].Mass();
    total_mass += mass;
    Vec3 XYZ = currentFrame.XYZ( *atom );
    CXYZ += ( XYZ * mass );
    double charge = (*CurrentParm_)[*atom].Charge();
    XYZ *= charge;
    VXYZ += ( XYZ );
  }
  CXYZ /= total_mass;
  Vec_->AddVxyz( VXYZ, CXYZ );
}
예제 #4
0
파일: hbp_hhb.c 프로젝트: mmravic314/bin
void sprintf_hb(char * o_str, int i, int j, struct vect nearest, float d, float ha, float daaa_ang, float haaa_ang)
{
    char      bndtyp[3], acctyp[4], dontyp[4], space=' ';
    int       ca_d, ri, rj, gap;
    char buf1[20],buf2[20]; /* buffers for atomid routines */
    float     tmp;
        
    /*we have a hydrogen bond!*/
    
    bndtyp[0] = bndtyp[1] = '?';
    acctyp[3] = dontyp[3] = bndtyp[2] = '\0';
    
    if (atom[i].aacode == TOTNAA || atom[i].hetflg )
	bndtyp[0] = 'H';
    else
    {
	if (atom[i].aacode <STDAA)
	{
	    bndtyp[0] = (atom[i].atmtyp <=3) ? 'M' : 'S';
	}
	else
	{
	    bndtyp[0] = (atom[i].atmtyp <=3) ? 'm' : 's';
	}
    }
    if (atom[j].aacode == TOTNAA || atom[j].hetflg )
	bndtyp[1] = 'H';
    else
    {
	if (atom[j].aacode <STDAA)
	{
	    bndtyp[1] = (atom[j].atmtyp <=3) ? 'M' : 'S';
	}
	else
	{
	    bndtyp[1] = (atom[j].atmtyp <=3) ? 'm' : 's';
	}
    }
 		
    ri = atom[i].caindex;
    rj = atom[j].caindex;
    
    gap=find_gap( ri, rj);
		
#if 0 		
    if (atom[i].aacode==TOTNAA || (ri == -99) || !residue[ri].ca ||                       atom[j].aacode==TOTNAA || (rj == -99) || !residue[rj].ca  )
	gap = -1;
    else
    {
	gap = cagap(ri,rj);
    }
#endif 		
    if (atom[i].aacode==TOTNAA || (ri == -99) || !residue[ri].ca ||  
	atom[j].aacode==TOTNAA || (rj == -99) || !residue[rj].ca  )
	ca_d = -1.0;
    else
    {
	ca_d = length_squared( to(*(residue[ri].ca),*(residue[rj].ca)) );
	
	if (ca_d > SQR(CAWARN) && debug)
	{
	    printf("WARNING: unusual CA-CA distance of %5.2f for",sqrt(ca_d));
	    printf("%s number ??\n", (nnbflg)?" interaction":" H-bond"/*,nhb*/);
	    printf("         between %s and %s\n", atomid(i,buf1),atomid(j,buf2));
	    
	}
    }
#if 0
    printf("%4s",   brcode);
    printf("%c",    (atom[i].chnid == '-') ? space : atom[i].chnid);
    printf("%4s/",  brcode);
    printf("%c",    atom[i].chnid);
    printf("%04d",  atom[i].aanum);
    if(OMLINSERT && atom[i].hetflg)
	printf("h");
    else
	printf("%c",    atom[i].inscode);
    /* printf("%3s",   dontyp);               */
    printf("%3s",   atom[i].resnam);
    printf("%4s",   atom[i].atmnam);
    printf("%c",    atom[i].strucsum);
    printf("%c",    (atom[j].chnid == '-') ? space : atom[j].chnid);
		printf("%4s/",  brcode);
		printf("%c",    atom[j].chnid);
		printf("%04d",  atom[j].aanum);
    if(OMLINSERT && atom[j].hetflg)
	printf("h");
    else
	printf("%c",    atom[j].inscode);
    /* printf("%3s",   acctyp);               */
		printf("%3s",   atom[j].resnam);
		printf("%4s",   atom[j].atmnam);
		printf("%c",    atom[j].strucsum);
		printf("%4.1f", sqrt(d));
		printf(" %2s",   bndtyp);
    printf("%4d",   gap);
    printf("%4.1f", (ca_d <= 0.0) ? -1.0 : sqrt(ca_d));
    printf("%6.1d", 180/3.1415927*angle(atom[i].p,nearest,atom[j].p) );
    printf("%4.1d", d);
    printf("%6d\n", nhb);
		
#endif
    *o_str = 0 ; 

/*This isn't neccessary if the longoutput format is used, but if the short
  format is used, then the first output must (i) include a 'strlen' in case
  it is part of a 'long format' output, and (ii) have some way of knowing
  where to begin in case of a 'short format' output. */
    
    if (longoutflg)  
 		{
 		    /* start to output the line, *.hhb format */
 		    sprintf(o_str              , "%4s",   brcode);
 		    sprintf(o_str+strlen(o_str), "%c",    (atom[i].chnid == '-') ? space : 
 			    atom[i].chnid);
 		    sprintf(o_str+strlen(o_str), "%4s/",  brcode);
 		}
 		sprintf(o_str+strlen(o_str), "%c",    atom[i].chnid);
 		sprintf(o_str+strlen(o_str), "%04d",  atom[i].aanum);
if(OMLINSERT && atom[i].hetflg) /*v3.13*/
    sprintf(o_str+strlen(o_str), "h");
else
    sprintf(o_str+strlen(o_str), "%c",    atom[i].inscode);
		/* sprintf(o_str+strlen(o_str), "%3s",   dontyp);               */
/* Amendment. RAL 14 Jun 2012 --> */
// 		if (atom[i].aacode==Cys && atom[i].atmtyp == 5 & cssflg)
 		if (atom[i].aacode==Cys && atom[i].atmtyp == 5 && cssflg)
/* <-- Amendment. RAL 14 Jun 2012 */
 		{
 		    if (atom[i].ssflg) 
 			sprintf(o_str+strlen(o_str),"CSS");
 		    else 
 			sprintf(o_str+strlen(o_str),"CYH");    }
 		else
 		    sprintf(o_str+strlen(o_str), "%3s",   atom[i].resnam);
 		sprintf(o_str+strlen(o_str), "%4s",   atom[i].atmnam);
 		if (longoutflg)  
 		{
 		    
 		    sprintf(o_str+strlen(o_str), "%c",    atom[i].strucsum);
 		    sprintf(o_str+strlen(o_str), "%c",    (atom[j].chnid == '-') ? space : 
 			    atom[j].chnid);
 		    sprintf(o_str+strlen(o_str), "%4s/",  brcode);
 		}
 		else
 		    sprintf(o_str+strlen(o_str), " ");
 		
 		sprintf(o_str+strlen(o_str), "%c",    atom[j].chnid);
                sprintf(o_str+strlen(o_str), "%04d",  atom[j].aanum);
    if(OMLINSERT && atom[j].hetflg) /*v3.13 start*/
	sprintf(o_str+strlen(o_str),"h");
    else /*v3.13 end*/
 		sprintf(o_str+strlen(o_str), "%c",    atom[j].inscode);
 		/* sprintf(o_str+strlen(o_str), "%3s",   acctyp);               */
 		if (atom[j].aacode==Cys && atom[j].atmtyp == 5 && cssflg)
 		{
 		    if (atom[j].ssflg) 
 			sprintf(o_str+strlen(o_str),"CSS");
 		    else 
 			sprintf(o_str+strlen(o_str),"CYH");    }
 		else
 		    sprintf(o_str+strlen(o_str), "%3s",   atom[j].resnam);
 		sprintf(o_str+strlen(o_str), "%4s",   atom[j].atmnam);
 		if (longoutflg) 
 		    sprintf(o_str+strlen(o_str), "%c",    atom[j].strucsum);
 		sprintf(o_str+strlen(o_str), "%5.2f", sqrt(d));
 		if (!longoutflg) 
 		    sprintf(o_str+strlen(o_str), " ");
 		sprintf(o_str+strlen(o_str), "%2s",  bndtyp);
 		sprintf(o_str+strlen(o_str), "%4d",   gap);
 		if (!longoutflg) 
 		    sprintf(o_str+strlen(o_str), " ");
 		sprintf(o_str+strlen(o_str), "%5.2f", (ca_d <= 0.0) ? -1.0 : sqrt(ca_d));
 		if (!longoutflg) 
 		    sprintf(o_str+strlen(o_str), " ");
 		if (atom[i].nh && h_atm[atom[i].h_ptr].typ)
 		{
 		    /* if it has hydrogens and if they have been placed */
		    tmp = angle(atom[i].p,nearest,atom[j].p);
		    
 		    sprintf(o_str+strlen(o_str), "%5.1f", (180.0/3.1415927)* tmp );
		    if (!longoutflg) 
			sprintf(o_str+strlen(o_str), " ");
 		    sprintf(o_str+strlen(o_str), "%5.2f", ha);
		    if (!longoutflg)
			sprintf(o_str+strlen(o_str), " ");
 		    if (haaa_ang>-50.0)
 			sprintf(o_str+strlen(o_str),"%5.1f", 180/3.1415927* (float) acos(haaa_ang) );
 		    else
 			sprintf(o_str+strlen(o_str),"%5.1f", -1.0);
		    
 		}
 		else
 		    if (longoutflg) 
 			sprintf(o_str+strlen(o_str), "%5.1f%5.2f%5.1f", -1.0, -1.0, -1.0);
 		    else
 			sprintf(o_str+strlen(o_str), "%5.1f %5.2f %5.1f", -1.0, -1.0, -1.0);
 		if (daaa_ang>-50.0)
 		    sprintf(o_str+strlen(o_str),"%6.1f", 180/3.1415927*acos(daaa_ang) );
 		else
 		    sprintf(o_str+strlen(o_str),"%6.1f", -1.0);
		
 		if (debug)
 		{
 		    sprintf(o_str+strlen(o_str), "D " );
 		    sprintf(o_str+strlen(o_str), TF,VXYZ(atom[i].p) );
 		    sprintf(o_str+strlen(o_str), " H " );
 		    sprintf(o_str+strlen(o_str), TF,VXYZ(nearest) );
 		    sprintf(o_str+strlen(o_str), " A " );
 		    sprintf(o_str+strlen(o_str), TF, VXYZ(atom[j].p) );
 		}
 		
/* 		sprintf(o_str+strlen(o_str), "%6d\n", nhb);
		THIS IS DONE BY THE CALLING ROUTINE */

 		/* end of outputting the line, *.hhb format */

    return;

}
예제 #5
0
파일: hbp_hhb.c 프로젝트: mmravic314/bin
int calc_hb(char o_str[256],int i, int j)
{
    int       l, /*ri, rj, gap,*/ h, near_h;
    
    /*char      bndtyp[3], acctyp[4], dontyp[4], space=' ';*/
    float     /*ca_d,*/ d, ha2,/*IM*/tmp_d, hd, ha, haaa_ang, daaa_ang;
    struct vect nearest, tmp_point, aromatic_axis, aa[MAXCON] /* acceptor antecedants*/;
    
    
    char buf1[20],buf2[20]; /* buffers for atomid routines */
    
    /* void find_ss()*/
    /* {*/
    /*     int i,j;*/
    /*     float d;*/
    short aromatic_flg;
    

    *o_str=0;
    
/*    if(i==203 && j==210)
    {
	printf("Testing from %s",atomid(i,buf1));
	printf(" to %s at start of calc_hb.\n",atomid(j,buf1));
    	debug=0;
    }
    else
	debug=0;
  */  

    d = length_squared( to(atom[i].p, atom[j].p) );
    if (debug==2)
	printf("don-acc distance ^2 = %f\n",d);
    
    if (d <= SQR(HBDIST))
	/* these are nearby ! */; /*IM begins*/
    else return(0);
    
    if (debug) printf("Acceptable distance\n");
    
    /* time to fill the acceptor array */
    daaa_ang= -99.9; /* reset it . . . . */
    
    aromatic_flg =  ( atom[j].aacode < TOTNAA )?(accepts[atom[j].aacode][atom[j].atmtyp] < 0):0;
    
    if (!aromatic_flg)    
    {
	for(l=0;l<MAXCON;l++)
	{
	    if (icon[j][l]>-1) 
	    {
		float daaa_tmp,aaa;
		char buf1[20],buf2[20];
		
		aa[l]=atom[icon[j][l] ].p;
		
		daaa_tmp= dot_product(
 						  to( aa[l], atom[j].p ), to( atom[i].p, atom[j].p )       ); /* = DA * A-AA * cos D-A-AA */
 			    aaa=vector_length ( to(aa[l], atom[j].p) );
 			    
 			    daaa_tmp/= aaa * sqrt( d); /* = cos D-A-AA */
 			    /* d= DA^2 */
 			    if (daaa_tmp>daaa_ang) daaa_ang=daaa_tmp; /* select lowest */
 			    if (aaa<0.8 || aaa > 6.0) 
				printf("WARNING: %5.2fA between %s and %s ((D..)A-AA bond).\n", aaa,atomid(icon[j][l],buf1),atomid(j,buf2));
 			   
 			}
 		    }
 		    if (daaa_ang > cosMIN_DAAA && daaa_ang>-99.9) 
 			if (!nnbflg)
 			    return(0);
 		    
 		    /*NB -99 was not originally used as a default whilst checking
 		      because we were wrongly trying to find a lowest possible 
 		      value */
 		    /*	printf("lowest daaa_ang %6.1f\n",daaa_ang);*/
 		}
 		else /*aromatic_hbond*/
 		{
 		    float daaa_tmp;
 		    /*if( !strncmp("4DFR/A0030-TRP CE3",atomid(j,buf1),18))
		      debug=1;*/
 		    
 		    if (debug){
 			printf("NOTE: %s is aromatic.\n",atomid(j,buf1));
 			printf("      connects to ");
 			for(l=0;l< atom[j].ncon;l++)
 			    printf("%s ",atomid(icon[j][l],buf1));
 			printf("\n");
 			
 		    }
 		    
 		    if ( accepts[atom[j].aacode][atom[j].atmtyp] != -1 )
 			printf("BUG: %s not registered as aromatic acceptor in \"aromatic_hbond\".\n",atomid(j,buf1));
 		    if ( atom[j].ncon!=2 && atom[j].ncon!=3 )
 			printf("BUG: %s has connectivity %d but is registered as aromatic.\n",atomid(j,buf1),atom[j].ncon);
 		    if ( atom[j].ncon==3 )
 		    {
 			aromatic_axis = unit_vector(
						    vector_plus( perpendicular( atom[ icon[j][0] ].p, atom[j].p, atom[ icon[j][1] ].p),
								vector_plus( perpendicular( atom[ icon[j][0] ].p, atom[j].p, atom[ icon[j][2] ].p),
									    perpendicular( atom[ icon[j][1] ].p, atom[j].p, atom[ icon[j][2] ].p) ) ) );
 			
 		    }
 		    else
 			aromatic_axis = unit_vector(perpendicular( atom[ icon[j][0] ].p, atom[j].p, atom[ icon[j][1] ].p));
 		    
 		    aa[0]= vector_plus( aromatic_axis, atom[j].p );
 		    aa[1]= vector_plus( float_times_vect( -1.0, aromatic_axis), atom[j].p );
 		    if (debug) printf("Perpendicular gives angles %5.3f and %5.3f with 1,2 / %d.\n",angle( atom[ icon[j][0] ].p, atom[j].p, aa[0] ), angle( atom[ icon[j][1] ].p, atom[j].p, aa[0] ) , atom[j].ncon);
 		    
 		    for(l=0;l<2;l++)
 		    {
 			daaa_tmp= dot_product( to( aa[l], atom[j].p), to( atom[i].p, atom[j].p ) ); /*=DA*A-AA*cosD-A-AA */
 			daaa_tmp /= sqrt(d); /* = cos D-A-AX */
 			if ( daaa_tmp > daaa_ang ) daaa_ang=daaa_tmp; /* select high values of cos D-A-AX ie low, better angles*/
 			if (debug) printf("Cosine of D-A-AX = %5.3f\n",daaa_tmp);
 		        if (debug) {
 			    printf("AX co-ods");
 			    printf(TF,VXYZ( aa[l] ) );
 			    printf("\n");
 			}
 			
 		    }
 		    if (daaa_ang < cosMAX_DAAX)
 		    {
 			if (debug)
 			    printf("Rejected because DAAX too high.\n");
 			if (!nnbflg)
 			    return(0);
 		    }
 		}
 		
 		
#define nearer(vector) { tmp_d=length_squared( to( atom[j].p, vector ) ); if (ha2>tmp_d) { ha2=tmp_d; nearest=vector; near_h = h;} }
 		
 		/* find the nearest possible H position on donor i */
 		ha2=100;
		/*	if (i==362) debug=1;
			else debug=0;*/
 		
 		if (debug && atom[i].hetflg) printf("H on %s %d  ",atom[i].resnam, atom[i].aanum);
 		if (debug) printf("%d Hs positioned\n",atom[i].nh);
 		
 		for(h=atom[i].h_ptr;h<atom[i].nh+atom[i].h_ptr;h++)
 		{
 		    if (debug)
 			printf("Hydrogen %d - type %d\n",atom[i].h_ptr,h_atm[h].typ);
 		    if (debug) printf("atom[i].nh %d, ].h_ptr %d, h %d\n",atom[i].nh,atom[i].h_ptr,h);
 		    
 		    switch (h_atm[h].typ)
 		    {
 		    case 0:
 			if (debug) printf("Atom %d (%s%s %d) has H %d missing\n",i,atom[i].atmnam,atom[i].resnam, atom[i].aanum, h);
 			/* no H present, must be HETATM */
 			;/* used to be ha2=1, cannot decide why */
 			break;
 		    case alternatives:
 			nearer( h_atm[h].a );
 			if (debug) printf("Checked alternative position: ha2 = %f\n",ha2);			    			    
 		    case fixed:
 			nearer( h_atm[h].p );
 			if (debug) printf("Checked default position: ha2 = %f\n",ha2);
 			break;
 		    case circle:
 			tmp_point= intersect(to(atom[i].p,h_atm[h].a),
 					     h_atm[h].p, atom[i].p, atom[j].p );
 			tmp_point= onto_sphere(tmp_point, h_atm[h].a,
 					       vector_length( to(h_atm[h].a, h_atm[h].p) ));
 			nearer(tmp_point);
 			tmp_point= vector_plus( tmp_point,
 					       float_times_vect(2,to(tmp_point, h_atm[h].a)));
 			nearer(tmp_point);
 			break;
 		    default:
 			printf("\nBUG: Unforseen htyp for atom %s in find_hb.\n", atomid(i,buf1));
 			printf("Please mail [email protected]\n");
			
 		    }/* end of switch*/
 		}/* end of h loop */
 		
 		if (ha2<100) /* ie if any Hydrogens have been found and
 				their positions taken.  Or, to put it 
 				another way, if it anything other than a hetatm 
 				which is flagged in .nh as having hydrogens but
 				has no positons in h_atm[].typ. */
 		{
 		    
 		    hd=vector_length( to(nearest, atom[i].p));
 		    ha=vector_length( to(nearest, atom[j].p));
 		    if (hd<0.9 || hd > 2.0) 
 		    {
 			printf("WARNING: %5.2fA between %s and %d (H).\n", hd, atomid(i,buf1),near_h-atom[i].h_ptr+1);		
 			if (debug) printf("atom[i].nh %d, ].h_ptr %d, h %d\n",atom[i].nh,atom[i].h_ptr,h);
 		    }
 		    
		    if (debug) printf("hd=%f,  ha=%f\n",hd,ha);
 		    
 		    if (!nnbflg)
 		    {
 			if (ha>MAX_HA)
 			    return(0);
 			if (debug)
 			    printf("HA length OK\n");
 			
 			if (dot_product( to(nearest, atom[i].p), 
 					to(nearest, atom[j].p) ) >= hd*ha*cosMIN_DHA)
 			    return(0);
 		    }
 		    
 		    haaa_ang=100.0; /* reset it . . . . */
 		    
 		    if (!aromatic_flg)
 		    {	
 			for(l=0;l<MAXCON;l++)
 			{
 			    if (icon[j][l]>-1) 
 			    {
 				float haaa_tmp,aaa;
 				aa[l]=atom[icon[j][l] ].p;
 				haaa_tmp= dot_product(
 						      to(atom[j].p, aa[l] ), to( atom[j].p, nearest )       );
 				aaa= vector_length( to(aa[l],atom[j].p) );
 				
 				haaa_tmp/= aaa *ha;
 				if (haaa_tmp<haaa_ang) haaa_ang=haaa_tmp; /* select lowest */
 				if (aaa<0.8 || aaa > 6.0) 
 				    printf("WARNING: %5.2fA between %s and %s ((H..)A-AA).\n", aaa,atomid(j,buf1),atomid(icon[j][l],buf2));		    
 			    }
 			}
 			if ((haaa_ang > cosMIN_HAAA && haaa_ang<100.0) && !nnbflg) 
 			    return(0);
 			else
 			    if (haaa_ang==100.0)
 				haaa_ang= -99.9;
 			/*NB -99 could not have been used as a default whilst checking
 			  because we are trying to find a lowest possible value */
 			
 			if (debug)
 			    printf("Angle OK\n");
 		    }
 		    else
 		    {
 			float haaa_tmp;
 			haaa_ang= -99; /*dealing with hAax, prefer small, ie big cosines*/
 			for(l=0;l<2;l++)
 			{
 			    
 			    haaa_tmp=dot_product( to(atom[j].p,aa[l]),to(atom[j ].p,nearest));
 			    haaa_tmp/= ha;
 			    if (debug) printf("Cosine of H-A-AX = %5.3f\n",haaa_tmp);
 			    if (haaa_tmp > haaa_ang) {
 				if (debug) printf("%5.3f > %5.3f.\n",haaa_tmp,haaa_ang);
 				
 				haaa_ang=haaa_tmp; /* select the low ie more meaningful */
 				if (debug) printf("Lowest yet.\n");
 			    }
 			    
 			}
 			if (haaa_ang < cosMAX_HAAX /* && haaa_ang<100.0 */ )
 			{
 			    if (debug) {
 				printf("Rejected because of wide HAAX angle.\n");
 				printf("Cos haaa_ang = %5.3f, cosMAX_HAAX = %5.3f.\n", haaa_ang, cosMAX_HAAX);
 			    }
 			    if (!nnbflg)
 				return(0);
 			}
 		    }
 		    
 		    
 		}/* end of 'if any Hs actually found' clause */
 		else
 		    if (d>SQR(MAX_HA+1.0))
 			if (!nnbflg)
 			    return(0); /* if the hydrogens are unfixed, knock
					 anything more than 1.0 Ang - the 
					 normal DH distance - back. */

    sprintf_hb(o_str,i,j,nearest,d,ha,daaa_ang,haaa_ang);
    return(1);
}