Loading...
Searching...
No Matches
pappso::MsRunDataSetTreeNode Class Reference

`#include <msrundatasettreenode.h>`

## Public Member Functions

| MsRunDataSetTreeNode ()
| MsRunDataSetTreeNode (const MsRunDataSetTreeNode &other)
| MsRunDataSetTreeNode (QualifiedMassSpectrumCstSPtr mass_spectrum_csp, MsRunDataSetTreeNode *parent_p=nullptr)
virtual | ~MsRunDataSetTreeNode ()
MsRunDataSetTreeNode & | operator= (const MsRunDataSetTreeNode &other)
void | setQualifiedMassSpectrum (QualifiedMassSpectrumCstSPtr qualified_mass_spectrum_csp)
QualifiedMassSpectrumCstSPtr | getQualifiedMassSpectrum () const
void | setParent (MsRunDataSetTreeNode *parent)
MsRunDataSetTreeNode * | getParent () const
bool | hasParent () const
void | size (std::size_t &cumulative_node_count) const
MsRunDataSetTreeNode * | findNode (std::size_t spectrum_index)
MsRunDataSetTreeNode * | findNode (QualifiedMassSpectrumCstSPtr mass_spectrum_csp)
void | flattenedView (std::vector< MsRunDataSetTreeNode * > &nodes, bool with_descendants=false)
void | flattenedViewChildrenOnly (std::vector< MsRunDataSetTreeNode * > &nodes, bool with_descendants=false)
void | flattenedViewMsLevelNodes (std::size_t ms_level, std::size_t depth, std::vector< MsRunDataSetTreeNode * > &nodes, bool with_descendants=false)
std::vector< MsRunDataSetTreeNode * > | productNodesByPrecursorMz (pappso_double precursor_mz, PrecisionPtr precision_ptr, std::vector< MsRunDataSetTreeNode * > &nodes)
std::vector< MsRunDataSetTreeNode * > | precursorIonNodesByPrecursorMz (pappso_double precursor_mz, PrecisionPtr precision_ptr, std::vector< MsRunDataSetTreeNode * > &nodes)
void | accept (MsRunDataSetTreeNodeVisitorInterface &visitor)
std::size_t | depth (std::size_t depth) const
QString | toString (bool with_data=false) const

## Private Attributes

QualifiedMassSpectrumCstSPtr | mcsp_massSpectrum = nullptr
MsRunDataSetTreeNode * | mp_parent = nullptr
std::vector< MsRunDataSetTreeNode * > | m_children

## Friends

class | MsRunDataSetTree

## Detailed Description

Definition at line 32 of file msrundatasettreenode.h.

## Constructor & Destructor Documentation

## MsRunDataSetTreeNode() [1/3]

pappso::MsRunDataSetTreeNode::MsRunDataSetTreeNode | ( |  | ) |

Definition at line 28 of file msrundatasettreenode.cpp.

{
}

Referenced by MsRunDataSetTreeNode(), MsRunDataSetTreeNode(), findNode(), findNode(), MsRunDataSetTree, operator=(), precursorIonNodesByPrecursorMz(), and setParent().

## MsRunDataSetTreeNode() [2/3]

pappso::MsRunDataSetTreeNode::MsRunDataSetTreeNode | ( | const MsRunDataSetTreeNode & | other | ) |

Definition at line 40 of file msrundatasettreenode.cpp.

: mcsp_massSpectrum(other.mcsp_massSpectrum), mp_parent(other.mp_parent)
{
for(auto &&node : other.m_children)
m_children.push_back(new MsRunDataSetTreeNode(*node));
}
pappso::MsRunDataSetTreeNode::mcsp_massSpectrum
QualifiedMassSpectrumCstSPtr mcsp_massSpectrum
Definition msrundatasettreenode.h:91
pappso::MsRunDataSetTreeNode::MsRunDataSetTreeNode
MsRunDataSetTreeNode()
Definition msrundatasettreenode.cpp:28
pappso::MsRunDataSetTreeNode::mp_parent
MsRunDataSetTreeNode * mp_parent
Definition msrundatasettreenode.h:93
pappso::MsRunDataSetTreeNode::m_children
std::vector< MsRunDataSetTreeNode * > m_children
Definition msrundatasettreenode.h:95

References MsRunDataSetTreeNode(), m_children, mcsp_massSpectrum, and mp_parent.

## MsRunDataSetTreeNode() [3/3]

