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

reading spectrum

parent 77f59a43
No related branches found
No related tags found
No related merge requests found
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#include "identificationxtandemfile.h" #include "identificationxtandemfile.h"
#include <pappsomspp/pappsoexception.h> #include <pappsomspp/pappsoexception.h>
#include <QFileInfo> #include <QFileInfo>
#include "../../utils/readspectrum.h"
IdentificationDataSource::MapIdentificationDataSources IdentificationDataSource::_map_identification_data_sources = [] IdentificationDataSource::MapIdentificationDataSources IdentificationDataSource::_map_identification_data_sources = []
...@@ -86,3 +87,9 @@ void IdentificationDataSource::setMsRunSp (pappso::MsRunIdSp ms_run_sp) { ...@@ -86,3 +87,9 @@ void IdentificationDataSource::setMsRunSp (pappso::MsRunIdSp ms_run_sp) {
pappso::MsRunIdSp IdentificationDataSource::getMsRunSp () const { pappso::MsRunIdSp IdentificationDataSource::getMsRunSp () const {
return (_ms_run_sp); return (_ms_run_sp);
} }
pappso::SpectrumSp IdentificationDataSource::getSpectrumSp(unsigned int scan_number) const {
pappso::SpectrumSp spectrum_sp = SpectrumStore::getSpectrumSpFromMsRunIdSp(_ms_run_sp, scan_number);
return spectrum_sp;
}
...@@ -46,7 +46,7 @@ public: ...@@ -46,7 +46,7 @@ public:
pappso::MsRunIdSp getMsRunSp () const; pappso::MsRunIdSp getMsRunSp () const;
/** @brief get the spectrum with scan number /** @brief get the spectrum with scan number
* */ * */
virtual pappso::SpectrumSp getSpectrumSp(unsigned int scan_number) const = 0; virtual pappso::SpectrumSp getSpectrumSp(unsigned int scan_number) const;
protected : protected :
QString _resource_name; QString _resource_name;
......
...@@ -41,6 +41,6 @@ bool IdentificationXtandemFile::operator==(const IdentificationXtandemFile& othe ...@@ -41,6 +41,6 @@ bool IdentificationXtandemFile::operator==(const IdentificationXtandemFile& othe
} }
pappso::SpectrumSp IdentificationXtandemFile::getSpectrumSp(unsigned int scan_number) const { pappso::SpectrumSp IdentificationXtandemFile::getSpectrumSp(unsigned int scan_number) const {
pappso::SpectrumSp spectrum_sp; pappso::SpectrumSp spectrum_sp = IdentificationDataSource::getSpectrumSp(scan_number);
return spectrum_sp; return spectrum_sp;
} }
...@@ -25,7 +25,9 @@ ...@@ -25,7 +25,9 @@
#include "../project_view/projectwindow.h" #include "../project_view/projectwindow.h"
#include "ui_peptide_detail_view.h" #include "ui_peptide_detail_view.h"
#include <pappsomspp/pappsoexception.h> #include <pappsomspp/pappsoexception.h>
#include <pappsomspp/spectrum/qualifiedspectrum.h>
#include <QMessageBox> #include <QMessageBox>
#include <QSettings>
PeptideWindow::PeptideWindow(ProjectWindow *parent): PeptideWindow::PeptideWindow(ProjectWindow *parent):
QMainWindow(parent), QMainWindow(parent),
...@@ -36,6 +38,15 @@ PeptideWindow::PeptideWindow(ProjectWindow *parent): ...@@ -36,6 +38,15 @@ PeptideWindow::PeptideWindow(ProjectWindow *parent):
/* /*
*/ */
QSettings settings;
QString unit = settings.value("peptideview/precision_unit", "dalton").toString();
pappso::mz precision = settings.value("peptideview/precision_value", "0.2").toDouble();
if (unit == "dalton") {
_p_precision = Precision::getDaltonInstance(precision);
} else {
_p_precision = Precision::getPpmInstance(precision);
}
#if QT_VERSION >= 0x050000 #if QT_VERSION >= 0x050000
// Qt5 code // Qt5 code
...@@ -86,6 +97,13 @@ void PeptideWindow::updateDisplay() { ...@@ -86,6 +97,13 @@ void PeptideWindow::updateDisplay() {
void PeptideWindow::setPeptideMatch(PeptideMatch * p_peptide_match) { void PeptideWindow::setPeptideMatch(PeptideMatch * p_peptide_match) {
_p_peptide_match = p_peptide_match; _p_peptide_match = p_peptide_match;
SpectrumSp spectrum = _p_peptide_match->getIdentificationDataSource()->getSpectrumSp(_p_peptide_match->getScan()); SpectrumSp spectrum = _p_peptide_match->getIdentificationDataSource()->getSpectrumSp(_p_peptide_match->getScan());
pappso::QualifiedSpectrum spectrum_copy;
spectrum_copy.setOriginalSpectrumSp(spectrum);
ui->spectrumWidget->setQualifiedSpectrum(spectrum_copy);
pappso::PeptideSp peptide = p_peptide_match->getPeptideXtpSp();
ui->spectrumWidget->setPrecision(_p_precision);
ui->spectrumWidget->setPeptideSp(peptide);
updateDisplay(); updateDisplay();
} }
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#include <QMainWindow> #include <QMainWindow>
#include <QTextDocument> #include <QTextDocument>
#include <pappsomspp/mass_range.h>
#include "../../core/peptidematch.h" #include "../../core/peptidematch.h"
#include "../../core/identificationgroup.h" #include "../../core/identificationgroup.h"
...@@ -53,6 +54,7 @@ private: ...@@ -53,6 +54,7 @@ private:
Ui::PeptideDetailView *ui; Ui::PeptideDetailView *ui;
ProjectWindow * _p_project_window; ProjectWindow * _p_project_window;
PeptideMatch * _p_peptide_match = nullptr; PeptideMatch * _p_peptide_match = nullptr;
pappso::PrecisionP _p_precision;
}; };
......
...@@ -116,7 +116,7 @@ void ProjectWindow::refreshGroup(IdentificationGroup * p_ident_group) { ...@@ -116,7 +116,7 @@ void ProjectWindow::refreshGroup(IdentificationGroup * p_ident_group) {
} }
else { else {
try { try {
vector< MsRunIdSp > ms_run_list = p_ident_group->getMsRunIdSpList(); vector< pappso::MsRunIdSp > ms_run_list = p_ident_group->getMsRunIdSpList();
ui->sample_number_display->setText(QString("%1").arg(ms_run_list.size())); ui->sample_number_display->setText(QString("%1").arg(ms_run_list.size()));
ui->group_number_display->setText(QString("%1").arg(p_ident_group->countGroup())); ui->group_number_display->setText(QString("%1").arg(p_ident_group->countGroup()));
...@@ -251,6 +251,18 @@ void ProjectWindow::setProjectSp(ProjectSp project_sp) { ...@@ -251,6 +251,18 @@ void ProjectWindow::setProjectSp(ProjectSp project_sp) {
_protein_list_window_collection.clear(); _protein_list_window_collection.clear();
_p_current_protein_list_window = nullptr; _p_current_protein_list_window = nullptr;
for (auto && p_window :_protein_detail_window_collection) {
delete p_window;
}
_protein_detail_window_collection.clear();
_p_current_protein_detail_window = nullptr;
for (auto && p_window :_peptide_detail_window_collection) {
delete p_window;
}
_peptide_detail_window_collection.clear();
_p_current_peptide_detail_window = nullptr;
_project_sp = project_sp; _project_sp = project_sp;
refreshGroup(_project_sp.get()->getCurrentIdentificationGroupP()); refreshGroup(_project_sp.get()->getCurrentIdentificationGroupP());
//_protein_list_window->setIdentificationGroup(_project_sp.get()->getCurrentIdentificationGroupP()); //_protein_list_window->setIdentificationGroup(_project_sp.get()->getCurrentIdentificationGroupP());
......
...@@ -24,6 +24,9 @@ ...@@ -24,6 +24,9 @@
#include "readspectrum.h" #include "readspectrum.h"
#include <QDebug> #include <QDebug>
#include <QSettings>
#include <QFileInfo>
#include <QDir>
#include <pappsomspp/spectrum/spectrum.h> #include <pappsomspp/spectrum/spectrum.h>
#include <pappsomspp/exception/exceptionnotfound.h> #include <pappsomspp/exception/exceptionnotfound.h>
...@@ -40,7 +43,7 @@ using namespace pappso; ...@@ -40,7 +43,7 @@ using namespace pappso;
pwiz::msdata::MSDataFile * getPwizMSDataFile(const QString & filename) { pwiz::msdata::MSDataFile * getPwizMSDataFile(const QString & filename) {
qDebug() << "getPwizMSDataFile opening file " << filename ; qDebug() << "getPwizMSDataFile opening file " << filename ;
std::string env; std::string env;
env=setlocale(LC_ALL,""); env=setlocale(LC_ALL,"");
struct lconv * lc = localeconv (); struct lconv * lc = localeconv ();
...@@ -59,8 +62,8 @@ pwiz::msdata::MSDataFile * getPwizMSDataFile(const QString & filename) { ...@@ -59,8 +62,8 @@ pwiz::msdata::MSDataFile * getPwizMSDataFile(const QString & filename) {
SpectrumSp getSpectrumSpFromPwizMSDataFile(pwiz::msdata::MSDataFile * p_ms_data_file, unsigned int scan_num, unsigned int & precursor_charge_state) { SpectrumSp getSpectrumSpFromPwizMSDataFile(pwiz::msdata::MSDataFile * p_ms_data_file, unsigned int scan_num, unsigned int & precursor_charge_state) {
if (p_ms_data_file == nullptr) { if (p_ms_data_file == nullptr) {
SpectrumSp empty; SpectrumSp empty;
return (empty); return (empty);
} }
const bool getBinaryData = true; const bool getBinaryData = true;
...@@ -216,3 +219,72 @@ Spectrum readSpectrum(const QString & filename, unsigned int scan_num, unsigned ...@@ -216,3 +219,72 @@ Spectrum readSpectrum(const QString & filename, unsigned int scan_num, unsigned
//qDebug() << " env=" << localeconv () << " lc->decimal_point " << lc->decimal_point; //qDebug() << " env=" << localeconv () << " lc->decimal_point " << lc->decimal_point;
return spectrum; return spectrum;
} }
std::map<pappso::MsRunIdSp, pwiz::msdata::MSDataFile *> create_map()
{
std::map<pappso::MsRunIdSp, pwiz::msdata::MSDataFile *> m;
return m;
}
std::map<pappso::MsRunIdSp, pwiz::msdata::MSDataFile *> SpectrumStore::_map_msrun_msdatafile = create_map();
const QString SpectrumStore::findMzFile(const QString &filename) {
QFileInfo file(filename);
if (file.exists()) {
return file.absoluteFilePath();
}
QString basename = file.baseName();
QString onlyfilename = file.fileName();
QSettings settings;
QString path = settings.value("path/mzdatadir", "/gorgone/pappso/formation/Janvier2014/TD/mzXML").toString();
QDir dir_search(path);
QFileInfoList files = dir_search.entryInfoList();
foreach (QFileInfo file, files) {
if (file.isDir()) {
qDebug() << "DIR: " << file.fileName();
} else {
qDebug() << "FILE: " << file.fileName();
if (onlyfilename == file.fileName()) {
return file.absoluteFilePath();
}
if (file.fileName().contains(onlyfilename)) {
return file.absoluteFilePath();
}
}
}
return QString();
}
pappso::SpectrumSp SpectrumStore::getSpectrumSpFromMsRunIdSp(pappso::MsRunIdSp msrun, unsigned int scan_num) {
pappso::SpectrumSp spectrum;
pwiz::msdata::MSDataFile * p_msdatafile = nullptr;
std::map<pappso::MsRunIdSp, pwiz::msdata::MSDataFile *>::iterator it_msdata = _map_msrun_msdatafile.find(msrun);
if (it_msdata == _map_msrun_msdatafile.end()) {
//not found
QString mz_file = findMzFile(msrun.get()->getFilename());
if (mz_file.isEmpty()) {
qDebug() << "SpectrumStore::getSpectrumSpFromMsRunIdSp ERROR file not found " << msrun.get()->getFilename();
return spectrum;
}
p_msdatafile = getPwizMSDataFile(mz_file);
_map_msrun_msdatafile.insert(std::pair<pappso::MsRunIdSp, pwiz::msdata::MSDataFile *>(msrun, p_msdatafile));
}
else {
p_msdatafile =it_msdata->second;
}
if (p_msdatafile == nullptr) {
return spectrum;
}
unsigned int precursor_charge_state;
spectrum = getSpectrumSpFromPwizMSDataFile(p_msdatafile, scan_num, precursor_charge_state);
return spectrum;
}
...@@ -26,15 +26,22 @@ ...@@ -26,15 +26,22 @@
#include <QString> #include <QString>
#include <pappsomspp/spectrum/spectrum.h> #include <pappsomspp/spectrum/spectrum.h>
#include <pappsomspp/msrun/msrunid.h>
#include <pwiz/data/msdata/MSDataFile.hpp> #include <pwiz/data/msdata/MSDataFile.hpp>
#include <map>
using namespace pappso; pappso::Spectrum readSpectrum(const QString & filename, unsigned int scan_num,unsigned int & precursor_charge_state);
Spectrum readSpectrum(const QString & filename, unsigned int scan_num,unsigned int & precursor_charge_state);
pwiz::msdata::MSDataFile * getPwizMSDataFile(const QString & filename); pwiz::msdata::MSDataFile * getPwizMSDataFile(const QString & filename);
SpectrumSp getSpectrumSpFromPwizMSDataFile(pwiz::msdata::MSDataFile * p_ms_data_file, unsigned int scan_num, unsigned int & precursor_charge_state); pappso::SpectrumSp getSpectrumSpFromPwizMSDataFile(pwiz::msdata::MSDataFile * p_ms_data_file, unsigned int scan_num, unsigned int & precursor_charge_state);
class SpectrumStore {
public:
static pappso::SpectrumSp getSpectrumSpFromMsRunIdSp(pappso::MsRunIdSp msrun, unsigned int scan_num);
private:
static const QString findMzFile(const QString &filename);
private:
static std::map<pappso::MsRunIdSp, pwiz::msdata::MSDataFile *> _map_msrun_msdatafile;
};
#endif // READSPECTRUM_H #endif // READSPECTRUM_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