libpappsomspp
Library for mass spectrometry
Loading...
Searching...
No Matches
pappso::MassSpecTracePlotWidget Class Reference

#include <massspectraceplotwidget.h>

Inheritance diagram for pappso::MassSpecTracePlotWidget:
pappso::BaseTracePlotWidget pappso::BasePlotWidget

Signals

void keyPressEventSignal (const MassSpecTracePlotContext &context)
void massDeconvolutionSignal (const MassSpecTracePlotContext &context)
void resolvingPowerComputationSignal (const MassSpecTracePlotContext &context)
void mousePressEventSignal (const MassSpecTracePlotContext &context)
void mouseReleaseEventSignal (const MassSpecTracePlotContext &context)
Signals inherited from pappso::BasePlotWidget
void setFocusSignal ()
void lastCursorHoveredPointSignal (const QPointF &pointf)
void plotRangesChangedSignal (const BasePlotContext &context)
void xAxisMeasurementSignal (const BasePlotContext &context, bool with_delta)
void keyPressEventSignal (const BasePlotContext &context)
void keyReleaseEventSignal (const BasePlotContext &context)
void mousePressEventSignal (const BasePlotContext &context)
void mouseReleaseEventSignal (const BasePlotContext &context)
void mouseWheelEventSignal (const BasePlotContext &context)
void plottableSelectionChangedSignal (QCPAbstractPlottable *plottable_p, bool selected)
void integrationRequestedSignal (const BasePlotContext &context)
void plottableDestructionRequestedSignal (BasePlotWidget *base_plot_widget_p, QCPAbstractPlottable *plottable_p, const BasePlotContext &context)

Public Member Functions

 MassSpecTracePlotWidget (QWidget *parent=0)
 MassSpecTracePlotWidget (QWidget *parent, const QString &x_axis_label, const QString &y_axis_label)
virtual ~MassSpecTracePlotWidget ()
void setChargeMinimalFractionalPart (double charge_fractional_part)
double getChargeMinimalFractionalPart () const
void setChargeStateEnvelopePeakSpan (int interval)
int getChargeStateEnvelopePeakSpan () const
bool deconvolute ()
 Deconvolute the mass peaks into charge and molecular mass.
bool deconvoluteIsotopicCluster ()
 Deconvolute the mass peaks into charge and molecular mass.
bool deconvoluteChargedState (int span=1)
 Deconvolute the mass peaks into charge and molecular mass.
bool computeResolvingPower ()
virtual void keyPressEvent (QKeyEvent *event) override
 Set the m_pressedKeyCode to the key code in event.
virtual void keyReleaseEvent (QKeyEvent *event) override
 Handle specific key codes and trigger respective actions.
virtual void mouseMoveHandler (QMouseEvent *event) override
 Handle mouse movements, in particular record all the last visited points.
virtual void mousePressHandler (QMouseEvent *event) override
 Record the clicks of the mouse.
virtual void mouseReleaseHandler (QMouseEvent *event) override
 React to the release of the mouse buttons.
virtual void mouseMoveHandlerNotDraggingCursor () override
virtual void mouseMoveHandlerDraggingCursor () override
const MassSpecTracePlotContextrefreshBaseContext () const
Public Member Functions inherited from pappso::BaseTracePlotWidget
 BaseTracePlotWidget (QWidget *parent=0)
 BaseTracePlotWidget (QWidget *parent, const QString &x_axis_label, const QString &y_axis_label)
virtual ~BaseTracePlotWidget ()
 Destruct this BaseTracePlotWidget instance.
virtual void setGraphData (int graph_index, const std::vector< double > &keys, const std::vector< double > &values)
virtual void setGraphData (QCPGraph *graph_p, const std::vector< double > &keys, const std::vector< double > &values)
virtual void clearGraphData (int graph_index)
virtual void axisDoubleClickHandler (QCPAxis *axis, QCPAxis::SelectablePart part, QMouseEvent *event) override
virtual void axisRescale () override
 RANGE-related functions.
virtual void axisReframe () override
virtual void axisZoom () override
virtual void axisPan () override
virtual QCPGraph * addTrace (const pappso::Trace &trace, const QColor &color)
virtual QCPBars * addBars (const pappso::Trace &bars, const QColor &color)
virtual bool findIntegrationLowerRangeForKey (int index, double key, QCPRange &range)
 Find a minimal integration range starting at an existing data point.
std::vector< double > getValuesX (int index) const
std::vector< double > getValuesY (int index) const
QCPRange getValueRangeOnKeyRange (QCPAbstractPlottable *plottable_p, bool &ok)
QCPRange getValueRangeOnKeyRange (int index, bool &ok)
double getYatX (double x, QCPGraph *graph_p)
double getYatX (double x, int index=0)
pappso::Trace toTrace (int index, bool only_visible_range=false) const
pappso::Trace toTrace (const QCPGraph *graph_p, bool only_visible_range=false) const
pappso::Trace toTrace (const QCPRange &x_axis_range, int index) const
pappso::Trace toTrace (const QCPRange &x_axis_range, const QCPGraph *graph_p) const
pappso::Trace toTrace (const QCPRange &x_axis_range, const QCPBars *bars_p) const
Public Member Functions inherited from pappso::BasePlotWidget
 BasePlotWidget (QWidget *parent)
 BasePlotWidget (QWidget *parent, const QString &x_axis_label, const QString &y_axis_label)
