ProteoWizard
Public Member Functions | Private Attributes
pwiz::msdata::TextWriter Class Reference

#include <TextWriter.hpp>

List of all members.

Public Member Functions

 TextWriter (std::ostream &os, int depth=0, int arrayExampleCount=3)
 constructs a TextWriter for MSData types
TextWriter child ()
TextWriteroperator() (const std::string &text)
TextWriteroperator() (const CVParam &cvParam)
TextWriteroperator() (const UserParam &userParam)
template<typename object_type >
TextWriteroperator() (const std::string &label, const std::vector< object_type > &v)
TextWriteroperator() (const MSData &msd, bool metadata_only=false)
TextWriteroperator() (const CV &cv)
TextWriteroperator() (const FileDescription &fd)
TextWriteroperator() (const ParamContainer &paramContainer)
TextWriteroperator() (const FileContent &fileContent)
TextWriteroperator() (const SourceFile &sf)
TextWriteroperator() (const Contact &contact)
TextWriteroperator() (const ParamGroup &paramGroup)
TextWriteroperator() (const Sample &sample)
TextWriteroperator() (const InstrumentConfiguration &instrumentConfiguration)
TextWriteroperator() (const ComponentList &componentList)
TextWriteroperator() (const Component &component)
TextWriteroperator() (const Software &software)
TextWriteroperator() (const ProcessingMethod &processingMethod)
TextWriteroperator() (const DataProcessing &dp)
TextWriteroperator() (const Target &target)
TextWriteroperator() (const ScanSettings &as)
TextWriteroperator() (const Run &run, bool metadata_only=false)
TextWriteroperator() (const SpectrumList &spectrumList, bool metadata_only=false)
TextWriteroperator() (const SpectrumListPtr &p, bool metadata_only=false)
TextWriteroperator() (const ChromatogramList &chromatogramList, bool metadata_only=false)
TextWriteroperator() (const ChromatogramListPtr &p, bool metadata_only=false)
TextWriteroperator() (const Spectrum &spectrum)
TextWriteroperator() (const Chromatogram &chromatogram)
TextWriteroperator() (const Scan &scan)
TextWriteroperator() (const ScanWindow &window)
TextWriteroperator() (const BinaryDataArrayPtr &p)
TextWriteroperator() (const SelectedIon &selectedIon)
TextWriteroperator() (const Precursor &precursor)
TextWriteroperator() (const Product &product)
TextWriteroperator() (const ScanList &scanList)
template<typename object_type >
TextWriteroperator() (const boost::shared_ptr< object_type > &p)

Private Attributes

std::ostream & os_
int depth_
size_t arrayExampleCount_
std::string indent_

Detailed Description

Definition at line 40 of file TextWriter.hpp.


Constructor & Destructor Documentation

pwiz::msdata::TextWriter::TextWriter ( std::ostream &  os,
int  depth = 0,
int  arrayExampleCount = 3 
)
inline

constructs a TextWriter for MSData types

Parameters:
osThe ostream to write to.
depthThe number of indentations to prefix to each output line.
arrayExampleCountThe number of example values to print for arrays (i.e. m/z and intensity); -1 for unlimited

Definition at line 48 of file TextWriter.hpp.

: os_(os),
depth_(depth),
: (size_t) arrayExampleCount),
indent_(depth*2, ' ')
{}

Member Function Documentation

TextWriter pwiz::msdata::TextWriter::child ( )
inline

Definition at line 56 of file TextWriter.hpp.

References os_.

Referenced by operator()().

TextWriter& pwiz::msdata::TextWriter::operator() ( const std::string &  text)
inline

Definition at line 58 of file TextWriter.hpp.

References os_.

{
os_ << indent_ << text << std::endl;
return *this;
}
TextWriter& pwiz::msdata::TextWriter::operator() ( const CVParam cvParam)
inline

Definition at line 64 of file TextWriter.hpp.

References pwiz::data::CVParam::cvid, CVID_Unknown, pwiz::cv::cvTermInfo(), pwiz::cv::CVTermInfo::name, os_, pwiz::data::CVParam::units, pwiz::data::CVParam::unitsName(), and pwiz::data::CVParam::value.

