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

first pwiz reader, not working yet

parent bc29f5ba
No related branches found
No related tags found
No related merge requests found
......@@ -53,6 +53,7 @@ SET(CPP_FILES
core/automaticfilterparameters.cpp
core/identificationgroup.cpp
core/identification_sources/identificationdatasource.cpp
core/identification_sources/identificationpwizfile.cpp
core/identification_sources/identificationxtandemfile.cpp
core/labeling/label.cpp
core/labeling/labelingmethod.cpp
......@@ -73,6 +74,7 @@ SET(CPP_FILES
grouping/ptm/ptmislandgroup.cpp
grouping/ptm/ptmislandsubgroup.cpp
gui/peptide_detail_view/spectrum_widget/spectrumpainter.cpp
input/identificationpwizreader.cpp
input/xpipsaxhandler.cpp
input/xtandemsaxhandler.cpp
output/masschroqml.cpp
......
......@@ -31,16 +31,16 @@
#include "identificationpwizfile.h"
#include <pappsomspp/pappsoexception.h>
#include "../project.h"
#include "../../input/xtandemsaxhandler.h"
#include "../../input/identificationpwizreader.h"
IdentificationPwizFile::IdentificationPwizFile(const QFileInfo & xtandem_file) : IdentificationDataSource(xtandem_file.absoluteFilePath()), _xtandem_file(xtandem_file)
IdentificationPwizFile::IdentificationPwizFile(const QFileInfo & ident_file) : IdentificationDataSource(ident_file.absoluteFilePath()), _ident_file(ident_file)
{
_engine = IdentificationEngine::XTandem;
//_engine = IdentificationEngine::XTandem;
}
IdentificationPwizFile::IdentificationPwizFile(const IdentificationPwizFile& other) : IdentificationDataSource(other),_xtandem_file (other._xtandem_file)
IdentificationPwizFile::IdentificationPwizFile(const IdentificationPwizFile& other) : IdentificationDataSource(other),_ident_file (other._ident_file)
{
_engine = IdentificationEngine::XTandem;
_engine = other._engine;
}
IdentificationPwizFile::~IdentificationPwizFile()
......@@ -62,9 +62,9 @@ pappso::SpectrumSp IdentificationPwizFile::getSpectrumSp(unsigned int scan_numbe
void IdentificationPwizFile::parseTo(Project* p_project) {
qDebug() << "Project::readXpipFile begin";
qDebug() << "Read X!Tandem XML result file '" << _xtandem_file.absoluteFilePath() << "'";
IdentificationPwizReader pwiz_reader(_ident_file);
MsRunSp msrun_sp = p_project->getMsRunStore().getInstance(QFileInfo(_xtandem_file).baseName());
MsRunSp msrun_sp = p_project->getMsRunStore().getInstance(pwiz_reader.getMsrunQFileInfo().baseName());
setMsRunSp(msrun_sp);
std::vector<IdentificationGroup *> identification_list = p_project->getIdentificationGroupList();
IdentificationGroup * identification_group_p = nullptr;
......@@ -88,28 +88,8 @@ void IdentificationPwizFile::parseTo(Project* p_project) {
}
}
identification_group_p->addIdentificationDataSourceP(this);
XtandemSaxHandler * parser = new XtandemSaxHandler(p_project, identification_group_p, this);
QXmlSimpleReader simplereader;
simplereader.setContentHandler(parser);
simplereader.setErrorHandler(parser);
QFile qfile(_xtandem_file.absoluteFilePath());
QXmlInputSource xmlInputSource(&qfile);
if (simplereader.parse(xmlInputSource)) {
qfile.close();
} else {
qDebug() << parser->errorString();
// throw PappsoException(
// QObject::tr("error reading tandem XML result file :\n").append(
// parser->errorString()));
qfile.close();
throw pappso::PappsoException(QObject::tr("Error reading %1 XPIP file :\n %2").arg(_xtandem_file.absoluteFilePath()).arg(parser->errorString()));
}
// throw pappso::PappsoException(QObject::tr("Error reading %1 XPIP file :\n %2").arg(_xtandem_file.absoluteFilePath()).arg(parser->errorString()));
}
......@@ -37,7 +37,7 @@
class IdentificationPwizFile: public IdentificationDataSource
{
public:
IdentificationPwizFile(const QFileInfo & xtandem_file);
IdentificationPwizFile(const QFileInfo & ident_file);
IdentificationPwizFile(const IdentificationPwizFile& other);
~IdentificationPwizFile();
bool operator==(const IdentificationPwizFile& other) const;
......@@ -46,7 +46,7 @@ public:
virtual void parseTo(Project* p_project) override;
private:
const QFileInfo _xtandem_file;
const QFileInfo _ident_file;
};
#endif // IDENTIFICATIONPWIZFILE_H
......@@ -5,4 +5,67 @@
* \brief read identification files using pwiz library
*/
/*******************************************************************************
* Copyright (c) 2017 Olivier Langella <Olivier.Langella@u-psud.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@u-psud.fr> - initial API and implementation
******************************************************************************/
#include "identificationpwizreader.h"
#include <QDebug>
#include <QSettings>
#include <QFileInfo>
#include <QDir>
#include <QString>
#include <pappsomspp/exception/exceptionnotfound.h>
#include <pwiz/data/identdata/IdentData.hpp>
#include <pwiz/data/identdata/IdentDataFile.hpp>
#include <locale>
pwiz::identdata::IdentDataFile * getPwizIdentDataFile(const QString & filename);
pwiz::identdata::IdentDataFile * getPwizIdentDataFile(const QString & filename) {
qDebug() << "getPwizIdentDataFile opening file " << filename ;
std::string env;
env=setlocale(LC_ALL,"");
struct lconv * lc = localeconv ();
qDebug() << " env=" << env.c_str() << " lc->decimal_point " << lc->decimal_point;
setlocale(LC_ALL,"C");
//lc = localeconv ();
//qDebug() << " env=" << localeconv () << " lc->decimal_point " << lc->decimal_point;
pwiz::identdata::IdentDataFile * dataFile = new pwiz::identdata::IdentDataFile(filename.toStdString());
setlocale(LC_ALL,env.c_str());
return dataFile;
}
IdentificationPwizReader::IdentificationPwizReader(const QFileInfo & filename):_identfile(filename) {
_pwiz_ident_data_file = getPwizIdentDataFile(filename.absoluteFilePath());
}
const QFileInfo & IdentificationPwizReader::getMsrunQFileInfo() const {
//qDebug() << "IdentificationPwizReader::getMsrunQFileInfo begin" << _pwiz_ident_data_file->analysisSampleCollection.size();
return _identfile;
}
......@@ -31,8 +31,21 @@
#ifndef IDENTIFICATIONPWIZREADER_H
#define IDENTIFICATIONPWIZREADER_H
#include <QFileInfo>
namespace pwiz::identdata {
class IdentDataFile;
}
class IdentificationPwizReader
{
public:
IdentificationPwizReader(const QFileInfo & filename);
const QFileInfo & getMsrunQFileInfo() const;
private:
QFileInfo _identfile;
pwiz::identdata::IdentDataFile * _pwiz_ident_data_file;
};
#endif // IDENTIFICATIONPWIZREADER_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