Holds an indexed list of bio-chemical elements.
More...
#include <OpenMS/CHEMISTRY/MASSDECOMPOSITION/IMS/IMSAlphabet.h>
List of all members.
Detailed Description
Holds an indexed list of bio-chemical elements.
Presents an indexed list of bio-chemical elements of type (or derived from type) Element. Due to indexed structure Alphabet can be used similar to std::vector, for example to add a new element to Alphabet function push_back(element_type) can be used. Elements or their properties (such as element's mass) can be accessed by index in a constant time. On the other hand accessing elements by their names takes linear time. Due to this and also the fact that Alphabet is 'heavy-weighted' (consisting of Element -s or their derivatives where the depth of derivation as well is undefined resulting in possibly 'heavy' access operations) it is recommended not use Alphabet directly in operations where fast access to Element 's properties is required. Instead consider to use 'light-weighted' equivalents, such as Weights.
Elements in Alphabet can be sorted by the Element 's properties: sequence and mass. When alphabet's data is loaded from file it is automatically sorted by mass. To load data from file default function load(str::string& fname) can be used. Then elements have to be stored in a flat file fname in a predefined format. To read more on this format, please,
- See also:
- AlphabetParser. If one wants to load data stored differently or in its own file format (i.e. xml) one has to define a new parser derived from
AlphabetParser and pass its pointer together with the file name to function load(const std::string& fname, AlphabetParser<>* parser). If there is any error happened while loading data, IOException will be thrown.
Member Typedef Documentation
Constructor & Destructor Documentation
Constructor with elements.
- Parameters:
-
| elements | Elements to be set |
Copy constructor.
- Parameters:
-
| alphabet | Alphabet to be assigned |
Member Function Documentation
Clears the alphabet data.
Removes the element with name name from the alphabet.
- Parameters:
-
| name | The name of the element to be removed from the alphabet. |
- Returns:
- A boolean indicating whether an element was removed (
true) or not (false).
Gets average masses of elements.
- Returns:
- Average masses of elements.
Gets the element with index index.
- Note:
- Operation takes constant time.
- Parameters:
-
- Returns:
- Element with the given index in alphabet
Gets mass of the element with an index index in alphabet.
- Parameters:
-
| index | Index of the element. |
- Returns:
- Mass of the element.
- See also:
- getMass(const std::string& name)
Gets mono isotopic mass of the element with the symbol name. If there is no such element, throws an Exception::InvalidValue.
- Parameters:
-
| name | Symbol of the element. |
- Returns:
- Mass of the element, or if there are no element
- Exceptions:
-
- See also:
- getMass(size_type index)
Gets masses of elements isotopes given by isotope_index.
- Parameters:
-
| isotope_index | Index of isotope |
- Returns:
- Masses of elements isotopes with the given index.
Gets the symbol of the element with an index index in alphabet.
- Parameters:
-
- Returns:
- Name of the element.
| bool hasName |
( |
const name_type & |
name |
) |
const |
Returns true if there is an element with symbol name in the alphabet, false - otherwise.
- Returns:
- True, if there is an element with symbol
name, false - otherwise.
| virtual void load |
( |
const std::string & |
fname, |
|
|
IMSAlphabetParser<> * |
parser | |
|
) |
| | [virtual] |
Loads the alphabet data from the file fname using parser. If there is no file fname found, throws an IOException.
- Parameters:
-
| fname | File name to be loaded. |
| parser | Parser to be used by loading. |
- Exceptions:
-
- See also:
- load(const std::string& fname)
-
AlphabetParser
| virtual void load |
( |
const std::string & |
fname |
) |
[virtual] |
Loads the alphabet data from the file fname using the default parser. If there is no file fname, throws an IOException.
- Parameters:
-
| fname | The file name to be loaded. |
- Exceptions:
-
- See also:
- load(const std::string& fname, AlphabetParser<>* parser)
Adds a new element element to the alphabet.
- Parameters:
-
Adds a new element with name name and mass value to the alphabet.
- Parameters:
-
| name | Name of the element to be added. |
| value | Mass of the element to be added. |
- See also:
- push_back(const element_type&)
Overwrites an element in the alphabet with the name with a new element constructed from the given name name and mass mass. If the parameter forced is set to true, a new element will be appended to the alphabet in the case the alphabet contains no element with the name name.
- Parameters:
-
| name | The name of the element that should be replaced in (or appended to) the alphabet. |
| mass | The new mass of the element in the alphabet. |
| forced | Indicates whether a new element should be created (if set to true) if there is no element with the name name or not (if set to false). |
Returns the alphabet size.
- Returns:
- The size of alphabet.
| virtual void sortByNames |
( |
|
) |
[virtual] |
| virtual void sortByValues |
( |
|
) |
[virtual] |
Member Data Documentation
Elements of the alphabet.