pappso::MsRunDataSetTreeNode::MsRunDataSetTreeNode | ( | QualifiedMassSpectrumCstSPtr | mass_spectrum_csp,
|  | MsRunDataSetTreeNode * | parent_p = nullptr )

Definition at line 33 of file msrundatasettreenode.cpp.

: mcsp_massSpectrum(mass_spectrum_csp), mp_parent(parent_p)
{
}

References MsRunDataSetTreeNode(), mcsp_massSpectrum, and mp_parent.

## ~MsRunDataSetTreeNode()

pappso::MsRunDataSetTreeNode::~MsRunDataSetTreeNode | ( |  | ) |

virtual

Definition at line 48 of file msrundatasettreenode.cpp.

{
for(auto &&node : m_children)
delete node;
m_children.clear();
}

References m_children.

## Member Function Documentation

## accept()

void pappso::MsRunDataSetTreeNode::accept | ( | MsRunDataSetTreeNodeVisitorInterface & | visitor | ) |

Definition at line 363 of file msrundatasettreenode.cpp.

{
// qDebug() << "now calling visitor.visit(*this);";
visitor.visit(*this);
// qDebug() << "and now calling node->accept(visitor) for each child node.";
visitor.setNodesToProcessCount(m_children.size());
for(auto &&node : m_children)
node->accept(visitor);
}

References m_children, pappso::MsRunDataSetTreeNodeVisitorInterface::setNodesToProcessCount(), and pappso::MsRunDataSetTreeNodeVisitorInterface::visit().

Referenced by MsRunDataSetTree.

## depth()

std::size_t pappso::MsRunDataSetTreeNode::depth | ( | std::size_t | depth | ) | const

Definition at line 379 of file msrundatasettreenode.cpp.

{
// qDebug() << "Got depth:" << depth;
// If there are no children in this node, that is the end of the tree.
// Do not change anything an return.
if(!m_children.size())
{
// qDebug() << "No children, returning" << depth;
return depth;
}
// qDebug() << "There are" << m_children.size() << "children nodes";
// At this point we know we can already increment depth by one because
// we go down one level by iterating in the m_children vector of nodes.
// qDebug() << "Children found, incrementing depth to" << depth + 1;
std::size_t local_depth = depth + 1;
std::size_t tmp_depth = 0;
std::size_t greatest_depth = 0;
for(auto &node : m_children)
{
// qDebug() << "In the children for loop";
tmp_depth = node->depth(local_depth);
// qDebug() << "Got depth from iterated node:" << tmp_depth;
if(tmp_depth > greatest_depth)
greatest_depth = tmp_depth;
}
// qDebug() << "Returning:" << greatest_depth;
return greatest_depth;
}
pappso::MsRunDataSetTreeNode::depth
std::size_t depth(std::size_t depth) const
Definition msrundatasettreenode.cpp:379

References depth(), and m_children.

Referenced by depth(), flattenedViewMsLevelNodes(), and MsRunDataSetTree.

## findNode() [1/2]

MsRunDataSetTreeNode * pappso::MsRunDataSetTreeNode::findNode | ( | QualifiedMassSpectrumCstSPtr | mass_spectrum_csp | ) |

Definition at line 168 of file msrundatasettreenode.cpp.

{
// qDebug();
// Finding a node that contains a qualified mass spectrum requires checking if
// that node is not *this and if not if it is not one of the children. By
// essence, this work is recursive.
if(mass_spectrum_csp == mcsp_massSpectrum)
{
// qDebug() << "The mass spectrum's node is this node.";
return this;
}
// qDebug() << "Need to go searching in the children.";
for(auto &node : m_children)
{
MsRunDataSetTreeNode *iterNode = node->findNode(mass_spectrum_csp);
if(iterNode != nullptr)
{
// qDebug() << "Found the mass spectrum's node.";
return iterNode;
}
}
return nullptr;
}

References MsRunDataSetTreeNode(), m_children, and mcsp_massSpectrum.

## findNode() [2/2]

MsRunDataSetTreeNode * pappso::MsRunDataSetTreeNode::findNode | ( | std::size_t | spectrum_index | ) |

Definition at line 133 of file msrundatasettreenode.cpp.

