19 #ifndef ATOMPROBE_APTRANGES_H 20 #define ATOMPROBE_APTRANGES_H 101 std::vector<std::pair<std::string,std::string> > ionNames;
110 std::vector< std::map<std::string,size_t> > ionFormulas;
115 std::vector<RGBf> colours;
126 std::vector<std::pair<float,float> > ranges;
130 std::vector<unsigned int> ionIDs;
134 std::vector<float> rangeVolumes;
141 unsigned int errState;
146 std::vector<std::string> warnMessages;
155 unsigned int openRNG(FILE *fp);
159 static unsigned int readRNGHeader(FILE *fpRange,
160 std::vector<std::pair<std::string,std::string> > &strNames,
161 std::vector<RGBf> &fileColours,
unsigned int &numRanges,
162 unsigned int &numIons);
166 static unsigned int readRNGFreqTable(FILE *fpRange,
char *inBuffer,
167 const unsigned int numIons,
const unsigned int numRanges,
168 const std::vector<std::pair<std::string,std::string> > &names,
169 std::vector<std::string> &colHeaders,
170 std::vector<unsigned int > &tableEntries,
171 std::vector<std::pair<float,float> > &massData,
172 std::vector<std::string> &warnings);
174 unsigned int openDoubleRNG(FILE *fp);
179 unsigned int openRRNG(FILE *fp);
182 unsigned int openENV(FILE *fp);
185 static std::string envDropChargeState(
const std::string &strName);
188 static bool enforceConsistency;
195 bool open(
const char *rangeFile);
199 unsigned int openFormat(
const char *rangeFile,
unsigned int format);
204 static void getAllExts(std::vector<std::string> &exts);
216 enforceConsistency=shouldEnforce;
247 std::pair<float,float>
getRange(
unsigned int )
const;
270 unsigned int getIonID(
float mass)
const;
283 unsigned int getIonID(
const char *name,
bool useShortName=
true)
const;
287 void setIonID(
unsigned int range,
unsigned int newIonId);
298 std::map<std::string,size_t>
getIonFormula(
unsigned int ionID)
const;
305 void setIonFormula(
const std::string &name,
const std::map<std::string,size_t> &formula,
bool useShortName=
true);
308 void setIonFormula(
const unsigned int ionID,
const std::map<std::string,size_t> &formula);
323 void range(std::vector<IonHit> &ionHits)
const;
332 bool range(std::vector<IonHit> &ionHits,
333 const std::string &shortIonName);
339 bool rangeByID(std::vector<IonHit> &ionHits,
345 unsigned int rangeID);
348 void extractIons(
const std::vector<IonHit> &ionHits,
349 const std::vector<unsigned int> &ionIDs, std::vector<IonHit> &hits)
const;
354 std::string
getName(
unsigned int ionID,
bool shortName=
true)
const;
357 std::string
getName(
const IonHit &ion,
bool shortName=
true)
const;
365 void setIonLongName(
unsigned int ionID,
const std::string &newName);
371 bool isRanged(std::string shortName,
bool caseSensitive=
true);
387 bool moveRange(
unsigned int range,
bool limit,
float newMass);
389 bool moveBothRanges(
unsigned int range,
float newLow,
float newHigh);
396 unsigned int addRange(
float start,
float end,
unsigned int ionID);
400 unsigned int addIon(
const std::string &shortName,
const std::string &longName,
const RGBf &ionCol);
420 std::vector<std::pair<std::string,size_t> > &fragments);
424 std::vector<std::pair<std::string,size_t> > &fragments)
const;
435 float tolerance=0.5f)
const;
void range(std::vector< IonHit > &ionHits) const
Clips out ions that are not inside the rangefile's ranges.
std::string getName(unsigned int ionID, bool shortName=true) const
Get the short name or long name of a specified ionID.
void clearFormulas()
Erase any formula data.
static void decomposeIonNameToFormula(const std::string &name, std::map< std::string, size_t > &formula)
Break a given string down into a chemical formula with a count of each element.
RGBf getColour(unsigned int) const
Retrieve a given colour from the ion ID.
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.
void eraseRange(unsigned int rangeId)
Erase given range - this will reorder rangeIDs, so any ids you had previously will not longer be vali...
Data holder for colour as float.
float getRangeVolume(unsigned int rangeId) const
Obtain an ions volume, if we have it. Zero may indicate no ion volume specfied for that range...
bool makeSelfConsistent()
Modify range file to ensure self-consistency, by arbitrary heuristics.
bool moveBothRanges(unsigned int range, float newLow, float newHigh)
Move both of a range's masses to a new location.
bool setRangeEnd(unsigned int rangeID, float v)
Set the upper bound of the given range.
static bool decomposeIonNames(const std::string &name, std::vector< std::pair< std::string, size_t > > &fragments)
static void getAllExts(std::vector< std::string > &exts)
Grab a vector that contains all the extensions that are valid for range files.
unsigned int getIonID(const std::string &name) const
static std::string rangeTypeString(unsigned int rangeType)
Return the human readable name for the given RANGE_FORMAT value.
const unsigned int NUM_ELEMENTS
bool guessChargeState(unsigned int rangeId, const AtomProbe::AbundanceData &massTable, unsigned int &charge, float tolerance=0.5f) const
Guess the charge state for the ion that corresponds to the given range's midpoint.
static bool extensionIsRange(const char *ext)
is the extension string the same as that for a range file? I don't advocate this method, but it is convenient in a pinch.
void setIonFormula(const std::string &name, const std::map< std::string, size_t > &formula, bool useShortName=true)
Set ion formula using ion short or long name (if it is already set)
bool isSelfConsistent() const
Performs checks for self consistency.
unsigned int getNumRanges() const
Get the number of unique ranges.
void extractIons(const std::vector< IonHit > &ionHits, const std::vector< unsigned int > &ionIDs, std::vector< IonHit > &hits) const
Extract ion hit events in the specified ion ID values, from the input ion ionhit sequence.
void setColour(unsigned int, const RGBf &r)
Set the colour using the ion ID.
static void setEnforceConsistent(bool shouldEnforce=true)
Set whether the class will attempt to enfore consistency when running.
void rangeByRangeID(std::vector< IonHit > &ionHits, unsigned int rangeID)
Range the given ions, allowing only ions in the specified range. Input data will be modified to retur...
bool setRangeStart(unsigned int rangeID, float v)
Set the lower bound of the given range.
bool moveRange(unsigned int range, bool limit, float newMass)
Move a range's mass to a new location.
void setIonShortName(unsigned int ionID, const std::string &newName)
set the short name for a given ion
const RangeFile & operator=(const RangeFile &other)
void guessFormulas(bool overwrite=false)
Use heuristics to guess missing formula data from the shortname.
bool isRanged(float mass) const
Returns true if a specified mass is ranged.
Class to load abundance information for natural isotopes.
unsigned int getErrState() const
Obtain the error state last set for this rangefile.
std::pair< float, float > & getRangeByRef(unsigned int)
Retrieve the start and end of a given range as a pair(start,end)
bool decomposeIonById(unsigned int ionId, std::vector< std::pair< std::string, size_t > > &fragments) const
Perform decomposeIonNames(...) for a given ionID.
bool open(const char *rangeFile)
Open a specified range file - returns true on success.
This is a data holding class for POS file ions, from.
void setIonLongName(unsigned int ionID, const std::string &newName)
Set the long name for a given ion.
void rangeInvertable(std::vector< IonHit > &ionHits, bool invert)
Clips out ions that are inside the rangefile's ranges, if invert is false. If true, then reverse the set.
bool haveRangeVolumes() const
Return true if we have range volume data, false otherwise.
bool rangeByID(std::vector< IonHit > &ionHits, unsigned int range)
Clips out ions that don't lie in the specified range number.
Data storage and retrieval class for various range files.
static unsigned int detectFileType(const char *file)
Attempt to detect the file format of an unknown rangefile.
unsigned int openFormat(const char *rangeFile, unsigned int format)
Open a specified range file using a given file format. Returns nonzero on failure.
unsigned int getNumIons() const
Get the number of unique ions.
void swap(RangeFile &rng)
Swap a range file with this one.
unsigned int write(std::ostream &o, size_t format=RANGE_FORMAT_ORNL) const
Write the rangefile to the specified output stream (default ORNL format)
void setIonID(unsigned int range, unsigned int newIonId)
Set the ion ID for a given range.
std::string getErrString() const
Retrieve the translated error associated with the current range file state.
std::map< std::string, size_t > getIonFormula(unsigned int ionID) const
Get ion formula by ion ID.
unsigned int getRangeID(float mass) const
Get a range ID from mass to charge.
unsigned int addRange(float start, float end, unsigned int ionID)
Add a range to the rangefile. Returns ID number of added range.
void setRangeVolume(unsigned int rangeId, float newVolume)
Set the ion volume for a given range. If ion volumes are not tracked, these will be created...
std::pair< float, float > getRange(unsigned int) const
Retrieve the start and end of a given range as a pair(start,end)
void eraseIon(unsigned int ionId)
erase given ions and associated ranges)