Changeset f5fa48
- Timestamp:
- Aug 20, 2014, 1:06:47 PM (11 years ago)
- Children:
- d635829
- Parents:
- ce0ca4
- git-author:
- Frederik Heber <heber@…> (07/18/14 17:08:09)
- git-committer:
- Frederik Heber <heber@…> (08/20/14 13:06:47)
- Location:
- src
- Files:
-
- 11 edited
-
Actions/FragmentationAction/FragmentationAction.cpp (modified) (4 diffs)
-
Actions/FragmentationAction/StoreSaturatedFragmentAction.cpp (modified) (2 diffs)
-
Fragmentation/Exporters/ExportGraph.cpp (modified) (2 diffs)
-
Fragmentation/Exporters/ExportGraph.hpp (modified) (2 diffs)
-
Fragmentation/Exporters/ExportGraph_ToFiles.cpp (modified) (1 diff)
-
Fragmentation/Exporters/ExportGraph_ToFiles.hpp (modified) (1 diff)
-
Fragmentation/Exporters/ExportGraph_ToJobs.cpp (modified) (1 diff)
-
Fragmentation/Exporters/ExportGraph_ToJobs.hpp (modified) (1 diff)
-
Fragmentation/Exporters/SaturatedFragment.cpp (modified) (8 diffs)
-
Fragmentation/Exporters/SaturatedFragment.hpp (modified) (5 diffs)
-
Fragmentation/Exporters/unittests/SaturatedFragmentUnitTest.cpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
src/Actions/FragmentationAction/FragmentationAction.cpp
rce0ca4 rf5fa48 42 42 #include "Fragmentation/Exporters/ExportGraph_ToFiles.hpp" 43 43 #include "Fragmentation/Exporters/ExportGraph_ToJobs.hpp" 44 #include "Fragmentation/Exporters/SaturatedFragment.hpp" 44 45 #include "Fragmentation/Fragmentation.hpp" 45 46 #include "Fragmentation/Graph.hpp" … … 261 262 } 262 263 264 // create global saturation positions map 265 SaturatedFragment::GlobalSaturationPositions_t globalsaturationpositions; 266 263 267 { 264 268 const enum HydrogenSaturation saturation = params.DoSaturation.get() ? DoSaturate : DontSaturate; … … 266 270 if (params.types.get().size() != 0) { 267 271 // store molecule's fragment to file 268 ExportGraph_ToFiles exporter(TotalGraph, treatment, saturation );272 ExportGraph_ToFiles exporter(TotalGraph, treatment, saturation, globalsaturationpositions); 269 273 exporter.setPrefix(params.prefix.get()); 270 274 exporter.setOutputTypes(params.types.get()); … … 272 276 } else { 273 277 // store molecule's fragment in FragmentJobQueue 274 ExportGraph_ToJobs exporter(TotalGraph, treatment, saturation );278 ExportGraph_ToJobs exporter(TotalGraph, treatment, saturation, globalsaturationpositions); 275 279 exporter.setLevel(params.level.get()); 276 280 exporter(); -
src/Actions/FragmentationAction/StoreSaturatedFragmentAction.cpp
rce0ca4 rf5fa48 39 39 #include "CodePatterns/Log.hpp" 40 40 #include "Fragmentation/Exporters/ExportGraph_ToFiles.hpp" 41 #include "Fragmentation/Exporters/SaturatedFragment.hpp" 41 42 #include "Fragmentation/Graph.hpp" 42 43 #include "World.hpp" … … 77 78 // store molecule's fragment to file 78 79 { 80 // we use an empty map here such that saturation is done locally 81 SaturatedFragment::GlobalSaturationPositions_t globalsaturationpositions; 82 79 83 const enum HydrogenSaturation saturation = params.DoSaturation.get() ? DoSaturate : DontSaturate; 80 ExportGraph_ToFiles exporter(TotalGraph, IncludeHydrogen, saturation );84 ExportGraph_ToFiles exporter(TotalGraph, IncludeHydrogen, saturation, globalsaturationpositions); 81 85 exporter.setPrefix(params.prefix.get()); 82 86 exporter.setOutputTypes(params.types.get()); -
src/Fragmentation/Exporters/ExportGraph.cpp
rce0ca4 rf5fa48 58 58 const Graph &_graph, 59 59 const enum HydrogenTreatment _treatment, 60 const enum HydrogenSaturation _saturation) : 60 const enum HydrogenSaturation _saturation, 61 const SaturatedFragment::GlobalSaturationPositions_t &_globalsaturationpositions) : 61 62 TotalGraph(_graph), 62 63 BondFragments(World::getPointer()), 63 64 treatment(_treatment), 64 65 saturation(_saturation), 66 globalsaturationpositions(_globalsaturationpositions), 65 67 CurrentKeySet(TotalGraph.begin()) 66 68 { … … 115 117 hydrogens, 116 118 treatment, 117 saturation) 119 saturation, 120 globalsaturationpositions) 118 121 ); 119 122 // and return -
src/Fragmentation/Exporters/ExportGraph.hpp
rce0ca4 rf5fa48 41 41 const Graph &_graph, 42 42 const enum HydrogenTreatment _treatment, 43 const enum HydrogenSaturation _saturation); 43 const enum HydrogenSaturation _saturation, 44 const SaturatedFragment::GlobalSaturationPositions_t &_globalsaturationpositions); 44 45 virtual ~ExportGraph(); 45 46 … … 102 103 const enum HydrogenSaturation saturation; 103 104 105 //!> Global information over all atoms with saturation positions to be used per fragment 106 const SaturatedFragment::GlobalSaturationPositions_t &globalsaturationpositions; 107 104 108 private: 105 109 //!> iterator pointing at the CurrentKeySet to be exported -
src/Fragmentation/Exporters/ExportGraph_ToFiles.cpp
rce0ca4 rf5fa48 57 57 * @param _treatment whether to always add already present hydrogens or not 58 58 * @param _saturation whether to saturate dangling bonds with hydrogen or not 59 * @param _globalsaturationpositions possibly empty map with global information 60 * where to place saturation hydrogens to fulfill consistency principle 59 61 */ 60 62 ExportGraph_ToFiles::ExportGraph_ToFiles( 61 63 const Graph &_graph, 62 64 const enum HydrogenTreatment _treatment, 63 const enum HydrogenSaturation _saturation) : 64 ExportGraph(_graph, _treatment, _saturation) 65 const enum HydrogenSaturation _saturation, 66 const SaturatedFragment::GlobalSaturationPositions_t &_globalsaturationpositions) : 67 ExportGraph(_graph, _treatment, _saturation, _globalsaturationpositions) 65 68 {} 66 69 -
src/Fragmentation/Exporters/ExportGraph_ToFiles.hpp
rce0ca4 rf5fa48 33 33 const Graph &_graph, 34 34 const enum HydrogenTreatment _treatment, 35 const enum HydrogenSaturation _saturation); 35 const enum HydrogenSaturation _saturation, 36 const SaturatedFragment::GlobalSaturationPositions_t &_globalsaturationpositions); 36 37 virtual ~ExportGraph_ToFiles(); 37 38 -
src/Fragmentation/Exporters/ExportGraph_ToJobs.cpp
rce0ca4 rf5fa48 59 59 const Graph &_graph, 60 60 const enum HydrogenTreatment _treatment, 61 const enum HydrogenSaturation _saturation) : 62 ExportGraph(_graph, _treatment, _saturation), 61 const enum HydrogenSaturation _saturation, 62 const SaturatedFragment::GlobalSaturationPositions_t &_globalsaturationpositions) : 63 ExportGraph(_graph, _treatment, _saturation,_globalsaturationpositions), 63 64 level(5) 64 65 {} -
src/Fragmentation/Exporters/ExportGraph_ToJobs.hpp
rce0ca4 rf5fa48 35 35 * \param _treatment whether hydrogen is excluded in the _graph or not 36 36 * \param _saturation whether we saturate dangling bonds or not 37 * \param _globalsaturationpositions possibly empty map with global information 38 * where to place saturation hydrogens to fulfill consistency principle 37 39 */ 38 40 ExportGraph_ToJobs( 39 41 const Graph &_graph, 40 42 const enum HydrogenTreatment _treatment, 41 const enum HydrogenSaturation _saturation); 43 const enum HydrogenSaturation _saturation, 44 const SaturatedFragment::GlobalSaturationPositions_t &_globalsaturationpositions); 42 45 virtual ~ExportGraph_ToJobs(); 43 46 -
src/Fragmentation/Exporters/SaturatedFragment.cpp
rce0ca4 rf5fa48 65 65 HydrogenPool &_hydrogens, 66 66 const enum HydrogenTreatment _treatment, 67 const enum HydrogenSaturation _saturation) : 67 const enum HydrogenSaturation _saturation, 68 const GlobalSaturationPositions_t &_globalsaturationpositions) : 68 69 container(_container), 69 70 set(_set), … … 79 80 container.insert(set); 80 81 81 // prepare saturation hydrogens 82 saturate(); 82 // prepare saturation hydrogens, either using global information 83 // or if not given, local information (created in the function) 84 if (_globalsaturationpositions.empty()) 85 saturate(); 86 else 87 saturate(_globalsaturationpositions); 83 88 } 84 89 … … 101 106 } 102 107 103 void SaturatedFragment::saturate() 104 { 105 // so far, we just have a set of keys. Hence, convert to atom refs 106 // and gather all atoms in a vector 107 std::vector<atom *>atoms;108 for (KeySet::const_iterator iter = FullMolecule.begin();109 iter != FullMolecule.end();108 typedef std::vector<atom *> atoms_t; 109 110 atoms_t gatherAllAtoms(const KeySet &_FullMolecule) 111 { 112 atoms_t atoms; 113 for (KeySet::const_iterator iter = _FullMolecule.begin(); 114 iter != _FullMolecule.end(); 110 115 ++iter) { 111 116 atom * const Walker = World::getInstance().getAtom(AtomById(*iter)); 112 117 ASSERT( Walker != NULL, 113 " SaturatedFragment::OutputConfig() - id "118 "gatherAllAtoms() - id " 114 119 +toString(*iter)+" is unknown to World."); 115 120 atoms.push_back(Walker); … … 117 122 LOG(4, "DEBUG: We have gathered the following atoms: " << atoms); 118 123 119 // bool LonelyFlag = false; 120 // go through each atom of the fragment and gather all cut bonds in list 121 typedef std::map<atom *, BondList > CutBonds_t; 124 return atoms; 125 } 126 127 typedef std::map<atom *, BondList > CutBonds_t; 128 129 CutBonds_t gatherCutBonds( 130 const atoms_t &_atoms, 131 const KeySet &_set, 132 const enum HydrogenTreatment _treatment, 133 KeySet &_FullMolecule) 134 { 135 // bool LonelyFlag = false; 122 136 CutBonds_t CutBonds; 123 for ( std::vector<atom *>::const_iterator iter =atoms.begin();124 iter != atoms.end();137 for (atoms_t::const_iterator iter = _atoms.begin(); 138 iter != _atoms.end(); 125 139 ++iter) { 126 140 atom * const Walker = *iter; … … 135 149 atom * const OtherWalker = (*BondRunner)->GetOtherAtom(Walker); 136 150 // if other atom is in key set 137 if ( set.find(OtherWalker->getId()) !=set.end()) {151 if (_set.find(OtherWalker->getId()) != _set.end()) { 138 152 LOG(4, "DEBUG: Walker " << *Walker << " is bound to " << *OtherWalker << "."); 139 153 // if (OtherWalker->getId() > Walker->getId()) { // add bond (Nr check is for adding only one of both variants: ab, ba) … … 150 164 LOG(4, "DEBUG: Walker " << *Walker << " is bound to " 151 165 << *OtherWalker << ", who is not in this fragment molecule."); 152 if (( treatment == ExcludeHydrogen) && (OtherWalker->getElementNo() == (atomicNumber_t)1)) {166 if ((_treatment == ExcludeHydrogen) && (OtherWalker->getElementNo() == (atomicNumber_t)1)) { 153 167 LOG(4, "REJECT: " << *OtherWalker << " is a hydrogen, that are excluded from the set."); 154 FullMolecule.insert(OtherWalker->getId());168 _FullMolecule.insert(OtherWalker->getId()); 155 169 } else { 156 170 LOG(3, "ACCEPT: Adding " << **BondRunner << " as a cut bond."); … … 162 176 } 163 177 LOG(4, "DEBUG: We have gathered the following CutBonds: " << CutBonds); 178 179 return CutBonds; 180 } 181 182 void SaturatedFragment::saturate() 183 { 184 // so far, we just have a set of keys. Hence, convert to atom refs 185 // and gather all atoms in a vector 186 std::vector<atom *> atoms = gatherAllAtoms(FullMolecule); 187 188 // go through each atom of the fragment and gather all cut bonds in list 189 CutBonds_t CutBonds = gatherCutBonds(atoms, set, treatment, FullMolecule); 164 190 165 191 // go through all cut bonds and replace with a hydrogen … … 172 198 if (!saturateAtom(Walker, atomiter->second)) 173 199 exit(1); 200 } 201 } else 202 LOG(3, "INFO: We are not saturating cut bonds."); 203 } 204 205 void SaturatedFragment::saturate( 206 const GlobalSaturationPositions_t &_globalsaturationpositions) 207 { 208 // so far, we just have a set of keys. Hence, convert to atom refs 209 // and gather all atoms in a vector 210 std::vector<atom *> atoms = gatherAllAtoms(FullMolecule); 211 212 // go through each atom of the fragment and gather all cut bonds in list 213 CutBonds_t CutBonds = gatherCutBonds(atoms, set, treatment, FullMolecule); 214 215 // go through all cut bonds and replace with a hydrogen 216 if (saturation == DoSaturate) { 217 for (CutBonds_t::const_iterator atomiter = CutBonds.begin(); 218 atomiter != CutBonds.end(); ++atomiter) { 219 atom * const Walker = atomiter->first; 220 LOG(4, "DEBUG: We are now saturating dangling bonds of " << *Walker); 221 222 // gather set of positions for this atom from global map 223 GlobalSaturationPositions_t::const_iterator mapiter = 224 _globalsaturationpositions.find(Walker->getId()); 225 ASSERT( mapiter != _globalsaturationpositions.end(), 226 "SaturatedFragment::saturate() - no global information for " 227 +toString(*Walker)); 228 const SaturationsPositionsPerNeighbor_t &saturationpositions = 229 mapiter->second; 230 231 // go through all cut bonds for this atom 232 for (BondList::const_iterator bonditer = atomiter->second.begin(); 233 bonditer != atomiter->second.end(); ++bonditer) { 234 atom * const OtherWalker = (*bonditer)->GetOtherAtom(Walker); 235 236 // get positions from global map 237 SaturationsPositionsPerNeighbor_t::const_iterator positionsiter = 238 saturationpositions.find(OtherWalker->getId()); 239 ASSERT(positionsiter != saturationpositions.end(), 240 "SaturatedFragment::saturate() - no information on bond neighbor " 241 +toString(*OtherWalker)+" to atom "+toString(*Walker)); 242 ASSERT(!positionsiter->second.empty(), 243 "SaturatedFragment::saturate() - no positions for saturating bond to" 244 +toString(*OtherWalker)+" to atom "+toString(*Walker)); 245 246 // get typical bond distance from elements database 247 double BondDistance = Walker->getType()->getHBondDistance(positionsiter->second.size()-1); 248 if (BondDistance < 0.) { 249 ELOG(2, "saturateAtoms() - no typical hydrogen bond distance of degree " 250 +toString(positionsiter->second.size())+" for element " 251 +toString(Walker->getType()->getName())); 252 // try bond degree 1 distance 253 BondDistance = Walker->getType()->getHBondDistance(1-1); 254 if (BondDistance < 0.) { 255 ELOG(1, "saturateAtoms() - no typical hydrogen bond distance for element " 256 +toString(Walker->getType()->getName())); 257 BondDistance = 1.; 258 } 259 } 260 ASSERT( BondDistance > 0., 261 "SaturatedFragment::saturate() - negative bond distance"); 262 263 // place hydrogen at each point 264 LOG(4, "DEBUG: Places to saturate for atom " << *OtherWalker 265 << " are " << positionsiter->second); 266 atom * const father = Walker; 267 for (SaturationsPositions_t::const_iterator positer = positionsiter->second.begin(); 268 positer != positionsiter->second.end(); ++positer) { 269 const atom& hydrogen = 270 setHydrogenReplacement(Walker, *positer, BondDistance, father); 271 FullMolecule.insert(hydrogen.getId()); 272 } 273 } 174 274 } 175 275 } else -
src/Fragmentation/Exporters/SaturatedFragment.hpp
rce0ca4 rf5fa48 23 23 #include "Parser/FormatParserStorage.hpp" 24 24 25 #include "LinearAlgebra/Vector.hpp" 26 25 27 class atom; 26 28 class HydrogenPool; 27 class Vector;28 29 29 30 /** The SaturatedFragment class acts as a wrapper to a KeySet by adding a list … … 43 44 typedef std::set<KeySet> KeySetsInUse_t; 44 45 46 //!> List of points giving saturation positions for a single bond neighbor 47 typedef std::list<Vector> SaturationsPositions_t; 48 //!> map for one atom, containing the saturation points for all its neighbors 49 typedef std::map<int, SaturationsPositions_t> SaturationsPositionsPerNeighbor_t; 50 //!> containing the saturation points over all desired atoms required 51 typedef std::map<int, SaturationsPositionsPerNeighbor_t> GlobalSaturationPositions_t; 52 45 53 /** Constructor of SaturatedFragment requires \a set which we are tightly 46 54 * associated. … … 49 57 * \param _container container to add KeySet as in-use 50 58 * \param _hydrogens pool with hydrogens for saturation 59 * \param _globalsaturationpositions saturation positions to be used 51 60 */ 52 61 SaturatedFragment( … … 55 64 HydrogenPool &_hydrogens, 56 65 const enum HydrogenTreatment _treatment, 57 const enum HydrogenSaturation saturation); 66 const enum HydrogenSaturation saturation, 67 const GlobalSaturationPositions_t &_globalsaturationpositions); 58 68 59 69 /** Destructor of class SaturatedFragment. … … 101 111 /** Helper function to lease and bring in place saturation hydrogens. 102 112 * 113 * Here, we use local information to calculate saturation positions. 114 * 103 115 */ 104 116 void saturate(); 117 118 /** Helper function to lease and bring in place saturation hydrogens. 119 * 120 * Here, saturation positions have to be calculated before and are fully 121 * stored in \a _globalsaturationpositions. 122 * 123 * \param_globalsaturationpositions 124 */ 125 void saturate(const GlobalSaturationPositions_t &_globalsaturationpositions); 126 127 /** Replaces all cut bonds with respect to the given atom by hydrogens. 128 * 129 * \param _atom atom whose cut bonds to saturate 130 * \param _cutbonds list of cut bonds for \a _atom 131 * \return true - bonds saturated, false - something went wrong 132 */ 133 bool saturateAtom(atom * const _atom, const BondList &_cutbonds); 105 134 106 135 /** Helper function to get a hydrogen replacement for a given \a replacement. -
src/Fragmentation/Exporters/unittests/SaturatedFragmentUnitTest.cpp
rce0ca4 rf5fa48 69 69 ASSERT_DO(Assert::Throw); 70 70 71 SaturatedFragment::GlobalSaturationPositions_t globalpositions; 71 72 set = new KeySet; 72 fragment = new SaturatedFragment(*set, KeySetsInUse, hydrogens, ExcludeHydrogen, DoSaturate); 73 fragment = new SaturatedFragment( 74 *set, 75 KeySetsInUse, 76 hydrogens, 77 ExcludeHydrogen, 78 DoSaturate, 79 globalpositions); 73 80 } 74 81
Note:
See TracChangeset
for help on using the changeset viewer.
