IMP  2.2.0
The Integrative Modeling Platform
SoapPairFilter.h
Go to the documentation of this file.
1 /**
2  * \file IMP/atom/SoapPairFilter.h
3  * \brief PairFilter for SOAP
4  *
5  * Copyright 2007-2014 IMP Inventors. All rights reserved.
6  *
7  */
8 
9 #ifndef IMPATOM_SOAP_PAIR_FILTER_H
10 #define IMPATOM_SOAP_PAIR_FILTER_H
11 
12 #include <IMP/atom/atom_config.h>
13 #include <IMP/score_functor/score_functor_config.h>
14 #include <IMP/PairPredicate.h>
15 #include <IMP/pair_macros.h>
16 #include "internal/soap_chain_separation.h"
17 #include "internal/soap_bond_separation.h"
18 
19 IMPATOM_BEGIN_NAMESPACE
20 
21 //! Filter atom pairs for SOAP.
22 /** Most SOAP potentials are trained using only a subset of particle pairs
23  (e.g. only pairs where the atoms are in different chains). This filter
24  can be used to exclude atom pairs not in that subset.
25  */
26 class SoapPairFilter : public PairPredicate {
27 #ifdef IMP_SCORE_FUNCTOR_USE_HDF5
28  internal::SoapBondSeparation bondsep_;
29  internal::SoapChainSeparation chainsep_;
30 #endif
31  public:
32  SoapPairFilter(std::string library) {
33 #ifdef IMP_SCORE_FUNCTOR_USE_HDF5
34  score_functor::internal::Hdf5File file_id(library);
35  bondsep_.read(file_id);
36  chainsep_.read(file_id);
37 #else
38  IMP_UNUSED(library);
39  IMP_THROW("Must configure IMP with HDF5 to use this class", ValueException);
40 #endif
41  }
42 
44  const kernel::ParticleIndexPair &p) const
45  IMP_OVERRIDE {
46 #ifdef IMP_SCORE_FUNCTOR_USE_HDF5
47  return !chainsep_.get_separation_ok(m, p) ||
48  !bondsep_.get_separation_ok(m, p);
49 #else
50  return true;
51 #endif
52  }
53 
55  kernel::Model *m, const kernel::ParticleIndexes &pis) const IMP_OVERRIDE {
57 #ifdef IMP_SCORE_FUNCTOR_USE_HDF5
58  if (chainsep_.enabled() || bondsep_.enabled()) {
59  // We touch the two parents (residue and chain) of each atom to
60  // determine chain separation; for bond separation we potentially touch
61  // other residues and atoms in the same chain as the inputs
62  // (to detect dissulfides) but this isn't currently handled here.
63  for (unsigned int i = 0; i < pis.size(); ++i) {
64  if (Atom::get_is_setup(m, pis[i])) {
65  Residue r = get_residue(Atom(m, pis[i]));
66  Hierarchy c = r.get_parent();
67  ret.push_back(r);
68  ret.push_back(c);
69  }
70  }
71  }
72 #endif
73  return ret;
74  }
75 
78 };
79 
80 IMPATOM_END_NAMESPACE
81 
82 #endif /* IMPATOM_SOAP_PAIR_FILTER_H */
Hierarchy get_parent() const
Import IMP/kernel/pair_macros.h in the namespace.
virtual int get_value_index(kernel::Model *m, const kernel::ParticleIndexPair &p) const
Compute the predicate and the derivative if needed.
ParticlesTemp get_particles(kernel::Model *m, const ParticleIndexes &ps)
#define IMP_UNUSED(variable)
Filter atom pairs for SOAP.
A class to store an fixed array of same-typed values.
Definition: base/Array.h:33
The standard decorator for manipulating molecular structures.
A decorator for a particle representing an atom.
Definition: atom/Atom.h:234
Import IMP/kernel/PairPredicate.h in the namespace.
#define IMP_PAIR_PREDICATE_METHODS(Name)
Define extra the functions needed for a PairPredicate.
#define IMP_OBJECT_METHODS(Name)
Define the basic things needed by any Object.
Abstract predicate function.
virtual kernel::ModelObjectsTemp do_get_inputs(kernel::Model *m, const kernel::ParticleIndexes &pis) const
A decorator for a residue.
Definition: Residue.h:133
#define IMP_THROW(message, exception_name)
Throw an exception with a message.
Residue get_residue(Atom d, bool nothrow=false)
Return the Residue containing this atom.
Class for storing model, its restraints, constraints, and particles.
Definition: kernel/Model.h:72