libpappsomspp
Library for mass spectrometry
obopsimod.cpp
Go to the documentation of this file.
1
2/*******************************************************************************
3 * Copyright (c) 2015 Olivier Langella <Olivier.Langella@moulon.inra.fr>.
4 *
5 * This file is part of the PAPPSOms++ library.
6 *
7 * PAPPSOms++ is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * PAPPSOms++ is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with PAPPSOms++. If not, see <http://www.gnu.org/licenses/>.
19 *
20 * Contributors:
21 * Olivier Langella <Olivier.Langella@moulon.inra.fr> - initial API and
22 *implementation
23 ******************************************************************************/
24
25#include <QDir>
26#include <QDebug>
27#include "obopsimod.h"
28#include "../pappsoexception.h"
29#include <iostream>
30
31inline void
33{
34 Q_INIT_RESOURCE(libpappsomsppresources);
35}
36
37
38namespace pappso
39{
40
41OboPsiMod::OboPsiMod(OboPsiModHandlerInterface &handler) : m_handler(handler)
42{
43 qDebug();
45 parse();
46}
47
49{
50}
51
52
53void
55{
56 // std::cout << "OboPsiMod::parse Begin parsing OBO file" << std::endl;
57 qDebug() << "OboPsiMod::parse Begin parsing OBO file";
58 QFile obofile(":/resources/PSI-MOD.obo");
59 if(!obofile.exists())
60 {
61 throw PappsoException(
62 QObject::tr("PSI-MOD OBO resource file : %1 not found")
63 .arg(obofile.fileName()));
64 }
65 obofile.open(QIODevice::ReadOnly);
66 QTextStream p_in(&obofile);
67
68 // Search accession conta
69 // QTextStream in(p_in);
70 QString line = p_in.readLine();
71 bool in_term = false;
72 while(!p_in.atEnd())
73 {
74 // qDebug() << "OboPsiMod::parse line "<< line;
75 if(line.startsWith("[Term]"))
76 {
77 in_term = true;
79 }
80 else if(line.isEmpty())
81 {
82 if(in_term)
83 {
85 in_term = false;
86 }
87 }
88 else
89 {
90 if(in_term)
92 // m_handler.setSequence(line);
93 }
94 line = p_in.readLine();
95 }
96 if(in_term)
97 {
99 }
100 // p_in->close();
101
102 obofile.close();
103}
104
105} // namespace pappso
virtual void setOboPsiModTerm(const OboPsiModTerm &term)=0
triggered function on each obo term when parsing obo file
void parseLine(const QString &line)
OboPsiMod(OboPsiModHandlerInterface &handler)
Definition: obopsimod.cpp:41
void parse()
starts reading obo file and reports each term with the callback function
Definition: obopsimod.cpp:54
OboPsiModTerm m_term
Definition: obopsimod.h:41
OboPsiModHandlerInterface & m_handler
Definition: obopsimod.h:42
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
Definition: aa.cpp:39
void initMyResource()
Definition: obopsimod.cpp:32