virtual ~BasePlotWidget ()
 Destruct this BasePlotWidget instance.
virtual bool setupWidget ()
virtual void setPen (const QPen &pen)
virtual const QPen & getPen () const
virtual void setPlottingColor (QCPAbstractPlottable *plottable_p, const QColor &new_color)
virtual void setPlottingColor (int index, const QColor &new_color)
virtual QColor getPlottingColor (QCPAbstractPlottable *plottable_p) const
virtual QColor getPlottingColor (int index=0) const
virtual void setAxisLabelX (const QString &label)
virtual void setAxisLabelY (const QString &label)
virtual void resetAxesRangeHistory ()
virtual void updateAxesRangeHistory ()
 Create new axis range history items and append them to the history.
virtual void restorePreviousAxesRangeHistory ()
 Go up one history element in the axis history.
virtual void restoreAxesRangeHistory (std::size_t index)
 Get the axis histories at index index and update the plot ranges.
virtual void spaceKeyReleaseEvent (QKeyEvent *event)
virtual void directionKeyPressEvent (QKeyEvent *event)
virtual void directionKeyReleaseEvent (QKeyEvent *event)
virtual void mousePseudoButtonKeyPressEvent (QKeyEvent *event)
virtual void mousePseudoButtonKeyReleaseEvent (QKeyEvent *event)
virtual void mouseReleaseHandlerLeftButton ()
virtual void mouseReleaseHandlerRightButton ()
virtual void mouseWheelHandler (QWheelEvent *event)
virtual void mouseMoveHandlerLeftButtonDraggingCursor ()
virtual void mouseMoveHandlerRightButtonDraggingCursor ()
bool isClickOntoXAxis (const QPointF &mousePoint)
bool isClickOntoYAxis (const QPointF &mousePoint)
int dragDirection ()
 MOUSE-related EVENTS.
virtual void moveMouseCursorGraphCoordToGlobal (QPointF plot_coordinates)
virtual void moveMouseCursorPixelCoordToGlobal (QPointF local_coordinates)
virtual void horizontalMoveMouseCursorCountPixels (int pixel_count)
virtual QPointF horizontalGetGraphCoordNewPointCountPixels (int pixel_count)
virtual void verticalMoveMouseCursorCountPixels (int pixel_count)
virtual QPointF verticalGetGraphCoordNewPointCountPixels (int pixel_count)
virtual QCPRange getRangeX (bool &found_range, int index) const
 MOUSE MOVEMENTS mouse/keyboard-triggered.
virtual QCPRange getRangeY (bool &found_range, int index) const
QCPRange getRange (Enums::Axis axis, RangeType range_type, bool &found_range) const
virtual QCPRange getInnermostRangeX (bool &found_range) const
virtual QCPRange getOutermostRangeX (bool &found_range) const
virtual QCPRange getInnermostRangeY (bool &found_range) const
virtual QCPRange getOutermostRangeY (bool &found_range) const
void yMinMaxOnXAxisCurrentRange (double &min, double &max, QCPAbstractPlottable *plottable_p=nullptr)
void yMinMaxOnXAxisCurrentRange (double &min, double &max, int index)
virtual void replotWithAxesRanges (QCPRange xAxisRange, QCPRange yAxisRange, Enums::Axis axis)
virtual void replotWithAxisRangeX (double lower, double upper)
virtual void replotWithAxisRangeY (double lower, double upper)
virtual void hideAllPlotItems ()
 PLOTTING / REPLOTTING functions.
virtual void showTracers ()
 Show the traces (vertical and horizontal).
virtual void hideTracers ()
 Hide the traces (vertical and horizontal).
virtual void drawXScopeSpanFeatures ()
virtual void drawYScopeSpanFeatures ()
virtual void calculateDragDeltas ()
virtual bool isVerticalDisplacementAboveThreshold ()
virtual void drawSelectionRectangleAndPrepareZoom (bool as_line_segment=false, bool for_integration=false)
virtual void updateIntegrationScopeDrawing (bool as_line_segment=false, bool for_integration=false)
virtual void resetSelectionRectangle ()
virtual void hideSelectionRectangle (bool reset_values=false)
virtual bool isSelectionRectangleVisible ()
virtual SelectionDrawingLines whatIsVisibleOfTheSelectionRectangle ()
virtual void setFocus ()
 PLOT ITEMS : TRACER TEXT ITEMS...
virtual void redrawPlotBackground (QWidget *focusedPlotWidget)
 Redraw the background of the focusedPlotWidget plot widget.
virtual void updateContextXandYAxisRanges ()
virtual const BasePlotContextgetContext () const

Protected Attributes

MassSpecTracePlotContext m_context
double m_chargeMinimalFractionalPart = 0.990
int m_chargeStateEnvelopePeakSpan = 1
Protected Attributes inherited from pappso::BasePlotWidget
QString m_name = "NOT_SET"
 Name of the plot widget.
QString m_desc = "NOT_SET"
 Description of the plot widget.
QString m_fileName
 The name of the data file from which the mass data were read.
QString m_axisLabelX
QString m_axisLabelY
BasePlotContext m_context
int m_leftMousePseudoButtonKey = Qt::Key_Less
int m_rightMousePseudoButtonKey = Qt::Key_Greater
QCPItemLine * mp_selectionRectangeLine1 = nullptr
 Rectangle defining the borders of zoomed-in/out data.
