Loading...
Searching...
No Matches
obolistmodel.cpp
Go to the documentation of this file.
/**
* \file pappsomspp/widget/obo/obolistwidget/obolistmodel.h
* \date 19/04/2021
* \author Olivier Langella
* \brief MVC model of OBO term list
*/
/*******************************************************************************
* Copyright (c) 2021 Olivier Langella
*<Olivier.Langella@universite-paris-saclay.fr>.
*
* This file is part of the PAPPSOms++ library.
*
* PAPPSOms++ is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PAPPSOms++ is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PAPPSOms++. If not, see <http://www.gnu.org/licenses/>.
*
******************************************************************************/
#include "obolistmodel.h"
#include "pappsomspp/core/obo/obopsimod.h"
#include "pappsomspp/core/obo/obounimod.h"
#include "obolistwidget.h"
#include "pappsomspp/core/exception/exceptionnotfound.h"
#include "pappsomspp/core/amino_acid/chemicalformula.h"
#include <QColor>
#include <QDebug>
using namespace pappso;
OboListModel::OboListModel(QObject *parent) : QStringListModel(parent)
{
}
OboListModel::~OboListModel()
{
}
pappso::OboListModel::OboPsiModHandler::OboPsiModHandler(pappso::OboListModel *parent)
{
mp_parent = parent;
}
pappso::OboListModel::OboPsiModHandler::~OboPsiModHandler()
{
}
void
pappso::OboListModel::OboPsiModHandler::setOboPsiModTerm(const pappso::OboPsiModTerm &term)
{
mp_parent->m_oboPsiModTermList.push_back(term);
}
void
OboListModel::loadPsiMod()
{
OboPsiModHandler handler(this);
OboPsiMod reader(handler);
OboUnimod unimod_reader(handler);
// https://pubchem.ncbi.nlm.nih.gov/compound/640368
OboPsiModTerm term;
term.setAccession("USER:2-Ethynylbenzaldehyde");
term.m_diffFormula = "H 4 C 9 O 0"; // C9H6O
term.m_name = "2-Ethynylbenzaldehyde";
ChemicalFormula formula;
formula.setOboPsiModTerm(term);
term.m_diffMono = formula.getMass();
m_oboPsiModTermList.push_back(term);
qDebug() << m_oboPsiModTermList.size();
}
QVariant
pappso::OboListModel::data(const QModelIndex &index, int role) const
{
// generate a log message when this method gets called
std::size_t row = index.row();
// int col = index.column();
// qDebug() << QString("row %1, col%2, role %3")
// .arg(row).arg(col).arg(role);
if(row < m_oboPsiModTermList.size())
{
switch(role)
{
case Qt::CheckStateRole:
break;
case Qt::BackgroundRole:
// return QVariant(QColor("grey"));
break;
case Qt::SizeHintRole:
// qDebug() << "ProteinTableModel::headerData " <<
// ProteinTableModel::getColumnWidth(section);
// return QSize(PeptideTableModel::getColumnWidth(col), 30);
break;
case Qt::ToolTipRole:
break;
case Qt::DisplayRole:
return QVariant(QString("%1 %2 %3")
.arg(m_oboPsiModTermList[row].getAccession())
.arg(m_oboPsiModTermList[row].m_diffMono)
.arg(m_oboPsiModTermList[row].m_name));
break;
case Qt::UserRole:
QVariant value;
value.setValue(m_oboPsiModTermList[row]);
return value;
break;
}
}
return QVariant();
}
int
pappso::OboListModel::rowCount(const QModelIndex &parent [[maybe_unused]]) const
{
return (int)m_oboPsiModTermList.size();
}
const pappso::OboPsiModTerm &
pappso::OboListModel::getOboPsiModTerm(int row) const
{
if(row < (int)m_oboPsiModTermList.size())
{
return m_oboPsiModTermList[row];
}
else
{
throw pappso::ExceptionNotFound(tr("OBO term not found"));
}
}
chemicalformula.h
pappso::ChemicalFormula
Definition chemicalformula.h:44
pappso::ChemicalFormula::setOboPsiModTerm
void setOboPsiModTerm(const OboPsiModTerm &term)
get formula from an Obo term
Definition chemicalformula.cpp:352
pappso::ChemicalFormula::getMass
double getMass() const
Definition chemicalformula.cpp:296
pappso::ExceptionNotFound
Definition exceptionnotfound.h:32
pappso::OboListModel::OboPsiModHandler
Definition obolistmodel.h:71
pappso::OboListModel::OboPsiModHandler::~OboPsiModHandler
virtual ~OboPsiModHandler()
Definition obolistmodel.cpp:55
pappso::OboListModel::OboPsiModHandler::mp_parent
pappso::OboListModel * mp_parent
Definition obolistmodel.h:80
pappso::OboListModel::OboPsiModHandler::OboPsiModHandler
OboPsiModHandler(OboListModel *parent)
Definition obolistmodel.cpp:50
pappso::OboListModel::OboPsiModHandler::setOboPsiModTerm
void setOboPsiModTerm(const OboPsiModTerm &term) override
triggered function on each obo term when parsing obo file
Definition obolistmodel.cpp:60
pappso::OboListModel
Definition obolistmodel.h:46
pappso::OboListModel::data
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override
Definition obolistmodel.cpp:89
pappso::OboListModel::getOboPsiModTerm
const OboPsiModTerm & getOboPsiModTerm(int row) const
Definition obolistmodel.cpp:138
pappso::OboListModel::OboListModel
OboListModel(QObject *parent=nullptr)
Definition obolistmodel.cpp:42
pappso::OboListModel::m_oboPsiModTermList
std::vector< OboPsiModTerm > m_oboPsiModTermList
Definition obolistmodel.h:83
pappso::OboListModel::rowCount
int rowCount(const QModelIndex &parent=QModelIndex()) const override
Definition obolistmodel.cpp:132
pappso::OboListModel::~OboListModel
~OboListModel()
Definition obolistmodel.cpp:46
pappso::OboListModel::loadPsiMod
void loadPsiMod()
Definition obolistmodel.cpp:67
pappso::OboPsiModTerm
Definition obopsimodterm.h:34
pappso::OboPsiModTerm::setAccession
void setAccession(const QString &accession)
Definition obopsimodterm.cpp:267
pappso::OboPsiModTerm::m_diffFormula
QString m_diffFormula
Definition obopsimodterm.h:62
pappso::OboPsiModTerm::m_diffMono
double m_diffMono
Definition obopsimodterm.h:66
pappso::OboPsiModTerm::m_name
QString m_name
Definition obopsimodterm.h:58
pappso::OboPsiMod
Definition obopsimod.h:35
pappso::OboUnimod
Definition obounimod.h:39
exceptionnotfound.h
pappso
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
Definition aa.cpp:39
obolistmodel.h
obolistwidget.h
obopsimod.h
obounimod.h