diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 2367b510127f1a7954ee1f956715eb8cf7308546..e91c08516e6aa48c2ae4deea7de8179ac099497e 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -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 diff --git a/src/core/identification_sources/identificationpwizfile.cpp b/src/core/identification_sources/identificationpwizfile.cpp index 556212006967ea22e288770057f161d25ee7dd6e..2b79687d9005eb4b1a1b3fa9ea956fdc4f9e597f 100644 --- a/src/core/identification_sources/identificationpwizfile.cpp +++ b/src/core/identification_sources/identificationpwizfile.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())); + } diff --git a/src/core/identification_sources/identificationpwizfile.h b/src/core/identification_sources/identificationpwizfile.h index 3e15f074f369e55cb1ff419ad8911d544dea3aa8..01da96a8c9f8369255d34688982f161a88f0b421 100644 --- a/src/core/identification_sources/identificationpwizfile.h +++ b/src/core/identification_sources/identificationpwizfile.h @@ -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 diff --git a/src/input/identificationpwizreader.cpp b/src/input/identificationpwizreader.cpp index 2dd6449edae4f1c1feb100483387b6253de4c686..52adda2e121a0dcbbe881692e32efe6f6239b504 100644 --- a/src/input/identificationpwizreader.cpp +++ b/src/input/identificationpwizreader.cpp @@ -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; + } diff --git a/src/input/identificationpwizreader.h b/src/input/identificationpwizreader.h index a658dd273b4be10f19d404b16dcb05ad30478e6d..66317aaa11e774013aa149ec5052d6990c3f6d43 100644 --- a/src/input/identificationpwizreader.h +++ b/src/input/identificationpwizreader.h @@ -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