Exemple #1
0
void Area(CHAIN **Chain, int NChain, COMMAND *Cmd)
{

	double *Coord, *Radii, OverallArea, *AreaPerAtom, *p1, *p2;
	int At, TotalAt=0, Cn, Res, DotsPerSphere=600;

	for( Cn=0; Cn<NChain; Cn++ ) {

		if( !Chain[Cn]->Valid )
			continue;

		for( Res=0; Res<Chain[Cn]->NRes; Res++ )
			for( At=0; At<Chain[Cn]->Rsd[Res]->NAtom; At++ )
				if( !IsHydrogen(Chain[Cn]->Rsd[Res]->AtomType[At]) )
					TotalAt ++;
	}

	Coord = (double *)ckalloc(3*TotalAt*sizeof(double));
	Radii = (double *)ckalloc(TotalAt*sizeof(double));

	p1 = Coord;
	p2 = Radii;

	for( Cn=0; Cn<NChain; Cn++ ) {

		if( !Chain[Cn]->Valid )
			continue;

		for( Res=0; Res<Chain[Cn]->NRes; Res++ )
			for( At=0; At<Chain[Cn]->Rsd[Res]->NAtom; At++ ) 
				if( !IsHydrogen(Chain[Cn]->Rsd[Res]->AtomType[At]) ) {
					(*p1++) = (double)Chain[Cn]->Rsd[Res]->Coord[At][0];
					(*p1++) = (double)Chain[Cn]->Rsd[Res]->Coord[At][1];
					(*p1++) = (double)Chain[Cn]->Rsd[Res]->Coord[At][2];
					(*p2++) = GetAtomRadius(Chain[Cn]->Rsd[Res]->AtomType[At])+1.4;
				}

	}  

	NSC(Coord,Radii,TotalAt,DotsPerSphere,FLAG_ATOM_AREA,&OverallArea,
		&AreaPerAtom,NULL,NULL,NULL);

	/* J.D. Gans 5/20/01 -- Save a pointer to free this memory later! */
	p1 = AreaPerAtom; 

	for( Cn=0; Cn<NChain; Cn++ ) {

		if( !Chain[Cn]->Valid )
			continue;

		for( Res=0; Res<Chain[Cn]->NRes; Res++ ) {
			Chain[Cn]->Rsd[Res]->Prop->Solv = 0.0;
			for( At=0; At<Chain[Cn]->Rsd[Res]->NAtom; At++ )
				if( !IsHydrogen(Chain[Cn]->Rsd[Res]->AtomType[At]) ) {
					Chain[Cn]->Rsd[Res]->Prop->Solv += (float)(*AreaPerAtom++);
				}
		}
	}
	free(Coord);
	free(Radii);

	if(p1){
		free(p1);
		p1 = NULL;
	}

}
main () {

    int    i, j, ndots;
    real   co[3*NAT], ra[NAT], area, volume, a, b, c;
    real * dots;
    real * at_area;
    FILE  *fp;


    a  = 1.; c = 0.1;
    fp = fopen("nsc.txt", "w+");
    for (i = 1; i <= NAT; i++)
    {
        j         = i-1;
        co[3*i-3] = j*1*c;
        co[3*i-2] = j*1*c;
        co[3*i-1] = j*1*c;
        /*
           co[3*i-3] = i*1.4;
           co[3*i-2] = 0.;
           co[3*i-1] = 0.;
         */
        /*
           co[3*i-2] = a*0.3;
           a = -a; b=0;
           if (i%3 == 0) b=0.5;
           co[3*i-1] = b;
           ra[i-1] = 2.0;
         */
        ra[i-1] = (1.+j*0.5)*c;
    }
    /*
       if (NSC(co, ra, NAT, 42, NULL, &area,
     */
    if (NSC(co, ra, NAT, 42, NULL, &area,
            NULL, NULL, NULL, NULL))
    {
        ERROR("error in NSC");
    }
    fprintf(fp, "\n");
    fprintf(fp, "area     : %8.3f\n", area);
    fprintf(fp, "\n");
    fprintf(fp, "\n");
    fprintf(fp, "next call\n");
    fprintf(fp, "\n");
    fprintf(fp, "\n");

    if (NSC(co, ra, NAT, 42, FLAG_VOLUME | FLAG_ATOM_AREA | FLAG_DOTS, &area,
            &at_area, &volume,
            &dots, &ndots))
    {
        ERROR("error in NSC");
    }

    fprintf(fp, "\n");
    fprintf(fp, "area     : %8.3f\n", area);
    printf("area     : %8.3f\n", area);
    fprintf(fp, "volume   : %8.3f\n", volume);
    printf("volume   : %8.3f\n", volume);
    fprintf(fp, "ndots    : %8d\n", ndots);
    printf("ndots    : %8d\n", ndots);
    fprintf(fp, "\n");
    for (i = 1; i <= NAT; i++)
    {
        fprintf(fp, "%4d ATOM %7.2f %7.2f %7.2f  ra=%4.1f  area=%8.3f\n",
                i, co[3*i-3], co[3*i-2], co[3*i-1], ra[i-1], at_area[i-1]);
    }
    fprintf(fp, "\n");
    fprintf(fp, "DOTS : %8d\n", ndots);
    for (i = 1; i <= ndots; i++)
    {
        fprintf(fp, "%4d DOTS %8.2f %8.2f %8.2f\n",
                i, dots[3*i-3], dots[3*i-2], dots[3*i-1]);
    }
}