Index: kernel/include/IMP/score_states/BipartiteNonbondedListScoreState.h =================================================================== --- kernel/include/IMP/score_states/BipartiteNonbondedListScoreState.h (revision 0) +++ kernel/include/IMP/score_states/BipartiteNonbondedListScoreState.h (revision 0) @@ -0,0 +1,47 @@ +/** + * \file BipartiteNonbondedListScoreState.h + * \brief Allow iteration through pairs of a set of atoms. + * + * Copyright 2007-8 Sali Lab. All rights reserved. + */ + +#ifndef __IMP_BIPARTITE_NONBONDED_LIST_SCORE_STATE_H +#define __IMP_BIPARTITE_NONBONDED_LIST_SCORE_STATE_H + +#include "../ScoreState.h" +#include "NonbondedListScoreState.h" +#include +#include + +namespace IMP +{ + +class BondedListScoreState; + +//! 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. + */ +class IMPDLLEXPORT BipartiteNonbondedListScoreState: + public NonbondedListScoreState +{ + typedef NonbondedListScoreState P; + Particles ps_; + + void rescan(); + void set_particles(const Particles &ps0) { + // hide the parent's version + } +public: + BipartiteNonbondedListScoreState(const Particles &ps0, + const Particles &ps1); + virtual ~BipartiteNonbondedListScoreState(); + + IMP_SCORE_STATE("0.5", "Daniel Russel"); + + void set_particles(const Particles &ps0, const Particles &ps1); +}; + +} // namespace IMP + +#endif /* __IMP_BIPARITENONBONDED_LIST_SCORE_STATE_H */ Index: kernel/src/score_states/BipartiteNonbondedListScoreState.cpp =================================================================== --- kernel/src/score_states/BipartiteNonbondedListScoreState.cpp (revision 0) +++ kernel/src/score_states/BipartiteNonbondedListScoreState.cpp (revision 0) @@ -0,0 +1,61 @@ +/** + * \file BipartiteNonbondedListScoreState.cpp + * \brief Allow iteration through pairs of a set of atoms. + * + * Copyright 2007-8 Sali Lab. All rights reserved. + */ + +#include "IMP/score_states/BipartiteNonbondedListScoreState.h" +#include "IMP/decorators/XYZDecorator.h" + +namespace IMP { + +BipartiteNonbondedListScoreState +::BipartiteNonbondedListScoreState(const Particles &ps0, + const Particles &ps1): + NonbondedListScoreState(ps0) +{ + set_particles(ps0, ps1); +} + +BipartiteNonbondedListScoreState::~BipartiteNonbondedListScoreState() +{ +} + +void BipartiteNonbondedListScoreState::rescan() { + nbl_.clear(); + for (unsigned int i = 0; i< ps_.size(); ++i) { + Particle *pi= ps_[i]; + for (unsigned int j = 0; j < P::ps_.size(); ++j) { + Particle *pj = P::ps_[j]; + P::add_if_nonbonded(pi,pj); + } + } +} + +void BipartiteNonbondedListScoreState::set_particles(const Particles &ps0, + const Particles &ps1) +{ + ps_=ps0; + P::ps_=ps1; + Particles aps(ps0); + aps.insert(aps.end(), ps1.begin(), ps1.end()); + + P::audit_particles(aps); + P::propagate_set_particles(aps); + + rescan(); +} + +void BipartiteNonbondedListScoreState::update() +{ + P::propagate_update(); + rescan(); +} + +void BipartiteNonbondedListScoreState::show(std::ostream &out) const +{ + out << "BipartiteNonbondedList" << std::endl; +} + +}