Residue

class Residue

A Residue is a group of atoms belonging to the same logical unit. They can be molecules, amino-acids in a protein, monomers in polymers, etc.

Iterating over a Residue gives the indexes of the atoms in the associated Topology.

Public Functions

explicit Residue(std::string name)

Create a new residue with a given name and no residue id.

Residue(std::string name, int64_t resid)

Create a new residue with a given name and residue id resid.

inline const std::string &name() const

Get the name of the residue.

inline optional<int64_t> id() const

Get the residue identifier, or nullopt if it does not exist.

inline size_t size() const

Get the size of the residue, i.e. the number of atoms in this residue.

void add_atom(size_t i)

Add an atom with index i to this residue

If the atom is already in the residue, this does nothing.

bool contains(size_t i) const

Check if the residue contains a given atom with index i

inline const property_map &properties() const

Get the map of properties asociated with this residue. This map might be iterated over to list the properties of the residue, or directly accessed.

inline void set(std::string name, Property value)

Set an arbitrary Property for this residue with the given name and value. If a property with this name already exist, it is replaced with the new value.

inline optional<const Property&> get(const std::string &name) const

Get the Property with the given name for this residue if it exists.

If no property with the given name is found, this function returns nullopt.

template<Property::Kind kind>
inline optional<typename property_metadata<kind>::type> get(const std::string &name) const

Get the Property with the given name for this residue if it exists, and check that it has the required kind.

If no property with the given name is found, this function returns nullopt.

If a property with the given name is found, but has a different kind, this function emits a warning and returns nullopt.