QCPItemLine * mp_selectionRectangeLine2 = nullptr
QCPItemLine * mp_selectionRectangeLine3 = nullptr
QCPItemLine * mp_selectionRectangeLine4 = nullptr
QCPItemText * mp_xDeltaTextItem = nullptr
 Text describing the x-axis delta value during a drag operation.
QCPItemText * mp_yDeltaTextItem = nullptr
bool m_shouldTracersBeVisible = true
 Tells if the tracers should be visible.
QCPItemLine * mp_hPosTracerItem = nullptr
 Horizontal position tracer.
QCPItemLine * mp_vPosTracerItem = nullptr
 Vertical position tracer.
QCPItemLine * mp_vStartTracerItem = nullptr
 Vertical selection start tracer (typically in green).
QCPItemLine * mp_vEndTracerItem = nullptr
 Vertical selection end tracer (typically in red).
std::size_t m_lastAxisRangeHistoryIndex = 0
 Index of the last axis range history item.
std::vector< QCPRange * > m_xAxisRangeHistory
 List of x axis ranges occurring during the panning zooming actions.
std::vector< QCPRange * > m_yAxisRangeHistory
 List of y axis ranges occurring during the panning zooming actions.
int m_mouseMoveHandlerSkipAmount = 10
 How many mouse move events must be skipped *‍/.
int m_mouseMoveHandlerSkipCount = 0
 Counter to handle the "fat data" mouse move event handling.
QColor m_unfocusedColor = QColor("lightgray")
 Color used for the background of unfocused plot.
QBrush m_unfocusedBrush = QBrush(m_unfocusedColor)
 Color used for the background of unfocused plot.
QColor m_focusedColor = QColor(Qt::transparent)
 Color used for the background of focused plot.
QBrush m_focusedBrush = QBrush(m_focusedColor)
 Color used for the background of focused plot.
QPen m_pen
 Pen used to draw the graph and textual elements in the plot widget.

Additional Inherited Members

Protected Member Functions inherited from pappso::BasePlotWidget
virtual void createAllAncillaryItems ()
virtual void updateIntegrationScope (bool for_integration=false)
virtual void updateIntegrationScopeRect (bool for_integration=false)
virtual void updateIntegrationScopeHorizontalRhomb (bool for_integration=false)
virtual void updateIntegrationScopeVerticalRhomb (bool for_integration=false)
virtual void updateIntegrationScopeRhomb (bool for_integration=false)
virtual QString allLayerNamesToString () const
virtual QString layerableLayerName (QCPLayerable *layerable_p) const
virtual int layerableLayerIndex (QCPLayerable *layerable_p) const

Detailed Description

Definition at line 57 of file massspectraceplotwidget.h.

Constructor & Destructor Documentation

◆ MassSpecTracePlotWidget() [1/2]

pappso::MassSpecTracePlotWidget::MassSpecTracePlotWidget ( QWidget * parent = 0)
explicit

Definition at line 53 of file massspectraceplotwidget.cpp.

53 : BaseTracePlotWidget(parent)
54{
56 m_context.m_dataKind = Enums::DataKind::mz;
57
58 // qDebug() << "Data kind:" << static_cast<int>(m_context.m_dataKind);
59}
Enums::DataKind m_dataKind
BasePlotContext m_context

References pappso::BaseTracePlotWidget::BaseTracePlotWidget(), pappso::BasePlotWidget::m_context, m_context, and pappso::Enums::mz.

◆ MassSpecTracePlotWidget() [2/2]

pappso::MassSpecTracePlotWidget::MassSpecTracePlotWidget ( QWidget * parent,
const QString & x_axis_label,
const QString & y_axis_label )
explicit

Definition at line 61 of file massspectraceplotwidget.cpp.

64 : BaseTracePlotWidget(parent, x_axis_label, y_axis_label)
65{
66 // Set the base context to be of kind Enums::DataKind::mz;
67
69 m_context.m_dataKind = Enums::DataKind::mz;
70
71 // qDebug() << "Data kind:" << static_cast<int>(m_context.m_dataKind);
72}

References pappso::BaseTracePlotWidget::BaseTracePlotWidget(), pappso::BasePlotWidget::m_context, m_context, and pappso::Enums::mz.

◆ ~MassSpecTracePlotWidget()

pappso::MassSpecTracePlotWidget::~MassSpecTracePlotWidget ( )
virtual

Definition at line 75 of file massspectraceplotwidget.cpp.

76{
77}

Member Function Documentation

◆ computeResolvingPower()

bool pappso::MassSpecTracePlotWidget::computeResolvingPower ( )

Definition at line 604 of file massspectraceplotwidget.cpp.