{
os_ << indent_ << "cvParam: " << cvTermInfo(cvParam.cvid).name;
if (!cvParam.value.empty())
os_ << ", " << cvParam.value;
if (cvParam.units != CVID_Unknown)
os_ << ", " << cvParam.unitsName();
os_ << std::endl;
return *this;
}
TextWriter& pwiz::msdata::TextWriter::operator() ( const UserParam userParam)
inline

Definition at line 75 of file TextWriter.hpp.

References CVID_Unknown, pwiz::cv::cvTermInfo(), pwiz::data::UserParam::name, pwiz::cv::CVTermInfo::name, os_, pwiz::data::UserParam::type, pwiz::data::UserParam::units, and pwiz::data::UserParam::value.

{
os_ << indent_ << "userParam: " << userParam.name;
if (!userParam.value.empty()) os_ << ", " << userParam.value;
if (!userParam.type.empty()) os_ << ", " << userParam.type;
if (userParam.units != CVID_Unknown) os_ << ", " << cvTermInfo(userParam.units).name;
os_ << std::endl;
return *this;
}
template<typename object_type >
TextWriter& pwiz::msdata::TextWriter::operator() ( const std::string &  label,
const std::vector< object_type > &  v 
)
inline

Definition at line 86 of file TextWriter.hpp.

{
(*this)(label);
for_each(v.begin(), v.end(), child());
return *this;
}
TextWriter& pwiz::msdata::TextWriter::operator() ( const MSData msd,
bool  metadata_only = false 
)
inline

Definition at line 94 of file TextWriter.hpp.

References pwiz::msdata::MSData::accession, pwiz::msdata::MSData::cvs, pwiz::msdata::MSData::dataProcessingPtrs, pwiz::msdata::FileDescription::empty(), pwiz::msdata::Run::empty(), pwiz::msdata::MSData::fileDescription, pwiz::msdata::MSData::id, pwiz::msdata::MSData::instrumentConfigurationPtrs, pwiz::msdata::MSData::paramGroupPtrs, pwiz::msdata::MSData::run, pwiz::msdata::MSData::samplePtrs, pwiz::msdata::MSData::scanSettingsPtrs, pwiz::msdata::MSData::softwarePtrs, and pwiz::msdata::MSData::version().

{
(*this)("msdata:");
("id: " + msd.id);
if (!msd.accession.empty())
child()("accession: " + msd.accession);
if (!msd.version().empty())
child()("version: " + msd.version());
if (!msd.cvs.empty())
child()("cvList: ", msd.cvs);
if (!msd.fileDescription.empty())
child()(msd.fileDescription);
if (!msd.paramGroupPtrs.empty())
child()("paramGroupList: ", msd.paramGroupPtrs);
if (!msd.samplePtrs.empty())
child()("sampleList: " , msd.samplePtrs);
if (!msd.softwarePtrs.empty())
child()("softwareList: ", msd.softwarePtrs);
if (!msd.scanSettingsPtrs.empty())
child()("scanSettingsList: ", msd.scanSettingsPtrs);
if (!msd.instrumentConfigurationPtrs.empty())
child()("instrumentConfigurationList: ", msd.instrumentConfigurationPtrs);
if (!msd.dataProcessingPtrs.empty())
child()("dataProcessingList: ", msd.dataProcessingPtrs);
if (!msd.run.empty())
child()(msd.run, metadata_only);
return *this;
}
TextWriter& pwiz::msdata::TextWriter::operator() ( const CV cv)
inline

Definition at line 126 of file TextWriter.hpp.

References pwiz::cv::CV::fullName, pwiz::cv::CV::id, pwiz::cv::CV::URI, and pwiz::cv::CV::version.

{
(*this)("cv:");
("id: " + cv.id)
("fullName: " + cv.fullName)
("version: " + cv.version)
("URI: " + cv.URI);
return *this;
}
TextWriter& pwiz::msdata::TextWriter::operator() ( const FileDescription fd)
inline

Definition at line 137 of file TextWriter.hpp.

References pwiz::msdata::FileDescription::contacts, pwiz::msdata::FileDescription::fileContent, and pwiz::msdata::FileDescription::sourceFilePtrs.

{
(*this)("fileDescription:");
(fd.fileContent)
("sourceFileList: ", fd.sourceFilePtrs);
for_each(fd.contacts.begin(), fd.contacts.end(), child());
return *this;
}
TextWriter& pwiz::msdata::TextWriter::operator() ( const ParamContainer paramContainer)
inline

