home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Best of Windows 95.com 1996 September
/
WIN95_09964.iso
/
apps
/
ammp95.zip
/
VNOE.C
< prev
next >
Wrap
C/C++ Source or Header
|
1995-12-04
|
3KB
|
115 lines
/* vnoe.c
*
* build a virtual noe tree
*
* scan an input structure and generate distance terms
* input a pdb file
* input a close distance cut-off and a far distance cut-off
*
* generate noel terms with different formal short and long constants
*
* skip
* hydrogens (?)
* 0.,0.,0. atoms
*/
#include <stdio.h>
#define ANSI 1
/* misc includes - ANSI and some are just to be safe */
#include <stdio.h>
#include <ctype.h>
#include <math.h>
#include <string.h>
#ifdef ANSI
#include <stdlib.h>
#endif
#define MAX_ATOM 800
#ifdef WINDOWS
#endif
int main()
{
FILE *input,*output,*fopen();
char *fgets();
char keep[80],work[80]; /* buffers for reading */
char aname[10],atype[MAX_ATOM][10];
int i,j,ifile;
int inres;
int myres[MAX_ATOM];
float x[MAX_ATOM], y[MAX_ATOM],z[MAX_ATOM], r;
float r_out,r_in, dr;
printf("Please enter the coordinate file name:\n");
/* strip out the file name and put it in the right place for opening */
fgets( keep,80,stdin );
for(i= 0; i<80; i++)
if( keep[i] != ' ') break;
for( ifile = i; ifile < 80 ; ifile++)
{
if( keep[ifile] == ' ' ) break;
if( keep[ifile] == '\0' ) break;
if( keep[ifile] == '\n' ) break;
work[ifile -i ] = keep[ifile];
work[ifile -i +1 ] = '\0';
}
input = fopen( work, "r");
printf("Please enter the output file name:\n");
/* strip out the file name and put it in the right place for opening */
fgets( keep,80,stdin );
for(i= 0; i<80; i++)
if( keep[i] != ' ') break;
for( ifile = i; ifile < 80 ; ifile++)
{
if( keep[ifile] == ' ' ) break;
if( keep[ifile] == '\0' ) break;
if( keep[ifile] == '\n' ) break;
work[ifile -i ] = keep[ifile];
work[ifile -i +1 ] = '\0';
}
output = fopen( work, "w");
inres = 0;
while( fgets( keep,80,input) != NULL )
{
if( keep[0] == 'A' || keep[0] == 'H')
{
sscanf( &keep[22],"%d",&myres[inres]);
sscanf(&keep[29],"%f %f %f",&x[inres],&y[inres],&z[inres]);
sscanf(&keep[11],"%s",&atype[inres][0]);
/* sscanf(&keep[17],"%s",&aname[0]); */
/* skip zeros */
if( x[inres] != 0. && y[inres] != 0. && z[inres] != 0.)
inres ++;
} /* if ATOM or HETATM */
}/* end of the while( fgets())*/
fclose(input );
/* now do the work */
/* get r_in, r_out dr temp hard wire */
r_in = 4.; r_out = 15.; dr = 0.;
r_out *= r_out;
r_in *= r_in;
for( i=0; i< inres; i++)
{
fprintf( output,"serial i %d %s;\n", myres[i],&atype[i][0]);
for( j=i+1; j< inres; j++)
{
r = (x[i]-x[j])*(x[i]-x[j]);
r += (y[i]-y[j])*(y[i]-y[j]);
r += (z[i]-z[j])*(z[i]-z[j]);
if( r >= r_in && r <= r_out)
{
fprintf( output,"serial j %d %s;\n", myres[j],&atype[j][0]);
r = sqrt(r);
fprintf( output,"noel i j %f %f %f klow khigh;\n", r,dr,dr);
} /* if(r >= ... */
}/* j */
}/* i */
fclose(output );
}/* end of main */