605{
606
607 // m_xRangeLower and m_xRangeUpper and m_xDelta (in fabs() form) have been set
608 // during mouve movement handling. Note that the range values *are
609 // sorted*.
610
611 if(!m_context.m_xDelta || m_context.m_xDelta > 1)
612 {
613 m_context.m_lastResolvingPower = std::numeric_limits<double>::min();
614
615 return false;
616 }
617
618 // Resolving power is m/z / Delta(m/z), for singly-charged species.
619
620 // qDebug() << "Calculating the resolving power with these data:"
621 //<< "m_context.m_xRegionRangeStart: " << m_context.m_xRegionRangeStart
622 //<< "m_context.m_xRegionRangeEnd: " << m_context.m_xRegionRangeEnd
623 //<< "m_context.m_xDelta / 2: " << m_context.m_xDelta / 2;
624
625 m_context.m_lastResolvingPower =
626 (std::min<double>(m_context.m_xRegionRangeStart, m_context.m_xRegionRangeEnd) +
627 (m_context.m_xDelta / 2)) /
628 m_context.m_xDelta;
629
630 // The m_context was refreshed with the base class context in the calling
631 // chain.
633
634 return true;
635}
void resolvingPowerComputationSignal(const MassSpecTracePlotContext &context)

References m_context, and resolvingPowerComputationSignal().

Referenced by mouseMoveHandlerDraggingCursor().

◆ deconvolute()

bool pappso::MassSpecTracePlotWidget::deconvolute ( )

Deconvolute the mass peaks into charge and molecular mass.

Definition at line 285 of file massspectraceplotwidget.cpp.

286{
287
288 // qDebug() << "The current m_lastZ value:" << m_context.m_lastZ;
289
290 // There are two situations: when the user is deconvoluting on the
291 // basis of the distance between two consecutive peaks of a same
292 // isotopic cluster or when the user deconvolutes on the basis of two
293 // different charged-stated peaks that belong to the same envelope.
294
295 // We can tell the difference because in the first case the xDelta
296 // should be less than 1. In the other case, of course the difference
297 // is much greater than 1.
298
299 // In order to do the deconvolutions, we need to know what is the tolerance
300 // on the fractional part of the deconvoluted charge value. This value is set
301 // in the parent window's double spin box.
302
303 if(fabs(m_context.m_xDelta) >= 0 && fabs(m_context.m_xDelta) <= 1.1)
304 {
305 // qDebug() << "m_xDelta:" << m_context.m_xDelta
306 //<< "trying isotope-based deconvolution.";
307
309 }
310
311 // If not deconvoluting on the basis of the isotopic cluster, then:
312
314}
bool deconvoluteChargedState(int span=1)
Deconvolute the mass peaks into charge and molecular mass.
bool deconvoluteIsotopicCluster()
Deconvolute the mass peaks into charge and molecular mass.

References deconvoluteChargedState(), deconvoluteIsotopicCluster(), m_chargeStateEnvelopePeakSpan, and m_context.

Referenced by mouseMoveHandlerDraggingCursor().

◆ deconvoluteChargedState()

bool pappso::MassSpecTracePlotWidget::deconvoluteChargedState ( int span = 1)

Deconvolute the mass peaks into charge and molecular mass.

This is one of two methods to deconvolute mass data into a charge value and a Mr value. The method implemented in this function is based on the charge state envelope offered by the mass spectrum (most often for polymers of a reasonable size).

Parameters
spanvalue representing the number of peaks of the charge state envelope that are spanned by the user selection. Defaults to 1, that is, the span encompasses two consecutive mass peaks of a given charge state envelope.

The z charge that is computed is for the first peak that was clicked in the trace plot, and thus the Mr value that is returned is calculated from the m/z value under the peak that was clicked first.

Set m_lastMz, m_lastZ and m_lastMass.

Returns
true if the deconvolution could be performed, false otherwise.

Definition at line 339 of file massspectraceplotwidget.cpp.