Definition at line 147 of file TextWriter.hpp.

References pwiz::data::ParamContainer::cvParams, pwiz::data::ParamContainer::paramGroupPtrs, and pwiz::data::ParamContainer::userParams.

{
for (std::vector<ParamGroupPtr>::const_iterator it=paramContainer.paramGroupPtrs.begin();
it!=paramContainer.paramGroupPtrs.end(); ++it)
(*this)("referenceableParamGroupRef: " + (*it)->id);
for_each(paramContainer.cvParams.begin(), paramContainer.cvParams.end(), *this);
for_each(paramContainer.userParams.begin(), paramContainer.userParams.end(), *this);
return *this;
}
TextWriter& pwiz::msdata::TextWriter::operator() ( const FileContent fileContent)
inline

Definition at line 157 of file TextWriter.hpp.

{
(*this)("fileContent:");
child()(static_cast<const ParamContainer&>(fileContent));
return *this;
}
TextWriter& pwiz::msdata::TextWriter::operator() ( const SourceFile sf)
inline

Definition at line 164 of file TextWriter.hpp.

References pwiz::msdata::SourceFile::id, pwiz::msdata::SourceFile::location, and pwiz::msdata::SourceFile::name.

{
(*this)("sourceFile:");
("id: " + sf.id)
("name: " + sf.name)
("location: " + sf.location)
(static_cast<const ParamContainer&>(sf));
return *this;
}
TextWriter& pwiz::msdata::TextWriter::operator() ( const Contact contact)
inline

Definition at line 175 of file TextWriter.hpp.

{
(*this)("contact:");
child()(static_cast<const ParamContainer&>(contact));
return *this;
}
TextWriter& pwiz::msdata::TextWriter::operator() ( const ParamGroup paramGroup)
inline

Definition at line 182 of file TextWriter.hpp.

References pwiz::data::ParamGroup::id.

{
(*this)("paramGroup:");
("id: " + paramGroup.id)
(static_cast<const ParamContainer&>(paramGroup));
return *this;
}
TextWriter& pwiz::msdata::TextWriter::operator() ( const Sample sample)
inline

Definition at line 191 of file TextWriter.hpp.

References pwiz::msdata::Sample::id, and pwiz::msdata::Sample::name.

{
(*this)("sample:");
("id: " + sample.id)
("name: " + sample.name)
(static_cast<const ParamContainer&>(sample));
return *this;
}
TextWriter& pwiz::msdata::TextWriter::operator() ( const InstrumentConfiguration instrumentConfiguration)
inline

Definition at line 201 of file TextWriter.hpp.

References pwiz::msdata::InstrumentConfiguration::componentList, pwiz::msdata::InstrumentConfiguration::id, and pwiz::msdata::InstrumentConfiguration::softwarePtr.

{
(*this)("instrumentConfiguration:");
("id: " + instrumentConfiguration.id)
(static_cast<const ParamContainer&>(instrumentConfiguration));
if (!instrumentConfiguration.componentList.empty())
child()(instrumentConfiguration.componentList);
if (instrumentConfiguration.softwarePtr.get() && !instrumentConfiguration.softwarePtr->empty())
child()("softwareRef: " + instrumentConfiguration.softwarePtr->id);
return *this;
}
TextWriter& pwiz::msdata::TextWriter::operator() ( const ComponentList componentList)
inline

Definition at line 214 of file TextWriter.hpp.

{
(*this)("componentList:");
for (size_t i=0; i < componentList.size(); ++i)
child()(componentList[i]);
return *this;
}
TextWriter& pwiz::msdata::TextWriter::operator() ( const Component component)
inline

Definition at line 222 of file TextWriter.hpp.

References pwiz::msdata::ComponentType_Analyzer, pwiz::msdata::ComponentType_Detector, pwiz::msdata::ComponentType_Source, boost::lexical_cast(), pwiz::msdata::Component::order, and pwiz::msdata::Component::type.

{
switch(component.type)
{
(*this)("source: ");
break;
(*this)("analyzer: ");
break;
(*this)("detector: ");
break;
default:
break;
}
("order: " + boost::lexical_cast<std::string>(component.order))
(static_cast<const ParamContainer&>(component));
return *this;
}
TextWriter& pwiz::msdata::TextWriter::operator() ( const Software software)
inline