{
// qDebug();
// Finding a node that contains a qualified mass spectrum that has been
// acquired at spectrum_index, requires checking if that node is not *this and
// if not if it is not one of the children. By essence, this work is
// recursive.
if(mcsp_massSpectrum->getMassSpectrumId().getSpectrumIndex() == spectrum_index)
{
// qDebug() << "The mass spectrum's node is this node.";
return this;
}
// qDebug() << "Need to go searching in the children.";
for(auto &node : m_children)
{
MsRunDataSetTreeNode *iterNode = node->findNode(spectrum_index);
if(iterNode != nullptr)
{
// qDebug() << "Found the mass spectrum's node.";
return iterNode;
}
}
return nullptr;
}

References MsRunDataSetTreeNode(), m_children, and mcsp_massSpectrum.

Referenced by pappso::MsRunDataSetTree::findNode(), pappso::MsRunDataSetTree::findNode(), MsRunDataSetTree, and precursorIonNodesByPrecursorMz().

## flattenedView()

void pappso::MsRunDataSetTreeNode::flattenedView | ( | std::vector< MsRunDataSetTreeNode * > & | nodes,
|  | bool | with_descendants = false )

Definition at line 202 of file msrundatasettreenode.cpp.

{
// Do store this.
nodes.push_back(this);
// And now the descendants.
if(with_descendants)
{
for(auto &&node : m_children)
{
node->flattenedView(nodes, with_descendants);
}
}
else
{
}
}

References m_children.

Referenced by flattenedViewMsLevelNodes(), and MsRunDataSetTree.

## flattenedViewChildrenOnly()

void pappso::MsRunDataSetTreeNode::flattenedViewChildrenOnly | ( | std::vector< MsRunDataSetTreeNode * > & | nodes,
|  | bool | with_descendants = false )

Definition at line 226 of file msrundatasettreenode.cpp.

{
// Do not store this, only this->m_children !
for(auto &&node : m_children)
node->flattenedView(nodes, with_descendants);
}

References m_children.

Referenced by MsRunDataSetTree.

## flattenedViewMsLevelNodes()

void pappso::MsRunDataSetTreeNode::flattenedViewMsLevelNodes | ( | std::size_t | ms_level,
|  | std::size_t | depth,
|  | std::vector< MsRunDataSetTreeNode * > & | nodes,
|  | bool | with_descendants = false )

Definition at line 238 of file msrundatasettreenode.cpp.

{
if(ms_level == (depth + 1))
{
// There we are. The ms_level that is asked matches the current depth of
// the node we are in.
flattenedView(nodes, with_descendants);
}
else if(ms_level > (depth + 1))
{
// We still do not have to store the nodes, because what we are
// searching is down the tree...
for(auto &&node : m_children)
{
node->flattenedViewMsLevelNodes(ms_level, depth + 1, nodes, with_descendants);
}
}
}
pappso::MsRunDataSetTreeNode::flattenedView
void flattenedView(std::vector< MsRunDataSetTreeNode * > &nodes, bool with_descendants=false)
Definition msrundatasettreenode.cpp:202

References depth(), flattenedView(), and m_children.

Referenced by MsRunDataSetTree.

## getParent()

MsRunDataSetTreeNode * pappso::MsRunDataSetTreeNode::getParent | ( |  | ) | const

Definition at line 95 of file msrundatasettreenode.cpp.

{
// qDebug();
return mp_parent;
}

References mp_parent.

Referenced by MsRunDataSetTree.

## getQualifiedMassSpectrum()

QualifiedMassSpectrumCstSPtr pappso::MsRunDataSetTreeNode::getQualifiedMassSpectrum | ( |  | ) | const

Definition at line 81 of file msrundatasettreenode.cpp.

{
return mcsp_massSpectrum;
}

References mcsp_massSpectrum.

Referenced by MsRunDataSetTree.

## hasParent()

bool pappso::MsRunDataSetTreeNode::hasParent | ( |  | ) | const

Definition at line 104 of file msrundatasettreenode.cpp.

{
// qDebug();
if(mp_parent != nullptr)
return true;
else
return false;
}

References mp_parent.

Referenced by MsRunDataSetTree.

## operator=()

MsRunDataSetTreeNode & pappso::MsRunDataSetTreeNode::operator= | ( | const MsRunDataSetTreeNode & | other | ) |

Definition at line 58 of file msrundatasettreenode.cpp.

{
if(this == &other)
return *this;
mcsp_massSpectrum = other.mcsp_massSpectrum;
mp_parent = other.mp_parent;
for(auto &&node : other.m_children)
m_children.push_back(new MsRunDataSetTreeNode(*node));
return *this;
}

References MsRunDataSetTreeNode(), m_children, mcsp_massSpectrum, and mp_parent.

