00001 /*************************************************************************** 00002 *cr 00003 *cr (C) Copyright 1995-2008 The Board of Trustees of the 00004 *cr University of Illinois 00005 *cr All Rights Reserved 00006 *cr 00007 ***************************************************************************/ 00008 00009 /*************************************************************************** 00010 * RCS INFORMATION: 00011 * 00012 * $RCSfile: Atom.h,v $ 00013 * $Author: johns $ $Locker: $ $State: Exp $ 00014 * $Revision: 1.58 $ $Date: 2008/03/27 19:36:34 $ 00015 * 00016 *************************************************************************** 00017 * DESCRIPTION: 00018 * 00019 * Structure which holds data for one atom. 00020 * 00021 ***************************************************************************/ 00022 #ifndef ATOM_H 00023 #define ATOM_H 00024 00025 #include <string.h> 00026 #include <stdlib.h> 00027 #include "utilities.h" 00028 00029 // maximum number of bonds allowed to other atoms 00030 #define MAXATOMBONDS 12 00031 00032 // Atom type flags 00033 #define ATOMNORMAL 0 00034 #define ATOMPROTEINBACK 1 00035 #define ATOMNUCLEICBACK 2 00036 #define ATOMHYDROGEN 3 00037 00038 // Residue type flags 00039 #define RESNOTHING 0 00040 #define RESPROTEIN 1 00041 #define RESNUCLEIC 2 00042 #define RESWATERS 3 00043 00045 struct MolAtom { 00046 // XXX contents of the Atom structure are ordered specifically so 00047 // that the compiler will pack it efficiently. 00048 00049 // items that make this particular atom unique and are absolutely 00050 // needed to link it up to the rest of the structure, or are speed-critical 00051 short nameindex; 00052 short typeindex; 00053 int uniq_resid; 00054 int bondTo[MAXATOMBONDS]; 00055 signed char bonds; 00056 signed char atomicnumber; 00057 signed char altlocindex; 00058 char insertionstr[2]; 00059 00060 // items which could potentially be moved into other data structures 00061 // to save memory, but are presently kept here for extra simplicity or speed 00062 signed char chainindex; 00063 short segnameindex; 00064 int resid; 00065 short resnameindex; 00066 00067 // ATOMNORMAL, ATOMPROTEINBACK, ATOMNUCLEICBACK, ATOMHYDROGEN 00068 signed char atomType; 00069 00071 // RESNOTHING, RESPROTEIN, RESNUCLEIC, RESWATERS 00072 signed char residueType; 00073 00074 00075 00076 void init(int n, int theresid, char *insertion) { 00077 int i; 00078 00079 uniq_resid = 0; // don't know yet, found in BaseMolecule 00080 bonds = 0; 00081 resid = theresid; 00082 strncpy(insertionstr, insertion, 2); insertionstr[1] = '\0'; 00083 nameindex = typeindex = resnameindex = segnameindex = altlocindex = (-1); 00084 atomicnumber = (-1); 00085 00086 for (i=0; i<MAXATOMBONDS; i++) { 00087 bondTo[i] = -1; 00088 } 00089 atomType = ATOMNORMAL; 00090 residueType = RESNOTHING; 00091 } 00092 00096 int add_bond(int a, int type) { 00097 if(bonds >= MAXATOMBONDS) // fail 00098 return -1; 00099 00100 bondTo[(int) bonds] = a; 00101 if (type == ATOMPROTEINBACK || type == ATOMNUCLEICBACK) 00102 atomType = type; 00103 bonds++; 00104 return 0; 00105 } 00106 00109 int bonded(int a) { 00110 int i; 00111 for (i=0; i < bonds; i++) { 00112 if (bondTo[i] == a) { 00113 return TRUE; 00114 } 00115 } 00116 00117 return FALSE; 00118 } 00119 00120 }; 00121 00122 #endif 00123
1.2.14 written by Dimitri van Heesch,
© 1997-2002