18 #ifndef ATOMPROBE_ABUNDANCE_H 19 #define ATOMPROBE_ABUNDANCE_H 58 ABUNDANCE_ERR_BAD_DOC=1,
59 ABUNDANCE_ERR_NO_CONTEXT,
60 ABUNDANCE_ERROR_BAD_VALUE,
61 ABUNDANCE_ERROR_FAILED_VALIDATION,
62 ABUNDANCE_ERROR_MISSING_NODE,
63 ABUNDANCE_ERROR_MISSING_ROOT_NODE,
64 ABUNDANCE_ERROR_WRONG_ROOT_NODE,
65 ABUNDANCE_ERROR_ENUM_END
71 std::vector<std::vector<ISOTOPE_ENTRY> > isotopeData;
74 void checkErrors()
const;
81 size_t open(
const char *file,
bool strict=
false);
84 static const char *getErrorText(
size_t errorCode);
87 size_t numIsotopes()
const;
89 size_t numElements()
const;
96 size_t symbolIndex(
const char *
symbol,
bool caseSensitive=
true)
const;
99 void getSymbolIndices(
const std::vector<std::string> &symbols,
100 std::vector<size_t> &indices)
const;
103 void getSymbolIndices(
const std::vector<std::pair<std::string,size_t> > &symbols,
104 std::vector<std::pair<size_t,unsigned int> > &indices)
const;
107 std::string
elementName(
size_t elemIdx )
const {
return isotopeData[elemIdx][0].symbol;}
110 size_t symbolIdxFromAtomicNumber(
size_t atomicNumber)
const;
113 std::string elementNames(
size_t start,
size_t end,
char separator=
',')
const;
119 void isotopeIndex(
size_t elem,
float mass,
size_t &isotopeIdx)
const;
122 void isotopeIndex(
size_t elem,
float mass,
float tolerance,
size_t &isotopeIdx)
const;
125 unsigned int getAtomicNumber(
size_t elemIdx)
const;
128 const std::vector<ISOTOPE_ENTRY> &isotopes(
size_t offset)
const;
138 void generateIsotopeDist(
const std::vector<size_t> &elementIdx,
139 const std::vector<size_t> &frequency,
140 std::vector<std::pair<float,float> > &massDist)
const;
147 void generateGroupedIsotopeDist(
const std::vector<size_t> &elementIdx,
148 const std::vector<size_t> &frequency, std::vector<std::pair<float,float> > &massDist,
149 float massTolerance)
const;
152 void generateSingleAtomDist(
size_t atomIdx,
unsigned int repeatCount,
153 std::vector<std::pair<float,float> > &massDist)
const;
156 float abundanceBetweenLimits(
const std::vector<size_t> &elemIdx,
157 const std::vector<size_t> &frequency,
158 float massStart,
float massEnd)
const;
161 const ISOTOPE_ENTRY &isotope(
size_t elementIdx,
size_t isotopeIdx)
const;
164 size_t getMajorIsotopeFromElemIdx(
size_t elementIdx)
const;
167 float getNominalMass(
size_t elementIdx)
const;
173 size_t getNearestCharge(
const std::vector<std::pair<size_t,size_t> > &molecule,
float targetMass,
size_t maxCharge)
const;
177 static bool runUnitTests();
std::string elementName(size_t elemIdx) const
Obtain the name of an element from its index.
Class to load abundance information for natural isotopes.