Changeset d1134d
- Timestamp:
- Jul 12, 2017, 7:10:32 PM (7 years ago)
- Branches:
- Action_Thermostats, Adding_Graph_to_ChangeBondActions, Adding_MD_integration_tests, Adding_StructOpt_integration_tests, AutomationFragmentation_failures, Candidate_v1.6.1, ChemicalSpaceEvaluator, Enhanced_StructuralOptimization, Enhanced_StructuralOptimization_continued, Exclude_Hydrogens_annealWithBondGraph, Fix_Verbose_Codepatterns, ForceAnnealing_with_BondGraph, ForceAnnealing_with_BondGraph_continued, ForceAnnealing_with_BondGraph_continued_betteresults, ForceAnnealing_with_BondGraph_contraction-expansion, Gui_displays_atomic_force_velocity, JobMarket_RobustOnKillsSegFaults, JobMarket_StableWorkerPool, PythonUI_with_named_parameters, Recreated_GuiChecks, StoppableMakroAction, TremoloParser_IncreasedPrecision
- Children:
- 92d0e6
- Parents:
- 4a6ef3
- git-author:
- Frederik Heber <frederik.heber@…> (05/18/17 19:10:25)
- git-committer:
- Frederik Heber <frederik.heber@…> (07/12/17 19:10:32)
- Files:
-
- 2 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Actions/MoleculeAction/RotateAroundBondAction.cpp
r4a6ef3 rd1134d 46 46 #include "Graph/CyclicStructureAnalysis.hpp" 47 47 #include "Graph/DepthFirstSearchAnalysis.hpp" 48 #include "Graph/BoostGraphCreator.hpp" 49 #include "Graph/BoostGraphHelpers.hpp" 50 #include "Graph/BreadthFirstSearchGatherer.hpp" 48 51 49 52 #include "Atom/atom.hpp" … … 74 77 } 75 78 79 static bool addEdgePredicate( 80 const bond &_bond, 81 const std::vector<atomId_t> &_atomids) 82 { 83 ASSERT(_atomids.size() == (size_t)2, 84 "addEdgePredicate() - atomids must contain exactly two ids."); 85 // do not add selected edge 86 return ((_bond.leftatom->getId() != _atomids[0]) 87 || (_bond.rightatom->getId() != _atomids[1])); 88 } 89 76 90 ActionState::ptr MoleculeRotateAroundBondAction::performCall() 77 91 { … … 109 123 } 110 124 125 // gather sorted ids 126 std::vector<atomId_t> atomids(2); 127 atomids[0] = atoms[0]->getId(); 128 atomids[1] = atoms[1]->getId(); 129 std::sort(atomids.begin(), atomids.end()); 130 LOG(1, "DEBUG: Selected nodes are " << atomids); 131 132 // get nodes on either side of selected bond via BFS discovery 133 BoostGraphCreator BGcreator; 134 BGcreator.createFromMolecule(*mol, 135 boost::bind(addEdgePredicate, _1, boost::ref(atomids))); 136 BreadthFirstSearchGatherer NodeGatherer(BGcreator); 137 BoostGraphHelpers::Nodeset_t bondside_sets = 138 NodeGatherer(params.bondside.get() ? atoms[0]->getId() : atoms[1]->getId()); 139 std::sort(bondside_sets.begin(), bondside_sets.end()); 140 111 141 // convert from degrees to radian 112 142 const double angle_radian = params.angle.get() * M_PI/180.; … … 118 148 Plane bondplane(NormalVector, OffsetVector); 119 149 Line RotationAxis(OffsetVector, NormalVector); 150 120 151 // go through the molecule and rotate each atom relative two plane 121 152 for (molecule::iterator iter = mol->begin(); iter != mol->end(); ++iter) { 122 153 const Vector &position = (*iter)->getPosition(); 123 154 const double signed_distance = bondplane.SignedDistance(position); 155 // for each atom determine in which set of nodes it is and shift accordingly 156 const atomId_t &atomid = (*iter)->getId(); 124 157 LOG(3, "DEBUG: Inspecting atom " << **iter << " at " << position); 125 if ((params.bondside.get() && (signed_distance > 0)) || 126 (!params.bondside.get() && (signed_distance < 0))) { 158 if (std::binary_search(bondside_sets.begin(), bondside_sets.end(), atomid)) { 127 159 LOG(4, "DEBUG: Rotating atom " << **iter << " by " << angle_radian 128 160 << " rad around " << RotationAxis); -
tests/regression/Molecules/RotateAroundBond/testsuite-molecules-rotate-around-bond.at
r4a6ef3 rd1134d 86 86 87 87 AT_CLEANUP 88 89 AT_SETUP([Molecules - Rotate around bond on almost complete cycle]) 90 AT_KEYWORDS([molecules rotate-around-bond]) 91 92 file=benzene_90degree.pdb 93 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/tests/regression/Molecules/RotateAroundBond/pre/benzene.pdb $file], 0) 94 AT_CHECK([chmod u+w $file], 0) 95 AT_CHECK([../../molecuilder -i $file --select-atom-by-order -1 -6 --remove-atom --select-atom-by-id 3 5 --rotate-around-bond 90.], 0, [stdout], [stderr]) 96 AT_CHECK([diff -I '.*reated by molecuilder.*' $file ${abs_top_srcdir}/tests/regression/Molecules/RotateAroundBond/post/$file], 0, [ignore], [ignore]) 97 98 AT_CLEANUP
Note:
See TracChangeset
for help on using the changeset viewer.