Skip to content
Snippets Groups Projects
Commit d73fcb8b authored by Olivier Langella's avatar Olivier Langella
Browse files

sax parser for xpip file

parent 62fdfecd
No related branches found
No related tags found
No related merge requests found
......@@ -12,7 +12,7 @@
#FIND_PACKAGE(Boost REQUIRED)
#INCLUDE_DIRECTORIES( ${Boost_INCLUDE_DIRS})
FIND_PACKAGE( Qt4 COMPONENTS QTCORE QTGUI QTSVG REQUIRED )
FIND_PACKAGE( Qt4 COMPONENTS QTCORE QTGUI QTSVG QTXML REQUIRED )
FIND_PACKAGE( Odsstream REQUIRED ) #ODSSTREAM_INCLUDE_DIR AND ODSSTREAM_LIBRARY
......@@ -54,6 +54,7 @@ SET(CPP_FILES
utils/readspectrum.cpp
core/project.cpp
files/xpipfile.cpp
input/xpipsaxhandler.cpp
)
set(QTLIBS ${Qt5Xml_LIBRARIES} ${Qt5Gui_LIBRARIES} ${Qt5Svg_LIBRARIES})
......@@ -92,15 +93,17 @@ MESSAGE("XTPCPP_SRCS: ${XTPCPP_SRCS}")
ADD_EXECUTABLE(xtpcpp main.cpp ${CPP_FILES} ${XTPCPP_SRCS} ${GUI_UI_HDRS} ${XTPCPP_MOC_SRCS})
target_include_directories (xtpcpp PUBLIC ${QT_INCLUDE_DIR} ${QT_QTCORE_INCLUDE_DIR} ${QT_QTGUI_INCLUDE_DIR} ${QT_QTSVG_INCLUDE_DIR})
target_include_directories (xtpcpp PUBLIC ${QT_INCLUDE_DIR} ${QT_QTCORE_INCLUDE_DIR} ${QT_QTGUI_INCLUDE_DIR} ${QT_QTSVG_INCLUDE_DIR} ${QT_QTXML_INCLUDE_DIR})
SET_TARGET_PROPERTIES(xtpcpp
PROPERTIES OUTPUT_NAME xtpcpp
CLEAN_DIRECT_OUTPUT 1
COMPILE_DEFINITIONS "${QT_DEFINITIONS}"
#INCLUDE_DIRECTORIES "${QT_INCLUDE_DIR} ${QT_QTCORE_INCLUDE_DIR}"
)
TARGET_LINK_LIBRARIES(xtpcpp ${PAPPSOMSPP_QT4_LIBRARY} ${Pwiz_LIBRARY} ${ODSSTREAM_QT4_LIBRARY} ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} ${QT_QTSVG_LIBRARY})
TARGET_LINK_LIBRARIES(xtpcpp ${PAPPSOMSPP_QT4_LIBRARY} ${Pwiz_LIBRARY} ${ODSSTREAM_QT4_LIBRARY} ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} ${QT_QTSVG_LIBRARY} ${QT_QTXML_LIBRARY})
INSTALL(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/xtpcpp DESTINATION bin)
#configure_file (${CMAKE_SOURCE_DIR}/templates/share/applications/pt-peptideviewer.desktop.cmake ${CMAKE_BINARY_DIR}/templates/share/applications/pt-peptideviewer.desktop)
add_subdirectory(input)
\ No newline at end of file
......@@ -21,6 +21,7 @@
* Olivier Langella <Olivier.Langella@moulon.inra.fr> - initial API and implementation
******************************************************************************/
#include "project.h"
#include "../input/xpipsaxhandler.h"
Project::Project()
{
......@@ -33,5 +34,45 @@ Project::~Project()
}
ProjectSp Project::makeProjectSp() const {
return std::make_shared<Project>(*this);
}
\ No newline at end of file
return std::make_shared<Project>(*this);
}
void Project::readXpipFile(QFileInfo xpip_fileinfo) {
XpipSaxHandler * parser = new XpipSaxHandler();
QXmlSimpleReader simplereader;
simplereader.setContentHandler(parser);
simplereader.setErrorHandler(parser);
qDebug() << "Read XPIP XML result file '" << xpip_fileinfo.absoluteFilePath() << "'";
QFile qfile(xpip_fileinfo.absoluteFilePath());
QXmlInputSource xmlInputSource(&qfile);
if (simplereader.parse(xmlInputSource)) {
} else {
qDebug() << parser->errorString();
// throw PappsoException(
// QObject::tr("error reading tandem XML result file :\n").append(
// parser->errorString()));
}
qfile.close();
/*
GrpGroupingMonitor monitor;
GrpExperiment grpExperiment(monitor);
PeptideReader peptideReader(grpExperiment);
FastaReader reader(peptideReader);
reader.parse(&fastaFile);
fastaFile.close();
grpExperiment.startGrouping();
std::list<GrpProteinSp> protein_list;
grpExperiment.getGroupedProteinSpList(protein_list);
*/
}
......@@ -24,6 +24,8 @@
#define PROJECT_H
#include<memory>
#include <pappsomspp/grouping/grpexperiment.h>
#include <QFileInfo>
class Project;
typedef std::shared_ptr<Project> ProjectSp;
......@@ -35,6 +37,9 @@ public:
~Project();
ProjectSp makeProjectSp() const;
void readXpipFile(QFileInfo xpip_source);
pappso::GrpExperiment * _p_grp_experiment= nullptr;
};
#endif // PROJECT_H
......@@ -30,9 +30,12 @@ XpipFile::~XpipFile()
{
}
ProjectSp XpipFile::getProjectSp() const {
Project project;
ProjectSp project_sp = Project().makeProjectSp();
project_sp.get()->readXpipFile(QFileInfo(_xpip_source.toLocalFile()));
return (project.makeProjectSp());
return (project_sp);
}
\ No newline at end of file
......@@ -49,11 +49,11 @@ QVariant ProteinTableModel::headerData(int section, Qt::Orientation orientation,
switch (section)
{
case 0:
return QString("first");
return QString("group");
case 1:
return QString("second");
return QString("subgroup");
case 2:
return QString("third");
return QString("protein description");
}
}
}
......
/*******************************************************************************
* Copyright (c) 2016 Olivier Langella <Olivier.Langella@moulon.inra.fr>.
*
* This file is part of XTPcpp.
*
* XTPcpp 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.
*
* XTPcpp 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 XTPcpp. If not, see <http://www.gnu.org/licenses/>.
*
* Contributors:
* Olivier Langella <Olivier.Langella@moulon.inra.fr> - initial API and implementation
******************************************************************************/
#include "xpipsaxhandler.h"
XpipSaxHandler::XpipSaxHandler()
{
}
XpipSaxHandler::~XpipSaxHandler()
{
}
bool XpipSaxHandler::startElement(const QString & namespaceURI, const QString & localName,
const QString & qName, const QXmlAttributes & attributes) {
// qDebug() << namespaceURI << " " << localName << " " << qName ;
_tag_stack.push_back(qName);
bool is_ok = true;
try {
//startElement_group
if (qName == "group")
{
//is_ok = startElement_group(attributes);
}
_current_text.clear();
}
catch (PappsoException exception_pappso) {
_errorStr = QObject::tr("ERROR in XtandemResultsHandler::startElement tag %1, PAPPSO exception:\n%2").arg(qName).arg(exception_pappso.qwhat());
return false;
}
catch (std::exception exception_std) {
_errorStr = QObject::tr("ERROR in XtandemResultsHandler::startElement tag %1, std exception:\n%2").arg(qName).arg(exception_std.what());
return false;
}
return is_ok;
}
bool XpipSaxHandler::endElement(const QString & namespaceURI, const QString & localName,
const QString & qName) {
bool is_ok = true;
// endElement_peptide_list
try {
if (qName == "group")
{
//is_ok = endElement_group();
}
// end of detection_moulon
// else if ((_tag_stack.size() > 1) &&
// (_tag_stack[_tag_stack.size() - 2] == "detection_moulon"))
}
catch (PappsoException exception_pappso) {
_errorStr = QObject::tr("ERROR in XtandemResultsHandler::endElement tag %1, PAPPSO exception:\n%2").arg(qName).arg(exception_pappso.qwhat());
return false;
}
catch (std::exception exception_std) {
_errorStr = QObject::tr("ERROR in XtandemResultsHandler::endElement tag %1, std exception:\n%2").arg(qName).arg(exception_std.what());
return false;
}
_current_text.clear();
_tag_stack.pop_back();
return is_ok;
}
/*
bool XpipSaxHandler::endElement_group() {
if ((_tag_stack.size() > 1) && (_tag_stack[_tag_stack.size() - 2] == "group")) {
}
else {
// XtandemHyperscore hyperscore(_curent_spectrum, _current_peptide_sp, _precision, _ion_list, _max_charge,_refine_spectrum_synthesis);
}
return true;
}
*/
bool XpipSaxHandler::error(const QXmlParseException &exception) {
_errorStr = QObject::tr("Parse error at line %1, column %2 :\n"
"%3").arg(exception.lineNumber()).arg(exception.columnNumber()).arg(
exception.message());
return false;
}
bool XpipSaxHandler::fatalError(const QXmlParseException &exception) {
_errorStr = QObject::tr("Parse error at line %1, column %2 :\n"
"%3").arg(exception.lineNumber()).arg(exception.columnNumber()).arg(
exception.message());
return false;
}
QString XpipSaxHandler::errorString() const {
return _errorStr;
}
bool XpipSaxHandler::endDocument() {
return true;
}
bool XpipSaxHandler::startDocument() {
return true;
}
bool XpipSaxHandler::characters(const QString &str) {
_current_text += str;
return true;
}
/*******************************************************************************
* Copyright (c) 2016 Olivier Langella <Olivier.Langella@moulon.inra.fr>.
*
* This file is part of XTPcpp.
*
* XTPcpp 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.
*
* XTPcpp 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 XTPcpp. If not, see <http://www.gnu.org/licenses/>.
*
* Contributors:
* Olivier Langella <Olivier.Langella@moulon.inra.fr> - initial API and implementation
******************************************************************************/
#ifndef XPIPSAXHANDLER_H
#define XPIPSAXHANDLER_H
#include <QXmlDefaultHandler>
#include <pappsomspp/pappsoexception.h>
using namespace pappso;
class XpipSaxHandler: public QXmlDefaultHandler
{
public:
XpipSaxHandler();
~XpipSaxHandler();
bool startElement(const QString & namespaceURI, const QString & localName,
const QString & qName, const QXmlAttributes & attributes);
bool endElement(const QString & namespaceURI, const QString & localName,
const QString & qName);
bool startDocument();
bool endDocument();
bool characters(const QString &str);
bool fatalError(const QXmlParseException &exception);
bool error(const QXmlParseException &exception);
QString errorString() const;
private:
std::vector<QString> _tag_stack;
QString _errorStr;
QString _current_text;
};
#endif // XTANDEMRESULTSHANDLER_H
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment