Residue class

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

Residue(std::string name)

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

Residue(std::string name, uint64_t resid)

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

const std::string &name() const

Get the name of the residue

optional<uint64_t> id() const

Get the residue identifier if it exists.

This function returna an chemfiles::optional value that is close to C++17 std::optional.

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

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.

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.

This function returns an chemfiles::optional value that is close to C++17 std::optional.