1 Writing
new code {#new_code}
4 The easiest way to start writing
new functions and classes is to
5 create a
new module
using the [make-module.py](\ref dev_tools_make_module)
6 script. This creates a
new module in the `modules` directory. Alternatively,
7 you can simply use the `scratch` module.
9 If, instead, you choose to add code to an existing module, you need to
10 consult with the maintainer of that module. Their GitHub username
11 can be found on the [module main page](../ref/namespaces.html).
13 Either way, we highly recommend doing
this in a [git clone](@ref devsetup),
14 as described earlier, then
using [git](@ref faq_git) to keep track of
17 When designing the
interface for your new code, you should
19 - think about what exactly is the functionality you want to contribute. Is
20 it a single function, a single Restraint, a set of related classes
23 - search %IMP
for similar functionality and,
if there is any, adapt
24 the existing
interface for your purposes. (It might make more sense to
25 modify the existing code in cooperation with its author.) For example,
27 IMP::atom::read_pdb() and IMP::atom::write_pdb() functions provide
28 templates that should be used for the design of any functions that
29 create particles from a file or write particles to a file. Since
33 endpoints of a segment, any new object which defines similar
34 point-based geometry should do likewise.
36 - think about how other people are likely to use the code. For
37 example, not all molecular hierarchies have atoms as their leaves,
38 so make sure your code searches for arbitrary
42 - look for easy ways of splitting the functionality into pieces. It
43 generally makes sense, for %example, to split selection of the
44 particles from the action taken on them, either by accepting a
46 IMP::ParticleIndexes object. Similarly, rather than writing a Restraint,
50 You are encouraged to post to the
52 answering these questions as it can be hard to grasp all the various
53 pieces of functionality already in the repository.
55 See also the IMP::example module, which contains many examples of writing
56 new %IMP functionality in C++ or Python.
57 You may also want to read [the design example](\ref design_example) for
58 some suggestions on how to go about implementing your functionality
const Vector3D & get_point(unsigned int i) const