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

#include <obolistmodel.h>

Inheritance diagram for pappso::OboListModel:

Classes

class  OboPsiModHandler

Public Member Functions

 OboListModel (QObject *parent=nullptr)
 ~OboListModel ()
void loadPsiMod ()
QVariant data (const QModelIndex &index, int role=Qt::DisplayRole) const override
int rowCount (const QModelIndex &parent=QModelIndex()) const override
const OboPsiModTermgetOboPsiModTerm (int row) const

Protected Attributes

std::vector< OboPsiModTermm_oboPsiModTermList

Detailed Description

Todo
write docs

Definition at line 45 of file obolistmodel.h.

Constructor & Destructor Documentation

◆ OboListModel()

OboListModel::OboListModel ( QObject * parent = nullptr)

Default constructor

Definition at line 42 of file obolistmodel.cpp.

42 : QStringListModel(parent)
43{
44}

◆ ~OboListModel()

OboListModel::~OboListModel ( )

Destructor

Definition at line 46 of file obolistmodel.cpp.

47{
48}

Member Function Documentation

◆ data()

QVariant pappso::OboListModel::data ( const QModelIndex & index,
int role = Qt::DisplayRole ) const
override

Definition at line 89 of file obolistmodel.cpp.

90{
91
92 // generate a log message when this method gets called
93 std::size_t row = index.row();
94 // int col = index.column();
95 // qDebug() << QString("row %1, col%2, role %3")
96 // .arg(row).arg(col).arg(role);
97 if(row < m_oboPsiModTermList.size())
98 {
99
100 switch(role)
101 {
102 case Qt::CheckStateRole:
103
104 break;
105 case Qt::BackgroundRole:
106 // return QVariant(QColor("grey"));
107 break;
108 case Qt::SizeHintRole:
109 // qDebug() << "ProteinTableModel::headerData " <<
110 // ProteinTableModel::getColumnWidth(section);
111 // return QSize(PeptideTableModel::getColumnWidth(col), 30);
112 break;
113 case Qt::ToolTipRole:
114 break;
115 case Qt::DisplayRole:
116 return QVariant(QString("%1 %2 %3")
117 .arg(m_oboPsiModTermList[row].getAccession())
118 .arg(m_oboPsiModTermList[row].m_diffMono)
119 .arg(m_oboPsiModTermList[row].m_name));
120 break;
121 case Qt::UserRole:
122 QVariant value;
123 value.setValue(m_oboPsiModTermList[row]);
124 return value;
125 break;
126 }
127 }
128 return QVariant();
129}
std::vector< OboPsiModTerm > m_oboPsiModTermList

References m_oboPsiModTermList.

Referenced by pappso::OboListProxyModel::lessThan().

◆ getOboPsiModTerm()

const pappso::OboPsiModTerm & pappso::OboListModel::getOboPsiModTerm ( int row) const

Definition at line 138 of file obolistmodel.cpp.

139{
140 if(row < (int)m_oboPsiModTermList.size())
141 {
142 return m_oboPsiModTermList[row];
143 }
144 else
145 {
146 throw pappso::ExceptionNotFound(tr("OBO term not found"));
147 }
148}

References m_oboPsiModTermList.

◆ loadPsiMod()

void OboListModel::loadPsiMod ( )

Definition at line 67 of file obolistmodel.cpp.

68{
69 OboPsiModHandler handler(this);
70 OboPsiMod reader(handler);
71 OboUnimod unimod_reader(handler);
72
73
74 // https://pubchem.ncbi.nlm.nih.gov/compound/640368
75 OboPsiModTerm term;
76 term.setAccession("USER:2-Ethynylbenzaldehyde");
77 term.m_diffFormula = "H 4 C 9 O 0"; // C9H6O
78 term.m_name = "2-Ethynylbenzaldehyde";
79 ChemicalFormula formula;
80 formula.setOboPsiModTerm(term);
81 term.m_diffMono = formula.getMass();
82
83 m_oboPsiModTermList.push_back(term);
84
85 qDebug() << m_oboPsiModTermList.size();
86}
void setOboPsiModTerm(const OboPsiModTerm &term)
get formula from an Obo term
void setAccession(const QString &accession)

References pappso::ChemicalFormula::getMass(), pappso::OboPsiModTerm::m_diffFormula, pappso::OboPsiModTerm::m_diffMono, pappso::OboPsiModTerm::m_name, m_oboPsiModTermList, pappso::OboPsiModTerm::setAccession(), and pappso::ChemicalFormula::setOboPsiModTerm().

◆ rowCount()

int pappso::OboListModel::rowCount ( const QModelIndex & parent = QModelIndex()) const
override

Definition at line 132 of file obolistmodel.cpp.

133{
134 return (int)m_oboPsiModTermList.size();
135}

References m_oboPsiModTermList.

Member Data Documentation

◆ m_oboPsiModTermList

std::vector<OboPsiModTerm> pappso::OboListModel::m_oboPsiModTermList
protected

Definition at line 83 of file obolistmodel.h.

Referenced by data(), getOboPsiModTerm(), loadPsiMod(), and rowCount().


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