";
- s += "";
- s += to_string(id + 1);
- s += " | ";
+ s += printHTMLTableCell(to_string(id + 1), isred);
if (parameters->mode == dereplication) {
if ((parameters->peaklistfileformat == mis) || (parameters->peaklistfileformat == imzML)) {
- s += "";
- s += to_string(theoreticalspectrum->getExperimentalSpectrum().getCoordinateX());
- s += " | ";
- s += "";
- s += to_string(theoreticalspectrum->getExperimentalSpectrum().getCoordinateY());
- s += " | ";
+ s += printHTMLTableCell(to_string(theoreticalspectrum->getExperimentalSpectrum().getCoordinateX()), isred);
+ s += printHTMLTableCell(to_string(theoreticalspectrum->getExperimentalSpectrum().getCoordinateY()), isred);
}
secondspace = (int)peak->description.find(' ', peak->description.find(' ') + 1);
s += printHTMLTableCell(peak->description.substr(0, secondspace), isred);
@@ -420,7 +442,7 @@ string cSpectrumDetailWidget::getPartialPeaksTableAsHTMLString(int id, bool expo
s += printHTMLTableCell(to_string(cropPrecisionToSixDecimals(peak->mzratio)), isred);
- if ((parameters->mode == dereplication) && (parameters->generateisotopepattern)) {
+ if (parameters->generateisotopepattern) {
s += printHTMLTableCell(to_string(cropPrecisionToSixDecimals(peak->relativeintensity)), isred);
}
@@ -464,6 +486,13 @@ string cSpectrumDetailWidget::getPartialPeaksTableAsHTMLString(int id, bool expo
}
}
else {
+ if (parameters->generateisotopepattern) {
+ s += printHTMLTableCell(peak->isotopeformula, isred);
+ }
+ else {
+ s += printHTMLTableCell(peak->formula.getFancySummary(peak->charge).c_str(), isred);
+ }
+
pos = peak->description.find(':');
if ((pos != string::npos) && (pos + 2 < peak->description.size())) {
desc = peak->description.substr(pos + 2);
@@ -877,6 +906,7 @@ void cSpectrumDetailWidget::prepareToShow(ePeptideType peptidetype, QAction* act
connect(rotation, SIGNAL(currentIndexChanged(int)), spectrumscene, SLOT(rotationChanged(int)));
connect(rotation, SIGNAL(currentIndexChanged(QString)), spectrumscene, SLOT(rotationChanged(QString)));
connect(rotation, SIGNAL(currentIndexChanged(int)), cyclicwidget, SLOT(rotationChanged(int)));
+ connect(rotation, SIGNAL(currentIndexChanged(int)), this, SLOT(filterTableAfterRotationChanged(int)));
toolbarRotation = addToolBar(tr("Ring break up point"));
toolbarRotation->addWidget(widgetrotation);
@@ -894,6 +924,7 @@ void cSpectrumDetailWidget::prepareToShow(ePeptideType peptidetype, QAction* act
connect(trotation, SIGNAL(currentIndexChanged(int)), spectrumscene, SLOT(trotationChanged(int)));
connect(trotation, SIGNAL(currentIndexChanged(int)), branchedwidget, SLOT(trotationChanged(int)));
+ connect(trotation, SIGNAL(currentIndexChanged(int)), this, SLOT(filterTableAfterTRotationChanged(int)));
toolbarTrotation = addToolBar(tr("Linearized sequence"));
toolbarTrotation->addWidget(widgettrotation);
@@ -917,6 +948,7 @@ void cSpectrumDetailWidget::prepareToShow(ePeptideType peptidetype, QAction* act
connect(rotation, SIGNAL(currentIndexChanged(int)), spectrumscene, SLOT(rotationChanged(int)));
connect(rotation, SIGNAL(currentIndexChanged(QString)), spectrumscene, SLOT(rotationChanged(QString)));
connect(rotation, SIGNAL(currentIndexChanged(int)), branchcyclicwidget, SLOT(rotationChanged(int)));
+ connect(rotation, SIGNAL(currentIndexChanged(int)), this, SLOT(filterTableAfterRotationChanged(int)));
toolbarRotation = addToolBar(tr("Ring break up point"));
toolbarRotation->addWidget(widgetrotation);
@@ -931,7 +963,8 @@ void cSpectrumDetailWidget::prepareToShow(ePeptideType peptidetype, QAction* act
connect(trotation, SIGNAL(currentIndexChanged(int)), spectrumscene, SLOT(trotationChanged(int)));
connect(trotation, SIGNAL(currentIndexChanged(int)), branchcyclicwidget, SLOT(trotationChanged(int)));
-
+ connect(trotation, SIGNAL(currentIndexChanged(int)), this, SLOT(filterTableAfterTRotationChanged(int)));
+
toolbarTrotation = addToolBar(tr("Linearized sequence"));
toolbarTrotation->addWidget(widgettrotation);
}
@@ -1201,7 +1234,12 @@ void cSpectrumDetailWidget::preparePeaksTable() {
}
}
else {
- peakstablemodel->setColumnCount(7);
+ if (parameters->generateisotopepattern) {
+ peakstablemodel->setColumnCount(9);
+ }
+ else {
+ peakstablemodel->setColumnCount(8);
+ }
}
for (int i = 0; i < peakstablemodel->columnCount(); i++) {
@@ -1225,7 +1263,7 @@ void cSpectrumDetailWidget::preparePeaksTable() {
peakstablemodel->horizontalHeaderItem(currentcolumn)->setText("Theoretical m/z");
currentcolumn++;
- if ((parameters->mode == dereplication) && (parameters->generateisotopepattern)) {
+ if (parameters->generateisotopepattern) {
peakstablemodel->horizontalHeaderItem(currentcolumn)->setText("Theoretical Intensity [%]");
currentcolumn++;
}
@@ -1266,6 +1304,12 @@ void cSpectrumDetailWidget::preparePeaksTable() {
currentcolumn++;
}
else {
+ peakstablemodel->horizontalHeaderItem(currentcolumn)->setText("Summary Formula");
+ if (parameters->generateisotopepattern) {
+ peakstable->setItemDelegateForColumn(currentcolumn, new cHTMLDelegate());
+ }
+ currentcolumn++;
+
peakstablemodel->horizontalHeaderItem(currentcolumn)->setText("Sequence");
currentcolumn++;
}
@@ -1299,10 +1343,15 @@ void cSpectrumDetailWidget::preparePeaksTable() {
// theoretical peaks
for (int i = 0; i < thpeakscount; i++) {
peak = &((*thpeaks)[i]);
+
if (peak->descriptionid != -1) {
peak->description = parameters->peakidtodesc[peak->descriptionid];
}
+ if (peak->isotopeformulaid != -1) {
+ peak->isotopeformula = parameters->isotopeformulaidtodesc[peak->isotopeformulaid];
+ }
+
if (peak->matchedmz > 0) {
brush.setColor(QColor(255, 0, 0));
}
@@ -1330,10 +1379,12 @@ void cSpectrumDetailWidget::preparePeaksTable() {
peakstablemodel->item(i, currentcolumn)->setData(QVariant::fromValue(cropPrecisionToSixDecimalsByteArray(peak->mzratio)), Qt::DisplayRole);
currentcolumn++;
- if ((parameters->mode == dereplication) && (parameters->generateisotopepattern)) {
- peakstablemodel->setItem(i, currentcolumn, new QStandardItem());
- peakstablemodel->item(i, currentcolumn)->setForeground(brush);
- peakstablemodel->item(i, currentcolumn)->setData(QVariant::fromValue(cropPrecisionToSixDecimalsByteArray(peak->relativeintensity)), Qt::DisplayRole);
+ if (parameters->generateisotopepattern) {
+ if (peak->relativeintensity > 0) {
+ peakstablemodel->setItem(i, currentcolumn, new QStandardItem());
+ peakstablemodel->item(i, currentcolumn)->setForeground(brush);
+ peakstablemodel->item(i, currentcolumn)->setData(QVariant::fromValue(cropPrecisionToSixDecimalsByteArray(peak->relativeintensity)), Qt::DisplayRole);
+ }
currentcolumn++;
}
@@ -1419,6 +1470,24 @@ void cSpectrumDetailWidget::preparePeaksTable() {
}
}
else {
+ peakstablemodel->setItem(i, currentcolumn, new QStandardItem());
+ peakstablemodel->item(i, currentcolumn)->setForeground(brush);
+ if (parameters->generateisotopepattern) {
+ QString summary;
+ if (peak->matched > 0) {
+ summary += "";
+ }
+ summary += peak->isotopeformula.c_str();
+ if (peak->matched > 0) {
+ summary += "";
+ }
+ peakstablemodel->item(i, currentcolumn)->setText(summary);
+ }
+ else {
+ peakstablemodel->item(i, currentcolumn)->setText(peak->formula.getFancySummary(peak->charge).c_str());
+ }
+ currentcolumn++;
+
pos = peak->description.find(':');
if ((pos != string::npos) && (pos + 2 < peak->description.size())) {
peakstablemodel->setItem(i, currentcolumn, new QStandardItem());
@@ -1448,7 +1517,7 @@ void cSpectrumDetailWidget::preparePeaksTable() {
continue;
}
- if ((parameters->mode == dereplication) && (parameters->generateisotopepattern)) {
+ if (parameters->generateisotopepattern) {
currentcolumn = 3;
}
else {
@@ -1491,6 +1560,11 @@ void cSpectrumDetailWidget::preparePeaksTable() {
peakstable->setColumnWidth(6, min(400, peakstable->columnWidth(6)));
}
}
+ else {
+ if (parameters->generateisotopepattern) {
+ peakstable->setColumnWidth(7, min(400, peakstable->columnWidth(7)));
+ }
+ }
progress.setValue(thpeakscount + theoreticalspectrum->getUnmatchedExperimentalPeaksCount());
@@ -1848,10 +1922,35 @@ void cSpectrumDetailWidget::filterPeaksTable() {
bool hm = actionHideMatched->isChecked();
bool hu = actionHideUnmatched->isChecked();
bool hs = actionHideScrambled->isChecked();
+ bool hr = false;
+ bool ht = false;
+
+ QString pattern;
+
+ if (parameters && ((parameters->mode == denovoengine) || (parameters->mode == singlecomparison) || (parameters->mode == databasesearch))) {
+ if ((parameters->peptidetype == cyclic) || (parameters->peptidetype == branchcyclic) || (parameters->peptidetype == cyclicpolyketide)) {
+ if (rotation->currentIndex() > 0) {
+ pattern += rotation->currentText() + "_";
+ hr = true;
+ }
+ }
+ if ((parameters->peptidetype == branched) || (parameters->peptidetype == branchcyclic)) {
+ if (trotation->currentIndex() > 0) {
+ pattern += QString::number(trotation->currentIndex()) + "_";
+ ht = true;
+ }
+ }
+ }
+
+ if (hs) {
+ if (pattern.isEmpty()) {
+ pattern = "^((?!scrambled).)*$";
+ }
+ }
- proxymodel->setFlags(hm, hu, hs);
+ proxymodel->setFlags(hm, hu, hs, hr, ht);
proxymodel->setFilterKeyColumn(-1);
- proxymodel->setFilterFixedString("scrambled");
+ proxymodel->setFilterRegExp(pattern);
}
@@ -1873,6 +1972,16 @@ void cSpectrumDetailWidget::hideScrambledPeaks(bool hide) {
}
+void cSpectrumDetailWidget::filterTableAfterRotationChanged(int index) {
+ filterPeaksTable();
+}
+
+
+void cSpectrumDetailWidget::filterTableAfterTRotationChanged(int index) {
+ filterPeaksTable();
+}
+
+
void cSpectrumDetailWidget::showIsomersStateChanged() {
if (parameters->mode != dereplication) {
@@ -1917,10 +2026,15 @@ void cSpectrumDetailWidget::showIsomersStateChanged() {
for (int i = 0; i < thpeakscount; i++) {
peak = &((*thpeaks)[i]);
+
if (peak->descriptionid != -1) {
peak->description = parameters->peakidtodesc[peak->descriptionid];
}
+ if (peak->isotopeformulaid != -1) {
+ peak->isotopeformula = parameters->isotopeformulaidtodesc[peak->isotopeformulaid];
+ }
+
pos = peak->description.find(':');
if ((pos != string::npos) && (pos + 2 < peak->description.size()) && peakstablemodel->item(i, currentcolumn)) {
desc = peak->description.substr(pos + 2);
diff --git a/CycloBranch/gui/cSpectrumDetailWidget.h b/CycloBranch/gui/cSpectrumDetailWidget.h
index 2e7237a..c6eccd4 100644
--- a/CycloBranch/gui/cSpectrumDetailWidget.h
+++ b/CycloBranch/gui/cSpectrumDetailWidget.h
@@ -336,6 +336,12 @@ private slots:
void hideScrambledPeaks(bool hide);
+ void filterTableAfterRotationChanged(int index);
+
+
+ void filterTableAfterTRotationChanged(int index);
+
+
void showIsomersStateChanged();
diff --git a/CycloBranch/gui/cSpectrumSceneWidget.cpp b/CycloBranch/gui/cSpectrumSceneWidget.cpp
index 6ecc93f..832f500 100644
--- a/CycloBranch/gui/cSpectrumSceneWidget.cpp
+++ b/CycloBranch/gui/cSpectrumSceneWidget.cpp
@@ -204,12 +204,24 @@ void cSpectrumSceneWidget::wheelEvent(QWheelEvent *event) {
void cSpectrumSceneWidget::mouseMoveEvent(QMouseEvent *event) {
QGraphicsView::mouseMoveEvent(event);
- if (enablemousemzselection && (pressedx != -1) && (pressedy != -1)) {
+ if ((pressedx != -1) && (pressedy != -1)) {
QPointF p = mapToScene(event->x(), event->y());
currentx = (int)p.x();
currenty = (int)p.y();
- updateZoomGroup();
+ if (enablemousemzselection) {
+ updateZoomGroup();
+ }
+ else {
+ calculateMinMaxMZ();
+
+ emit updateMZInterval(minmzratio, maxmzratio);
+
+ pressedx = currentx;
+ pressedy = currenty;
+
+ redrawScene();
+ }
}
event->accept();
@@ -219,44 +231,22 @@ void cSpectrumSceneWidget::mouseMoveEvent(QMouseEvent *event) {
void cSpectrumSceneWidget::mouseReleaseEvent(QMouseEvent *event) {
QGraphicsView::mouseReleaseEvent(event);
- if (enablemousemzselection) {
- if (pressedx == currentx) {
- pressedx = -1;
- currentx = -1;
+ if (pressedx == currentx) {
+ pressedx = -1;
+ currentx = -1;
- redrawScene();
- }
+ redrawScene();
+ }
- if ((event->button() == Qt::LeftButton) && (pressedx != -1) && (pressedy != -1)) {
- if (pressedx < leftmargin) {
- pressedx = leftmargin;
- }
-
- if (pressedx > origwidth - rightmargin) {
- pressedx = origwidth - rightmargin;
- }
-
- if (currentx < leftmargin) {
- currentx = leftmargin;
- }
-
- if (currentx > origwidth - rightmargin) {
- currentx = origwidth - rightmargin;
- }
+ if ((event->button() == Qt::LeftButton) && (pressedx != -1) && (pressedy != -1)) {
+ calculateMinMaxMZ();
- double tmpminmzratio = getMZRatioFromXPosition((pressedx < currentx)?pressedx:currentx, origwidth);
- double tmpmaxmzratio = getMZRatioFromXPosition((pressedx < currentx)?currentx:pressedx, origwidth);
+ emit updateMZInterval(minmzratio, maxmzratio);
- minmzratio = tmpminmzratio;
- maxmzratio = tmpmaxmzratio;
+ pressedx = -1;
+ pressedy = -1;
- emit updateMZInterval(minmzratio, maxmzratio);
-
- pressedx = -1;
- pressedy = -1;
-
- redrawScene();
- }
+ redrawScene();
}
event->accept();
@@ -266,25 +256,27 @@ void cSpectrumSceneWidget::mouseReleaseEvent(QMouseEvent *event) {
void cSpectrumSceneWidget::mousePressEvent(QMouseEvent *event) {
QGraphicsView::mousePressEvent(event);
- if (enablemousemzselection) {
- if (event->button() == Qt::LeftButton) {
- QPointF p = mapToScene(event->x(), event->y());
- pressedx = (int)p.x();
- pressedy = (int)p.y();
+ if (event->button() == Qt::LeftButton) {
+ QPointF p = mapToScene(event->x(), event->y());
+ pressedx = (int)p.x();
+ pressedy = (int)p.y();
- currentx = pressedx;
- currenty = pressedy;
+ currentx = pressedx;
+ currenty = pressedy;
+ if (enablemousemzselection) {
updateZoomGroup();
}
+ }
- if (event->button() == Qt::RightButton) {
- pressedx = -1;
- pressedy = -1;
+ if (event->button() == Qt::RightButton) {
+ pressedx = -1;
+ pressedy = -1;
- redrawScene();
- }
+ redrawScene();
+ }
+ if (enablemousemzselection) {
if (event->button() == Qt::MiddleButton) {
pressedx = -1;
pressedy = -1;
@@ -478,7 +470,7 @@ void cSpectrumSceneWidget::redrawScene() {
visiblepeaks[visiblepeakscount].description += parameters->peakidtodesc[thpeaks[*it].descriptionid].substr(0, parameters->peakidtodesc[thpeaks[*it].descriptionid].rfind(':'));
}
else {
- visiblepeaks[visiblepeakscount].description += thpeaks[*it].description.substr(0, thpeaks[*it].description.find(':'));
+ visiblepeaks[visiblepeakscount].description += parameters->peakidtodesc[thpeaks[*it].descriptionid].substr(0, parameters->peakidtodesc[thpeaks[*it].descriptionid].find(':'));
}
}
@@ -674,6 +666,43 @@ void cSpectrumSceneWidget::updateZoomGroup() {
}
+void cSpectrumSceneWidget::calculateMinMaxMZ() {
+ if (pressedx < leftmargin) {
+ pressedx = leftmargin;
+ }
+
+ if (pressedx > origwidth - rightmargin) {
+ pressedx = origwidth - rightmargin;
+ }
+
+ if (currentx < leftmargin) {
+ currentx = leftmargin;
+ }
+
+ if (currentx > origwidth - rightmargin) {
+ currentx = origwidth - rightmargin;
+ }
+
+ double tmpminmzratio = getMZRatioFromXPosition((pressedx < currentx) ? pressedx : currentx, origwidth);
+ double tmpmaxmzratio = getMZRatioFromXPosition((pressedx < currentx) ? currentx : pressedx, origwidth);
+
+ if (enablemousemzselection) {
+ minmzratio = tmpminmzratio;
+ maxmzratio = tmpmaxmzratio;
+ }
+ else {
+ if (pressedx > currentx) {
+ minmzratio = min(minmzratio + tmpmaxmzratio - tmpminmzratio, theoreticalspectrum->getExperimentalSpectrum().getMaximumMZRatio());
+ maxmzratio = min(maxmzratio + tmpmaxmzratio - tmpminmzratio, theoreticalspectrum->getExperimentalSpectrum().getMaximumMZRatio());
+ }
+ else {
+ minmzratio = max(0.0, minmzratio - tmpmaxmzratio + tmpminmzratio);
+ maxmzratio = max(0.0, maxmzratio - tmpmaxmzratio + tmpminmzratio);
+ }
+ }
+}
+
+
void cSpectrumSceneWidget::zoomIn() {
if (currentscale < 32) {
currentscale += factor;
diff --git a/CycloBranch/gui/cSpectrumSceneWidget.h b/CycloBranch/gui/cSpectrumSceneWidget.h
index aca5ca8..ee85068 100644
--- a/CycloBranch/gui/cSpectrumSceneWidget.h
+++ b/CycloBranch/gui/cSpectrumSceneWidget.h
@@ -196,6 +196,9 @@ class cSpectrumSceneWidget : public QGraphicsView
void updateZoomGroup();
+ void calculateMinMaxMZ();
+
+
signals:
diff --git a/CycloBranch/gui/cSummaryPeaksTableWidget.cpp b/CycloBranch/gui/cSummaryPeaksTableWidget.cpp
index 2d7a91c..cd0db03 100644
--- a/CycloBranch/gui/cSummaryPeaksTableWidget.cpp
+++ b/CycloBranch/gui/cSummaryPeaksTableWidget.cpp
@@ -264,12 +264,22 @@ bool cSummaryPeaksTableWidget::prepareToShow(QStandardItemModel* resultsstandard
}
}
else if (parameters->mode == denovoengine) {
- databasemodel->setColumnCount(9);
+ if (parameters->generateisotopepattern) {
+ databasemodel->setColumnCount(11);
+ }
+ else {
+ databasemodel->setColumnCount(10);
+ }
}
else {
- databasemodel->setColumnCount(8);
+ if (parameters->generateisotopepattern) {
+ databasemodel->setColumnCount(10);
+ }
+ else {
+ databasemodel->setColumnCount(9);
+ }
}
-
+
databasemodel->setHorizontalHeaderItem(0, new QStandardItem());
databasemodel->horizontalHeaderItem(0)->setText("ID");
database->setItemDelegateForColumn(0, new QItemDelegate());
@@ -320,7 +330,7 @@ bool cSummaryPeaksTableWidget::prepareToShow(QStandardItemModel* resultsstandard
database->setItemDelegateForColumn(currentcolumn, new QItemDelegate());
currentcolumn++;
- if ((parameters->mode == dereplication) && (parameters->generateisotopepattern)) {
+ if (parameters->generateisotopepattern) {
databasemodel->setHorizontalHeaderItem(currentcolumn, new QStandardItem());
databasemodel->horizontalHeaderItem(currentcolumn)->setText("Theoretical Intensity [%]");
database->setItemDelegateForColumn(currentcolumn, new QItemDelegate());
@@ -381,11 +391,21 @@ bool cSummaryPeaksTableWidget::prepareToShow(QStandardItemModel* resultsstandard
currentcolumn++;
}
else {
+ databasemodel->setHorizontalHeaderItem(currentcolumn, new QStandardItem());
+ databasemodel->horizontalHeaderItem(currentcolumn)->setText("Summary Formula");
+ if (parameters->generateisotopepattern) {
+ database->setItemDelegateForColumn(currentcolumn, new cHTMLDelegate());
+ }
+ else {
+ database->setItemDelegateForColumn(currentcolumn, new QItemDelegate());
+ }
+ currentcolumn++;
+
databasemodel->setHorizontalHeaderItem(currentcolumn, new QStandardItem());
databasemodel->horizontalHeaderItem(currentcolumn)->setText("Sequence");
database->setItemDelegateForColumn(currentcolumn, new QItemDelegate());
currentcolumn++;
- }
+ }
rowsfiltercombobox->clear();
for (int i = 0; i < databasemodel->columnCount(); i++) {
@@ -436,7 +456,7 @@ bool cSummaryPeaksTableWidget::prepareToShow(QStandardItemModel* resultsstandard
spectrumindex = resultsstandardmodel->item(i, 1)->data(Qt::DisplayRole).toInt() - 1;
- if ((parameters->mode == dereplication) && (parameters->peaklistfileformat != mis) && (parameters->peaklistfileformat != imzML)) {
+ if ((parameters->mode == dereplication) && (parameters->peaklistfileformat != mis) && (parameters->peaklistfileformat != imzML)) {
addEICPeak(eicchromatogram, (*spectralist)[spectrumindex].getExperimentalSpectrum());
}
@@ -451,10 +471,15 @@ bool cSummaryPeaksTableWidget::prepareToShow(QStandardItemModel* resultsstandard
// theoretical peaks
for (int j = 0; j < thpeakscount; j++) {
peak = &((*thpeaks)[j]);
+
if (peak->descriptionid != -1) {
peak->description = parameters->peakidtodesc[peak->descriptionid];
}
+ if (peak->isotopeformulaid != -1) {
+ peak->isotopeformula = parameters->isotopeformulaidtodesc[peak->isotopeformulaid];
+ }
+
if (peak->matchedmz == 0) {
continue;
}
@@ -475,7 +500,7 @@ bool cSummaryPeaksTableWidget::prepareToShow(QStandardItemModel* resultsstandard
databasemodel->item(currentrow, currentcolumn)->setForeground(brush);
databasemodel->item(currentrow, currentcolumn)->setData(QVariant::fromValue((*spectralist)[spectrumindex].getExperimentalSpectrum().getCoordinateX()), Qt::DisplayRole);
currentcolumn++;
-
+
databasemodel->setItem(currentrow, currentcolumn, new QStandardItem());
databasemodel->item(currentrow, currentcolumn)->setForeground(brush);
databasemodel->item(currentrow, currentcolumn)->setData(QVariant::fromValue((*spectralist)[spectrumindex].getExperimentalSpectrum().getCoordinateY()), Qt::DisplayRole);
@@ -487,29 +512,29 @@ bool cSummaryPeaksTableWidget::prepareToShow(QStandardItemModel* resultsstandard
databasemodel->setItem(currentrow, currentcolumn, new QStandardItem());
databasemodel->item(currentrow, currentcolumn)->setForeground(brush);
databasemodel->item(currentrow, currentcolumn)->setText(peak->description.substr(0, secondspace).c_str());
- currentcolumn++;
+ currentcolumn++;
}
if (parameters->mode == denovoengine) {
databasemodel->setItem(currentrow, currentcolumn, new QStandardItem());
databasemodel->item(currentrow, currentcolumn)->setForeground(brush);
databasemodel->item(currentrow, currentcolumn)->setData(QVariant::fromValue((*spectralist)[spectrumindex].getPathId() + 1), Qt::DisplayRole);
- currentcolumn++;
+ currentcolumn++;
}
-
+
if (parameters->mode != dereplication) {
databasemodel->setItem(currentrow, currentcolumn, new QStandardItem());
databasemodel->item(currentrow, currentcolumn)->setForeground(brush);
databasemodel->item(currentrow, currentcolumn)->setText(peak->description.substr(0, peak->description.find(':')).c_str());
- currentcolumn++;
+ currentcolumn++;
}
-
+
databasemodel->setItem(currentrow, currentcolumn, new QStandardItem());
databasemodel->item(currentrow, currentcolumn)->setForeground(brush);
databasemodel->item(currentrow, currentcolumn)->setData(QVariant::fromValue(cropPrecisionToSixDecimalsByteArray(peak->mzratio)), Qt::DisplayRole);
currentcolumn++;
- if ((parameters->mode == dereplication) && (parameters->generateisotopepattern)) {
+ if (parameters->generateisotopepattern) {
databasemodel->setItem(currentrow, currentcolumn, new QStandardItem());
databasemodel->item(currentrow, currentcolumn)->setForeground(brush);
databasemodel->item(currentrow, currentcolumn)->setData(QVariant::fromValue(cropPrecisionToSixDecimalsByteArray(peak->relativeintensity)), Qt::DisplayRole);
@@ -552,7 +577,7 @@ bool cSummaryPeaksTableWidget::prepareToShow(QStandardItemModel* resultsstandard
databasemodel->setItem(currentrow, currentcolumn, new QStandardItem());
databasemodel->item(currentrow, currentcolumn)->setForeground(brush);
databasemodel->item(currentrow, currentcolumn)->setText(peak->description.substr(peak->description.rfind('(') + 1, peak->description.rfind(')') - peak->description.rfind('(') - 1).c_str());
- currentcolumn++;
+ currentcolumn++;
langle = (int)peak->description.rfind("");
rangle = (int)peak->description.find('>');
@@ -569,7 +594,7 @@ bool cSummaryPeaksTableWidget::prepareToShow(QStandardItemModel* resultsstandard
coordinates.back().name += databasemodel->item(currentrow, currentcolumn)->text().toStdString();
}
}
- currentcolumn++;
+ currentcolumn++;
tmp = (int)peak->description.find('<');
stmp = peak->description.substr(tmp, rangle - tmp + 1);
@@ -579,7 +604,7 @@ bool cSummaryPeaksTableWidget::prepareToShow(QStandardItemModel* resultsstandard
databasemodel->setItem(currentrow, currentcolumn, new QStandardItem());
databasemodel->item(currentrow, currentcolumn)->setForeground(brush);
databasemodel->item(currentrow, currentcolumn)->setText(stmp.c_str());
- currentcolumn++;
+ currentcolumn++;
}
else {
databasemodel->setItem(currentrow, currentcolumn, new QStandardItem());
@@ -594,15 +619,25 @@ bool cSummaryPeaksTableWidget::prepareToShow(QStandardItemModel* resultsstandard
coordinates.back().name += databasemodel->item(currentrow, currentcolumn)->text().toStdString();
}
}
- currentcolumn++;
+ currentcolumn++;
databasemodel->setItem(currentrow, currentcolumn, new QStandardItem());
databasemodel->item(currentrow, currentcolumn)->setForeground(brush);
databasemodel->item(currentrow, currentcolumn)->setText("");
- currentcolumn++;
+ currentcolumn++;
}
}
else {
+ databasemodel->setItem(currentrow, currentcolumn, new QStandardItem());
+ databasemodel->item(currentrow, currentcolumn)->setForeground(brush);
+ if (parameters->generateisotopepattern) {
+ databasemodel->item(currentrow, currentcolumn)->setText(peak->isotopeformula.c_str());
+ }
+ else {
+ databasemodel->item(currentrow, currentcolumn)->setText(peak->formula.getFancySummary(peak->charge).c_str());
+ }
+ currentcolumn++;
+
databasemodel->setItem(currentrow, currentcolumn, new QStandardItem());
databasemodel->item(currentrow, currentcolumn)->setForeground(brush);
databasemodel->item(currentrow, currentcolumn)->setText("");
@@ -613,17 +648,17 @@ bool cSummaryPeaksTableWidget::prepareToShow(QStandardItemModel* resultsstandard
}
databasemodel->item(currentrow, currentcolumn)->setText(fragmentname.c_str());
}
- currentcolumn++;
+ currentcolumn++;
}
}
- progress->setValue(i);
- if (progress->wasCanceled()) {
+ progress->setValue(i);
+ if (progress->wasCanceled()) {
deleteTable();
emit tableCancelled();
break;
- }
+ }
}
@@ -636,30 +671,40 @@ bool cSummaryPeaksTableWidget::prepareToShow(QStandardItemModel* resultsstandard
for (int i = 0; i < databasemodel->columnCount(); i++) {
database->resizeColumnToContents(i);
}
- }
- if ((parameters->mode == dereplication) && !progress->wasCanceled()) {
- if ((parameters->peaklistfileformat == mis) || (parameters->peaklistfileformat == imzML)) {
- emit resetRegion();
- emit sendFilterOptionsToImageWindow(coordinates, rowsfiltercombobox->currentText().toStdString(), rowsfiltercomparatorcombobox->currentText().toStdString(), rowsfilterline->text().toStdString(), rowsfiltercasesensitive->isChecked(), rowsfilterwholeword->isChecked());
+ if (parameters->mode == dereplication) {
+ if ((parameters->peaklistfileformat == mis) || (parameters->peaklistfileformat == imzML)) {
+ emit resetRegion();
+ emit sendFilterOptionsToImageWindow(coordinates, rowsfiltercombobox->currentText().toStdString(), rowsfiltercomparatorcombobox->currentText().toStdString(), rowsfilterline->text().toStdString(), rowsfiltercasesensitive->isChecked(), rowsfilterwholeword->isChecked());
- if (parameters->generateisotopepattern) {
- database->setColumnWidth(12, min(400, database->columnWidth(12)));
+ if (parameters->generateisotopepattern) {
+ database->setColumnWidth(12, min(400, database->columnWidth(12)));
+ }
+ else {
+ database->setColumnWidth(9, min(400, database->columnWidth(9)));
+ }
}
else {
+ eicchromatogram.normalizeIntenzity();
+ origeicchromatogram = eicchromatogram;
+ emit sendFilterOptionsToChromatogram(eicchromatogram);
+
+ if (parameters->generateisotopepattern) {
+ database->setColumnWidth(10, min(400, database->columnWidth(10)));
+ }
+ else {
+ database->setColumnWidth(7, min(400, database->columnWidth(7)));
+ }
+ }
+ }
+ else if (parameters->mode == denovoengine) {
+ if (parameters->generateisotopepattern) {
database->setColumnWidth(9, min(400, database->columnWidth(9)));
}
}
else {
- eicchromatogram.normalizeIntenzity();
- origeicchromatogram = eicchromatogram;
- emit sendFilterOptionsToChromatogram(eicchromatogram);
-
if (parameters->generateisotopepattern) {
- database->setColumnWidth(10, min(400, database->columnWidth(10)));
- }
- else {
- database->setColumnWidth(7, min(400, database->columnWidth(7)));
+ database->setColumnWidth(8, min(400, database->columnWidth(8)));
}
}
}
@@ -1042,11 +1087,13 @@ void cSummaryPeaksTableWidget::exportStatistics() {
int idcol;
int xcol, ycol;
int relintcol, absintcol;
- int scorecol, qvaluecol;
+ int scorecol, fdrcol;
int experimentalmzcol;
int ppmcol;
+ int thintcol;
+
if (parameters->mode == dereplication) {
if ((parameters->peaklistfileformat == mis) || (parameters->peaklistfileformat == imzML)) {
@@ -1057,7 +1104,7 @@ void cSummaryPeaksTableWidget::exportStatistics() {
namecol = 13;
referencecol = 14;
scorecol = 10;
- qvaluecol = 11;
+ fdrcol = 11;
idcol = 0;
xcol = 1;
ycol = 2;
@@ -1085,7 +1132,7 @@ void cSummaryPeaksTableWidget::exportStatistics() {
namecol = 11;
referencecol = 12;
scorecol = 8;
- qvaluecol = 9;
+ fdrcol = 9;
idcol = 0;
relintcol = 5;
absintcol = 6;
@@ -1104,18 +1151,42 @@ void cSummaryPeaksTableWidget::exportStatistics() {
}
else if (parameters->mode == denovoengine) {
- theoreticalmzcol = 3;
- experimentalmzcol = 4;
- relintcol = 5;
- absintcol = 6;
- ppmcol = 7;
+ if (parameters->generateisotopepattern) {
+ theoreticalmzcol = 3;
+ thintcol = 4;
+ experimentalmzcol = 5;
+ relintcol = 6;
+ absintcol = 7;
+ ppmcol = 8;
+ summaryformulacol = 9;
+ }
+ else {
+ theoreticalmzcol = 3;
+ experimentalmzcol = 4;
+ relintcol = 5;
+ absintcol = 6;
+ ppmcol = 7;
+ summaryformulacol = 8;
+ }
}
else {
- theoreticalmzcol = 2;
- experimentalmzcol = 3;
- relintcol = 4;
- absintcol = 5;
- ppmcol = 6;
+ if (parameters->generateisotopepattern) {
+ theoreticalmzcol = 2;
+ thintcol = 3;
+ experimentalmzcol = 4;
+ relintcol = 5;
+ absintcol = 6;
+ ppmcol = 7;
+ summaryformulacol = 8;
+ }
+ else {
+ theoreticalmzcol = 2;
+ experimentalmzcol = 3;
+ relintcol = 4;
+ absintcol = 5;
+ ppmcol = 6;
+ summaryformulacol = 7;
+ }
}
map, cIonSummaryTableKeyMS_comp> ionmapms;
@@ -1132,6 +1203,10 @@ void cSummaryPeaksTableWidget::exportStatistics() {
keyms.clear();
+ item = databasemodel->itemFromIndex(proxymodel->mapToSource(proxymodel->index(i, idcol)));
+ if (item) {
+ keyms.id = item->text().toStdString();
+ }
item = databasemodel->itemFromIndex(proxymodel->mapToSource(proxymodel->index(i, iontypecol)));
if (item) {
keyms.iontype = item->text().toStdString();
@@ -1152,6 +1227,16 @@ void cSummaryPeaksTableWidget::exportStatistics() {
if (item) {
keyms.reference = item->text().toStdString();
}
+ if (parameters->generateisotopepattern) {
+ item = databasemodel->itemFromIndex(proxymodel->mapToSource(proxymodel->index(i, scorecol)));
+ if (item) {
+ keyms.score = item->text().toStdString();
+ }
+ item = databasemodel->itemFromIndex(proxymodel->mapToSource(proxymodel->index(i, fdrcol)));
+ if (item) {
+ keyms.fdr = item->text().toStdString();
+ }
+ }
auto obj = ionmapms.find(keyms);
if (obj != ionmapms.end()) {
@@ -1184,6 +1269,10 @@ void cSummaryPeaksTableWidget::exportStatistics() {
if (item) {
keymsms.theoreticalmz = item->text().toStdString();
}
+ item = databasemodel->itemFromIndex(proxymodel->mapToSource(proxymodel->index(i, thintcol)));
+ if (item) {
+ keymsms.thint = item->text().toStdString();
+ }
item = databasemodel->itemFromIndex(proxymodel->mapToSource(proxymodel->index(i, experimentalmzcol)));
if (item) {
keymsms.experimentalmz = item->text().toStdString();
@@ -1200,6 +1289,10 @@ void cSummaryPeaksTableWidget::exportStatistics() {
if (item) {
keymsms.ppmerror = item->text().toStdString();
}
+ item = databasemodel->itemFromIndex(proxymodel->mapToSource(proxymodel->index(i, summaryformulacol)));
+ if (item) {
+ keymsms.summary = item->text().toStdString();
+ }
auto obj = mapmsms.find(keymsms);
if (obj != mapmsms.end()) {
@@ -1226,11 +1319,11 @@ void cSummaryPeaksTableWidget::exportStatistics() {
double relintmax, relintavg, relintmed, relintcur;
double absintmax, absintavg, absintmed, absintcur;
double scoremin, scoreavg, scoremed, scoremax, scorecur;
- double qvaluemin, qvalueavg, qvaluemed, qvaluemax, qvaluecur;
+ double fdrmin, fdravg, fdrmed, fdrmax, fdrcur;
vector relintmedianvector;
vector absintmedianvector;
vector scoremedianvector;
- vector qvaluemedianvector;
+ vector fdrmedianvector;
if (parameters->mode == dereplication) {
@@ -1274,65 +1367,79 @@ void cSummaryPeaksTableWidget::exportStatistics() {
out << "\"Whole Pattern Statistics\"" << endl << endl;
- out << "\"Name\",\"Pattern Type\",";
+ out << "\"Name\",\"Pattern Type\",\"Number of Patterns\",";
out << "\"Minimum Score\",\"Average Score\",\"Median Score\",\"Maximum Score\",";
out << "\"Minimum FDR\",\"Average FDR\",\"Median FDR\",\"Maximum FDR\",";
out << "\"Reference\"" << endl;
- for (auto it = envelopestatisticsms.begin(); it != envelopestatisticsms.end(); ++it) {
+ scoremin = DBL_MAX;
+ scoremax = 0;
+ scoreavg = 0;
+ scoremedianvector.clear();
- scoremin = DBL_MAX;
- scoremax = 0;
- scoreavg = 0;
- scoremedianvector.clear();
+ fdrmin = DBL_MAX;
+ fdrmax = 0;
+ fdravg = 0;
+ fdrmedianvector.clear();
- qvaluemin = DBL_MAX;
- qvaluemax = 0;
- qvalueavg = 0;
- qvaluemedianvector.clear();
+ int envelopesstatisticssize = (int)envelopestatisticsms.size();
+ int cnt = 0;
+ for (int i = 0; i < envelopesstatisticssize; i++) {
- for (auto it2 = it->second.begin(); it2 != it->second.end(); ++it2) {
- item = databasemodel->itemFromIndex(proxymodel->mapToSource(proxymodel->index(*it2, scorecol)));
- if (item) {
- scorecur = item->data(Qt::DisplayRole).toDouble();
- if (scorecur > scoremax) {
- scoremax = scorecur;
- }
- if (scorecur < scoremin) {
- scoremin = scorecur;
- }
- scoreavg += scorecur;
- scoremedianvector.push_back(scorecur);
- }
+ scorecur = QString(envelopestatisticsms[i].first.score.c_str()).toDouble();
+ if (scorecur > scoremax) {
+ scoremax = scorecur;
+ }
+ if (scorecur < scoremin) {
+ scoremin = scorecur;
+ }
+ scoreavg += scorecur;
+ scoremedianvector.push_back(scorecur);
- item = databasemodel->itemFromIndex(proxymodel->mapToSource(proxymodel->index(*it2, qvaluecol)));
- if (item) {
- qvaluecur = item->data(Qt::DisplayRole).toDouble();
- if (qvaluecur > qvaluemax) {
- qvaluemax = qvaluecur;
- }
- if (qvaluecur < qvaluemin) {
- qvaluemin = qvaluecur;
- }
- qvalueavg += qvaluecur;
- qvaluemedianvector.push_back(qvaluecur);
- }
+ fdrcur = QString(envelopestatisticsms[i].first.fdr.c_str()).toDouble();
+ if (fdrcur > fdrmax) {
+ fdrmax = fdrcur;
+ }
+ if (fdrcur < fdrmin) {
+ fdrmin = fdrcur;
+ }
+ fdravg += fdrcur;
+ fdrmedianvector.push_back(fdrcur);
+
+ cnt++;
+
+ if ((i + 1 < envelopesstatisticssize) && (envelopestatisticsms[i].first.iontype.compare(envelopestatisticsms[i + 1].first.iontype) == 0)
+ && (envelopestatisticsms[i].first.name.compare(envelopestatisticsms[i + 1].first.name) == 0)
+ && (envelopestatisticsms[i].first.reference.compare(envelopestatisticsms[i + 1].first.reference) == 0)) {
+ continue;
}
- scoreavg /= (double)it->second.size();
- qvalueavg /= (double)it->second.size();
+ scoreavg /= (double)cnt;
+ fdravg /= (double)cnt;
scoremed = median(scoremedianvector);
- qvaluemed = median(qvaluemedianvector);
+ fdrmed = median(fdrmedianvector);
- out << "\"" << it->first.name.c_str() << "\",\"" << it->first.iontype.c_str() << "\",\"";
+ out << "\"" << envelopestatisticsms[i].first.name.c_str() << "\",\"" << envelopestatisticsms[i].first.iontype.c_str() << "\",\"" << cnt << "\",\"";
stringstream ss;
ss << std::fixed << std::setprecision(6) << scoremin << "\",\"" << scoreavg << "\",\"" << scoremed << "\",\"" << scoremax << "\",\"";
- ss << std::fixed << std::setprecision(6) << qvaluemin << "\",\"" << qvalueavg << "\",\"" << qvaluemed << "\",\"" << qvaluemax << "\",\"";
+ ss << std::fixed << std::setprecision(6) << fdrmin << "\",\"" << fdravg << "\",\"" << fdrmed << "\",\"" << fdrmax << "\",\"";
out << ss.str().c_str();
- out << it->first.reference.c_str() << "\"" << endl;
+ out << envelopestatisticsms[i].first.reference.c_str() << "\"" << endl;
+
+ scoremin = DBL_MAX;
+ scoremax = 0;
+ scoreavg = 0;
+ scoremedianvector.clear();
+
+ fdrmin = DBL_MAX;
+ fdrmax = 0;
+ fdravg = 0;
+ fdrmedianvector.clear();
+
+ cnt = 0;
}
@@ -1466,7 +1573,11 @@ void cSummaryPeaksTableWidget::exportStatistics() {
}
else {
- out << "\"Number of Matches\",\"Theoretical m/z\",\"Experimental m/z\",\"Relative Intensity [%]\",\"Absolute Intensity\",\"Error [ppm]\"" << endl;
+ out << "\"Number of Matches\",\"Theoretical m/z\",";
+ if (parameters->generateisotopepattern) {
+ out << "\"Theoretical Intensity [%]\",";
+ }
+ out << "\"Experimental m/z\",\"Relative Intensity [%]\",\"Absolute Intensity\",\"Error [ppm]\",\"Summary Formula\"" << endl;
vector< pair > > statisticsmsms;
@@ -1480,7 +1591,11 @@ void cSummaryPeaksTableWidget::exportStatistics() {
sort(statisticsmsms.begin(), statisticsmsms.end(), cmpmsms);
for (auto it = statisticsmsms.begin(); it != statisticsmsms.end(); ++it) {
- out << "\"" << it->second.size() << "\",\"" << it->first.theoreticalmz.c_str() << "\",\"" << it->first.experimentalmz.c_str() << "\",\"" << it->first.relint.c_str() << "\",\"" << it->first.absint.c_str() << "\",\"" << it->first.ppmerror.c_str() << "\"" << endl;
+ out << "\"" << it->second.size() << "\",\"" << it->first.theoreticalmz.c_str() << "\",";
+ if (parameters->generateisotopepattern) {
+ out << "\"" << it->first.thint.c_str() << "\",";
+ }
+ out << "\"" << it->first.experimentalmz.c_str() << "\",\"" << it->first.relint.c_str() << "\",\"" << it->first.absint.c_str() << "\",\"" << it->first.ppmerror.c_str() << "\",\"" << stripHTML(it->first.summary).c_str() << "\"" << endl;
}
}
diff --git a/CycloBranch/gui/cSummaryPeaksTableWidget.h b/CycloBranch/gui/cSummaryPeaksTableWidget.h
index b9e7bfc..76ac558 100644
--- a/CycloBranch/gui/cSummaryPeaksTableWidget.h
+++ b/CycloBranch/gui/cSummaryPeaksTableWidget.h
@@ -47,6 +47,12 @@ class QMenu;
*/
struct cSummaryTableKeyMS {
+ /**
+ \brief Identification ID subkey.
+ */
+ string id;
+
+
/**
\brief Ion type subkey.
*/
@@ -77,15 +83,30 @@ struct cSummaryTableKeyMS {
string reference;
+ /**
+ \brief Score subkey.
+ */
+ string score;
+
+
+ /**
+ \brief FDR subkey.
+ */
+ string fdr;
+
+
/**
\brief Clear the structure.
*/
void clear() {
+ id.clear();
iontype.clear();
theoreticalmz.clear();
summaryformula.clear();
name.clear();
reference.clear();
+ score.clear();
+ fdr.clear();
}
};
@@ -102,6 +123,12 @@ struct cSummaryTableKeyMSMS {
string theoreticalmz;
+ /**
+ \brief Theoretical intensity subkey.
+ */
+ string thint;
+
+
/**
\brief Experimental m/z subkey.
*/
@@ -126,15 +153,23 @@ struct cSummaryTableKeyMSMS {
string ppmerror;
+ /**
+ \brief summary formula subkey.
+ */
+ string summary;
+
+
/**
\brief Clear the structure.
*/
void clear() {
theoreticalmz.clear();
+ thint.clear();
experimentalmz.clear();
relint.clear();
absint.clear();
ppmerror.clear();
+ summary.clear();
}
};
@@ -170,7 +205,7 @@ struct cEnvelopeSummaryTableKeyMS_comp {
\retval bool true if the first object is less than the second object
*/
bool operator()(const cSummaryTableKeyMS& left, const cSummaryTableKeyMS& right) const {
- return (left.iontype + left.name + left.reference < right.iontype + right.name + right.reference);
+ return (left.id + left.iontype + left.name + left.reference < right.id + right.iontype + right.name + right.reference);
}
};
@@ -188,7 +223,7 @@ struct cSummaryTableKeyMSMS_comp {
\retval bool true if the first object is less than the second object
*/
bool operator()(const cSummaryTableKeyMSMS& left, const cSummaryTableKeyMSMS& right) const {
- return (left.theoreticalmz + left.experimentalmz + left.relint + left.absint + left.ppmerror < right.theoreticalmz + right.experimentalmz + right.relint + right.absint + right.ppmerror);
+ return (left.theoreticalmz + left.thint + left.experimentalmz + left.relint + left.absint + left.ppmerror + left.summary < right.theoreticalmz + right.thint + right.experimentalmz + right.relint + right.absint + right.ppmerror + right.summary);
}
};
diff --git a/CycloBranch/parallel/cSpectrumComparatorThread.cpp b/CycloBranch/parallel/cSpectrumComparatorThread.cpp
index d6c27fa..8deac28 100644
--- a/CycloBranch/parallel/cSpectrumComparatorThread.cpp
+++ b/CycloBranch/parallel/cSpectrumComparatorThread.cpp
@@ -3,6 +3,34 @@
#include "core/cTheoreticalSpectrumList.h"
+bool comparePaths(vector& a, vector& b) {
+ if (a.size() < b.size()) {
+ return true;
+ }
+
+ if (a.size() > b.size()) {
+ return false;
+ }
+
+ for (int i = 0; i < a.size(); i++) {
+ if (a[i].nodeid < b[i].nodeid) {
+ return true;
+ }
+ if (a[i].nodeid > b[i].nodeid) {
+ return false;
+ }
+ if (a[i].edgeid < b[i].edgeid) {
+ return true;
+ }
+ if (a[i].edgeid > b[i].edgeid) {
+ return false;
+ }
+ }
+
+ return false;
+}
+
+
bool compareBandAllIonsDesc(const cTheoreticalSpectrum& a, const cTheoreticalSpectrum& b) {
if (a.getNumberOfMatchedPeaks(b_ion) > b.getNumberOfMatchedPeaks(b_ion)) {
return true;
@@ -10,16 +38,25 @@ bool compareBandAllIonsDesc(const cTheoreticalSpectrum& a, const cTheoreticalSpe
if (a.getNumberOfMatchedPeaks(b_ion) < b.getNumberOfMatchedPeaks(b_ion)) {
return false;
}
+
if (a.getNumberOfMatchedPeaks() > b.getNumberOfMatchedPeaks()) {
return true;
}
if (a.getNumberOfMatchedPeaks() < b.getNumberOfMatchedPeaks()) {
return false;
}
+
if (a.getPathId() < b.getPathId()) {
return true;
}
- return false;
+ if (a.getPathId() > b.getPathId()) {
+ return false;
+ }
+
+ vector v1 = ((cTheoreticalSpectrum&)a).getCandidate().getPath();
+ vector v2 = ((cTheoreticalSpectrum&)b).getCandidate().getPath();
+
+ return comparePaths(v1, v2);
}
@@ -30,16 +67,25 @@ bool compareBBwaterLossAndAllIonsDesc(const cTheoreticalSpectrum& a, const cTheo
if (a.getNumberOfMatchedPeaks(b_ion) + a.getNumberOfMatchedPeaks(b_ion_dehydrated) < b.getNumberOfMatchedPeaks(b_ion) + b.getNumberOfMatchedPeaks(b_ion_dehydrated)) {
return false;
}
+
if (a.getNumberOfMatchedPeaks() > b.getNumberOfMatchedPeaks()) {
return true;
}
if (a.getNumberOfMatchedPeaks() < b.getNumberOfMatchedPeaks()) {
return false;
}
+
if (a.getPathId() < b.getPathId()) {
return true;
}
- return false;
+ if (a.getPathId() > b.getPathId()) {
+ return false;
+ }
+
+ vector v1 = ((cTheoreticalSpectrum&)a).getCandidate().getPath();
+ vector v2 = ((cTheoreticalSpectrum&)b).getCandidate().getPath();
+
+ return comparePaths(v1, v2);
}
@@ -50,16 +96,25 @@ bool compareBBammoniaLossAndAllIonsDesc(const cTheoreticalSpectrum& a, const cTh
if (a.getNumberOfMatchedPeaks(b_ion) + a.getNumberOfMatchedPeaks(b_ion_deamidated) < b.getNumberOfMatchedPeaks(b_ion) + b.getNumberOfMatchedPeaks(b_ion_deamidated)) {
return false;
}
+
if (a.getNumberOfMatchedPeaks() > b.getNumberOfMatchedPeaks()) {
return true;
}
if (a.getNumberOfMatchedPeaks() < b.getNumberOfMatchedPeaks()) {
return false;
}
+
if (a.getPathId() < b.getPathId()) {
return true;
}
- return false;
+ if (a.getPathId() > b.getPathId()) {
+ return false;
+ }
+
+ vector v1 = ((cTheoreticalSpectrum&)a).getCandidate().getPath();
+ vector v2 = ((cTheoreticalSpectrum&)b).getCandidate().getPath();
+
+ return comparePaths(v1, v2);
}
@@ -70,16 +125,25 @@ bool compareYBandAllIonsDesc(const cTheoreticalSpectrum& a, const cTheoreticalSp
if (a.getNumberOfMatchedPeaksYB() < b.getNumberOfMatchedPeaksYB()) {
return false;
}
+
if (a.getNumberOfMatchedPeaks() > b.getNumberOfMatchedPeaks()) {
return true;
}
if (a.getNumberOfMatchedPeaks() < b.getNumberOfMatchedPeaks()) {
return false;
}
+
if (a.getPathId() < b.getPathId()) {
return true;
}
- return false;
+ if (a.getPathId() > b.getPathId()) {
+ return false;
+ }
+
+ vector v1 = ((cTheoreticalSpectrum&)a).getCandidate().getPath();
+ vector v2 = ((cTheoreticalSpectrum&)b).getCandidate().getPath();
+
+ return comparePaths(v1, v2);
}
@@ -90,16 +154,25 @@ bool compareYandAllIonsDesc(const cTheoreticalSpectrum& a, const cTheoreticalSpe
if (a.getNumberOfMatchedPeaks(y_ion) < b.getNumberOfMatchedPeaks(y_ion)) {
return false;
}
+
if (a.getNumberOfMatchedPeaks() > b.getNumberOfMatchedPeaks()) {
return true;
}
if (a.getNumberOfMatchedPeaks() < b.getNumberOfMatchedPeaks()) {
return false;
}
+
if (a.getPathId() < b.getPathId()) {
return true;
}
- return false;
+ if (a.getPathId() > b.getPathId()) {
+ return false;
+ }
+
+ vector v1 = ((cTheoreticalSpectrum&)a).getCandidate().getPath();
+ vector v2 = ((cTheoreticalSpectrum&)b).getCandidate().getPath();
+
+ return comparePaths(v1, v2);
}
@@ -110,10 +183,18 @@ bool compareWeightedIntensityDesc(const cTheoreticalSpectrum& a, const cTheoreti
if (a.getWeightedIntensityScore() < b.getWeightedIntensityScore()) {
return false;
}
+
if (a.getPathId() < b.getPathId()) {
return true;
}
- return false;
+ if (a.getPathId() > b.getPathId()) {
+ return false;
+ }
+
+ vector v1 = ((cTheoreticalSpectrum&)a).getCandidate().getPath();
+ vector v2 = ((cTheoreticalSpectrum&)b).getCandidate().getPath();
+
+ return comparePaths(v1, v2);
}
@@ -124,10 +205,18 @@ bool compareNumberOfMatchedPeaksDesc(const cTheoreticalSpectrum& a, const cTheor
if (a.getNumberOfMatchedPeaks() < b.getNumberOfMatchedPeaks()) {
return false;
}
+
if (a.getPathId() < b.getPathId()) {
return true;
}
- return false;
+ if (a.getPathId() > b.getPathId()) {
+ return false;
+ }
+
+ vector v1 = ((cTheoreticalSpectrum&)a).getCandidate().getPath();
+ vector v2 = ((cTheoreticalSpectrum&)b).getCandidate().getPath();
+
+ return comparePaths(v1, v2);
}
@@ -138,21 +227,29 @@ bool compareNumberOfMatchedBricksDesc(const cTheoreticalSpectrum& a, const cTheo
if (a.getNumberOfMatchedBricks() < b.getNumberOfMatchedBricks()) {
return false;
}
+
if (a.getPathId() < b.getPathId()) {
return true;
}
- return false;
+ if (a.getPathId() > b.getPathId()) {
+ return false;
+ }
+
+ vector v1 = ((cTheoreticalSpectrum&)a).getCandidate().getPath();
+ vector v2 = ((cTheoreticalSpectrum&)b).getCandidate().getPath();
+
+ return comparePaths(v1, v2);
}
-void cSpectrumComparatorThread::initialize(cCandidate& candidate, cPeaksList& peaklist, cBricksDatabase* bricksdatabasewithcombinations, cTheoreticalSpectrumList* theoreticalspectrumlist, cParameters* parameters, regex* rxsequencetag, regex* rxsearchedsequence, double worstscore, bool* terminatecomputation) {
+void cSpectrumComparatorThread::initialize(cCandidate& candidate, cPeaksList& peaklist, cBricksDatabase* bricksdatabasewithcombinations, cTheoreticalSpectrumList* theoreticalspectrumlist, cParameters* parameters, regex* rxsequencetag, regex* rxsearchedsequence, double currentworstscore, bool* terminatecomputation) {
this->candidate = candidate;
this->peaklist = peaklist;
this->theoreticalspectrumlist = theoreticalspectrumlist;
this->parameters = parameters;
this->rxsequencetag = rxsequencetag;
this->rxsearchedsequence = rxsearchedsequence;
- this->worstscore = worstscore;
+ this->lastavailableworstscore = currentworstscore;
this->terminatecomputation = terminatecomputation;
this->bricksdatabasewithcombinations = bricksdatabasewithcombinations;
}
@@ -193,30 +290,29 @@ void cSpectrumComparatorThread::run() {
}
}
- switch (parameters->peptidetype)
- {
- case linear:
- theoreticalpeaksrealsize = tsp.compareLinear(peaklist, *bricksdatabasewithcombinations, false, *rxsequencetag, *rxsearchedsequence);
- break;
- case cyclic:
- theoreticalpeaksrealsize = tsp.compareCyclic(peaklist, *bricksdatabasewithcombinations, false, *rxsequencetag, *rxsearchedsequence);
- break;
- case branched:
- theoreticalpeaksrealsize = tsp.compareBranched(peaklist, *bricksdatabasewithcombinations, false, *rxsequencetag, *rxsearchedsequence);
- break;
- case branchcyclic:
- theoreticalpeaksrealsize = tsp.compareBranchCyclic(peaklist, *bricksdatabasewithcombinations, false, *rxsequencetag, *rxsearchedsequence);
- break;
- case linearpolyketide:
- theoreticalpeaksrealsize = tsp.compareLinearPolyketide(peaklist, *bricksdatabasewithcombinations, false, *rxsequencetag, *rxsearchedsequence);
- break;
- case cyclicpolyketide:
- theoreticalpeaksrealsize = tsp.compareCyclicPolyketide(peaklist, *bricksdatabasewithcombinations, false, *rxsequencetag, *rxsearchedsequence);
- break;
- case other:
- break;
- default:
- break;
+ switch (parameters->peptidetype) {
+ case linear:
+ theoreticalpeaksrealsize = tsp.compareLinear(peaklist, *bricksdatabasewithcombinations, false, *rxsequencetag, *rxsearchedsequence);
+ break;
+ case cyclic:
+ theoreticalpeaksrealsize = tsp.compareCyclic(peaklist, *bricksdatabasewithcombinations, false, *rxsequencetag, *rxsearchedsequence);
+ break;
+ case branched:
+ theoreticalpeaksrealsize = tsp.compareBranched(peaklist, *bricksdatabasewithcombinations, false, *rxsequencetag, *rxsearchedsequence);
+ break;
+ case branchcyclic:
+ theoreticalpeaksrealsize = tsp.compareBranchCyclic(peaklist, *bricksdatabasewithcombinations, false, *rxsequencetag, *rxsearchedsequence);
+ break;
+ case linearpolyketide:
+ theoreticalpeaksrealsize = tsp.compareLinearPolyketide(peaklist, *bricksdatabasewithcombinations, false, *rxsequencetag, *rxsearchedsequence);
+ break;
+ case cyclicpolyketide:
+ theoreticalpeaksrealsize = tsp.compareCyclicPolyketide(peaklist, *bricksdatabasewithcombinations, false, *rxsequencetag, *rxsearchedsequence);
+ break;
+ case other:
+ break;
+ default:
+ break;
}
// invalid sequence tag
@@ -226,34 +322,34 @@ void cSpectrumComparatorThread::run() {
score = 0;
switch (parameters->scoretype) {
- case b_ions:
- score = tsp.getNumberOfMatchedPeaks(b_ion);
- break;
- case b_ions_and_b_dehydrated_ions:
- score = tsp.getNumberOfMatchedPeaks(b_ion) + tsp.getNumberOfMatchedPeaks(b_ion_dehydrated);
- break;
- case b_ions_and_b_deamidated_ions:
- score = tsp.getNumberOfMatchedPeaks(b_ion) + tsp.getNumberOfMatchedPeaks(b_ion_deamidated);
- break;
- case y_ions_and_b_ions:
- score = tsp.getNumberOfMatchedPeaksYB();
- break;
- case y_ions:
- score = tsp.getNumberOfMatchedPeaks(y_ion);
- break;
- case weighted_intensity:
- score = tsp.getWeightedIntensityScore();
- break;
- case matched_peaks:
- score = tsp.getNumberOfMatchedPeaks();
- break;
- case matched_bricks:
- score = tsp.getNumberOfMatchedBricks();
- break;
+ case b_ions:
+ score = tsp.getNumberOfMatchedPeaks(b_ion);
+ break;
+ case b_ions_and_b_dehydrated_ions:
+ score = tsp.getNumberOfMatchedPeaks(b_ion) + tsp.getNumberOfMatchedPeaks(b_ion_dehydrated);
+ break;
+ case b_ions_and_b_deamidated_ions:
+ score = tsp.getNumberOfMatchedPeaks(b_ion) + tsp.getNumberOfMatchedPeaks(b_ion_deamidated);
+ break;
+ case y_ions_and_b_ions:
+ score = tsp.getNumberOfMatchedPeaksYB();
+ break;
+ case y_ions:
+ score = tsp.getNumberOfMatchedPeaks(y_ion);
+ break;
+ case weighted_intensity:
+ score = tsp.getWeightedIntensityScore();
+ break;
+ case matched_peaks:
+ score = tsp.getNumberOfMatchedPeaks();
+ break;
+ case matched_bricks:
+ score = tsp.getNumberOfMatchedBricks();
+ break;
}
- if (score >= worstscore) {
- theoreticalspectrumlist->addButDoNotFitSize(tsp, theoreticalpeaksrealsize);
+ if (score >= lastavailableworstscore) {
+ lastavailableworstscore = theoreticalspectrumlist->updatekNNList(tsp, theoreticalpeaksrealsize, score, rxsearchedsequence);
}
}
diff --git a/CycloBranch/parallel/cSpectrumComparatorThread.h b/CycloBranch/parallel/cSpectrumComparatorThread.h
index c7c7a23..cf2a052 100644
--- a/CycloBranch/parallel/cSpectrumComparatorThread.h
+++ b/CycloBranch/parallel/cSpectrumComparatorThread.h
@@ -15,6 +15,14 @@
class cTheoreticalSpectrumList;
+/**
+ \brief Compare two paths of a peptide sequence candidate as a string.
+ \param a first theoretical spectrum
+ \param b second theoretical spectrum
+ \retval bool true if the path of \a a is smaller than the path of \a b
+*/
+bool comparePaths(vector& a, vector& b);
+
/**
\brief Compare scores of two theoretical spectra (number of b-ions and all ions secondly).
@@ -103,7 +111,7 @@ class cSpectrumComparatorThread : public QObject, public QRunnable {
cParameters* parameters;
regex* rxsequencetag;
regex* rxsearchedsequence;
- double worstscore;
+ double lastavailableworstscore;
bool* terminatecomputation;
cBricksDatabase* bricksdatabasewithcombinations;
@@ -119,10 +127,10 @@ class cSpectrumComparatorThread : public QObject, public QRunnable {
\param parameters pointer to program parameters
\param rxsequencetag pointer to a regular expression of a sequence tag
\param rxsearchedsequence pointer to a regular expression of a searched sequence
- \param worstscore worst score in the resulting set of theoretical spectra
+ \param currentworstscore worst score in the resulting set of theoretical spectra
\param terminatecomputation reference to a variable determining that the thread must be stopped
*/
- void initialize(cCandidate& candidate, cPeaksList& peaklist, cBricksDatabase* bricksdatabasewithcombinations, cTheoreticalSpectrumList* theoreticalspectrumlist, cParameters* parameters, regex* rxsequencetag, regex* rxsearchedsequence, double worstscore, bool* terminatecomputation);
+ void initialize(cCandidate& candidate, cPeaksList& peaklist, cBricksDatabase* bricksdatabasewithcombinations, cTheoreticalSpectrumList* theoreticalspectrumlist, cParameters* parameters, regex* rxsequencetag, regex* rxsearchedsequence, double currentworstscore, bool* terminatecomputation);
protected: