Difference between revisions of "MSL Objects:AtomContainer"
(→Description) |
(→Get atoms (and check for their existance)) |
||
Line 28: | Line 28: | ||
*Atoms can also be obtained by "atom id" ("chain,residue number,atom name", such as "A,37,CB") either with the () operator or a getAtom function. | *Atoms can also be obtained by "atom id" ("chain,residue number,atom name", such as "A,37,CB") either with the () operator or a getAtom function. | ||
<source lang="cpp"> | <source lang="cpp"> | ||
− | Atom & operator | + | Atom & operator[](std::string _atomId); // use argument as ["A,7,CA"]; |
Atom & getAtom(std::string _atomId); | Atom & getAtom(std::string _atomId); | ||
</source> | </source> | ||
Line 43: | Line 43: | ||
---- | ---- | ||
+ | |||
==== Add and remove atoms ==== | ==== Add and remove atoms ==== | ||
The AtomContainers can add atoms at the end (addAtom function) with functions such as the following (see the source for more) | The AtomContainers can add atoms at the end (addAtom function) with functions such as the following (see the source for more) |
Revision as of 00:13, 17 March 2010
Contents
Description
The AtomContainer is the simpler of the two molecular objects of MSL. It is essentially the equivalent of an array of atoms, without any internal representation of chains and residues, such as is present in the System. The AtomContainer also lacks the support for energy calculations. Because of its simplicity it has less of an overhead and it should be used every time that the advanced features of the System are not necessary.
Constructor
- It can take a vector of atom pointers (AtomPointerVector).
AtomContainer(const AtomPointerVector & _atoms);
- Note: the AtomContainer will create copies of those atoms, and it won't refer to the same memory of the original AtomPointerVector.
Reading and writing coordinates from/to file
- The AtomContainer can read and write PDB files. The functions return true if the I/O operation was succesful.
bool readPdb(std::string _filename);
bool writePdb(std::string _filename);
Get atoms (and check for their existance)
- The AtomContaners can act as an array. It has a .size() function that returns the number of atoms and a braket operator that returns the i-th atom (or using the getAtom function).
unsigned int size() const;
Atom & operator[](unsigned int _n);
Atom & getAtom(unsigned int _n);
- Atoms can also be obtained by "atom id" ("chain,residue number,atom name", such as "A,37,CB") either with the () operator or a getAtom function.
Atom & operator[](std::string _atomId); // use argument as ["A,7,CA"];
Atom & getAtom(std::string _atomId);
- To avoid errors, one can check for the estance of an atom. The getLastFoundAtom function return the atom without performing a second lookup.
bool atomExists(std::string _atomId);
Atom & getLastFoundAtom();
- All atoms can be obtained as an AtomPointerVector.
AtomPointerVector & getAtoms();
- See the example programs described below for usage.
Add and remove atoms
The AtomContainers can add atoms at the end (addAtom function) with functions such as the following (see the source for more)
void addAtom(const Atom & _atom);
void addAtom(std::string _atomId, const CartesianPoint & _coor=CartesianPoint(0.0, 0.0, 0.0));
Insert atoms in the middle (after skipping a number of positions
void insertAtom(const Atom & _atom, unsigned int _skipPositions);
void insertAtom(std::string _atomId, const CartesianPoint & _coor, unsigned int _skipPositions);
... and remove atoms (the atom id is in the form "chain,residue number,atom name", such as "A,37,CB"
bool removeAtom(std::string _atomId);
Save sets of coordinates (a conformation) to a buffer and retrieve them
- The current conformation of the molecule (all coordinates) can be saved to a buffer. Saved buffers can be restored later (for example, to undo an unfavorable conformational move)
void saveCoor(std::string _coordName);
bool applySavedCoor(std::string _coordName);
void clearSavedCoor();
Usage examples
The following tutorials offer examples on how to use the AtomContainer: