00001 // -*- Mode: C++; tab-width: 2; -*- 00002 // vi: set ts=2: 00003 // 00004 00005 #ifndef BALL_MOLMEC_AMBER_GAFFTYPEPROCESSOR_H 00006 #define BALL_MOLMEC_AMBER_GAFFTYPEPROCESSOR_H 00007 00008 #ifndef BALL_CONCEPT_COMPOSITE_H 00009 # include <BALL/CONCEPT/composite.h> 00010 #endif 00011 00012 #ifndef BALL_CONCEPT_PROCESSOR_H 00013 # include <BALL/CONCEPT/processor.h> 00014 #endif 00015 00016 #ifndef BALL_MOLMEC_AMBER_GAFFCESPARSER_H 00017 # include <BALL/MOLMEC/AMBER/GAFFCESParser.h> 00018 #endif 00019 00020 #ifndef BALL_DATATYPE_OPTIONS_H 00021 # include <BALL/DATATYPE/options.h> 00022 #endif 00023 00024 #ifndef BALL_COMMON_EXCEPTION_H 00025 # include <BALL/COMMON/exception.h> 00026 #endif 00027 00028 #ifndef BALL_KERNEL_MOLECULE_H 00029 # include <BALL/KERNEL/molecule.h> 00030 #endif 00031 00032 #include <vector> 00033 #include <map> 00034 00035 namespace BALL 00036 { 00037 class BALL_EXPORT GAFFTypeProcessor : public UnaryProcessor<Composite> 00038 { 00039 public: 00041 struct TypeDefinition 00042 { 00043 String atom_type; 00044 int atomic_number; 00045 int connectivity; 00046 String attached_hydrogens; 00047 String electron_withdrawal_atoms; 00048 String atomic_property; 00049 String chemical_environment; 00050 }; 00051 00052 struct Option 00053 { 00055 static const String ATOMTYPE_FILENAME; 00056 00058 static const String GAFF_ATOMTYPE_POSTPROCESSING; 00059 }; 00060 00061 struct Default 00062 { 00064 static const String ATOMTYPE_FILENAME; 00065 00067 static const bool GAFF_ATOMTYPE_POSTPROCESSING; 00068 }; 00069 00070 enum BOND_TYPES 00071 { 00072 sb, 00073 SB, 00074 db, 00075 DB, 00076 TB, 00077 DL, 00078 AB 00079 }; 00080 00081 GAFFTypeProcessor(); 00082 GAFFTypeProcessor(const Options& new_options); 00083 virtual ~GAFFTypeProcessor(); 00084 virtual Processor::Result operator() (Composite &composite); 00085 00086 Options options; 00087 00088 protected: 00089 // helper functions used in identifying the correct atom type 00090 std::vector<TypeDefinition> getCarbonTypes_() { return atom_types_[6]; } 00091 std::vector<TypeDefinition> getHydrogenTypes_() { return atom_types_[1]; } 00092 std::vector<TypeDefinition> getNitrogenTypes_() { return atom_types_[7]; } 00093 std::vector<TypeDefinition> getOxygenTypes_() { return atom_types_[8]; } 00094 std::vector<TypeDefinition> getSulfurTypes_() { return atom_types_[16]; } 00095 00102 void parseAtomtypeTableFile_() 00103 throw(Exception::FileNotFound); 00104 00106 void precomputeBondProperties_(Molecule* molecule); 00107 00111 void precomputeAtomProperties_(Molecule* molecule); 00112 00114 void annotateBondTypes_(); 00115 00117 void annotateRingSizes_(); 00118 void annotateAliphaticAndAromaticRingAtoms_(); 00119 void annotatePlanarRingAtoms_(); 00120 bool planarAtom_(const Atom& atom); 00121 00124 bool assignAtomtype_(Atom& atom); 00125 00128 void postProcessAtomTypes_(Molecule* molecule); 00129 00130 //for every CESstring in atomtable store the "predicate tree" 00131 //built by GAFFCESParser 00132 StringHashMap<GAFFCESParser*> ces_parsers_; 00133 00134 // stores the vectors of atom types indexed by atomic number for fast retrieval 00135 std::map<Position, std::vector<TypeDefinition> > atom_types_; 00136 00137 // smallest set of smallest rings used for atomic environment strings 00138 std::vector<std::vector<Atom*> > sssr_; 00139 00141 Molecule* current_molecule_; 00142 }; 00143 } 00144 00145 #endif