48 ASSERT(p.first < p.second);
49 return (p.first <= m && p.second >=m);
56 const RangeFile &rng,
unsigned int rangeId)
68 if(symbolIdx ==(
size_t)-1)
70 vector<pair<string,size_t> > namedComponent;
79 for(
size_t uj=0;uj<namedComponent.size();uj++)
81 symbolIdx=massTable.
symbolIndex(namedComponent[uj].first.c_str());
82 if( symbolIdx == (
size_t)-1)
90 mol.
components.push_back(make_pair(symbolIdx,namedComponent[uj].second));
95 mol.
components.push_back(make_pair(symbolIdx,1));
102 float massTolerance,
unsigned int maxChargeState,
103 unsigned int maxComponents,std::vector<bool> &badRanges)
116 size_t totalComponents;
118 for(
size_t uk=0;uk<rngMol.
components.size();uk++)
119 totalComponents+=rngMol.
components[uk].second;
123 if(totalComponents > maxComponents)
127 pair<float,float> thisRange;
131 thisRange.first-=massTolerance;
132 thisRange.second+=massTolerance;
136 vector<size_t> elements;
137 vector<size_t> composition;
138 for(
size_t uj=0;uj<rngMol.
components.size();uj++)
140 for(
size_t uk=0;uk<rngMol.
components[uj].second; uk++)
142 elements.push_back(rngMol.
components[uj].first);
143 composition.push_back(1);
148 vector<pair<float,float> > isotopeDist;
155 for(
size_t uj=1;uj<=maxChargeState;uj++)
157 for(
size_t um=0;um<isotopeDist.size();um++)
159 if(
pairContains(thisRange,isotopeDist[um].first/(
float)uj))
179 bool testRangeChecking()
185 if(natData.
open(
"naturalAbundance.xml"))
192 auto ionIdTi=rng.
addIon(
"Ti",
"Ti",c);
193 auto ionIdH = rng.
addIon(
"H",
"H",c);
196 auto rngH=rng.
addRange(0.95,1.05,ionIdH);
197 auto rngTi=rng.
addRange(23.9,24.1,ionIdTi);
200 vector<bool> badRanges;
204 TEST(badRanges.size() == 2,
"Check bad range count");
206 TEST((badRanges[0] ==
false) && (badRanges[1] ==
false)
207 ,
"Ranges should be OK");
213 TEST((badRanges[rngH] ==
false) && (badRanges[rngTi] ==
true)
214 ,
"Ranges should be wrong");
size_t symbolIndex(const char *symbol, bool caseSensitive=true) const
Return the element's position in table, starting from 0.
std::string getName(unsigned int ionID, bool shortName=true) const
Get the short name or long name of a specified ionID.
unsigned int getIonID(float mass) const
Get the ion's ID from a specified mass.
unsigned int addIon(const std::string &shortName, const std::string &longName, const RGBf &ionCol)
Add the ion to the database returns ion ID if successful, -1 otherwise.
Data holder for colour as float.
bool moveBothRanges(unsigned int range, float newLow, float newHigh)
Move both of a range's masses to a new location.
void generateIsotopeDist(const std::vector< size_t > &elementIdx, const std::vector< size_t > &frequency, std::vector< std::pair< float, float > > &massDist) const
Compute the mass-probability distribution for the grouped set of ions.
static bool decomposeIonNames(const std::string &name, std::vector< std::pair< std::string, size_t > > &fragments)
unsigned int getNumRanges() const
Get the number of unique ranges.
vector< pair< size_t, size_t > > components
void checkMassRangingCorrectness(const AtomProbe::RangeFile &rng, AtomProbe::AbundanceData &massTable, float massTolerance, unsigned int maxChargeState, unsigned int maxComponents, std::vector< bool > &badRanges)
Ensure that each mass given spans a peak that should exist.
size_t open(const char *file, bool strict=false)
Attempt to open the abundance data file, return 0 on success, nonzero on failure. ...
Class to load abundance information for natural isotopes.
bool pairContains(const pair< float, float > &p, float m)
Data storage and retrieval class for various range files.
RANGE_MOLECULE getRangeMolecule(const AbundanceData &massTable, const RangeFile &rng, unsigned int rangeId)
unsigned int addRange(float start, float end, unsigned int ionID)
Add a range to the rangefile. Returns ID number of added range.
std::pair< float, float > getRange(unsigned int) const
Retrieve the start and end of a given range as a pair(start,end)