#include "pdb.h" /* These routines calculate the volume associated with each atom. The whole file is traversed and the volume calculated for each atom. The calculation is done by calculating the planes between the atom and each of its neibour, then forming a big tetrahedron around the atom, and chopping it down by putting int the planes. Putting in a plane means checking if any of the current vertices is on the other side of the plane from the origin atom. If a vertex is on the other side, it is deleted, and the neighbours participating in making it at are added in pair to the addition_vector. For each pair check if it is already in the addition vector. If the pair is there already, the line where their planes crossed is outside the new plane, so we remove the pair from the addition vector. After all the vertices for deletion have been identified, they are deleted, and new vertices are added at the points the lines to the deleted vertices are crossing the plane. This is done by adding a vertex for each pair in the addition_vector, on the new plane, i.e. generate a vertex for each pair and the neibour the new plane belongs to. During the calculation the atom is called the origin atom. neibour_descr describe the information associated with a neighbouring atoms. This information includes the diffrence in x, y and z, which is the vector between the two atom. The plane between them is defined by this vector and additional constant, plane_constant, such that for each point (x,y,z) on the plane: x * dx + y * dy + z * dz + plane_constant = 0 ; distance is the distance between the neighbour and the origin atom, dsq is the square of the distance. protein is 0 for dummy atoms, 1 otherwise; currently, we include non-protein atoms. flag is supposed to flag something; currently, it is just used to flag those neighbours which are not completely eliminated from the calculations, because the plane is too far. The vertex data type contains its coordinates, pointers to the three neibours, and a flag used in the last stage. */ typedef struct neibour_descr { double dx,dy,dz,distance,dsq, plane_constant ; atom_record * atom ; int flag,protein ; } neibour_descr ; /* Generating a vertex is done by finding the point where the three planes of three neighbours match, and therefore each vertex is associated with three neighbours. */ typedef struct vertex { neibour_descr *a1; neibour_descr *a2; neibour_descr *a3; double x,y,z; int flag ; } vertex ; /* These are the sizes of the datastructures used in the volume calculation. They had to be made bigger to handle hydrogens. */ # define MAX_NBR_DESCRIPTOR 1000 # define MAX_VERTEX 2000 extern vertex vertices [MAX_VERTEX] ; extern double volume_max_distance /* = 64.0 */ ; extern int the_method /* = 2 */ ; extern int vertices_count /* = 0 */; extern FILE * plot_file /* = NULL */ ; double tet_volume (atom_record *atom, vertex *v1, vertex *v2, vertex *v3) ; void generate_initial_dummy_vertices (atom_record * atom, neibour_descr *n_atoms,int n_count) ; void process_neibour(atom_record * atom, neibour_descr * nd) ; int fill_atoms_for_volume(atom_record * atom, atom_record **neibours, int neibour_count, neibour_descr *descr) ; void calculate_atom_volume(atom_record *atom, atom_record **neibours, int neibour_count) ; double NNcalculate_ratio (atom_record *atom, neibour_descr *nd) ; # ifndef STDERR # define STDERR(msg) { fprintf(stderr,"%s [%d]: %s\n",__FILE__,__LINE__,msg);} # endif