Index: kernel/src/singleton_scores/SConscript =================================================================== --- kernel/src/singleton_scores/SConscript (revision 390) +++ kernel/src/singleton_scores/SConscript (working copy) @@ -1,6 +1,4 @@ Import('env') - -files = ['DistanceToSingletonScore.cpp'] - -files = [File(x) for x in files] +files=[] +files.append(File( 'DistanceToSingletonScore.cpp' )) Return('files') Index: kernel/src/unary_functions/SConscript =================================================================== --- kernel/src/unary_functions/SConscript (revision 390) +++ kernel/src/unary_functions/SConscript (working copy) @@ -1,7 +1,8 @@ Import('env') - -files = ['Harmonic.cpp', 'HarmonicLowerBound.cpp', 'HarmonicUpperBound.cpp', - 'OpenCubicSpline.cpp', 'Cosine.cpp'] - -files = [File(x) for x in files] +files=[] +files.append(File( 'Cosine.cpp' )) +files.append(File( 'Harmonic.cpp' )) +files.append(File( 'HarmonicLowerBound.cpp' )) +files.append(File( 'HarmonicUpperBound.cpp' )) +files.append(File( 'OpenCubicSpline.cpp' )) Return('files') Index: kernel/src/SConscript =================================================================== --- kernel/src/SConscript (revision 390) +++ kernel/src/SConscript (working copy) @@ -1,35 +1,32 @@ Import('env', 'get_sharedlib_environment') - -# Get an environment suitable for building a shared library: env = get_sharedlib_environment(env, 'IMP_EXPORTS', cplusplus=True) -env.Append(CPPPATH=["#/kernel/include", env['BOOST_CPPPATH']]) - -# Subdirectories: -restraints_files = SConscript('restraints/SConscript') -optimizers_files = SConscript('optimizers/SConscript') -decorators_files = SConscript('decorators/SConscript') -unary_functions_files = SConscript('unary_functions/SConscript') -score_states_files = SConscript('score_states/SConscript') -pair_scores_files = SConscript('pair_scores/SConscript') -singleton_scores_files = SConscript('singleton_scores/SConscript') -triplet_scores_files = SConscript('triplet_scores/SConscript') -score_states_files = SConscript('score_states/SConscript') -internal_files = SConscript('internal/SConscript') - -# Source files -files = ['base_types.cpp', 'Model.cpp', 'ModelData.cpp', - 'Particle.cpp', 'ScoreState.cpp', - 'OptimizerState.cpp', 'Log.cpp', 'Restraint.cpp', 'Optimizer.cpp', - 'Object.cpp', 'BasicScoreFuncParams.cpp', 'random.cpp' - ] + decorators_files + restraints_files + optimizers_files \ - + unary_functions_files + pair_scores_files + singleton_scores_files \ - + triplet_scores_files + score_states_files + internal_files - -# Build the shared library: -lib = env.SharedLibrary('imp', files) - -# Install the library: +env.Append(CPPPATH="#/kernel/include") +env.Append(LIBS= '' ) +files=[] +files.append(File( 'BasicScoreFuncParams.cpp' )) +files.append(File( 'Log.cpp' )) +files.append(File( 'Model.cpp' )) +files.append(File( 'ModelData.cpp' )) +files.append(File( 'Object.cpp' )) +files.append(File( 'Optimizer.cpp' )) +files.append(File( 'OptimizerState.cpp' )) +files.append(File( 'Particle.cpp' )) +files.append(File( 'Restraint.cpp' )) +files.append(File( 'ScoreState.cpp' )) +files.append(File( 'base_types.cpp' )) +files.append(File( 'random.cpp' )) +files.append(SConscript( 'Test.xcodeproj/SConscript' )) +files.append(SConscript( 'decorators/SConscript' )) +files.append(SConscript( 'doc/SConscript' )) +files.append(SConscript( 'internal/SConscript' )) +files.append(SConscript( 'optimizers/SConscript' )) +files.append(SConscript( 'pair_scores/SConscript' )) +files.append(SConscript( 'restraints/SConscript' )) +files.append(SConscript( 'score_states/SConscript' )) +files.append(SConscript( 'singleton_scores/SConscript' )) +files.append(SConscript( 'triplet_scores/SConscript' )) +files.append(SConscript( 'unary_functions/SConscript' )) +lib = env.SharedLibrary( 'IMP' , files) libinst = env.Install(env['libdir'], lib) env.Alias('install', [libinst]) - Return('lib') Index: kernel/src/score_states/BondDecoratorListScoreState.cpp =================================================================== --- kernel/src/score_states/BondDecoratorListScoreState.cpp (revision 390) +++ kernel/src/score_states/BondDecoratorListScoreState.cpp (working copy) @@ -5,7 +5,7 @@ * Copyright 2007-8 Sali Lab. All rights reserved. */ -#include "IMP/score_states/bonded_lists/BondDecoratorListScoreState.h" +#include "IMP/score_states/BondDecoratorListScoreState.h" namespace IMP { Index: kernel/src/score_states/NonbondedListScoreState.cpp =================================================================== --- kernel/src/score_states/NonbondedListScoreState.cpp (revision 390) +++ kernel/src/score_states/NonbondedListScoreState.cpp (working copy) @@ -13,178 +13,22 @@ namespace IMP { -NonbondedListScoreState::NonbondedListScoreState(const Particles &ps, - float tvs): - target_voxel_side_(tvs), grid_valid_(false) +NonbondedListScoreState::NonbondedListScoreState() { last_cutoff_=-1; - FloatKeys fks; - fks.push_back(FloatKey("x")); - fks.push_back(FloatKey("y")); - fks.push_back(FloatKey("z")); - mc_= std::auto_ptr(new MaxChangeScoreState(fks)); - set_particles(ps); } -NonbondedListScoreState::~NonbondedListScoreState() -{ -} -void NonbondedListScoreState::audit_particles(const Particles &ps) const -{ - for (unsigned int i=0; i< ps.size(); ++i) { - try { - XYZDecorator d= XYZDecorator::cast(ps[i]); - } catch (...) { - IMP_WARN("Particle " << ps[i]->get_index() - << " does not have x,y,z coordinates " - << " but was passed to the NonbondedListScoreState.\n"); - } - } -} -void NonbondedListScoreState::add_if_nonbonded(Particle *a, Particle *b) -{ - if (!a->get_is_active() || !b->get_is_active()) return; - bool found=false; - for (BondedListIterator bli= bonded_lists_begin(); - bli != bonded_lists_end(); ++bli) { - if ((*bli)->are_bonded(a, b)) { - found = true; - break; - } - } - if (!found) { - /*IMP_LOG(VERBOSE, "Found pair " << a->get_index() - << " " << b->get_index() << std::endl);*/ - nbl_.push_back(std::make_pair(a, b)); - } -} -void NonbondedListScoreState::create_grid() -{ - IMP_LOG(VERBOSE, "Creating nonbonded grid..." << std::flush); - float mn[3]= {std::numeric_limits::max(), - std::numeric_limits::max(), - std::numeric_limits::max()}; - float mx[3]={-std::numeric_limits::max(), - -std::numeric_limits::max(), - -std::numeric_limits::max()}; - for (unsigned int i = 0; i < get_particles().size(); ++i) { - XYZDecorator d= XYZDecorator::cast(get_particles()[i]); - for (unsigned int j=0; j<3; ++j) { - if (d.get_coordinate(j)< mn[j]) mn[j]= d.get_coordinate(j); - if (d.get_coordinate(j)> mx[j]) mx[j]= d.get_coordinate(j); - } - } - grid_= Grid(target_voxel_side_, - Vector3D(mn[0], mn[1], mn[2]), - Vector3D(mx[0], mx[1], mx[2]), - Particles()); - for (unsigned int i = 0; i < get_particles().size(); ++i) { - XYZDecorator d= XYZDecorator::cast(get_particles()[i]); - Vector3D v(d.get_x(), d.get_y(), d.get_z()); - grid_.get_voxel(grid_.get_index(v)).push_back(get_particles()[i]); - } - grid_valid_=true; - mc_->reset(); - invalidate_nbl(); - IMP_LOG(VERBOSE, "done." << std::endl); -} -void NonbondedListScoreState::handle_particle(Particle *p, - const Grid::VirtualIndex ¢er, - float cut, - bool skip_lower) +void NonbondedListScoreState::propagate_particles(const Particles&ps) { - Grid::VirtualIndex lc, uc; - - if ( cut > target_voxel_side_*1000 ) { - // This is needed to handle overflow - lc=Grid::VirtualIndex(0,0,0); - uc=Grid::VirtualIndex(grid_.get_number_of_voxels(0), - grid_.get_number_of_voxels(1), - grid_.get_number_of_voxels(2)); - } else { - // it is important that this is not unsigned - int ncells= static_cast(std::ceil(cut/target_voxel_side_)); - // to allow laziness in rebuilding - ++ncells; - lc=Grid::VirtualIndex(center[0]-ncells, - center[1]-ncells, - center[2]-ncells); - uc=Grid::VirtualIndex(center[0]+ncells, - center[1]+ncells, - center[2]+ncells); - } - //IMP_LOG(VERBOSE, "Iteration bounds are " << lc << " and " - // << uc << std::endl); - for (Grid::IndexIterator cur= grid_.indexes_begin(lc, uc); - cur != grid_.indexes_end(lc, uc); - ++cur){ - if ( skip_lower && center >= *cur) continue; - if (grid_.get_voxel(*cur).empty()) continue; - //IMP_LOG(VERBOSE, "Paired with " << cur << std::endl); - - for (unsigned int pi= 0; - pi< grid_.get_voxel(*cur).size(); ++pi) { - Particle *op = grid_.get_voxel(*cur)[pi]; - add_if_nonbonded(p, op); - } - } - if (skip_lower) { - Grid::Index ri= grid_.get_index(center); - if (ri != Grid::Index()) { - const IMP::Particles &pis= grid_.get_voxel(ri); - for (unsigned int pj= 0; pis[pj] != p; ++pj) { - Particle *op= pis[pj]; - add_if_nonbonded(p, op); - } - } - } -} - - -void NonbondedListScoreState::rescan(float cut) -{ - if (last_cutoff_ >= cut) { - return; - } - IMP_LOG(VERBOSE, "Rescanning " << cut - << "(" << last_cutoff_ << ")" << std::endl); - - last_cutoff_=cut; - - nbl_.clear(); - IMP_LOG(VERBOSE, "Scanning for nonbonded pairs..." << std::flush); - for (Grid::IndexIterator center= grid_.all_indexes_begin(); - center != grid_.all_indexes_end(); - ++center) { - if (grid_.get_voxel(*center).empty()) continue; - //IMP_LOG(VERBOSE, "Scanning from grid index " << *center << std::endl); - for (unsigned int pi= 0; pi< grid_.get_voxel(*center).size(); ++pi) { - Particle *p= grid_.get_voxel(*center)[pi]; - handle_particle(p, *center, cut, true); - } - } - IMP_LOG(VERBOSE, "done" << std::endl); - //IMP_LOG(VERBOSE, "Found " << nbl_.size() << " nonbonded pairs" - //<< std::endl); - IMP_LOG(VERBOSE, "Found " << nbl_.size() << " nonbonded pairs" - << " for " << get_particles().size() - << " particles" << std::endl); -} - -void NonbondedListScoreState::set_particles(const Particles &ps) -{ - audit_particles(get_particles()); + clear_nbl(); for (BondedListScoreStateIterator bli= bonded_lists_begin(); bli != bonded_lists_end(); ++bli) { (*bli)->set_particles(ps); } - mc_->clear_particles(); - mc_->add_particles(ps); - grid_valid_=false; } void NonbondedListScoreState::update() @@ -194,9 +38,6 @@ bli != bonded_lists_end(); ++bli) { (*bli)->update(); } - if (!grid_valid_ || mc_->get_max() > target_voxel_side_) { - create_grid(); - } } void NonbondedListScoreState::show(std::ostream &out) const Index: kernel/src/score_states/BipartiteNonbondedListScoreState.cpp =================================================================== --- kernel/src/score_states/BipartiteNonbondedListScoreState.cpp (revision 390) +++ kernel/src/score_states/BipartiteNonbondedListScoreState.cpp (working copy) @@ -7,7 +7,7 @@ #include "IMP/score_states/BipartiteNonbondedListScoreState.h" #include "IMP/decorators/XYZDecorator.h" -#include "IMP/internal/Grid3D.h" +#include "IMP/score_states/MaxChangeScoreState.h" namespace IMP { @@ -31,7 +31,7 @@ BipartiteNonbondedListScoreState ::BipartiteNonbondedListScoreState(const Particles &ps0, const Particles &ps1, float target): - NonbondedListScoreState(ps0, target) + grid_(target) { FloatKeys fks; fks.push_back(FloatKey("x")); @@ -41,40 +41,21 @@ set_particles(ps0, ps1); } -BipartiteNonbondedListScoreState::~BipartiteNonbondedListScoreState() +void BipartiteNonbondedListScoreState::rebuild_nbl(float cut) { -} - -void BipartiteNonbondedListScoreState::rescan(float cut) -{ - if (P::last_cutoff_ >= cut) { - return; - } - P::last_cutoff_=cut; - - /*for (Grid::IndexIterator it= P::grid_.all_indexes_begin(); - it != P::grid_.all_indexes_end(); ++it) { - if (!P::grid_.get_voxel(*it).empty()) { - IMP_LOG(VERBOSE, "Voxel " << *it << ":"); - for (unsigned int i=0; i< P::grid_.get_voxel(*it).size(); ++i) { - IMP_LOG(VERBOSE, " " << P::grid_.get_voxel(*it)[i]->get_index()); - } - IMP_LOG(VERBOSE, std::endl); - } - }*/ - - nbl_.clear(); - for (unsigned int i=0; i< get_particles().size(); ++i) { - Particle *p= get_particles()[i]; + for (unsigned int i=0; i< mc_->get_particles().size(); ++i) { + Particle *p= mc_->get_particles()[i]; + NonbondedListScoreState::AddToNBL f(this, p); XYZDecorator d= XYZDecorator::cast(p); - Grid::VirtualIndex index - = P::grid_.get_virtual_index(Vector3D(d.get_x(), d.get_y(), d.get_z())); + internal::ParticleGrid::VirtualIndex index + = grid_.get_virtual_index(Vector3D(d.get_x(), d.get_y(), d.get_z())); //IMP_LOG(VERBOSE, "Index is " << index << std::endl); - P::handle_particle(p, index, cut, false); + grid_.apply_to_nearby(f, index, cut, false); } - IMP_LOG(VERBOSE, "Found " << nbl_.size() << " bipartite nonbonded pairs" - << " for " << P::get_particles().size() << " and " - << get_particles().size() << " sized sets" << std::endl); + IMP_LOG(VERBOSE, "Found " << P::size_nbl() + << " bipartite nonbonded pairs" + << " for " << mc_->get_particles().size() + << " nongridded particles" << std::endl); } void BipartiteNonbondedListScoreState::set_particles(const Particles &ps0, @@ -84,19 +65,23 @@ << " and " << ps1.size() << std::endl); mc_->clear_particles(); mc_->add_particles(ps1); - P::set_particles(ps0); - P::audit_particles(ps1); - IMP_assert(ps0.size() == P::get_particles().size(), - "Where did they go?"); - IMP_assert(ps1.size() == get_particles().size(), + grid_.clear_particles(); + grid_.add_particles(ps0); + Particles all(ps0); + all.insert(all.end(), ps1.begin(), ps1.end()); + NonbondedListScoreState::propagate_particles(all); + /*IMP_assert(ps0.size() == P::get_particles().size(), + "Where did they go?");*/ + IMP_assert(ps1.size() == mc_->get_particles().size(), "Where did we go?"); } void BipartiteNonbondedListScoreState::update() { - P::update(); - if (mc_->get_max() > P::target_voxel_side_) { - P::invalidate_nbl(); + NonbondedListScoreState::update(); + if (mc_->get_max() > grid_.get_voxel_size() + || grid_.update()) { + NonbondedListScoreState::clear_nbl(); } } Index: kernel/src/score_states/SConscript =================================================================== --- kernel/src/score_states/SConscript (revision 390) +++ kernel/src/score_states/SConscript (working copy) @@ -1,9 +1,9 @@ Import('env') - -files = ['NonbondedListScoreState.cpp', 'BipartiteNonbondedListScoreState.cpp', - 'MaxChangeScoreState.cpp'] - -bonded_lists_files = SConscript('bonded_lists/SConscript') - -files = [File(x) for x in files] + bonded_lists_files +files=[] +files.append(File( 'AllNonbondedListScoreState.cpp' )) +files.append(File( 'BipartiteNonbondedListScoreState.cpp' )) +files.append(File( 'BondDecoratorListScoreState.cpp' )) +files.append(File( 'MaxChangeScoreState.cpp' )) +files.append(File( 'NonbondedListScoreState.cpp' )) +files.append(SConscript( 'bonded_lists/SConscript' )) Return('files') Index: kernel/src/score_states/bonded_lists/BondDecoratorListScoreState.cpp =================================================================== --- kernel/src/score_states/bonded_lists/BondDecoratorListScoreState.cpp (revision 390) +++ kernel/src/score_states/bonded_lists/BondDecoratorListScoreState.cpp (working copy) @@ -1,55 +0,0 @@ -/** - * \file BondDecoratorListScoreState.cpp - * \brief Allow iteration through pairs of a set of atoms. - * - * Copyright 2007-8 Sali Lab. All rights reserved. - */ - -#include "IMP/score_states/bonded_lists/BondDecoratorListScoreState.h" - -namespace IMP -{ - -BondDecoratorListScoreState::BondDecoratorListScoreState(const Particles &ps) : - ps_(ps) -{ -} - -void BondDecoratorListScoreState::update() -{ - bonds_.clear(); - for (unsigned int i=0; i< ps_.size(); ++i) { - if (!ps_[i]->get_is_active()) continue; - BondedDecorator di= BondedDecorator::cast(ps_[i]); - ParticleIndex pi= ps_[i]->get_index(); - for (unsigned int j=0; j< di.get_number_of_bonds(); ++j) { - BondedDecorator dj= di.get_bonded(j); - if (! dj.get_particle()->get_is_active()) continue; - if (di < dj) { - bonds_.push_back(di.get_bond(j)); - } - } - } - IMP_LOG(VERBOSE, "Found " << bonds_.size() << " bonds"<< std::endl); -} - -void BondDecoratorListScoreState::set_particles(const Particles &ps) -{ - ps_=ps; - bonds_.clear(); -} - - -bool BondDecoratorListScoreState::are_bonded(Particle *a, Particle *b) const -{ - try { - BondedDecorator da= BondedDecorator::cast(a); - BondedDecorator db= BondedDecorator::cast(b); - return get_bond(da, db) != BondDecorator(); - } catch (...) { - IMP_LOG(VERBOSE, "Exception thrown in are_bonded"<< std::endl); - } - return false; -} - -} // namespace IMP Index: kernel/src/score_states/bonded_lists/SConscript =================================================================== --- kernel/src/score_states/bonded_lists/SConscript (revision 390) +++ kernel/src/score_states/bonded_lists/SConscript (working copy) @@ -1,6 +0,0 @@ -Import('env') - -files = ['BondDecoratorListScoreState.cpp'] - -files = [File(x) for x in files] -Return('files') Index: kernel/src/score_states/AllNonbondedListScoreState.cpp =================================================================== --- kernel/src/score_states/AllNonbondedListScoreState.cpp (revision 0) +++ kernel/src/score_states/AllNonbondedListScoreState.cpp (revision 0) @@ -0,0 +1,66 @@ +/** + * \file NonbondedListScoreState.cpp + * \brief Allow iteration through pairs of a set of atoms. + * + * Copyright 2007-8 Sali Lab. All rights reserved. + */ + +#include "IMP/score_states/AllNonbondedListScoreState.h" +#include "IMP/decorators/XYZDecorator.h" +#include "IMP/internal/Grid3D.h" +#include "IMP/score_states/MaxChangeScoreState.h" + +namespace IMP +{ + +AllNonbondedListScoreState::AllNonbondedListScoreState(const Particles &ps, + float tvs): + grid_(tvs) +{ + set_particles(ps); +} + +void AllNonbondedListScoreState::rebuild_nbl(float cut) +{ + IMP_LOG(VERBOSE, "Scanning for nonbonded pairs..." << std::flush); + internal::ParticleGrid::Index last_index; + for (internal::ParticleGrid::ParticleVoxelIterator it + = grid_.particle_voxels_begin(); + it != grid_.particle_voxels_end(); ++it) { + IMP_LOG(VERBOSE, "Searching with particle " << it->first->get_index() + << std::endl); + NonbondedListScoreState::AddToNBL f(this, it->first); + grid_.apply_to_nearby(f, it->second, cut, true); + if (it->second != last_index) { + grid_.apply_to_cell_pairs(f, it->second); + } + last_index=it->second; + } + + IMP_LOG(VERBOSE, "done" << std::endl); + IMP_LOG(VERBOSE, "Found " << NonbondedListScoreState::size_nbl() + << " nonbonded pairs" + << std::endl); +} + +void AllNonbondedListScoreState::set_particles(const Particles &ps) +{ + grid_.clear_particles(); + grid_.add_particles(ps); + NonbondedListScoreState::propagate_particles(ps); +} + +void AllNonbondedListScoreState::update() +{ + NonbondedListScoreState::update(); + if (grid_.update()) { + NonbondedListScoreState::clear_nbl(); + } +} + +void AllNonbondedListScoreState::show(std::ostream &out) const +{ + out << "NonbondedList" << std::endl; +} + +} // namespace IMP Index: kernel/src/restraints/BondDecoratorRestraint.cpp =================================================================== --- kernel/src/restraints/BondDecoratorRestraint.cpp (revision 390) +++ kernel/src/restraints/BondDecoratorRestraint.cpp (working copy) @@ -8,7 +8,7 @@ #include "IMP/restraints/BondDecoratorRestraint.h" #include "IMP/UnaryFunction.h" -#include "IMP/score_states/bonded_lists/BondDecoratorListScoreState.h" +#include "IMP/score_states/BondDecoratorListScoreState.h" #include "IMP/decorators/bond_decorators.h" #include "IMP/pair_scores/DistancePairScore.h" Index: kernel/src/restraints/SConscript =================================================================== --- kernel/src/restraints/SConscript (revision 390) +++ kernel/src/restraints/SConscript (working copy) @@ -1,12 +1,16 @@ Import('env') - -files = ['PairConnectivityRestraint.cpp', - 'ConnectivityRestraint.cpp', 'ProximityRestraint.cpp', - 'RestraintSet.cpp', - 'DistanceRestraint.cpp', 'AngleRestraint.cpp', 'DihedralRestraint.cpp', - 'TorusRestraint.cpp', 'ExclusionVolumeRestraint.cpp', - 'NonbondedRestraint.cpp', 'BondDecoratorRestraint.cpp', - 'ListRestraint.cpp', 'ChainTripletRestraint.cpp'] - -files = [File(x) for x in files] +files=[] +files.append(File( 'AngleRestraint.cpp' )) +files.append(File( 'BondDecoratorRestraint.cpp' )) +files.append(File( 'ChainTripletRestraint.cpp' )) +files.append(File( 'ConnectivityRestraint.cpp' )) +files.append(File( 'DihedralRestraint.cpp' )) +files.append(File( 'DistanceRestraint.cpp' )) +files.append(File( 'ExclusionVolumeRestraint.cpp' )) +files.append(File( 'ListRestraint.cpp' )) +files.append(File( 'NonbondedRestraint.cpp' )) +files.append(File( 'PairConnectivityRestraint.cpp' )) +files.append(File( 'ProximityRestraint.cpp' )) +files.append(File( 'RestraintSet.cpp' )) +files.append(File( 'TorusRestraint.cpp' )) Return('files') Index: kernel/src/triplet_scores/SConscript =================================================================== --- kernel/src/triplet_scores/SConscript (revision 390) +++ kernel/src/triplet_scores/SConscript (working copy) @@ -1,6 +1,4 @@ Import('env') - -files = ['AngleTripletScore.cpp'] - -files = [File(x) for x in files] +files=[] +files.append(File( 'AngleTripletScore.cpp' )) Return('files') Index: kernel/src/optimizers/states/SConscript =================================================================== --- kernel/src/optimizers/states/SConscript (revision 390) +++ kernel/src/optimizers/states/SConscript (working copy) @@ -1,6 +1,5 @@ Import('env') - -files = ['VRMLLogOptimizerState.cpp', 'CMMLogOptimizerState.cpp'] - -files = [File(x) for x in files] +files=[] +files.append(File( 'CMMLogOptimizerState.cpp' )) +files.append(File( 'VRMLLogOptimizerState.cpp' )) Return('files') Index: kernel/src/optimizers/SConscript =================================================================== --- kernel/src/optimizers/SConscript (revision 390) +++ kernel/src/optimizers/SConscript (working copy) @@ -1,10 +1,10 @@ Import('env') - -states_files = SConscript('states/SConscript') -movers_files = SConscript('movers/SConscript') - -files = [ 'SteepestDescent.cpp', 'ConjugateGradients.cpp', - 'MolecularDynamics.cpp', 'MonteCarlo.cpp', 'MoverBase.cpp']+states_files +movers_files - -files = [File(x) for x in files] +files=[] +files.append(File( 'ConjugateGradients.cpp' )) +files.append(File( 'MolecularDynamics.cpp' )) +files.append(File( 'MonteCarlo.cpp' )) +files.append(File( 'MoverBase.cpp' )) +files.append(File( 'SteepestDescent.cpp' )) +files.append(SConscript( 'movers/SConscript' )) +files.append(SConscript( 'states/SConscript' )) Return('files') Index: kernel/src/optimizers/movers/SConscript =================================================================== --- kernel/src/optimizers/movers/SConscript (revision 390) +++ kernel/src/optimizers/movers/SConscript (working copy) @@ -1,6 +1,5 @@ Import('env') - -files = [ 'BallMover.cpp', 'NormalMover.cpp'] - -files = [File(x) for x in files] +files=[] +files.append(File( 'BallMover.cpp' )) +files.append(File( 'NormalMover.cpp' )) Return('files') Index: kernel/src/decorators/SConscript =================================================================== --- kernel/src/decorators/SConscript (revision 390) +++ kernel/src/decorators/SConscript (working copy) @@ -1,8 +1,10 @@ Import('env') - -files = ['AtomDecorator.cpp', 'bond_decorators.cpp', - 'HierarchyDecorator.cpp', 'NameDecorator.cpp', 'ResidueDecorator.cpp', - 'MolecularHierarchyDecorator.cpp', 'XYZDecorator.cpp'] - -files = [File(x) for x in files] +files=[] +files.append(File( 'AtomDecorator.cpp' )) +files.append(File( 'HierarchyDecorator.cpp' )) +files.append(File( 'MolecularHierarchyDecorator.cpp' )) +files.append(File( 'NameDecorator.cpp' )) +files.append(File( 'ResidueDecorator.cpp' )) +files.append(File( 'XYZDecorator.cpp' )) +files.append(File( 'bond_decorators.cpp' )) Return('files') Index: kernel/src/pair_scores/SConscript =================================================================== --- kernel/src/pair_scores/SConscript (revision 390) +++ kernel/src/pair_scores/SConscript (working copy) @@ -1,6 +1,5 @@ Import('env') - -files = ['DistancePairScore.cpp', 'SphereDistancePairScore.cpp'] - -files = [File(x) for x in files] +files=[] +files.append(File( 'DistancePairScore.cpp' )) +files.append(File( 'SphereDistancePairScore.cpp' )) Return('files') Index: kernel/src/internal/SConscript =================================================================== --- kernel/src/internal/SConscript (revision 390) +++ kernel/src/internal/SConscript (working copy) @@ -1,6 +1,5 @@ Import('env') - -files = ['graph_base.cpp'] - -files = [File(x) for x in files] +files=[] +files.append(File( 'ParticleGrid.cpp' )) +files.append(File( 'graph_base.cpp' )) Return('files') Index: kernel/src/internal/ParticleGrid.cpp =================================================================== --- kernel/src/internal/ParticleGrid.cpp (revision 0) +++ kernel/src/internal/ParticleGrid.cpp (revision 0) @@ -0,0 +1,85 @@ +#include "IMP/internal/ParticleGrid.h" +#include "IMP/score_states/MaxChangeScoreState.h" +#include "IMP/decorators/XYZDecorator.h" + +namespace IMP +{ + +namespace internal +{ + + +ParticleGrid::ParticleGrid(float tvs): target_voxel_side_(tvs), + grid_valid_(false) +{ + FloatKeys fks; + fks.push_back(FloatKey("x")); + fks.push_back(FloatKey("y")); + fks.push_back(FloatKey("z")); + mc_= std::auto_ptr(new MaxChangeScoreState(fks)); + +} + +void ParticleGrid::build_grid() +{ + IMP_LOG(VERBOSE, "Creating nonbonded grid..." << std::flush); + float mn[3]= {std::numeric_limits::max(), + std::numeric_limits::max(), + std::numeric_limits::max()}; + float mx[3]={-std::numeric_limits::max(), + -std::numeric_limits::max(), + -std::numeric_limits::max()}; + for (unsigned int i = 0; i < mc_->get_particles().size(); ++i) { + XYZDecorator d= XYZDecorator::cast(mc_->get_particles()[i]); + for (unsigned int j=0; j<3; ++j) { + if (d.get_coordinate(j)< mn[j]) mn[j]= d.get_coordinate(j); + if (d.get_coordinate(j)> mx[j]) mx[j]= d.get_coordinate(j); + } + } + grid_= Grid(target_voxel_side_, + Vector3D(mn[0], mn[1], mn[2]), + Vector3D(mx[0], mx[1], mx[2]), + Particles()); + for (unsigned int i = 0; i < mc_->get_particles().size(); ++i) { + XYZDecorator d= XYZDecorator::cast(mc_->get_particles()[i]); + Vector3D v(d.get_x(), d.get_y(), d.get_z()); + grid_.get_voxel(grid_.get_index(v)).push_back(mc_->get_particles()[i]); + } + grid_valid_=true; + mc_->reset(); + IMP_LOG(VERBOSE, "done." << std::endl); +} + + +void ParticleGrid::add_particles(const Particles &ps) { + audit_particles(ps); + mc_->add_particles(ps); +} +void ParticleGrid::clear_particles() { + mc_->clear_particles(); +} + +bool ParticleGrid::update() { + if (!grid_valid_ || mc_->get_max() > target_voxel_side_) { + build_grid(); + return true; + } + return false; +} + +void ParticleGrid::audit_particles(const Particles &ps) const +{ + for (unsigned int i=0; i< ps.size(); ++i) { + try { + XYZDecorator d= XYZDecorator::cast(ps[i]); + } catch (...) { + IMP_WARN("Particle " << ps[i]->get_index() + << " does not have x,y,z coordinates " + << " but was passed to the NonbondedListScoreState.\n"); + } + } +} + +} + +} Index: kernel/include/IMP/internal/ParticleGrid.h =================================================================== --- kernel/include/IMP/internal/ParticleGrid.h (revision 0) +++ kernel/include/IMP/internal/ParticleGrid.h (revision 0) @@ -0,0 +1,181 @@ +/** + * \file ParticleGrid.h + * \brief A grid for keeping track of particles. + * + * Copyright 2007-8 Sali Lab. All rights reserved. + */ + +#ifndef __IMP_PARTICLEGRID_H +#define __IMP_PARTICLEGRID_H + +#include "Grid3D.h" +#include "../base_types.h" + +namespace IMP +{ + +class MaxChangeScoreState; + +namespace internal +{ + +/** \internal*/ +class ParticleGrid { + typedef internal::Grid3D Grid; + Grid grid_; + std::auto_ptr mc_; + Float target_voxel_side_; + bool grid_valid_; + + void build_grid(); + void audit_particles(const Particles &ps) const; +public: + //! suggested grid edge size. + ParticleGrid(Float sz); + + Float get_voxel_size() const {return target_voxel_side_;} + + void add_particles(const Particles &ps); + void clear_particles(); + bool update(); + + typedef Grid::VirtualIndex VirtualIndex; + typedef Grid::Index Index; + Grid::VirtualIndex get_virtual_index(Vector3D pt) const { + return grid_.get_index(pt); + } + + //! Apply the function F to all particles near to the center + /** \param[in] f The functor. It should take a particle as an argument. + \param[in] center The starting point to search from + \param[in] cut The maximum distance to search + \param[in] skip_lower If true, all voxels with lower index are skipped. + Use this if searching for points which are already in the grid. + \note that for various technical reasons, this does not include particles + in the cell center. + + */ + template + void apply_to_nearby(F f, const Grid::VirtualIndex ¢er, + float cut, + bool skip_lower) { + Grid::VirtualIndex lc, uc; + + if ( cut > target_voxel_side_*1000 ) { + // This is needed to handle overflow + lc=Grid::VirtualIndex(0,0,0); + uc=Grid::VirtualIndex(grid_.get_number_of_voxels(0), + grid_.get_number_of_voxels(1), + grid_.get_number_of_voxels(2)); + } else { + // it is important that this is not unsigned + int ncells= static_cast(std::ceil(cut/target_voxel_side_)); + // to allow laziness in rebuilding + ++ncells; + lc=Grid::VirtualIndex(center[0]-ncells, + center[1]-ncells, + center[2]-ncells); + uc=Grid::VirtualIndex(center[0]+ncells, + center[1]+ncells, + center[2]+ncells); + } + //IMP_LOG(VERBOSE, "Iteration bounds are " << lc << " and " + // << uc << std::endl); + for (Grid::IndexIterator cur= grid_.indexes_begin(lc, uc); + cur != grid_.indexes_end(lc, uc); + ++cur){ + if ( skip_lower && center >= *cur) continue; + if (grid_.get_voxel(*cur).empty()) continue; + //IMP_LOG(VERBOSE, "Paired with " << cur << std::endl); + + for (unsigned int pi= 0; + pi< grid_.get_voxel(*cur).size(); ++pi) { + Particle *op = grid_.get_voxel(*cur)[pi]; + f(op); + } + } + + } + + template + void apply_to_cell_pairs(F f, const Grid::Index ¢er) { + const Particles &ps= grid_.get_voxel(center); + for (unsigned int i=0; i< ps.size(); ++i) { + for (unsigned int j=0; j< i; ++j) { + f(ps[i], ps[j]); + } + } + } + + // This is not a real iterator yet + class ParticleVoxelIterator { + Grid::IndexIterator cvoxel_; + Grid::IndexIterator evoxel_; + Particles::const_iterator curp_; + const Grid *grid_; + typedef std::pair VT; + VT temp_; + void find_voxel() { + while (cvoxel_ != evoxel_ && grid_->get_voxel(*cvoxel_).empty()) { + ++cvoxel_; + } + if (cvoxel_ != evoxel_) { + curp_= grid_->get_voxel(*cvoxel_).begin(); + temp_= std::make_pair(*curp_, *cvoxel_); + } + } + public: + typedef VT value_type; + typedef const value_type& reference_type; + typedef const value_type* pointer_type; + + ParticleVoxelIterator(const Grid::IndexIterator& c, + const Grid::IndexIterator& e, + const Grid *grid): cvoxel_(c), + evoxel_(e), + grid_(grid) { + IMP_assert(grid_, "NULL grid"); + find_voxel(); + } + + void operator++() { + IMP_assert(cvoxel_ != evoxel_, "Too many increments"); + ++curp_; + if (curp_== grid_->get_voxel(*cvoxel_).end()) { + ++cvoxel_; + find_voxel(); + } + } + + reference_type operator*() const { + return temp_; + } + pointer_type operator->() const { + return &temp_; + } + bool operator==(const ParticleVoxelIterator &o) const { + return cvoxel_== o.cvoxel_ && (cvoxel_ == evoxel_ + && o.cvoxel_ == o.evoxel_ + || curp_ == o.curp_); + } + bool operator!=(const ParticleVoxelIterator &o) const { + return !operator==(o); + } + }; + ParticleVoxelIterator particle_voxels_begin() const { + return ParticleVoxelIterator(grid_.all_indexes_begin(), + grid_.all_indexes_end(), + &grid_); + } + ParticleVoxelIterator particle_voxels_end() const { + return ParticleVoxelIterator(grid_.all_indexes_end(), + grid_.all_indexes_end(), + &grid_); + } +}; + +} // namespace internal + +} // namespace IMP + +#endif Index: kernel/include/IMP/internal/AttributeTable.h =================================================================== --- kernel/include/IMP/internal/AttributeTable.h (revision 390) +++ kernel/include/IMP/internal/AttributeTable.h (working copy) @@ -37,8 +37,8 @@ IMP_check(contains(k), "Attribute \"" << k.get_string() << "\" not found in table.", - IndexException(std::string("Invalid attribute \"") - + k.get_string() + "\" requested")); + IndexException((std::string("Invalid attribute \"") + + k.get_string() + "\" requested").c_str())); return map_[k.get_index()]; } void insert(Key k, Value v); Index: kernel/include/IMP/internal/Grid3D.h =================================================================== --- kernel/include/IMP/internal/Grid3D.h (revision 390) +++ kernel/include/IMP/internal/Grid3D.h (working copy) @@ -96,6 +96,7 @@ IMP_COMPARISONS_1(cur_); This operator++() { + IMP_assert(*this != GridIndexIterator(), "Incrementing invalid iterator"); IMP_assert(cur_ >= lb_, "cur out of range"); IMP_assert(cur_ < ub_, "cur out of range"); int r[3]; @@ -121,14 +122,17 @@ return *this; } This operator++(int) { + IMP_assert(*this != GI(), "Incrementing invalid iterator"); This o= *this; operator++; return o; } reference_type operator*() const { + IMP_assert(*this != GridIndexIterator(), "Dereferencing invalid iterator"); return cur_; } pointer_type operator->() const { + IMP_assert(*this != GridIndexIterator(), "Dereferencing invalid iterator"); return &cur_; } }; @@ -206,7 +210,8 @@ return IndexType(index[0], index[1], index[2]); } - int snap(int dim, int v) const { + int snap(unsigned int dim, int v) const { + IMP_assert(dim <3, "Invalid dim"); if (v < 0) return 0; else if (v > d_[dim]) return d_[dim]; else return v; Index: kernel/include/IMP/internal/SConscript =================================================================== --- kernel/include/IMP/internal/SConscript (revision 390) +++ kernel/include/IMP/internal/SConscript (working copy) @@ -1,10 +1,12 @@ +Import('env') import os.path -Import('env') - -files = ['AttributeTable.h', 'graph_base.h', 'Grid3D.h', 'Vector.h', - 'ObjectContainer.h'] - -# Install the include files: -includedir = os.path.join(env['includedir'], 'IMP', 'internal') +files=[] +files.append( 'AttributeTable.h' ) +files.append( 'Grid3D.h' ) +files.append( 'ObjectContainer.h' ) +files.append( 'ParticleGrid.h' ) +files.append( 'Vector.h' ) +files.append( 'graph_base.h' ) +includedir = os.path.join(env['includedir'], 'IMP', 'internal' ) inst = env.Install(includedir, files) env.Alias('install', inst) Index: kernel/include/IMP/score_states/BondDecoratorListScoreState.h =================================================================== --- kernel/include/IMP/score_states/BondDecoratorListScoreState.h (revision 390) +++ kernel/include/IMP/score_states/BondDecoratorListScoreState.h (working copy) @@ -9,8 +9,8 @@ #define __IMP_BOND_DECORATOR_LIST_SCORE_STATE_H #include -#include "../BondedListScoreState.h" -#include "../../decorators/bond_decorators.h" +#include "BondedListScoreState.h" +#include "../decorators/bond_decorators.h" namespace IMP { Index: kernel/include/IMP/score_states/NonbondedListScoreState.h =================================================================== --- kernel/include/IMP/score_states/NonbondedListScoreState.h (revision 390) +++ kernel/include/IMP/score_states/NonbondedListScoreState.h (working copy) @@ -1,6 +1,6 @@ /** * \file NonbondedListScoreState.h - * \brief Allow iteration through pairs of a set of atoms. + * \brief Allow iteration through pairs of a set of particles. * * Copyright 2007-8 Sali Lab. All rights reserved. */ @@ -8,67 +8,93 @@ #ifndef __IMP_NONBONDED_LIST_SCORE_STATE_H #define __IMP_NONBONDED_LIST_SCORE_STATE_H +#include "../ScoreState.h" +#include "../internal/ParticleGrid.h" +#include "BondedListScoreState.h" + #include #include -#include "BondedListScoreState.h" -#include "MaxChangeScoreState.h" -#include "../ScoreState.h" -#include "../internal/Grid3D.h" namespace IMP { -class BondedListScoreState; -class MaxChangeScoreState; typedef std::vector BondedListScoreStates; -//! This class maintains a list of non-bonded pairs. +//! A base class for classes that maintain a list of non-bonded pairs. /** \ingroup restraint */ class IMPDLLEXPORT NonbondedListScoreState: public ScoreState { -protected: - float target_voxel_side_; +private: typedef std::vector > NBL; NBL nbl_; float last_cutoff_; - bool grid_valid_; - typedef internal::Grid3D Grid; - Grid grid_; - std::auto_ptr mc_; +protected: + unsigned int size_nbl() const {return nbl_.size();} - virtual void rescan(float cut); - void audit_particles(const Particles &ps) const; - void add_if_nonbonded(Particle *a, Particle *b); - void invalidate_nbl() { + //! rebuild the nonbonded list + /** \internal + */ + virtual void rebuild_nbl(float cut)=0; + + void clear_nbl() { last_cutoff_=-1; + nbl_.clear(); } - void create_grid(); - // Handle the particle against all the cells other than - // the one containing it. - void handle_particle(Particle *p, - const Grid::VirtualIndex& v, - float cut, - bool skip_lower); + struct AddToNBL; + friend struct AddToNBL; + + struct AddToNBL{ + NonbondedListScoreState *state_; + Particle *p_; + AddToNBL(NonbondedListScoreState *s, Particle *p): state_(s), + p_(p){} + void operator()(Particle *p) { + operator()(p_, p); + } + void operator()(Particle *a, Particle *b) { + state_->add_to_nbl(a,b); + } + }; + + //! tell the bonded lists what particles to pay attention to + void propagate_particles(const Particles &ps); + + void add_to_nbl(Particle *a, Particle *b) { + if (!a->get_is_active() || !b->get_is_active()) return; + bool found=false; + for (BondedListIterator bli= bonded_lists_begin(); + bli != bonded_lists_end(); ++bli) { + if ((*bli)->are_bonded(a, b)) { + found = true; + break; + } + } + if (!found) { + /*IMP_LOG(VERBOSE, "Found pair " << a->get_index() + << " " << b->get_index() << std::endl);*/ + nbl_.push_back(std::make_pair(a, b)); + } + } + public: /** - \param[in] ps A list of particles to use. - \param[in] tvs A suggested size for the voxel side. */ - NonbondedListScoreState(const Particles &ps, float tvs=1); - virtual ~NonbondedListScoreState(); + NonbondedListScoreState(); + IMP_CONTAINER(BondedListScoreState, bonded_list, BondedListIndex); // kind of evil hack to make the names better // perhaps the macro should be made more flexible typedef BondedListScoreStateIterator BondedListIterator; -public: + IMP_SCORE_STATE("0.5", "Daniel Russel"); - void set_particles(const Particles &ps); - + //! An iterator through nonbonded particles + /** The value type is an std::pair + */ typedef NBL::const_iterator NonbondedIterator; //! This iterates through the pairs of non-bonded particles @@ -76,24 +102,34 @@ apart than the cutoff. \note that this is highly unsafe and iteration can only be done once at a time. I will fix that eventually. + + \note The distance cutoff is the l2 norm between the 3D coordinates + of the Particles. It ignore any size that may be associated with + the particles. */ NonbondedIterator nonbonded_begin(Float cutoff =std::numeric_limits::max()) { IMP_assert(last_cutoff_== cutoff || last_cutoff_==-1, "Bad things are happening with the iterators in " << "NonbondedListScoreState"); - rescan(cutoff); + if (last_cutoff_ < cutoff) { + IMP_LOG(VERBOSE, "Rebuilding NBL cutoff " << cutoff << std::endl); + clear_nbl(); + rebuild_nbl(cutoff); + last_cutoff_=cutoff; + } return nbl_.begin(); } NonbondedIterator nonbonded_end(Float cutoff =std::numeric_limits::max()) { - rescan(cutoff); + if (last_cutoff_ < cutoff) { + IMP_LOG(VERBOSE, "Rebuilding NBL cutoff " << cutoff << std::endl); + clear_nbl(); + rebuild_nbl(cutoff); + last_cutoff_=cutoff; + } return nbl_.end(); } - - const Particles &get_particles() const { - return mc_->get_particles(); - } }; } // namespace IMP Index: kernel/include/IMP/score_states/SConscript =================================================================== --- kernel/include/IMP/score_states/SConscript (revision 390) +++ kernel/include/IMP/score_states/SConscript (working copy) @@ -1,13 +1,14 @@ +Import('env') import os.path -Import('env') - -files = ['BondedListScoreState.h', 'NonbondedListScoreState.h', - 'BipartiteNonbondedListScoreState.h', 'MaxChangeScoreState.h'] - - -# Install the include files: -includedir = os.path.join(env['includedir'], 'IMP', 'score_states') +files=[] +files.append( 'AllNonbondedListScoreState.h' ) +files.append( 'BipartiteNonbondedListScoreState.h' ) +files.append( 'BondDecoratorListScoreState.h' ) +files.append( 'BondedListScoreState.h' ) +files.append( 'MaxChangeScoreState.h' ) +files.append( 'NonbondedListScoreState.h' ) +files.append( 'NonbondedSphereListScoreState.h' ) +includedir = os.path.join(env['includedir'], 'IMP', 'score_states' ) inst = env.Install(includedir, files) env.Alias('install', inst) - -SConscript('bonded_lists/SConscript') +SConscript( 'bonded_lists/SConscript' ) Index: kernel/include/IMP/score_states/BipartiteNonbondedListScoreState.h =================================================================== --- kernel/include/IMP/score_states/BipartiteNonbondedListScoreState.h (revision 390) +++ kernel/include/IMP/score_states/BipartiteNonbondedListScoreState.h (working copy) @@ -8,10 +8,11 @@ #ifndef __IMP_BIPARTITE_NONBONDED_LIST_SCORE_STATE_H #define __IMP_BIPARTITE_NONBONDED_LIST_SCORE_STATE_H +#include "NonbondedListScoreState.h" +#include "../internal/ParticleGrid.h" + #include #include -#include "../ScoreState.h" -#include "NonbondedListScoreState.h" namespace IMP { @@ -21,29 +22,24 @@ //! This class maintains a list of non-bonded pairs between two sets. /** The class works roughly like the NonbondedListScoreState except only pairs where one particle is taken from each set are returned. + \ingroup restraint */ class IMPDLLEXPORT BipartiteNonbondedListScoreState: public NonbondedListScoreState { typedef NonbondedListScoreState P; std::auto_ptr mc_; + internal::ParticleGrid grid_; - virtual void rescan(float cut); - void set_particles(const Particles &ps0) { - // hide the parent's version - } + virtual void rebuild_nbl(float cut); public: BipartiteNonbondedListScoreState(const Particles &ps0, const Particles &ps1, float target_side); - virtual ~BipartiteNonbondedListScoreState(); IMP_SCORE_STATE("0.5", "Daniel Russel"); void set_particles(const Particles &ps0, const Particles &ps1); - const Particles &get_particles() const { - return mc_->get_particles(); - } }; } // namespace IMP Index: kernel/include/IMP/score_states/bonded_lists/BondDecoratorListScoreState.h =================================================================== --- kernel/include/IMP/score_states/bonded_lists/BondDecoratorListScoreState.h (revision 390) +++ kernel/include/IMP/score_states/bonded_lists/BondDecoratorListScoreState.h (working copy) @@ -1,57 +0,0 @@ -/** - * \file BondDecoratorListScoreState.h - * \brief Allow iteration through pairs of a set of atoms. - * - * Copyright 2007-8 Sali Lab. All rights reserved. - */ - -#ifndef __IMP_BOND_DECORATOR_LIST_SCORE_STATE_H -#define __IMP_BOND_DECORATOR_LIST_SCORE_STATE_H - -#include -#include "../BondedListScoreState.h" -#include "../../decorators/bond_decorators.h" - -namespace IMP -{ - -class BondDecoratorListScoreState; -typedef Index BondDecoratorListIndex; - -//! Keep track of particles that are connected by BondDecorator bonds. -/** We also may want to add lazy rescanning of bonds rather than doing - it every update call and a faster lookup of bonds. - \ingroup bond - */ -class IMPDLLEXPORT BondDecoratorListScoreState: public BondedListScoreState -{ - std::vector bonds_; - Particles ps_; -public: - //! Find bonds amongst the following points. - /** \param [in] ps The set of particles to use. - */ - BondDecoratorListScoreState(const Particles &ps); - virtual ~BondDecoratorListScoreState(){} - - virtual void set_particles(const Particles &ps); - - virtual bool are_bonded(Particle *a, Particle *b) const; - - virtual void update(); - - //! This iterates through the pairs of bonded particles - /** \note update() must be called first for this to be valid. - */ - typedef std::vector::const_iterator BondIterator; - BondIterator bonds_begin() const { - return bonds_.begin(); - } - BondIterator bonds_end() const { - return bonds_.end(); - } -}; - -} // namespace IMP - -#endif /* __IMP_BOND_DECORATOR_LIST_SCORE_STATE_H */ Index: kernel/include/IMP/score_states/bonded_lists/SConscript =================================================================== --- kernel/include/IMP/score_states/bonded_lists/SConscript (revision 390) +++ kernel/include/IMP/score_states/bonded_lists/SConscript (working copy) @@ -1,10 +0,0 @@ -import os.path -Import('env') - -files = ['BondDecoratorListScoreState.h'] - -# Install the include files: -includedir = os.path.join(env['includedir'], 'IMP', 'score_states', - 'bonded_lists') -inst = env.Install(includedir, files) -env.Alias('install', inst) Index: kernel/include/IMP/score_states/AllNonbondedListScoreState.h =================================================================== --- kernel/include/IMP/score_states/AllNonbondedListScoreState.h (revision 0) +++ kernel/include/IMP/score_states/AllNonbondedListScoreState.h (revision 0) @@ -0,0 +1,44 @@ +/** + * \file AllNonbondedListScoreState.h + * \brief Allow iteration through pairs of a set of particles. + * + * Copyright 2007-8 Sali Lab. All rights reserved. + */ + +#ifndef __IMP_ALLNONBONDED_LIST_SCORE_STATE_H +#define __IMP_ALLNONBONDED_LIST_SCORE_STATE_H + +#include "NonbondedListScoreState.h" + +#include +#include + +namespace IMP +{ + +//! This class maintains a list of non-bonded pairs. +/** The nonbonded list returns all nonboned pairs in the set of points. + \ingroup restraint + */ +class IMPDLLEXPORT AllNonbondedListScoreState: public NonbondedListScoreState +{ +protected: + internal::ParticleGrid grid_; + + virtual void rebuild_nbl(float cut); + +public: + /** + \param[in] ps A list of particles to use. + \param[in] tvs A suggested size for the voxel side. + */ + AllNonbondedListScoreState(const Particles &ps, float tvs=1); + + IMP_SCORE_STATE("0.5", "Daniel Russel"); + + void set_particles(const Particles &ps); +}; + +} // namespace IMP + +#endif /* __IMP_NONBONDED_LIST_SCORE_STATE_H */ Index: kernel/test/states/test_nonbonded_list.py =================================================================== --- kernel/test/states/test_nonbonded_list.py (revision 390) +++ kernel/test/states/test_nonbonded_list.py (working copy) @@ -36,7 +36,7 @@ d.set_x(random.uniform(0,10)) d.set_y(random.uniform(0,10)) d.set_z(random.uniform(0,10)) - s= IMP.NonbondedListScoreState(m.get_particles()) + s= IMP.AllNonbondedListScoreState(m.get_particles()) m.add_score_state(s) o= OnePair() r= IMP.NonbondedRestraint(s, o, 15) @@ -62,7 +62,7 @@ pts.append(p) for i in range(1,10): IMP.custom_bond(bds[i-1], bds[i], 1, .1) - s= IMP.NonbondedListScoreState(pts, 1) + s= IMP.AllNonbondedListScoreState(pts, 1) b= IMP.BondDecoratorListScoreState(pts) s.add_bonded_list(b) m.add_score_state(s) @@ -93,7 +93,7 @@ d.set_x(random.uniform(50,60)) d.set_y(random.uniform(50,60)) d.set_z(random.uniform(50,60)) - s= IMP.NonbondedListScoreState(ps) + s= IMP.AllNonbondedListScoreState(ps) m.add_score_state(s) o= OnePair() r= IMP.NonbondedRestraint(s, o, 15) Index: kernel/pyext/IMP.i =================================================================== --- kernel/pyext/IMP.i (revision 390) +++ kernel/pyext/IMP.i (working copy) @@ -146,8 +146,9 @@ %include "IMP/score_states/BondedListScoreState.h" %include "IMP/score_states/MaxChangeScoreState.h" %include "IMP/score_states/NonbondedListScoreState.h" +%include "IMP/score_states/AllNonbondedListScoreState.h" %include "IMP/score_states/BipartiteNonbondedListScoreState.h" -%include "IMP/score_states/bonded_lists/BondDecoratorListScoreState.h" +%include "IMP/score_states/BondDecoratorListScoreState.h" namespace IMP { %template(IntIndex) Index;