Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

Atom.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *cr                                                                       
00003  *cr            (C) Copyright 1995-2019 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.75 $        $Date: 2020/02/26 03:51:30 $
00015  *
00016  ***************************************************************************/
00023 #ifndef ATOM_H
00024 #define ATOM_H
00025 
00026 #include <string.h>
00027 #include <stdlib.h>
00028 #include "utilities.h"
00029 
00030 // maximum number of bonds allowed to other atoms
00031 // XXX It may be desirable to finally get around
00032 //     to reimplementing the bond storage using the same scheme that is used
00033 //     for bond types and bond orders, which are each based on dynamically
00034 //     allocated auxilliary arrays associated with string keywords.
00035 //     There should be low impact on structure traversal performance except 
00036 //     for a minor increase in CPU TLB pressure due to traversal of multiple
00037 //     arrays rather than just one, and the code would look almost the same.
00038 #if 0
00039 // Anyone can hack this macro for whatever max bond count they need to 
00040 // support unusual models.  
00041 #define MAXATOMBONDS      256L // example of a huge user-requested bond count
00042 #elif defined(ARCH_BLUEWATERS) || defined(ARCH_CRAY_XC) || defined(ARCH_CRAY_XK)
00043 #define MAXATOMBONDS      8L
00044 #else
00045 #define MAXATOMBONDS      12L
00046 #endif
00047 
00048 // Atom type flags
00049 #define ATOMNORMAL      0
00050 #define ATOMPROTEINBACK 1
00051 #define ATOMNUCLEICBACK 2
00052 #define ATOMHYDROGEN    3
00053 
00054 // Residue type flags
00055 #define RESNOTHING      0
00056 #define RESPROTEIN      1
00057 #define RESNUCLEIC      2
00058 #define RESWATERS       3
00059 
00061 class MolAtom {
00062 public:
00063   // XXX contents of the Atom structure are ordered specifically so 
00064   // that the compiler will pack it efficiently.
00065  
00066   // items that make this particular atom unique and are absolutely 
00067   // needed to link it up to the rest of the structure, or are speed-critical
00068   short nameindex;              
00069   short typeindex;              
00070   int uniq_resid;               
00071   int bondTo[MAXATOMBONDS];     
00072   signed char bonds;            
00073   signed char atomicnumber;     
00074   signed char altlocindex;      
00075   char insertionstr[2];         
00076 
00077   // items which could potentially be moved into other data structures 
00078   // to save memory, but are presently kept here for extra simplicity or speed
00079   short chainindex;             
00080   short segnameindex;           
00081   int resid;                    
00082   short resnameindex;           
00083 
00084   // ATOMNORMAL, ATOMPROTEINBACK, ATOMNUCLEICBACK, ATOMHYDROGEN
00085   // XXX this should be converted to an unsigned bit-field to save memory
00086   signed char atomType;         
00087 
00089   // RESNOTHING, RESPROTEIN, RESNUCLEIC, RESWATERS
00090   // XXX this should be converted to an unsigned bit-field to save memory
00091   signed char residueType;      
00092 
00093 
00094 
00095   void init(int n, int theresid, const char *insertion) { 
00096     uniq_resid = 0; // don't know yet, found in BaseMolecule
00097     bonds = 0;
00098     resid = theresid;
00099     strncpy(insertionstr, insertion, 2);        insertionstr[1] = '\0';
00100     nameindex = typeindex = resnameindex = segnameindex = altlocindex = (-1);
00101     atomicnumber = (-1);
00102 
00103     for (int i=0; i<MAXATOMBONDS; i++) {
00104       bondTo[i] = -1;
00105     }
00106     atomType = ATOMNORMAL;
00107     residueType = RESNOTHING;
00108   }
00109   
00113   int add_bond(int a, int type) {
00114     if(bonds >= MAXATOMBONDS) // fail
00115       return -1;
00116 
00117     bondTo[(int) bonds] = a;
00118     if (type == ATOMPROTEINBACK || type == ATOMNUCLEICBACK)
00119       atomType = type;
00120     bonds++;
00121     return 0;
00122   }
00123 
00126   int bonded(int a) {
00127     for (int i=0; i < bonds; i++) {
00128       if (bondTo[i] == a) {
00129         return TRUE;
00130       }
00131     }
00132 
00133     return FALSE;
00134   }
00135 
00136 };
00137 
00138 #endif
00139 

Generated on Sat Apr 20 02:42:01 2024 for VMD (current) by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002