Skip to content
Snippets Groups Projects
Commit 3a18efe1 authored by Olivier Langella's avatar Olivier Langella
Browse files

ptm sequence color

parent 1180dc3c
No related branches found
No related tags found
No related merge requests found
......@@ -30,6 +30,12 @@
#include "ptmsamplescan.h"
#include "../../grouping/ptm/ptmgroupingexperiment.h"
QColor PtmSampleScan::_color_best = QColor("red");
QColor PtmSampleScan::_color_other_best = QColor("#ff7878");
QColor PtmSampleScan::_color_no_best = QColor("yellow");
PtmSampleScan::PtmSampleScan(const PeptideMatch * p_peptide_match) {
_peptide_match_list.push_back(p_peptide_match);
}
......@@ -80,3 +86,52 @@ bool PtmSampleScan::add(const PeptideMatch * p_peptide_match) {
position_list.erase(last, position_list.end());
return position_list;
}
const QString PtmSampleScan::getHtmlSequence(const PtmGroupingExperiment * p_ptm_grouping_experiment) const
{
const PeptideMatch * p_representative_peptide = getRepresentativePeptideMatch();
size_t pep_size = p_representative_peptide->getPeptideXtpSp().get()->size();
//qDebug() << "ProteinMatch::getCoverage begin prot_size=" << prot_size << " " << _protein_sp.get()-//>getSequence();
if (pep_size == 0) return 0;
bool best_bool[pep_size] = {false};
bool other_best_bool[pep_size] = {false};
bool nobest_bool[pep_size] = {false};
double best_evalue = p_representative_peptide->getEvalue();
for (auto & p_peptide_match : _peptide_match_list) {
bool is_best= false;
if (p_peptide_match->getEvalue() == best_evalue) {
is_best= true;
}
std::vector<unsigned int> position_list = p_ptm_grouping_experiment->getPtmPositions(p_peptide_match);
for (unsigned int position :position_list) {
if (p_representative_peptide == p_peptide_match) {
best_bool[position] = true;
}
else if (is_best) {
other_best_bool[position] = true;
}
else {
nobest_bool[position] = true;
}
}
}
QString sequence = p_representative_peptide->getPeptideXtpSp().get()->getSequence();
QString sequence_html;
for (unsigned int i=0; i < pep_size; i++) {
if (best_bool[i]) {
sequence_html.append(QString("<span style=\"color:%2;\">%1</span>").arg(sequence[i]).arg(_color_best.name()));
}
else if (other_best_bool[i]) {
sequence_html.append(QString("<span style=\"color:%2;\">%1</span>").arg(sequence[i]).arg(_color_other_best.name()));
}
else if (nobest_bool[i]){
sequence_html.append(QString("<span style=\"color:%2;\">%1</span>").arg(sequence[i]).arg(_color_no_best.name()));
}
else {
sequence_html.append(sequence[i]);
}
}
return sequence_html;
}
......@@ -52,9 +52,13 @@ public:
bool add(const PeptideMatch * p_peptide_match);
std::vector<unsigned int> getBestPtmPositionList(const PtmGroupingExperiment * p_ptm_grouping_experiment) const;
std::vector<unsigned int> getObservedPtmPositionList(const PtmGroupingExperiment * p_ptm_grouping_experiment) const;
const QString getHtmlSequence(const PtmGroupingExperiment * p_ptm_grouping_experiment) const;
private:
std::vector<const PeptideMatch *> _peptide_match_list;
static QColor _color_best;
static QColor _color_other_best;
static QColor _color_no_best;
};
......
......@@ -50,7 +50,7 @@ PtmPeptideListWindow::PtmPeptideListWindow(PtmIslandListWindow * parent):QMainWi
ui->ptm_peptide_tableview->setModel( _ptm_proxy_model_p );
ui->ptm_peptide_tableview->setSortingEnabled(true);
ui->ptm_peptide_tableview->setAlternatingRowColors(true);
PtmSequenceDelegate * p_sequence_delegate = new PtmSequenceDelegate();
PtmSequenceDelegate * p_sequence_delegate = new PtmSequenceDelegate(_p_ptm_island_list_window, this);
ui->ptm_peptide_tableview->setItemDelegateForColumn((std::int8_t) PtmPeptideListColumn::sequence, p_sequence_delegate);
......
......@@ -28,11 +28,12 @@
#include "ptmsequencedelegate.h"
#include "../../grouping/ptm/ptmsamplescan.h"
#include "../ptm_island_list_view/ptmislandlistwindow.h"
#include <QTextDocument>
#include <QPainter>
PtmSequenceDelegate::PtmSequenceDelegate(QWidget *parent) : QStyledItemDelegate(parent) {
PtmSequenceDelegate::PtmSequenceDelegate(PtmIslandListWindow * p_ptm_island_list_window, QWidget *parent) : QStyledItemDelegate(parent) {
_p_ptm_island_list_window = p_ptm_island_list_window;
}
void PtmSequenceDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option,
......@@ -45,7 +46,7 @@ void PtmSequenceDelegate::paint(QPainter *painter, const QStyleOptionViewItem &o
// painter->fillRect(option.rect, option.palette.highlight());
QTextDocument document;
document.setDocumentMargin(2);
document.setHtml(p_ptm_sample_scan->getRepresentativePeptideMatch()->getPeptideXtpSp().get()->getSequence());
document.setHtml(p_ptm_sample_scan->getHtmlSequence(_p_ptm_island_list_window->getIdentificationGroup()->getPtmGroupingExperiment()));
painter->translate(option.rect.topLeft());
document.drawContents(painter);
painter->translate(-option.rect.topLeft());
......
......@@ -30,13 +30,14 @@
#define PTMSEQUENCEDELEGATE_H
#include <QStyledItemDelegate>
class PtmIslandListWindow;
class PtmSequenceDelegate : public QStyledItemDelegate
{
Q_OBJECT
public:
PtmSequenceDelegate(QWidget *parent = 0);
PtmSequenceDelegate(PtmIslandListWindow * p_ptm_island_list_window, QWidget *parent = 0);
void paint(QPainter *painter, const QStyleOptionViewItem &option,
const QModelIndex &index) const override;
......@@ -47,6 +48,7 @@ public:
//void setEditorData(QWidget *editor, const QModelIndex &index) const override;
//void setModelData(QWidget *editor, QAbstractItemModel *model,
// const QModelIndex &index) const override;
private:
PtmIslandListWindow * _p_ptm_island_list_window;
};
#endif // PTMSEQUENCEDELEGATE_H
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment