From 60eeb09cc7a77ff0d068ee0fe095d8fc5811bf19 Mon Sep 17 00:00:00 2001 From: Olivier Langella <Olivier.Langella@moulon.inra.fr> Date: Thu, 30 Mar 2017 11:09:50 +0200 Subject: [PATCH] html sequence coverage --- src/CMakeLists.txt | 4 +- src/core/proteinmatch.cpp | 42 +++++++++++++++++++++ src/core/proteinmatch.h | 4 ++ src/gui/protein_view/protein_detail_view.ui | 4 +- src/gui/protein_view/proteinwindow.cpp | 2 +- 5 files changed, 51 insertions(+), 5 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 617e2004..46172223 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -29,8 +29,8 @@ SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt5Xml_EXECUTABLE_COMPILE_FLAGS} ${Qt5 #sudo apt-get install libpappsomspp-dev #FIND_PACKAGE( Pappsomspp REQUIRED ) - SET (PAPPSOMSPP_DIR "/home/olivier/eclipse/git/pappsomspp") -# SET (PAPPSOMSPP_DIR "/home/langella/developpement/git/pappsomspp") +# SET (PAPPSOMSPP_DIR "/home/olivier/eclipse/git/pappsomspp") + SET (PAPPSOMSPP_DIR "/home/langella/developpement/git/pappsomspp") SET (PAPPSOMSPP_INCLUDE_DIR "${PAPPSOMSPP_DIR}/src") SET (PAPPSOMSPP_QT4_LIBRARY "${PAPPSOMSPP_DIR}/cbuild/src/libpappsomspp-qt4.so") diff --git a/src/core/proteinmatch.cpp b/src/core/proteinmatch.cpp index 29635494..1dec8423 100644 --- a/src/core/proteinmatch.cpp +++ b/src/core/proteinmatch.cpp @@ -258,6 +258,48 @@ pappso::pappso_double ProteinMatch::getPAI(const pappso::MsRunIdSp & sp_msrun_id return PAI; } + +const QString ProteinMatch::getHtmlSequence() const +{ + size_t prot_size = _protein_sp.get()->size(); + //qDebug() << "ProteinMatch::getCoverage begin prot_size=" << prot_size << " " << _protein_sp.get()-//>getSequence(); + if (prot_size == 0) return 0; + bool cover_bool[prot_size] = {false}; + for (auto & p_peptide_match : _peptide_match_list) { + if (p_peptide_match->isValidAndChecked()) { + size_t size = p_peptide_match->getPeptideXtpSp().get()->size(); + size_t offset = p_peptide_match->getStart(); + if (offset >= 0) { + for (size_t i=0; (i < size) && (offset < prot_size) ; i++,offset++) { + cover_bool[offset] = true; + } + } + } + } + QString sequence = getProteinXtpSp().get()->getSequence(); + QString sequence_html; + for (unsigned int i=0; i < prot_size; i++) { + + if(cover_bool[i]) { + sequence_html.append(QString("<span style=\"background-color:yellow;\">%1").arg(sequence[i])); + for (;i < prot_size; i++) { + if(cover_bool[i]) { + sequence_html.append(sequence[i]); + } + else { + sequence_html.append(QString("</span>%1").arg(sequence[i])); + break; + } + } + sequence_html.append(QString("</span>")); + } + else { + sequence_html.append(sequence[i]); + } + } + return sequence_html; +} + pappso::pappso_double ProteinMatch::getCoverage() const { size_t prot_size = _protein_sp.get()->size(); //qDebug() << "ProteinMatch::getCoverage begin prot_size=" << prot_size << " " << _protein_sp.get()-//>getSequence(); diff --git a/src/core/proteinmatch.h b/src/core/proteinmatch.h index 74ce8c12..9269a875 100644 --- a/src/core/proteinmatch.h +++ b/src/core/proteinmatch.h @@ -58,6 +58,10 @@ public: * */ pappso::pappso_double getCoverage() const; +/** @brief get coverage sequence (html representation) + **/ + const QString getHtmlSequence() const; + /** @brief compute Protein Abundance Index (PAI) * overall sample PAI computation (Rappsilber et al. 2002) * */ diff --git a/src/gui/protein_view/protein_detail_view.ui b/src/gui/protein_view/protein_detail_view.ui index c0bd5932..addfcf9f 100644 --- a/src/gui/protein_view/protein_detail_view.ui +++ b/src/gui/protein_view/protein_detail_view.ui @@ -40,9 +40,9 @@ </widget> </item> <item> - <widget class="QPlainTextEdit" name="sequenceTextEdit"> + <widget class="QTextEdit" name="sequenceTextEdit"> <property name="lineWrapMode"> - <enum>QPlainTextEdit::WidgetWidth</enum> + <enum>QTextEdit::WidgetWidth</enum> </property> </widget> </item> diff --git a/src/gui/protein_view/proteinwindow.cpp b/src/gui/protein_view/proteinwindow.cpp index 2fc6f334..8ba96d76 100644 --- a/src/gui/protein_view/proteinwindow.cpp +++ b/src/gui/protein_view/proteinwindow.cpp @@ -55,5 +55,5 @@ ProteinWindow::~ProteinWindow() void ProteinWindow::setProteinMatch(ProteinMatch * p_protein_match) { ui->descriptionLabel->setText(p_protein_match->getProteinXtpSp().get()->getAccession()); //ui->sequenceLabel->setText(p_protein_match->getProteinXtpSp().get()->getSequence()); - ui->sequenceTextEdit->setPlainText(p_protein_match->getProteinXtpSp().get()->getSequence()); + ui->sequenceTextEdit->setText(p_protein_match->getHtmlSequence()); } -- GitLab