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

mzidentml : circumvent buggy spectrum id

parent eccbbcd0
No related branches found
No related tags found
No related merge requests found
......@@ -35,11 +35,13 @@
#include <QFileInfo>
#include <QDir>
#include <QString>
#include <QRegularExpression>
#include <pappsomspp/pappsoexception.h>
#include <pappsomspp/exception/exceptionoutofrange.h>
#include <pwiz/data/common/ParamTypes.hpp>
#include <pwiz/data/identdata/IdentData.hpp>
#include <pwiz/data/msdata/MSData.hpp>
#include <pwiz/data/identdata/IdentDataFile.hpp>
#include "../core/peptidematch.h"
#include <locale>
......@@ -138,11 +140,11 @@ IdentificationPwizReader::getIdentificationEngine() const
</AnalysisSoftware>
</AnalysisSoftwareList>
*/
IdentificationEngine identification_engine = IdentificationEngine::peptider;
IdentificationEngine identification_engine = IdentificationEngine::unknown;
for(pwiz::identdata::AnalysisSoftwarePtr software_ptr :
_pwiz_ident_data_file->analysisSoftwareList)
{
return getIdentificationEngine(software_ptr);
identification_engine = getIdentificationEngine(software_ptr);
}
return identification_engine;
}
......@@ -166,9 +168,17 @@ IdentificationPwizReader::getIdentificationEngine(const QString &xml_id) const
{
if(software_ptr.get()->id == xml_id.toStdString())
{
return getIdentificationEngine(software_ptr);
identification_engine = getIdentificationEngine(software_ptr);
}
}
/*
throw pappso::PappsoException(
QObject::tr("Analysis software (%1 %2) not known to XTPcpp")
.arg(analysis_software_p->id.c_str())
.arg(analysis_software_p->name.c_str()));
*/
return identification_engine;
}
......@@ -192,10 +202,7 @@ IdentificationPwizReader::getIdentificationEngine(
}
else
{
throw pappso::PappsoException(
QObject::tr("Analysis software (%1 %2) not known to XTPcpp")
.arg(analysis_software_p->id.c_str())
.arg(analysis_software_p->name.c_str()));
return IdentificationEngine::unknown;
}
return identification_engine;
......@@ -364,8 +371,48 @@ IdentificationPwizReader::read(
}
else
{
throw pappso::PappsoException(
QObject::tr("Scan number not found"));
// spectrumID="20170616_test_digestion_liquide_2_2_1_1H4.mzXML
// scan 2271 (charge 2)"
QRegularExpression re("^.* scan (\\d+) .*$");
QRegularExpressionMatch match =
re.match(spectrum_ptr.get()->spectrumID.c_str());
if(match.hasMatch())
{
// this is a bad hack to circumvent buggy spectrum id...
scan = match.captured(1).toULong();
}
else
{
// last try : regular proteowizard spectrum id
try
{
scan =
QString(pwiz::msdata::id::value(
spectrum_ptr.get()->spectrumID, "scan")
.c_str())
.toULong();
}
catch(runtime_error &pwiz_error)
{
throw pappso::PappsoException(
QObject::tr("Pwiz runtime error :\n%1\n parsing "
"spectrum ID :\n%2")
.arg(pwiz_error.what())
.arg(spectrum_ptr.get()->spectrumID.c_str()));
}
}
/* QString(pwiz::msdata::id::translateNativeIDToScanNumber(
pwiz::cv::CVID::MS_mzIdentML_format,
spectrum_ptr.get()->spectrumID)
.c_str())
.toULong();*/
if(scan == 0)
{
throw pappso::PappsoException(
QObject::tr(
"Failure parsing spectrumID %1 to find scan number")
.arg(spectrum_ptr.get()->spectrumID.c_str()));
}
}
//<cvParam accession="MS:1001115" cvRef="PSI-MS" value="4925"
// name="scan number(s)"/>
......
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