Definition at line 244 of file TextWriter.hpp.

References pwiz::msdata::Software::id, and pwiz::msdata::Software::version.

{
(*this)("software:");
("id: " + software.id)
("version: " + software.version)
(static_cast<const ParamContainer&>(software));
return *this;
}
TextWriter& pwiz::msdata::TextWriter::operator() ( const ProcessingMethod processingMethod)
inline

Definition at line 254 of file TextWriter.hpp.

References boost::lexical_cast(), pwiz::msdata::ProcessingMethod::order, and pwiz::msdata::ProcessingMethod::softwarePtr.

{
(*this)("processingMethod:");
("order: " + boost::lexical_cast<std::string>(processingMethod.order));
if (processingMethod.softwarePtr.get() && !processingMethod.softwarePtr->empty())
child()("softwareRef: " + processingMethod.softwarePtr->id);
(static_cast<const ParamContainer&>(processingMethod));
return *this;
}
TextWriter& pwiz::msdata::TextWriter::operator() ( const DataProcessing dp)
inline

Definition at line 266 of file TextWriter.hpp.

References pwiz::msdata::DataProcessing::id, and pwiz::msdata::DataProcessing::processingMethods.

{
(*this)("dataProcessing:");
("id: " + dp.id);
for_each(dp.processingMethods.begin(), dp.processingMethods.end(), child());
return *this;
}
TextWriter& pwiz::msdata::TextWriter::operator() ( const Target target)
inline

Definition at line 275 of file TextWriter.hpp.

{
(*this)("target:");
child()(static_cast<const ParamContainer&>(target));
return *this;
}
TextWriter& pwiz::msdata::TextWriter::operator() ( const ScanSettings as)
inline

Definition at line 282 of file TextWriter.hpp.

References pwiz::msdata::ScanSettings::id, pwiz::msdata::ScanSettings::sourceFilePtrs, and pwiz::msdata::ScanSettings::targets.

{
(*this)("scanSettings:");
("id: " + as.id);
for_each(as.targets.begin(), as.targets.end(), child());
child()("sourceFileList: ", as.sourceFilePtrs);
return *this;
}
TextWriter& pwiz::msdata::TextWriter::operator() ( const Run run,
bool  metadata_only = false 
)
inline

Definition at line 292 of file TextWriter.hpp.

References pwiz::msdata::Run::chromatogramListPtr, pwiz::msdata::Run::defaultInstrumentConfigurationPtr, pwiz::msdata::Run::defaultSourceFilePtr, pwiz::msdata::Run::id, pwiz::msdata::Run::samplePtr, pwiz::msdata::Run::spectrumListPtr, and pwiz::msdata::Run::startTimeStamp.

{
(*this)("run:");
child()("id: " + run.id);
if (run.defaultInstrumentConfigurationPtr.get())
child()("defaultInstrumentConfigurationRef: " + run.defaultInstrumentConfigurationPtr->id);
if (run.samplePtr.get())
child()("sampleRef: " + run.samplePtr->id);
if (!run.startTimeStamp.empty())
child()("startTimeStamp: " + run.startTimeStamp);
child()(static_cast<const ParamContainer&>(run));
if (run.defaultSourceFilePtr.get())
child()("defaultSourceFileRef: " + run.defaultSourceFilePtr->id);
if (run.spectrumListPtr.get())
child()(run.spectrumListPtr, metadata_only);
if (run.chromatogramListPtr.get())
child()(run.chromatogramListPtr, metadata_only);
return *this;
}
TextWriter& pwiz::msdata::TextWriter::operator() ( const SpectrumList spectrumList,
bool  metadata_only = false 
)
inline

Definition at line 312 of file TextWriter.hpp.

References pwiz::msdata::SpectrumList::dataProcessingPtr(), pwiz::msdata::SpectrumList::size(), and pwiz::msdata::SpectrumList::spectrum().

{
std::string text("spectrumList (" + boost::lexical_cast<std::string>(spectrumList.size()) + " spectra)");
if (!metadata_only)
text += ":";
(*this)(text);
if (spectrumList.dataProcessingPtr().get())
child()(*spectrumList.dataProcessingPtr());
if (!metadata_only)
for (size_t index=0; index<spectrumList.size(); ++index)
(*spectrumList.spectrum(index, true));
return *this;
}
TextWriter& pwiz::msdata::TextWriter::operator() ( const SpectrumListPtr p,
bool  metadata_only = false 
)
inline