Referenced by MsRunDataSetTree.

## precursorIonNodesByPrecursorMz()

std::vector< MsRunDataSetTreeNode * > pappso::MsRunDataSetTreeNode::precursorIonNodesByPrecursorMz | ( | pappso_double | precursor_mz,
|  | PrecisionPtr | precision_ptr,
|  | std::vector< MsRunDataSetTreeNode * > & | nodes )

Definition at line 309 of file msrundatasettreenode.cpp.

{
if(precision_ptr == nullptr)
throw ExceptionNotPossible(
QObject::tr("Fatal error at msrundatasettreenode.cpp "
"-- ERROR precision_ptr cannot be nullptr. "
"Program aborted."));
// Calculate the mz range using the tolerance.
pappso_double lower_mz = precursor_mz - (precision_ptr->delta(precursor_mz) / 2);
pappso_double upper_mz = precursor_mz + (precision_ptr->delta(precursor_mz) / 2);
// Check if this node matches the requirements.
pappso_double mz = mcsp_massSpectrum->getPrecursorMz();
if(mz != std::numeric_limits<double>::max())
{
if(mz >= lower_mz && mz <= upper_mz)
{
// We are iterating in a node that hold a mass spectrum that was
// acquired by fragmenting an ion matching the searched mz value. We
// can extract the spectrum index of that precursor mass spectrum and
// then get its corresponding node, that we'll store.
std::size_t precursor_spectrum_index = mcsp_massSpectrum->getPrecursorSpectrumIndex();
MsRunDataSetTreeNode *found_node = findNode(precursor_spectrum_index);
if(precursor_spectrum_index !=
found_node->mcsp_massSpectrum->getMassSpectrumId().getSpectrumIndex())
throw ExceptionNotPossible(
QObject::tr("Fatal error at msrundatasettreenode.cpp "
"-- ERROR precursor_spectrum_index bad value. "
"Program aborted."));
nodes.push_back(found_node);
}
}
// Now handle in the same way, but recursively, all the children of this node.
for(auto &&node : m_children)
{
node->precursorIonNodesByPrecursorMz(precursor_mz, precision_ptr, nodes);
}
return nodes;
}
pappso::MsRunDataSetTreeNode::findNode
MsRunDataSetTreeNode * findNode(std::size_t spectrum_index)
Definition msrundatasettreenode.cpp:133
pappso::Enums::PrecisionUnit::mz
@ mz
Definition types.h:101
pappso::pappso_double
double pappso_double
A type definition for doubles.
Definition types.h:60

References MsRunDataSetTreeNode(), pappso::PrecisionBase::delta(), findNode(), m_children, and mcsp_massSpectrum.

Referenced by MsRunDataSetTree.

## productNodesByPrecursorMz()

std::vector< MsRunDataSetTreeNode * > pappso::MsRunDataSetTreeNode::productNodesByPrecursorMz | ( | pappso_double | precursor_mz,
|  | PrecisionPtr | precision_ptr,
|  | std::vector< MsRunDataSetTreeNode * > & | nodes )

Definition at line 266 of file msrundatasettreenode.cpp.

{
if(precision_ptr == nullptr)
throw ExceptionNotPossible(
QObject::tr("Fatal error at msrundatasettreenode.cpp "
"-- ERROR precision_ptr cannot be nullptr. "
"Program aborted."));
// Check if this node matches the requirements.
pappso_double mz = mcsp_massSpectrum->getPrecursorMz();
if(mz != std::numeric_limits<double>::max())
{
// Calculate the mz range using the tolerance.
pappso_double lower_mz = precursor_mz - (precision_ptr->delta(precursor_mz) / 2);
pappso_double upper_mz = precursor_mz + (precision_ptr->delta(precursor_mz) / 2);
if(mz >= lower_mz && mz <= upper_mz)
{
// We are iterating in a node that holds a mass spectrum that was
// acquired by fragmenting an ion that matches the searched mz value.
nodes.push_back(this);
}
}
// Now handle in the same way, but recursively, all the children of this node.
for(auto &&node : m_children)
{
node->productNodesByPrecursorMz(precursor_mz, precision_ptr, nodes);
}
return nodes;
}

References pappso::PrecisionBase::delta(), m_children, and mcsp_massSpectrum.

Referenced by MsRunDataSetTree.

## setParent()

void pappso::MsRunDataSetTreeNode::setParent | ( | MsRunDataSetTreeNode * | parent | ) |

