24#ifndef _MSDATAANALYZER_HPP_
25#define _MSDATAANALYZER_HPP_
38using namespace msdata;
114template <
typename analyzer_type>
118 static const char*
id() {
return "analyzer_traits not specialized";}
121 static const char*
description() {
return typeid(analyzer_type).name();}
127 static std::vector<std::string>
argsUsage() {
return std::vector<std::string>();}
135 public std::vector<MSDataAnalyzerPtr>
192template <
typename value_type>
193bool parseRange(
const std::string &desiredArg,
const std::string& text, std::pair<value_type,value_type>& result,
const std::string& callerName)
195 if (!text.compare(0,desiredArg.size()+1,desiredArg+
"="))
197 std::string val = text.substr(desiredArg.size()+1);
198 std::string::size_type indexPairSeperator = val.find(
',');
199 if (std::string::npos == indexPairSeperator)
201 indexPairSeperator = val.find(
'-');
202 if (0==indexPairSeperator)
204 indexPairSeperator = string::npos;
207 int bracket = (val[0] ==
'[')?1:0;
209 ((bracket!=0) && val[val.size()-1] !=
']'))
211 std::cerr <<
"[" << callerName <<
"] Unable to parse range: " << text << endl;
217 if (std::string::npos == indexPairSeperator)
219 std::string first = val.substr(bracket,val.size()-(2*bracket));
220 result.first = result.second = lexical_cast<value_type>(first);
224 std::string first = val.substr(bracket, indexPairSeperator-bracket);
225 std::string second = val.substr(indexPairSeperator+1, val.size()-indexPairSeperator-(1+bracket));
226 result.first = lexical_cast<value_type>(first);
228 result.second = lexical_cast<value_type>(second);
230 result.second = numeric_limits<value_type>::max();
234 catch (boost::bad_lexical_cast&)
236 std::cerr <<
"[" << callerName <<
"] Unable to parse range: " << text << endl;
242template <
typename value_type>
243bool parseValue(
const std::string &desiredArg,
const std::string& text, value_type& result,
const std::string& callerName)
245 if (!text.compare(0,desiredArg.size()+1,desiredArg+
"="))
247 std::string val = text.substr(desiredArg.size()+1);
250 std::cerr <<
"[" << callerName <<
"] Unable to parse value: " << text << endl;
256 result = lexical_cast<value_type>(val);
259 catch (boost::bad_lexical_cast&)
261 std::cerr <<
"[" << callerName <<
"] Unable to parse value: " << text << endl;
container of MSDataAnalyzer (composite pattern)
virtual void open(const DataInfo &dataInfo)
start analysis of the data
virtual void update(const DataInfo &dataInfo, const Spectrum &spectrum)
analyze a single spectrum
virtual void close(const DataInfo &dataInfo)
end analysis of the data
virtual UpdateRequest updateRequested(const DataInfo &dataInfo, const SpectrumIdentity &spectrumIdentity) const
ask analyzer if it wants an update
progress callback interface
virtual size_t iterationsPerCallback() const
virtual ~ProgressCallback()
virtual Status progress(size_t index, size_t size)
event generator for MSDataAnalyzer
MSDataAnalyzer & analyzer_
Status analyze(const MSDataAnalyzer::DataInfo &dataInfo, ProgressCallback *progressCallback=0) const
analyze a single MSData object, calling back to client if requested
MSDataAnalyzerDriver(MSDataAnalyzer &analyzer)
instantiate with an MSDataAnalyzer
Interface for MSData analyzers.
virtual UpdateRequest updateRequested(const DataInfo &dataInfo, const SpectrumIdentity &spectrumIdentity) const
ask analyzer if it wants an update
virtual void close(const DataInfo &dataInfo)
end analysis of the data
virtual ~MSDataAnalyzer()
virtual void open(const DataInfo &dataInfo)
start analysis of the data
virtual void update(const DataInfo &dataInfo, const Spectrum &spectrum)
analyze a single spectrum
boost::shared_ptr< MSDataAnalyzer > MSDataAnalyzerPtr
bool parseValue(const std::string &desiredArg, const std::string &text, value_type &result, const std::string &callerName)
bool parseRange(const std::string &desiredArg, const std::string &text, std::pair< value_type, value_type > &result, const std::string &callerName)
information about the data to be analyzed
std::string outputDirectory
std::string sourceFilename
DataInfo(const MSData &_msd)
This auxilliary class should be specialized for MSDataAnalyzers whose instantiation is controlled by ...
static const char * argsFormat()
format of args string
static std::vector< std::string > argsUsage()
description of args string options
static const char * description()
description of the analyzer
static const char * id()
string identifier for the analyzer
This is the root element of ProteoWizard; it represents the mzML element, defined as: intended to cap...
The structure that captures the generation of a peak list (including the underlying acquisitions)
Identifying information for a spectrum.