Definition at line 330 of file TextWriter.hpp.

{
return p.get() ? (*this)(*p, metadata_only) : *this;
}
TextWriter& pwiz::msdata::TextWriter::operator() ( const ChromatogramList chromatogramList,
bool  metadata_only = false 
)
inline

Definition at line 335 of file TextWriter.hpp.

References pwiz::msdata::ChromatogramList::chromatogram(), pwiz::msdata::ChromatogramList::dataProcessingPtr(), and pwiz::msdata::ChromatogramList::size().

{
std::string text("chromatogramList (" + boost::lexical_cast<std::string>(chromatogramList.size()) + " chromatograms)");
if (!metadata_only)
text += ":";
(*this)(text);
if (chromatogramList.dataProcessingPtr().get())
child()(*chromatogramList.dataProcessingPtr());
if (!metadata_only)
for (size_t index=0; index<chromatogramList.size(); ++index)
(*chromatogramList.chromatogram(index, true));
return *this;
}
TextWriter& pwiz::msdata::TextWriter::operator() ( const ChromatogramListPtr p,
bool  metadata_only = false 
)
inline

Definition at line 353 of file TextWriter.hpp.

{
return p.get() ? (*this)(*p, metadata_only) : *this;
}
TextWriter& pwiz::msdata::TextWriter::operator() ( const Spectrum spectrum)
inline

Definition at line 358 of file TextWriter.hpp.

References pwiz::msdata::Spectrum::binaryDataArrayPtrs, pwiz::msdata::Spectrum::dataProcessingPtr, pwiz::msdata::Spectrum::defaultArrayLength, pwiz::msdata::ScanList::empty(), pwiz::msdata::SpectrumIdentity::id, pwiz::msdata::SpectrumIdentity::index, boost::lexical_cast(), pwiz::msdata::Spectrum::precursors, pwiz::msdata::Spectrum::scanList, pwiz::msdata::Spectrum::sourceFilePtr, and pwiz::msdata::SpectrumIdentity::spotID.

{
(*this)("spectrum:");
("index: " + boost::lexical_cast<std::string>(spectrum.index))
("id: " + spectrum.id);
if (!spectrum.spotID.empty())
child()("spotID: " + spectrum.spotID);
if (spectrum.sourceFilePtr.get())
child()(spectrum.sourceFilePtr);
("defaultArrayLength: " + boost::lexical_cast<std::string>(spectrum.defaultArrayLength))
(spectrum.dataProcessingPtr)
(static_cast<const ParamContainer&>(spectrum));
if (!spectrum.scanList.empty())
child()(spectrum.scanList);
if (!spectrum.precursors.empty())
child()("precursorList: ", spectrum.precursors);
for_each(spectrum.binaryDataArrayPtrs.begin(), spectrum.binaryDataArrayPtrs.end(), child());
return *this;
}
TextWriter& pwiz::msdata::TextWriter::operator() ( const Chromatogram chromatogram)
inline

Definition at line 380 of file TextWriter.hpp.

References pwiz::msdata::Chromatogram::binaryDataArrayPtrs, pwiz::msdata::Chromatogram::dataProcessingPtr, pwiz::msdata::Chromatogram::defaultArrayLength, pwiz::msdata::ChromatogramIdentity::id, pwiz::msdata::ChromatogramIdentity::index, and boost::lexical_cast().

{
(*this)("chromatogram:");
("index: " + boost::lexical_cast<std::string>(chromatogram.index))
("id: " + chromatogram.id)
("defaultArrayLength: " + boost::lexical_cast<std::string>(chromatogram.defaultArrayLength))
(chromatogram.dataProcessingPtr)
(static_cast<const ParamContainer&>(chromatogram));
for_each(chromatogram.binaryDataArrayPtrs.begin(), chromatogram.binaryDataArrayPtrs.end(), child());
return *this;
}
TextWriter& pwiz::msdata::TextWriter::operator() ( const Scan scan)
inline

Definition at line 393 of file TextWriter.hpp.

