1 Frequently asked questions (FAQ) {#faq}
2 ================================
6 # General {#faq_general}
8 ## How do I make my script run faster?
9 * Use specialized scores that don
't take a IMP::UnaryFunction argument, e.g.
10 replace the combination of IMP::core::SphereDistancePairScore and
11 IMP::core::HarmonicLowerBound with IMP::core::SoftSpherePairScore.
12 This reduces the number of virtual function calls during evaluation.
13 * Group similar restraints: e.g. replace a large number of
14 IMP::core::PairRestraint objects with a single
15 IMP::container::PairsRestraint. This also reduces the number of
17 * If you are programming in C++, you can use IMP::container::create_restraint()
18 to create a 'generic' restraint from a container and a pair score. This
19 removes a few more virtual function calls. If you are creating a restraint
20 with only a single particle or pair, use IMP::create_restraint() instead.
21 * Adjusting slack parameters on non-bonded lists: IMP::container::ClosePairContainer and IMP::core::ExcludedVolumeRestraint have "slack" parameters which adjust how often the non-bonded lists that are used are recomputed. Changing this parameter does not change the computed score, just how often the lists are updated. As a rough guideline, you want the slack to be larger than the total amount any particle moves in, say 20 evaluates (e.g. 20 MD steps). Experiment with changing the parameter to see what yields the best results or try the IMP::container::get_slack_estimate() function to try to estimate the best value to use automatically.
22 * Turn off or turn down logging: call IMP.set_log_level(IMP.SILENT)
23 or [recompile from the source code](@ref installation_source) passing
24 [-DIMP_MAX_LOG=SILENT to cmake](@ref cmake_further) (the latter will be
26 * Turn off runtime checks: call IMP.set_check_level(IMP.USAGE) or
27 IMP.set_check_level(IMP.NONE). Proceed very carefully, since with
28 runtime checks turned off, %IMP will not warn you if you do something
29 foolish - be sure to test your protocol first! Again, this will be more
31 [recompile from the source code](@ref installation_source) passing
32 [the -DIMP_MAX_CHECKS option to cmake](@ref cmake_further).
34 ## Why can't I clone a Particle?
35 The
short answer is:
"because no one knows how to do it safely". The complication is that the attributes of various particles may have relationships to one another that would be violated by the cloning process. For example, a Particle attribute in a Particle could be part of a bond, in which
case the bond particle must also be cloned and the attribute in the
new particle must point to the
new bond, or it could be a pointer to a particle which keeps track of all of the atoms in the system, in which
case the attribute value should be copied unchanged. A clone
function would have no way of knowing which should be done.
37 We suggest that you either
38 * call your initialization code more than once (to create two copies of the set of particles):
43 * use the `IMP.atom.
create_clone()` function to clone a molecular hierarchy.
47 ## What is the difference between the two functions for adding Particle attributes?
49 Restraints are not allowed to add/
remove/change attributes during restraint evaluation. The reason
for this is that the order of evaluation of restraints is not defined and
if restraints could change attributes, the score could depend on what order they were evaluated in. However, in certain cases it makes sense to cache computations in the particle so as to avoid having to recompute it next time (or in a different restraint). The (undocumented) method add_cache_attribute() provides a means to do that. The assumptions made are that
50 - any restraint that writes it should write an equivalent value
51 - it should get cleared if anything "significant" (a still vague concept) in the particle changes.
53 One usage of it currently is for the collision detection hierarchies used with rigid bodies. This hierarchy is computed on demand (for example when trying to evaluate a distance pair score on a pair of rigid bodies). Any time the rigid body is changed (eg the internal coordinates of a member are changed), the hierarchy gets cleared out and must be recomputed the next time.
55 ## What is this XXXEXPORT stuff?
56 In %IMP we only export selected functions and classes from the dynamically linked libraries. This is required
for things to work on Windows;
while it is not strictly necessary on other platforms it gives slightly faster code. As a result, each
class/
function that is used outside of the library needs to be marked with `IMPMODULENAMEEXPORT`. The rules
for doing
this are as follows:
58 * Any
class which has any methods which are implemented in a .cpp file must be declared as
59 `
class IMPMODULENAMEEXPORT ClassName:
public BaseClass{};`
60 * Any
function whose implementation is in a .cpp file must be declared as
61 `IMPMODULENAMEEXPORT ReturnType function_name(ArgumentType arg_name);`
62 * Non-
template functions defined entirely in a header must be declared
inline and **NOT** have an `IMPMODULENAMEEXPORT`
63 * Template functions or classes must **NOT** have `IMPMODULENAMEEXPORT` tags
65 Note that the pickiest compiler about
this is the Visual Studio compiler, so the fact that your code works with gcc does not guarantee it is correct.
67 ## How
do I use CPPCheck with %IMP
69 `cppcheck --enable=all . -I../debug/build/include --
template=
"{file}:{line}:{severity},{id},{message}"`
71 ## What does this mean? IMP.InternalException: Internal check failure: Particle BLAH missing required attributes for decorator MyDecorator
73 You are trying to decorate a particle before setting it up as an instance of the decorator. Use MyDecorator.setup_particle(blah)
74 and now you can decorate:
79 ## What files do I have to edit to connect C++ to Python?
81 The `swig.i-in` file that you will find under `mymodule/pyext`.
83 ## Why is SWIG telling me that a
class is not defined?
85 The order of the includes in the `swig.i-in` matters. If a
class uses code that is in another file, then you should put the latter first (note also that SWIG does not recursively follow `#include`s inside the `.h` files you `%include`). For example,
if your
class EnergyTermsRestraint requires EnergyTerms these lines in the `swig.i-in` must appear in
this order:
87 %include
"IMP/mymodule/EnergyTerms.h"
88 %include
"IMP/mymodule/EnergyTermsRestraint.h"
92 ## What are some resources for getting started with GIT?
93 One of its strengths is that there are excellent references, and Google will find you good answers to almost any question you have (many on [Stack Overflow](https:
94 * [An introduction to GitHub](http:
95 * [The official Git tutorial](https:
96 * [A light-weight explanation of most commands and workflows](https:
97 * a [git-flow teaser](http:
98 * the full [git-flow description](http:
99 * [10 Things I Hate About Git](https:
101 In addition, help
for any git command can be found by doing `git help <command>`.
103 ## What are the key git commands to use?
105 Show the branches in the log
106 `git log --graph --all --decorate`
108 Show which words change in the diff
109 `git diff --word-diff`
111 Clean out unknown files from repository
114 Use a nice interface when there are merge conflicts
Provenance create_clone(Provenance p)
Hierarchy create_protein(Model *m, std::string name, double target_radius, int number_of_residues, int first_residue_index=0, double volume=-1)