340{
341 // We assume that we are dealing with two successive (if span is 1) mass
342 // peaks belonging to a given charge state family.
343
344 // We call span the number of intervals in a given charge state envelope
345 // that separate the initial peak (lowerMz) from the last peak (upperMz).
346 // That parameter defaults to 1, that is the two peaks are immediately
347 // consecutive, that is, there is only one interval.
348
349 // qDebug() << "The span is:" << span;
350
351 // The m_context ranges are inherently sorted. This is not something that
352 // is favorable to us because we need to know what is the direction of the
353 // drag. That should be configurable, but we can establish that by
354 // default, the z value will be calculated for the mass peak at which
355 // the mouse drag movement started.
356
357 // These two values reflect a m/z range:
358 // startMz and curMz are always sorted (startMz < curMz)
359 double startMz = m_context.m_xRegionRangeStart;
360 double curMz = m_context.m_xRegionRangeEnd;
361
362 // qDebug() << "startMz:" << startMz << "curMz:" << curMz;
363
364 if(startMz == curMz)
365 {
366 m_context.m_lastZ = std::numeric_limits<quint16>::max();
367 m_context.m_lastMz = qQNaN();
368 m_context.m_lastTicIntensity = qQNaN();
369 m_context.m_lastMr = qQNaN();
370
371 // qDebug() << "Start and Cur are the same, no deconvolution possible.";
372 return false;
373 }
374
375 // After much discussing, the agreement we reached with users is that the
376 // m/z value that is reported has to be that of the clicked peak, that is
377 // the start point of the mouse cursor drag operation. The z charge value
378 // has to be related to that m/z value.
379
380 double chargeTemp = ((startMz * span) - span) / (curMz - startMz);
381 // This is the charge of the least charged peak, that is, by necessity
382 // the charge of the peak on the right (curMz, because the values
383 // are sorted).
384
385 // Make a judicious roundup.
386
387 double chargeIntPart;
388 double chargeFracPart = modf(chargeTemp, &chargeIntPart);
389
390 // When calculating the charge of the ion, very rarely does it provide a
391 // perfect integer value. Most often (if deconvolution is for bona fide
392 // peaks belonging to the same charge state envelope) that value is with
393 // either a large fractional part or a very small fractional part. What we
394 // test here, it that fractional part. If it is greater than
395 // m_chargeMinimalFractionalPart, then we simply round up to the next integer
396 // value (that is, chargeIntPart = 27 and chargeFracPart 0.995, then we
397 // set charge to 28). If it is lesser or equal to (1 -
398 // m_chargeMinimalFractionalPart /* that is >= 0.01 */, then we let
399 // chargeIntPart unmodified (that is, chargeIntPart = 29 and
400 // chargeFracPart 0.01, then we set charge to 29). If chargeFracPart is in
401 // between (1 - m_chargeMinimalFractionalPart) and
402 // m_chargeMinimalFractionalPart, then we consider that the peaks do not
403 // belong to the same charge state envelope.
404
405 // qDebug() << "Charge:" << chargeIntPart << "Charge fractional part: " << chargeFracPart;
406
407
408 if(chargeFracPart >= (1 - m_chargeMinimalFractionalPart /* that is >= 0.01 */) &&
409 chargeFracPart <= m_chargeMinimalFractionalPart /* that is <= 0.99 */)
410 {
411 m_context.m_lastZ = std::numeric_limits<quint16>::max();
412 m_context.m_lastMz = qQNaN();
413 m_context.m_lastTicIntensity = qQNaN();
414 m_context.m_lastMr = qQNaN();
415
416 // qDebug() << "Not a charge state family peak,"
417 // << "returning from deconvoluteChargeState";
418
419 return false;
420 }
421
422 if(chargeFracPart > m_chargeMinimalFractionalPart)
423 m_context.m_lastZ = chargeIntPart + 1;
424 else
425 m_context.m_lastZ = chargeIntPart;
426
427 // qDebug() << "Initially computed m_lastZ as " << m_context.m_lastZ;
428
429 // We know the that formula above computed the charge of the least charged
430 // ion, that corresponds to the greater m/z value of the range: curMz.
431
432 // Now, if the user did click on that least-charged peak, nothing is
433 // to be modified. But, if the user did click on the most-charged
434 // peak, that is on startMz, the we need to fix the values:
435
436 if(static_cast<int>(m_context.m_dragDirections) & static_cast<int>(DragDirections::RIGHT_TO_LEFT))
437 {
438 // qDebug() << "Dragging from right to left, that is from higher m/z value.";
439 m_context.m_lastMz = curMz;
440 }
441 else if(static_cast<int>(m_context.m_dragDirections) &
442 static_cast<int>(DragDirections::LEFT_TO_RIGHT))
443 {
444 // qDebug() << "Dragging from left to right, we need to report"
445 // << "the mass for the left peak, that is for z+span and lower m/z value.";
446 m_context.m_lastZ += span;
447 m_context.m_lastMz = startMz;
448 }
449
450 // qDebug() << "Final m_lastZ is " << m_context.m_lastZ << "m/z: m_context.m_lastMz";
451
452 m_context.m_lastMr = (m_context.m_lastMz * m_context.m_lastZ) - (m_context.m_lastZ * MPROTON);
453
454 // qDebug() << "startMz:" << QString("%1").arg(startMz, 0, 'f', 6)
455 // << "curMz:" << QString("%1").arg(curMz, 0, 'f', 6)
456 // << "m_lastMz (make computation for this startMz):"
457 // << QString("%1").arg(m_context.m_lastMz, 0, 'f', 6)
458 // << "m_lastZ:" << QString("%1").arg(m_context.m_lastZ)
459 // << "m_lastMass:" << QString("%1").arg(m_context.m_lastMr, 0, 'f', 6);
460
461 // The m_context was refreshed with the base class context in the calling
462 // chain.
464
465 return true;
466}
void massDeconvolutionSignal(const MassSpecTracePlotContext &context)
const pappso_double MPROTON(1.007276466879)

References pappso::LEFT_TO_RIGHT, m_chargeMinimalFractionalPart, m_context, massDeconvolutionSignal(), pappso::MPROTON(), and pappso::RIGHT_TO_LEFT.

Referenced by deconvolute().

◆ deconvoluteIsotopicCluster()

bool pappso::MassSpecTracePlotWidget::deconvoluteIsotopicCluster ( )

Deconvolute the mass peaks into charge and molecular mass.

This is one of two methods to deconvolute mass data into a charge value and a Mr value. The method implemented in this function is based on the distance that separates two immediately consecutive peaks of an isotopic cluster. This method can be used as long as the instrument produced data with a resolution sufficient to separate reasonably well the different peaks of an isotopic cluster.

Set m_lastMz, m_lastZ and m_lastMass.

Returns
true if the deconvolution could be performed, false otherwise.

Definition at line 484 of file massspectraceplotwidget.cpp.