References pwiz::msdata::Scan::instrumentConfigurationPtr, and pwiz::msdata::Scan::scanWindows.

{
(*this)("scan:");
if (scan.instrumentConfigurationPtr.get()) child()(*scan.instrumentConfigurationPtr);
child()(static_cast<const ParamContainer&>(scan));
if (!scan.scanWindows.empty())
child()("scanWindowList: ", scan.scanWindows);
return *this;
}
TextWriter& pwiz::msdata::TextWriter::operator() ( const ScanWindow window)
inline

Definition at line 403 of file TextWriter.hpp.

References pwiz::data::ParamContainer::cvParams.

{
(*this)("scanWindow:");
for_each(window.cvParams.begin(), window.cvParams.end(), child());
return *this;
}
TextWriter& pwiz::msdata::TextWriter::operator() ( const BinaryDataArrayPtr p)
inline

Definition at line 410 of file TextWriter.hpp.

References boost::lexical_cast().

{
if (!p.get() || p->empty()) return *this;
std::stringstream oss;
oss << "[" << boost::lexical_cast<std::string>(p->data.size()) << "] ";
oss.precision(12);
for (size_t i=0; i < arrayExampleCount_ && i < p->data.size(); i++)
oss << p->data[i] << " ";
if (p->data.size() > arrayExampleCount_)
oss << "...";
(*this)("binaryDataArray:");
child() (static_cast<const ParamContainer&>(*p));
if (p->dataProcessingPtr.get() && !p->dataProcessingPtr->empty())
child()(p->dataProcessingPtr);
if (!p->data.empty())
child()("binary: " + oss.str());
return *this;
}
TextWriter& pwiz::msdata::TextWriter::operator() ( const SelectedIon selectedIon)
inline

Definition at line 431 of file TextWriter.hpp.

{
(*this)("selectedIon:");
child()(static_cast<const ParamContainer&>(selectedIon));
return *this;
}
TextWriter& pwiz::msdata::TextWriter::operator() ( const Precursor precursor)
inline

Definition at line 438 of file TextWriter.hpp.

References pwiz::msdata::Precursor::activation, child(), pwiz::data::ParamContainer::empty(), pwiz::msdata::Precursor::isolationWindow, pwiz::msdata::Precursor::selectedIons, and pwiz::msdata::Precursor::spectrumID.

{
(*this)("precursor:");
("spectrumRef: " + precursor.spectrumID)
(static_cast<const ParamContainer&>(precursor));
if (!precursor.isolationWindow.empty())
{
child()("isolationWindow:");
child().child()(precursor.isolationWindow);
}
if (!precursor.selectedIons.empty())
{
child()("selectedIons:", precursor.selectedIons);
}
if (!precursor.activation.empty())
{
child()("activation:");
child().child()(precursor.activation);
}
return *this;
}
TextWriter& pwiz::msdata::TextWriter::operator() ( const Product product)
inline

Definition at line 465 of file TextWriter.hpp.

References child(), pwiz::data::ParamContainer::empty(), and pwiz::msdata::Product::isolationWindow.

{
(*this)("product:");
if (!product.isolationWindow.empty())
{
child()("isolationWindow:");
child().child()(product.isolationWindow);
}
return *this;
}
TextWriter& pwiz::msdata::TextWriter::operator() ( const ScanList scanList)
inline

Definition at line 478 of file TextWriter.hpp.

References pwiz::msdata::ScanList::scans.

{
(*this)
(static_cast<const ParamContainer&>(scanList))
("scanList:", scanList.scans);
return *this;
}
template<typename object_type >
TextWriter& pwiz::msdata::TextWriter::operator() ( const boost::shared_ptr< object_type > &  p)
inline

Definition at line 488 of file TextWriter.hpp.

{
return p.get() ? (*this)(*p) : *this;
}

Member Data Documentation

std::ostream& pwiz::msdata::TextWriter::os_
private

Definition at line 495 of file TextWriter.hpp.

int pwiz::msdata::TextWriter::depth_
private

Definition at line 496 of file TextWriter.hpp.

size_t pwiz::msdata::TextWriter::arrayExampleCount_
private

Definition at line 497 of file TextWriter.hpp.

std::string pwiz::msdata::TextWriter::indent_
private

Definition at line 498 of file TextWriter.hpp.


The documentation for this class was generated from the following file: