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