485{
486 // The m_context ranges are inherently sorted. This is not something that
487 // is favorable to us because we need to know what is the direction of the
488 // drag. That should be configurable, but we can establish that by
489 // default, the z value will be calculated for the mass peak at which
490 // the mouse drag movement started.
491
492 double startMz = m_context.m_xRegionRangeStart;
493 double curMz = m_context.m_xRegionRangeEnd;
494
495 // qDebug() << "startMz:" << startMz << "curMz:" << curMz;
496
497 if(startMz == curMz)
498 {
499 m_context.m_lastZ = std::numeric_limits<quint16>::max();
500 m_context.m_lastMz = qQNaN();
501 m_context.m_lastTicIntensity = qQNaN();
502 m_context.m_lastMr = qQNaN();
503
504 return false;
505 }
506
507 // After much discussion with people who perform mass data analysis for
508 // heavy isotope fully labelled analytes, it was decided that the Mr
509 // value thas is returned is for the peak from which the drag operation
510 // was performed. This is an analogous way of computing Mr as that used
511 // in the charge state envelope method.
512
513
514 double chargeTemp = 1 / fabs(m_context.m_xDelta);
515
516 // qDebug() << qSetRealNumberPrecision(6) << "curMz - startMz = " << fabs(curMz - startMz)
517 // << "while m_context.m_xDelta = " << m_context.m_xDelta;
518
519 // Sanity check
520 if(fabs(m_context.m_xDelta) != fabs(curMz - startMz))
521 qFatal() << "Programming error.";
522
523 // Make a judicious roundup.
524 double chargeIntPart;
525 double chargeFracPart = modf(chargeTemp, &chargeIntPart);
526
527 // qDebug() << "m_xDelta:" << m_context.m_xDelta
528 // << "chargeTemp:" << QString("%1").arg(chargeTemp, 0, 'f', 6)
529 // << "chargeIntPart:" << chargeIntPart
530 // << "chargeFracPart:" << QString("%1").arg(chargeFracPart, 0, 'f', 6)
531 // << "m_chargeMinimalFractionalPart:" << m_chargeMinimalFractionalPart;
532
533 if(chargeFracPart >= (1 - m_chargeMinimalFractionalPart /* that is >= 0.01 */) &&
534 chargeFracPart <= m_chargeMinimalFractionalPart /* that is <= 0.99 */)
535 {
536 m_context.m_lastZ = std::numeric_limits<quint16>::max();
537 m_context.m_lastMz = qQNaN();
538 m_context.m_lastTicIntensity = qQNaN();
539 m_context.m_lastMr = qQNaN();
540
541 // qDebug() << "Not in a isotopic cluster peak:"
542 // << "returning from deconvoluteIsotopicCluster";
543
544 return false;
545 }
546
547 if(chargeFracPart > m_chargeMinimalFractionalPart)
548 {
549 m_context.m_lastZ = chargeIntPart + 1;
550
551 // qDebug() << "chargeFracPart > m_chargeMinimalFractionalPart -> m_lastZ
552 // = "
553 //<< m_context.m_lastZ;
554 }
555 else
556 {
557 m_context.m_lastZ = chargeIntPart;
558
559 // qDebug()
560 //<< "chargeFracPart <= m_chargeMinimalFractionalPart -> m_lastZ = "
561 //<< m_context.m_lastZ;
562 }
563
564 // qDebug() << "Settled on m_lastZ: " << m_context.m_lastZ;
565
566 // Now that we have the charge in the form of an int, we can compute the
567 // Mr of the isotopic cluster peak that was under the cursor when the
568 // mouse drag started.
569
570 // If we know the drag direction, we would automatically know what is the
571 // peak that was under the cursor when the mouse drag mouvement was initiated.
572 // This is because the curMz is inherently larger than startMz because
573 // m_context.m_xRegionRangeStart and m_context.m_xRegionRangeEnd are inherently
574 // sorted (start < end).
575
576 if(static_cast<int>(m_context.m_dragDirections) & static_cast<int>(DragDirections::RIGHT_TO_LEFT))
577 {
578 // qDebug() << "Dragging from right to left, that is from higher m/z value.";
579 m_context.m_lastMz = curMz;
580 }
581 else if(static_cast<int>(m_context.m_dragDirections) &
582 static_cast<int>(DragDirections::LEFT_TO_RIGHT))
583 {
584 // qDebug() << "Dragging from left to right, we need to report"
585 // << "the mass for the left peak.";
586 m_context.m_lastMz = startMz;
587 }
588
589 m_context.m_lastMr = (m_context.m_lastMz * m_context.m_lastZ) - (m_context.m_lastZ * MPROTON);
590
591 // qDebug() << "m_lastMz :" << QString("%1").arg(m_context.m_lastMz, 0, 'f', 6)
592 // << "m_lastZ:" << QString("%1").arg(m_context.m_lastZ)
593 // << "m_lastMr:" << QString("%1").arg(m_context.m_lastMr, 0, 'f', 6);
594
595 // The m_context was refreshed with the base class context in the calling
596 // chain.
598
599 return true;
600}

References pappso::LEFT_TO_RIGHT, m_chargeMinimalFractionalPart, m_context, massDeconvolutionSignal(), pappso::MPROTON(), and pappso::RIGHT_TO_LEFT.

Referenced by deconvolute().

◆ getChargeMinimalFractionalPart()

double pappso::MassSpecTracePlotWidget::getChargeMinimalFractionalPart ( ) const

Definition at line 263 of file massspectraceplotwidget.cpp.