Definition at line 88 of file msrundatasettreenode.cpp.

{
mp_parent = parent;
}

References MsRunDataSetTreeNode(), and mp_parent.

Referenced by MsRunDataSetTree.

## setQualifiedMassSpectrum()

void pappso::MsRunDataSetTreeNode::setQualifiedMassSpectrum | ( | QualifiedMassSpectrumCstSPtr | qualified_mass_spectrum_csp | ) |

Definition at line 73 of file msrundatasettreenode.cpp.

{
mcsp_massSpectrum = qualified_mass_spectrum_csp;
}

References mcsp_massSpectrum.

Referenced by MsRunDataSetTree.

## size()

void pappso::MsRunDataSetTreeNode::size | ( | std::size_t & | cumulative_node_count | ) | const

Definition at line 116 of file msrundatasettreenode.cpp.

{
// First account for this node.
++cumulative_node_count;
// Then ask for each child to recursively account for themselves and their
// children.
for(auto &&node : m_children)
{
node->size(cumulative_node_count);
}
}

References m_children.

Referenced by MsRunDataSetTree.

## toString()

QString pappso::MsRunDataSetTreeNode::toString | ( | bool | with_data = false | ) | const

Definition at line 426 of file msrundatasettreenode.cpp.

{
QString text =
QString("mcsp_massSpectrum: %1 ; to string: %2 ; children: %3\n")
.arg(Utils::pointerToString(const_cast<QualifiedMassSpectrum *>(mcsp_massSpectrum.get())))
.arg(mcsp_massSpectrum->toString())
.arg(m_children.size());
if(with_data)
text += mcsp_massSpectrum->getMassSpectrumCstSPtr()->toString();
return text;
}
pappso::Utils::pointerToString
static QString pointerToString(const void *const pointer)
Definition utils.cpp:317

References m_children, mcsp_massSpectrum, and pappso::Utils::pointerToString().

Referenced by MsRunDataSetTree.

## Friends And Related Symbol Documentation

## MsRunDataSetTree

friend class MsRunDataSetTree

friend

Definition at line 34 of file msrundatasettreenode.h.

References MsRunDataSetTreeNode(), accept(), depth(), findNode(), flattenedView(), flattenedViewChildrenOnly(), flattenedViewMsLevelNodes(), getParent(), getQualifiedMassSpectrum(), hasParent(), MsRunDataSetTree, operator=(), precursorIonNodesByPrecursorMz(), productNodesByPrecursorMz(), setParent(), setQualifiedMassSpectrum(), size(), and toString().

Referenced by MsRunDataSetTree.

## Member Data Documentation

## m_children

std::vector<MsRunDataSetTreeNode *> pappso::MsRunDataSetTreeNode::m_children

private

Definition at line 95 of file msrundatasettreenode.h.

Referenced by MsRunDataSetTreeNode(), ~MsRunDataSetTreeNode(), accept(), pappso::MsRunDataSetTree::addMassSpectrum(), pappso::MsRunDataSetTree::addMassSpectrum(), depth(), findNode(), findNode(), flattenedView(), flattenedViewChildrenOnly(), flattenedViewMsLevelNodes(), operator=(), precursorIonNodesByPrecursorMz(), productNodesByPrecursorMz(), pappso::MsRunDataSetTree::productNodesByPrecursorSpectrumIndex(), size(), and toString().

## mcsp_massSpectrum

QualifiedMassSpectrumCstSPtr pappso::MsRunDataSetTreeNode::mcsp_massSpectrum = nullptr

private

Definition at line 91 of file msrundatasettreenode.h.

Referenced by MsRunDataSetTreeNode(), MsRunDataSetTreeNode(), findNode(), findNode(), getQualifiedMassSpectrum(), operator=(), precursorIonNodesByPrecursorMz(), pappso::MsRunDataSetTree::precursorNodeByProductSpectrumIndex(), productNodesByPrecursorMz(), setQualifiedMassSpectrum(), and toString().

## mp_parent

MsRunDataSetTreeNode* pappso::MsRunDataSetTreeNode::mp_parent = nullptr

private

Definition at line 93 of file msrundatasettreenode.h.

Referenced by MsRunDataSetTreeNode(), MsRunDataSetTreeNode(), getParent(), hasParent(), operator=(), and setParent().

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

- pappsomspp/core/msrun/msrundatasettreenode.h
- pappsomspp/core/msrun/msrundatasettreenode.cpp