Changeset e139180
- Timestamp:
- Aug 20, 2014, 1:04:08 PM (11 years ago)
- Children:
- d734ff
- Parents:
- 0d5ca7
- git-author:
- Frederik Heber <heber@…> (06/04/14 11:22:49)
- git-committer:
- Frederik Heber <heber@…> (08/20/14 13:04:08)
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified src/Fragmentation/Exporters/SaturatedFragment.cpp ¶
r0d5ca7 re139180 38 38 #include "SaturatedFragment.hpp" 39 39 40 #include <algorithm> 40 41 #include <cmath> 41 42 #include <iostream> … … 114 115 atoms.push_back(Walker); 115 116 } 117 LOG(4, "DEBUG: We have gathered the following atoms: " << atoms); 116 118 117 119 // bool LonelyFlag = false; … … 123 125 ++iter) { 124 126 atom * const Walker = *iter; 127 // start with an empty list 128 CutBonds.insert( std::make_pair(Walker, BondList() )); 125 129 126 130 // go through all bonds … … 146 150 LOG(4, "DEBUG: Walker " << *Walker << " is bound to " 147 151 << *OtherWalker << ", who is not in this fragment molecule."); 148 if (saturation == DoSaturate) { 149 // LOG(3, "ACCEPT: Adding Hydrogen to " << (*iter)->Name << " and a bond in between."); 150 if (CutBonds.count(Walker) == 0) 151 CutBonds.insert( std::make_pair(Walker, BondList() )); 152 if ((treatment == ExcludeHydrogen) && (OtherWalker->getElementNo() == (atomicNumber_t)1)) { 153 LOG(4, "REJECT: " << *OtherWalker << " is a hydrogen, that are excluded from the set."); 154 FullMolecule.insert(OtherWalker->getId()); 155 } else { 156 LOG(3, "ACCEPT: Adding " << **BondRunner << " as a cut bond."); 157 // there is always at least an empty list 152 158 CutBonds[Walker].push_back(*BondRunner); 153 159 } 154 // } else if ((treatment == ExcludeHydrogen) && (OtherWalker->getElementNo() == (atomicNumber_t)1)) {155 // // just copy the atom if it's a hydrogen156 // atom * const OtherWalker = Leaf->AddCopyAtom(OtherWalker);157 // Leaf->AddBond((*iter), OtherWalker, (*BondRunner)->getDegree());158 // }159 //NumBonds[(*iter)->getNr()] += Binder->getDegree();160 160 } 161 161 } 162 162 } 163 LOG(4, "DEBUG: We have gathered the following CutBonds: " << CutBonds); 163 164 164 165 // go through all cut bonds and replace with a hydrogen 165 for (CutBonds_t::const_iterator atomiter = CutBonds.begin(); 166 atomiter != CutBonds.end(); ++atomiter) { 167 atom * const Walker = atomiter->first; 168 if (!saturateAtom(Walker, atomiter->second)) 169 exit(1); 170 } 166 if (saturation == DoSaturate) { 167 for (CutBonds_t::const_iterator atomiter = CutBonds.begin(); 168 atomiter != CutBonds.end(); ++atomiter) { 169 atom * const Walker = atomiter->first; 170 LOG(4, "DEBUG: We are now saturating " << *Walker); 171 172 if (!saturateAtom(Walker, atomiter->second)) 173 exit(1); 174 } 175 } else 176 LOG(3, "INFO: We are not saturating cut bonds."); 171 177 } 172 178 … … 188 194 // } 189 195 190 // gather the nodes of the shape defined by the current set of bonded atoms191 196 SphericalPointDistribution::Polygon_t Polygon; 192 for (BondList::const_iterator bonditer = _cutbonds.begin(); 193 bonditer != _cutbonds.end(); ++bonditer) { 194 Vector DistanceVector; 195 if ((*bonditer)->leftatom == _atom) 196 DistanceVector = (*bonditer)->rightatom->getPosition() - (*bonditer)->leftatom->getPosition(); 197 else 198 DistanceVector = (*bonditer)->leftatom->getPosition() - (*bonditer)->rightatom->getPosition(); 199 // always use unit distances 200 DistanceVector.Normalize(); 201 Polygon.push_back( DistanceVector ); 202 } 203 LOG(3, "DEBUG: Polygon of atom " << _atom << " to saturate is " << Polygon); 204 205 // get the new number of bonds (where all cut bonds are replaced by as 206 // many hydrogens as is their degree) 207 // unsigned int NumberOfPoints = _atom->getElement().NoValenceOrbitals; 208 unsigned int NumberOfPoints = 209 _atom->getListOfBonds().size() - _cutbonds.size(); 210 const BondList& ListOfBonds = _atom->getListOfBonds(); 211 for (BondList::const_iterator BondRunner = ListOfBonds.begin(); 212 BondRunner != ListOfBonds.end(); 213 ++BondRunner) { 214 NumberOfPoints += (*BondRunner)->getDegree(); 215 // ALTERNATIVE starting from valence: 216 // // if not one of the cut bonds, reduce by its bond degree -1 (for the one bond itself) 217 // if (_cutbonds.count(*BondRunner)) 218 // NumberOfPoints -= (*BondRunner)->getDegree() - 1; 219 } 220 LOG(3, "DEBUG: There are " << NumberOfPoints 221 << " to fill in in total for this atom " << _atom << "."); 197 { 198 // prepare a list of "uncut" bonds via set_difference. For this both lists 199 // have to be sorted. 200 typedef std::vector<bond::ptr> BondVector_t; 201 BondVector_t ListOfBonds(_atom->getListOfBonds().begin(),_atom->getListOfBonds().end()); 202 std::sort(ListOfBonds.begin(), ListOfBonds.end()); 203 BondVector_t CutBonds(_cutbonds.begin(), _cutbonds.end()); 204 std::sort(CutBonds.begin(), CutBonds.end()); 205 const BondVector_t::iterator eraseiter = std::set_difference( 206 ListOfBonds.begin(), ListOfBonds.end(), 207 CutBonds.begin(), CutBonds.end(), 208 ListOfBonds.begin()); 209 ListOfBonds.erase(eraseiter, ListOfBonds.end()); 210 211 // gather the nodes of the shape defined by the current set of bonded atoms 212 for (BondVector_t::const_iterator bonditer = ListOfBonds.begin(); 213 bonditer != ListOfBonds.end(); 214 ++bonditer) { 215 Vector DistanceVector; 216 if ((*bonditer)->leftatom == _atom) 217 DistanceVector = (*bonditer)->rightatom->getPosition() - (*bonditer)->leftatom->getPosition(); 218 else 219 DistanceVector = (*bonditer)->leftatom->getPosition() - (*bonditer)->rightatom->getPosition(); 220 // always use unit distances 221 DistanceVector.Normalize(); 222 Polygon.push_back( DistanceVector ); 223 } 224 LOG(3, "DEBUG: Polygon of atom " << *_atom << " to saturate is " << Polygon); 225 } 226 227 unsigned int NumberOfPoints = 0; 228 { 229 // get the new number of bonds 230 const BondList & ListOfBonds = _atom->getListOfBonds(); 231 NumberOfPoints = ListOfBonds.size() - _cutbonds.size(); // number remaining bonds 232 NumberOfPoints += _atom->getElement().getNoValenceOrbitals(); // plus valence 233 // minus remaining bonds weighted by its degree 234 for (BondList::const_iterator BondRunner = ListOfBonds.begin(); 235 BondRunner != ListOfBonds.end(); 236 ++BondRunner) { 237 // if not one of the cut bonds, reduce by its bond degree -1 (for the one bond itself) 238 const BondList::const_iterator finditer = 239 std::find(_cutbonds.begin(), _cutbonds.end(), *BondRunner); 240 if (finditer == _cutbonds.end()) 241 NumberOfPoints -= (*BondRunner)->getDegree(); 242 } 243 LOG(3, "DEBUG: There are " << NumberOfPoints 244 << " places to fill in in total for this atom " << *_atom << "."); 245 } 222 246 223 247 // get perfect node distribution for the given remaining atoms with respect … … 287 311 atom * const _father = _atom; 288 312 LOG(4, "DEBUG: Filling saturation hydrogen for atom " << _atom << " at " << *iter); 289 setHydrogenReplacement(313 const atom& hydrogen = setHydrogenReplacement( 290 314 _atom, 291 315 *iter, 292 316 1., 293 317 _father); 318 FullMolecule.insert(hydrogen.getId()); 294 319 } 295 320 … … 355 380 } 356 381 357 voidSaturatedFragment::setHydrogenReplacement(382 const atom& SaturatedFragment::setHydrogenReplacement( 358 383 const atom * const _OwnerAtom, 359 384 const Vector &_position, … … 368 393 _atom->father = _father; 369 394 SaturationHydrogens.insert(_atom->getId()); 395 return *_atom; 370 396 } 371 397 -
TabularUnified src/Fragmentation/Exporters/SaturatedFragment.hpp ¶
r0d5ca7 re139180 117 117 * \param _distance scale factor to the distance (default 1.) 118 118 * \param _father bond partner of \a _OwnerAtom that is replaced 119 * \return pointer to saturation hydrogen atom 119 120 */ 120 voidsetHydrogenReplacement(121 const atom& setHydrogenReplacement( 121 122 const atom * const _OwnerAtom, 122 123 const Vector &_position, -
TabularUnified tests/regression/Fragmentation/FragmentMolecule/testsuite-fragmentation-fragment-molecule.at ¶
r0d5ca7 re139180 37 37 AT_SETUP([Fragmentation - Fragmentation with cycles]) 38 38 AT_KEYWORDS([fragmentation fragment-molecule cycle]) 39 AT_XFAIL_IF([/bin/true])40 39 41 40 file=benzene.pdb
Note:
See TracChangeset
for help on using the changeset viewer.