diff --git a/src/core/identification_sources/identificationpepxmlfile.cpp b/src/core/identification_sources/identificationpepxmlfile.cpp new file mode 100644 index 0000000000000000000000000000000000000000..cbf39e195208f973dfc5963211f97451b0ae2272 --- /dev/null +++ b/src/core/identification_sources/identificationpepxmlfile.cpp @@ -0,0 +1,97 @@ +/** + * \file /core/identification_sources/identificationpepxmlfile.cpp + * \date 16/6/2018 + * \author Olivier Langella + * \brief pep xml identification file handler + */ + +/******************************************************************************* +* Copyright (c) 2018 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/>. +* +******************************************************************************/ + +#include "identificationpepxmlfile.h" + +#include <pappsomspp/pappsoexception.h> +#include "../project.h" +#include "../../input/mascot/mascotdatparser.h" + +IdentificationPepXmlFile::IdentificationPepXmlFile(const QFileInfo & mascot_dat_file) : IdentificationDataSource(mascot_dat_file.absoluteFilePath()), _pep_xml_file(mascot_dat_file) +{ + _engine = IdentificationEngine::unknown; +} + +IdentificationPepXmlFile::IdentificationPepXmlFile(const IdentificationPepXmlFile& other) : IdentificationDataSource(other),_pep_xml_file (other._pep_xml_file) +{ + _engine = IdentificationEngine::unknown; +} + +IdentificationPepXmlFile::~IdentificationPepXmlFile() +{ + +} + +bool IdentificationPepXmlFile::operator==(const IdentificationPepXmlFile& other) const +{ + +} + +pappso::SpectrumSp IdentificationPepXmlFile::getSpectrumSp(unsigned int scan_number) const { + pappso::SpectrumSp spectrum_sp = IdentificationDataSource::getSpectrumSp(scan_number); + return spectrum_sp; +} + + +void IdentificationPepXmlFile::parseTo(Project* p_project) { + qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__; + + + MsRunSp msrun_sp = p_project->getMsRunStore().getInstance(QFileInfo(_pep_xml_file).baseName()); + setMsRunSp(msrun_sp); + std::vector<IdentificationGroup *> identification_list = p_project->getIdentificationGroupList(); + IdentificationGroup * identification_group_p = nullptr; + if (p_project->getProjectMode() == ProjectMode::combined) { + if (identification_list.size() == 0) { + identification_group_p = p_project->newIdentificationGroup(); + } + else { + identification_group_p = identification_list[0]; + } + } + else { + for (IdentificationGroup * identification_p_flist : identification_list) { + if (identification_p_flist->containSample(msrun_sp.get()->getSampleName())) { + identification_group_p = identification_p_flist; + break; + } + } + if (identification_group_p == nullptr) { + identification_group_p = p_project->newIdentificationGroup(); + } + } + + identification_group_p->addIdentificationDataSourceP(this); + MascotDatParser mascot_parser(p_project, identification_group_p, this); + + QFile qfile(_pep_xml_file.absoluteFilePath()); + mascot_parser.parse(&qfile); + + qfile.close(); + + qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__; +} diff --git a/src/core/identification_sources/identificationpepxmlfile.h b/src/core/identification_sources/identificationpepxmlfile.h new file mode 100644 index 0000000000000000000000000000000000000000..168c6dc043e6d174edf824eb34db1f94316096ad --- /dev/null +++ b/src/core/identification_sources/identificationpepxmlfile.h @@ -0,0 +1,51 @@ +/** + * \file /core/identification_sources/identificationpepxmlfile.h + * \date 16/6/2018 + * \author Olivier Langella + * \brief pep xml identification file handler + */ + +/******************************************************************************* +* Copyright (c) 2018 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/>. +* +******************************************************************************/ + +#ifndef IDENTIFICATIONPEPXMLFILE_H +#define IDENTIFICATIONPEPXMLFILE_H + +#include "identificationdatasource.h" +#include <QFileInfo> + +class IdentificationPepXmlFile: public IdentificationDataSource +{ +public: + IdentificationPepXmlFile(const QFileInfo & mascot_dat_file); + IdentificationPepXmlFile(const IdentificationPepXmlFile& other); + ~IdentificationPepXmlFile(); + bool operator==(const IdentificationPepXmlFile& other) const; + + virtual pappso::SpectrumSp getSpectrumSp(unsigned int scan_number) const override; + virtual void parseTo(Project* p_project) override; + + //virtual const bool isValid(const PeptideEvidence * p_peptide_evidence, const AutomaticFilterParameters & automatic_filter_parameters) const override; + +private: + const QFileInfo _pep_xml_file; +}; + +#endif // IDENTIFICATIONPEPXMLFILE_H diff --git a/src/core/identification_sources/identificationpwizfile.cpp b/src/core/identification_sources/identificationpwizfile.cpp index c2f5cc4535c17f51175f4a20f2306a36539e9bbb..6a7d0b83f9df21262e7db6c8a93272b7f3ad45fb 100644 --- a/src/core/identification_sources/identificationpwizfile.cpp +++ b/src/core/identification_sources/identificationpwizfile.cpp @@ -5,7 +5,6 @@ * \brief read identification files with proteowizard library */ - /******************************************************************************* * Copyright (c) 2017 Olivier Langella <olivier.langella@u-psud.fr>. * @@ -25,77 +24,75 @@ * along with XTPcpp. If not, see <http://www.gnu.org/licenses/>. * * Contributors: -* Olivier Langella <olivier.langella@u-psud.fr> - initial API and implementation +* Olivier Langella <olivier.langella@u-psud.fr> - initial API and +*implementation ******************************************************************************/ +#include "../../input/identificationpwizreader.h" +#include "../project.h" #include "identificationpwizfile.h" #include <pappsomspp/pappsoexception.h> -#include "../project.h" -#include "../../input/identificationpwizreader.h" - -IdentificationPwizFile::IdentificationPwizFile(const QFileInfo & ident_file) : IdentificationDataSource(ident_file.absoluteFilePath()), _ident_file(ident_file) -{ - //_engine = IdentificationEngine::XTandem; - _engine = IdentificationEngine::peptider; -} -IdentificationPwizFile::IdentificationPwizFile(const IdentificationPwizFile& other) : IdentificationDataSource(other),_ident_file (other._ident_file) -{ - _engine = other._engine; +IdentificationPwizFile::IdentificationPwizFile(const QFileInfo &ident_file) + : IdentificationDataSource(ident_file.absoluteFilePath()), + _ident_file(ident_file) { + //_engine = IdentificationEngine::XTandem; + _engine = IdentificationEngine::peptider; } -IdentificationPwizFile::~IdentificationPwizFile() -{ - +IdentificationPwizFile::IdentificationPwizFile( + const IdentificationPwizFile &other) + : IdentificationDataSource(other), _ident_file(other._ident_file) { + _engine = other._engine; } -bool IdentificationPwizFile::operator==(const IdentificationPwizFile& other) const -{ +IdentificationPwizFile::~IdentificationPwizFile() {} -} +bool IdentificationPwizFile:: +operator==(const IdentificationPwizFile &other) const {} -pappso::SpectrumSp IdentificationPwizFile::getSpectrumSp(unsigned int scan_number) const { - pappso::SpectrumSp spectrum_sp = IdentificationDataSource::getSpectrumSp(scan_number); - return spectrum_sp; +pappso::SpectrumSp +IdentificationPwizFile::getSpectrumSp(unsigned int scan_number) const { + pappso::SpectrumSp spectrum_sp = + IdentificationDataSource::getSpectrumSp(scan_number); + return spectrum_sp; } +void IdentificationPwizFile::parseTo(Project *p_project) { + qDebug() << "IdentificationPwizFile::parseTo begin"; -void IdentificationPwizFile::parseTo(Project* p_project) { - qDebug() << "IdentificationPwizFile::parseTo begin"; + IdentificationPwizReader pwiz_reader(_ident_file); - IdentificationPwizReader pwiz_reader(_ident_file); + MsRunSp msrun_sp = + p_project->getMsRunStore().getInstance(pwiz_reader.getMsrunName()); - MsRunSp msrun_sp = p_project->getMsRunStore().getInstance(pwiz_reader.getMsrunName()); - - _engine = pwiz_reader.getIdentificationEngine(); - setMsRunSp(msrun_sp); - std::vector<IdentificationGroup *> identification_list = p_project->getIdentificationGroupList(); - IdentificationGroup * identification_group_p = nullptr; - if (p_project->getProjectMode() == ProjectMode::combined) { - if (identification_list.size() == 0) { - identification_group_p = p_project->newIdentificationGroup(); - } - else { - identification_group_p = identification_list[0]; - } + _engine = pwiz_reader.getIdentificationEngine(); + setMsRunSp(msrun_sp); + std::vector<IdentificationGroup *> identification_list = + p_project->getIdentificationGroupList(); + IdentificationGroup *identification_group_p = nullptr; + if (p_project->getProjectMode() == ProjectMode::combined) { + if (identification_list.size() == 0) { + identification_group_p = p_project->newIdentificationGroup(); + } else { + identification_group_p = identification_list[0]; } - else { - for (IdentificationGroup * identification_p_flist : identification_list) { - if (identification_p_flist->containSample(msrun_sp.get()->getSampleName())) { - identification_group_p = identification_p_flist; - break; - } - } - if (identification_group_p == nullptr) { - identification_group_p = p_project->newIdentificationGroup(); - } + } else { + for (IdentificationGroup *identification_p_flist : identification_list) { + if (identification_p_flist->containSample( + msrun_sp.get()->getSampleName())) { + identification_group_p = identification_p_flist; + break; + } } - identification_group_p->addIdentificationDataSourceP(this); - pwiz_reader.read(this, p_project, identification_group_p); - - - qDebug() << "IdentificationPwizFile::parseTo end"; - // throw pappso::PappsoException(QObject::tr("Error reading %1 XPIP file :\n %2").arg(_xtandem_file.absoluteFilePath()).arg(parser->errorString())); - + if (identification_group_p == nullptr) { + identification_group_p = p_project->newIdentificationGroup(); + } + } + identification_group_p->addIdentificationDataSourceP(this); + pwiz_reader.read(this, p_project, identification_group_p); + qDebug() << "IdentificationPwizFile::parseTo end"; + // throw pappso::PappsoException(QObject::tr("Error reading %1 XPIP file :\n + // %2").arg(_xtandem_file.absoluteFilePath()).arg(parser->errorString())); } diff --git a/src/gui/xic_view/xicworkerthread.cpp b/src/gui/xic_view/xicworkerthread.cpp index ee895b4984260d64d84c8dee2ab8515f91823136..f82119f59266ccd5df1cc7911e6c835bde3ee98f 100644 --- a/src/gui/xic_view/xicworkerthread.cpp +++ b/src/gui/xic_view/xicworkerthread.cpp @@ -45,23 +45,19 @@ void XicWorkerThread::doXicLoad(MsRunSp p_msrun, std::vector<pappso::mz> mz_list if (p_msrun.get()->findMsRunFile()) { pappso::MsRunId msrun_id = * (p_msrun.get()); - qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__ << " " << msrun_id.getFilename() << " " << msrun_id.getXmlId(); + qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__ << " " << msrun_id.getFilename(); auto it = std::find_if(_extractor_list.begin(), _extractor_list.end(), [msrun_id](const pappso::MsRunXicExtractorSp & extractor_sp) { - qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__ << " " << extractor_sp.get()->getMsRunId().getXmlId(); return extractor_sp.get()->getMsRunId().getXmlId() == msrun_id.getXmlId(); }); pappso::MsRunXicExtractorSp extractor; if (it == _extractor_list.end()) { - qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__ << " NOT FOUND " << msrun_id.getXmlId() << " " << _extractor_list.size(); pappso::MsRunXicExtractorFactory::getInstance().setTmpDir("/tmp"); extractor = pappso::MsRunXicExtractorFactory::getInstance().buildMsRunXicExtractorDiskBufferSp(msrun_id); - qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__ << " NOT FOUND " << extractor.get()->getMsRunId().getXmlId(); _extractor_list.push_back(extractor); - qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__ << " NOT FOUND " << _extractor_list.size(); + _extractor_list.push_back(extractor); } else { - qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__ << " FOUND " << msrun_id.getXmlId(); extractor = *it; } qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__ ;