264{
266}

References m_chargeMinimalFractionalPart.

◆ getChargeStateEnvelopePeakSpan()

int pappso::MassSpecTracePlotWidget::getChargeStateEnvelopePeakSpan ( ) const

Definition at line 277 of file massspectraceplotwidget.cpp.

278{
280}

References m_chargeStateEnvelopePeakSpan.

◆ keyPressEvent()

void pappso::MassSpecTracePlotWidget::keyPressEvent ( QKeyEvent * event)
overridevirtual

Set the m_pressedKeyCode to the key code in event.

Reimplemented from pappso::BasePlotWidget.

Definition at line 82 of file massspectraceplotwidget.cpp.

83{
84 // qDebug() << "ENTER";
86
87 // Before working on the various data belonging to the base context, we need
88 // to get it from the base class and refresh our local context with it.
90
91 // qDebug() << "Going to emit keyPressEventSignal(m_context);";
92
94}
virtual void keyPressEvent(QKeyEvent *event)
KEYBOARD-related EVENTS.
const MassSpecTracePlotContext & refreshBaseContext() const
void keyPressEventSignal(const MassSpecTracePlotContext &context)

References pappso::BasePlotWidget::keyPressEvent(), keyPressEventSignal(), m_context, and refreshBaseContext().

◆ keyPressEventSignal

void pappso::MassSpecTracePlotWidget::keyPressEventSignal ( const MassSpecTracePlotContext & context)
signal

Referenced by keyPressEvent().

◆ keyReleaseEvent()

void pappso::MassSpecTracePlotWidget::keyReleaseEvent ( QKeyEvent * event)
overridevirtual

Handle specific key codes and trigger respective actions.

Reimplemented from pappso::BasePlotWidget.

Definition at line 99 of file massspectraceplotwidget.cpp.

100{
101 // Before working on the various data belonging to the base context, we need
102 // to get it from the base class and refresh our local context with it.
104
106}
virtual void keyReleaseEvent(QKeyEvent *event)
Handle specific key codes and trigger respective actions.

References pappso::BasePlotWidget::keyReleaseEvent(), and refreshBaseContext().

◆ massDeconvolutionSignal

void pappso::MassSpecTracePlotWidget::massDeconvolutionSignal ( const MassSpecTracePlotContext & context)
signal

◆ mouseMoveHandler()

void pappso::MassSpecTracePlotWidget::mouseMoveHandler ( QMouseEvent * event)
overridevirtual

Handle mouse movements, in particular record all the last visited points.

This function is reponsible for storing at each time the last visited point in the graph. Here, point is intended as any x/y coordinate in the plot widget viewport, not a graph point.

The stored values are then the basis for a large set of calculations throughout all the plot widget.

Parameters
pointerto QMouseEvent from which to retrieve the coordinates of the visited viewport points.

Reimplemented from pappso::BasePlotWidget.

Definition at line 123 of file massspectraceplotwidget.cpp.

124{
125 // Before working on the various data belonging to the base context, we need
126 // to get it from the base class and refresh our local context with it.
128
130}
virtual void mouseMoveHandler(QMouseEvent *event)
KEYBOARD-related EVENTS.

References pappso::BasePlotWidget::mouseMoveHandler(), and refreshBaseContext().

◆ mouseMoveHandlerDraggingCursor()

void pappso::MassSpecTracePlotWidget::mouseMoveHandlerDraggingCursor ( )
overridevirtual

Reimplemented from pappso::BasePlotWidget.

Definition at line 147 of file massspectraceplotwidget.cpp.

148{
150
151 // Before working on the various data belonging to the base context, we need
152 // to get it from the base class and refresh our local context with it.
154
155 if(m_context.m_mouseButtonsAtMousePress & Qt::LeftButton)
156 {
157 if(!m_context.m_isMeasuringDistance)
158 return;
159
160 // qDebug() << "Mouse Buttons at Mouse press:" << m_context.m_mouseButtonsAtMousePress;
161
162 // qDebug() << "The current m_lastZ value:" << m_context.m_lastZ;
163
164 deconvolute();
166 }
167}
virtual void mouseMoveHandlerDraggingCursor()
bool deconvolute()
Deconvolute the mass peaks into charge and molecular mass.

References computeResolvingPower(), deconvolute(), m_context, pappso::BasePlotWidget::mouseMoveHandlerDraggingCursor(), and refreshBaseContext().

◆ mouseMoveHandlerNotDraggingCursor()

void pappso::MassSpecTracePlotWidget::mouseMoveHandlerNotDraggingCursor ( )
overridevirtual

Reimplemented from pappso::BasePlotWidget.

Definition at line 134 of file massspectraceplotwidget.cpp.

135{
136 // Before working on the various data belonging to the base context, we need
137 // to get it from the base class and refresh our local context with it.
139
141
142 // qDebug() << "The current m_lastZ value:" << m_context.m_lastZ;
143}
virtual void mouseMoveHandlerNotDraggingCursor()

References pappso::BasePlotWidget::mouseMoveHandlerNotDraggingCursor(), and refreshBaseContext().

◆ mousePressEventSignal

void pappso::MassSpecTracePlotWidget::mousePressEventSignal ( const MassSpecTracePlotContext & context)
signal

Referenced by mousePressHandler().

◆ mousePressHandler()

void pappso::MassSpecTracePlotWidget::mousePressHandler ( QMouseEvent * event)
overridevirtual

Record the clicks of the mouse.

Reimplemented from pappso::BasePlotWidget.

Definition at line 172 of file massspectraceplotwidget.cpp.

173{
174 // qDebug() << "Entering";
175
176 // Before working on the various data belonging to the base context, we need
177 // to get it from the base class and refresh our local context with it.
179
181
182 // qDebug() << "The current m_lastZ value:" << m_context.m_lastZ;
183
185
186 // qDebug() << "Exiting after having emitted mousePressEventSignal with context:"
187 // << m_context.toString();
188}
virtual void mousePressHandler(QMouseEvent *event)
KEYBOARD-related EVENTS.
void mousePressEventSignal(const MassSpecTracePlotContext &context)

References m_context, mousePressEventSignal(), pappso::BasePlotWidget::mousePressHandler(), and refreshBaseContext().

◆ mouseReleaseEventSignal

void pappso::MassSpecTracePlotWidget::mouseReleaseEventSignal ( const MassSpecTracePlotContext & context)
signal

Referenced by mouseReleaseHandler().

◆ mouseReleaseHandler()

void pappso::MassSpecTracePlotWidget::mouseReleaseHandler ( QMouseEvent * event)
overridevirtual

React to the release of the mouse buttons.

Reimplemented from pappso::BasePlotWidget.

Definition at line 193 of file massspectraceplotwidget.cpp.

194{
195 // qDebug() << "Entering";
196
197 // Before working on the various data belonging to the base context, we need
198 // to get it from the base class and refresh our local context with it.
200
202
203 // qDebug() << "The current m_lastZ value:" << m_context.m_lastZ;
204
205 if(!m_context.m_isMouseDragging)
206 {
207 // Since we were not dragging, by essence we were not measuring
208 // distances and _a fortiori_ we were not deconvoluting. So
209 // reset deconvolution data in the context.
210
211 m_context.resetDeconvolutionData();
212 }
213
215
216 // qDebug() << "Exiting after having emitted mouseReleaseEventSignal with context:"
217 // << m_context.toString();
218}
virtual void mouseReleaseHandler(QMouseEvent *event)
void mouseReleaseEventSignal(const MassSpecTracePlotContext &context)

References m_context, mouseReleaseEventSignal(), pappso::BasePlotWidget::mouseReleaseHandler(), and refreshBaseContext().

◆ refreshBaseContext()

const MassSpecTracePlotContext & pappso::MassSpecTracePlotWidget::refreshBaseContext ( ) const

Definition at line 222 of file massspectraceplotwidget.cpp.

223{
224 // BasePlotWidget has a member m_context of type BasePlotContext.
225 // Here we also have a m_context *distinct* member that is of type
226 // MassSpecTracePlotContext.
227
228 // While MassSpecTracePlotContext is derived from BasePlotContext, the two
229 // m_context members are distinct and there are lots of housekeeping data that
230 // are managed by the parent BasePlotWidget class in its m_context member
231 // *independently* of what we have in the ::BasePlotContext part of our
232 // m_context member that is of type MassSpecTracePlotContext. We thus need to
233 // resynchronize the data from BasePlotWidget::m_context to our m_context.
234
235 // qDebug().noquote() << "The base plot context:" <<
236 // BasePlotWidget::m_context.toString();
237
238
239 // qDebug() << "Right before refreshing the context, the current m_lastZ value:"
240 // << m_context.m_lastZ;
241
243
244
245 // qDebug() << "Right after refreshing the context, the current m_lastZ value:"
246 // << m_context.m_lastZ;
247
248 // qDebug().noquote() << "After refreshing the base context, base context:"
249 // << m_context.toString();
250
251 return m_context;
252}

References pappso::BasePlotWidget::m_context, and m_context.

Referenced by keyPressEvent(), keyReleaseEvent(), mouseMoveHandler(), mouseMoveHandlerDraggingCursor(), mouseMoveHandlerNotDraggingCursor(), mousePressHandler(), and mouseReleaseHandler().

◆ resolvingPowerComputationSignal

void pappso::MassSpecTracePlotWidget::resolvingPowerComputationSignal ( const MassSpecTracePlotContext & context)
signal

Referenced by computeResolvingPower().

◆ setChargeMinimalFractionalPart()

void pappso::MassSpecTracePlotWidget::setChargeMinimalFractionalPart ( double charge_fractional_part)

Definition at line 256 of file massspectraceplotwidget.cpp.

257{
258 m_chargeMinimalFractionalPart = charge_fractional_part;
259}

References m_chargeMinimalFractionalPart.

◆ setChargeStateEnvelopePeakSpan()

void pappso::MassSpecTracePlotWidget::setChargeStateEnvelopePeakSpan ( int interval)

Definition at line 270 of file massspectraceplotwidget.cpp.

271{
273}

References m_chargeStateEnvelopePeakSpan.

Member Data Documentation

◆ m_chargeMinimalFractionalPart

double pappso::MassSpecTracePlotWidget::m_chargeMinimalFractionalPart = 0.990
protected

◆ m_chargeStateEnvelopePeakSpan

int pappso::MassSpecTracePlotWidget::m_chargeStateEnvelopePeakSpan = 1
protected

◆ m_context


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