diff --git a/CMakeLists.txt b/CMakeLists.txt index e7e0d57ec4a426e53c36f8b55929f7229099de2e..477412052e10a64c2b9ba6f9b8fb0e2e75132294 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -41,7 +41,7 @@ SET(SOFTWARE_NAME "XTPcpp") SET(XTPCPP_VERSION_MAJOR "0") SET(XTPCPP_VERSION_MINOR "1") -SET(XTPCPP_VERSION_PATCH "17") +SET(XTPCPP_VERSION_PATCH "18") SET(XTPCPP_VERSION "${XTPCPP_VERSION_MAJOR}.${XTPCPP_VERSION_MINOR}.${XTPCPP_VERSION_PATCH}") # Set the CMAKE_PREFIX_PATH for the find_library fonction when using non diff --git a/debian/changelog b/debian/changelog index 117859fb62b43b134d3437df03ba00eca1ac54af..0d790e1aba003cd0a703b8e7fae67b28b79b17cf 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +xtpcpp (0.1.18-1) stretch; urgency=medium + + * MS run and identification statistics + + -- Olivier Langella <olivier.langella@u-psud.fr> Tue, 26 Sep 2017 10:07:10 +0200 + xtpcpp (0.1.17-2) stretch; urgency=medium * fix desktop file diff --git a/src/output/ods/samplesheet.cpp b/src/output/ods/samplesheet.cpp index af74978257dd3ec2664ddf549e3f92f8a5533152..a435cd3596971e549534e16713203bed078b71b2 100644 --- a/src/output/ods/samplesheet.cpp +++ b/src/output/ods/samplesheet.cpp @@ -78,6 +78,20 @@ void SampleSheet::writeHeaders() { _p_writer->writeCell("Total unique assigned"); + if (_msrun_statistics) { + _p_writer->setCellAnnotation("total number of scans during the MS run (from mz file)"); + _p_writer->writeCell("Total scans"); + + _p_writer->setCellAnnotation("total number of MS level 1 during the MS run (from mz file)"); + _p_writer->writeCell("Total MS1"); + + _p_writer->setCellAnnotation("total number of MS level 2 during the MS run (from mz file)"); + _p_writer->writeCell("Total MS2"); + + _p_writer->setCellAnnotation("total number of MS level 3 during the MS run (from mz file)"); + _p_writer->writeCell("Total MS3"); + + } /* total_peptide_used=3,///< total number of peptides generated and used in identification @@ -93,7 +107,7 @@ void SampleSheet::writeIdentificationDataSource(IdentificationDataSource * p_ide if (_msrun_statistics) { SpectrumStore::checkMsRunStatistics(msrun_sp); } - + _p_writer->writeCell(msrun_sp.get()->getXmlId()); _p_writer->writeCell(msrun_sp.get()->getSampleName()); _p_writer->writeCell(msrun_sp.get()->getFilename()); @@ -140,7 +154,32 @@ void SampleSheet::writeIdentificationDataSource(IdentificationDataSource * p_ide } else { _p_writer->writeCell(var_sample.toInt()); } - - + + if (_msrun_statistics) { + var_sample = msrun_sp.get()->getMsRunStatistics(MsRunStatistics::total_spectra); + if (var_sample.isNull()) { + _p_writer->writeEmptyCell(); + } else { + _p_writer->writeCell(var_sample.toInt()); + } + var_sample = msrun_sp.get()->getMsRunStatistics(MsRunStatistics::total_spectra_ms1); + if (var_sample.isNull()) { + _p_writer->writeEmptyCell(); + } else { + _p_writer->writeCell(var_sample.toInt()); + } + var_sample = msrun_sp.get()->getMsRunStatistics(MsRunStatistics::total_spectra_ms2); + if (var_sample.isNull()) { + _p_writer->writeEmptyCell(); + } else { + _p_writer->writeCell(var_sample.toInt()); + } + var_sample = msrun_sp.get()->getMsRunStatistics(MsRunStatistics::total_spectra_ms3); + if (var_sample.isNull()) { + _p_writer->writeEmptyCell(); + } else { + _p_writer->writeCell(var_sample.toInt()); + } + } } diff --git a/src/output/ods/samplesheet.h b/src/output/ods/samplesheet.h index 9c1fc7c435ed2e77c014d4aa51de3db333b8866d..345d1629e356d9b77134489f4fcc51c71dd846a9 100644 --- a/src/output/ods/samplesheet.h +++ b/src/output/ods/samplesheet.h @@ -46,7 +46,7 @@ private : OdsExport * _p_ods_export; const Project * _p_project; CalcWriterInterface * _p_writer; - bool _msrun_statistics = false; + bool _msrun_statistics = true; }; #endif // SAMPLESHEET_H diff --git a/src/utils/readspectrum.cpp b/src/utils/readspectrum.cpp index 67c8579ceac160f43115a5d3cf6e8780e3ebf930..7b9f599774262ff8cdf8d32807ae1ef8aa4d1dbe 100644 --- a/src/utils/readspectrum.cpp +++ b/src/utils/readspectrum.cpp @@ -133,17 +133,17 @@ pappso::QualifiedSpectrum getQualifiedSpectrumFromPwizMSDataFile(pwiz::msdata::M try { simple_spectrum_pwiz = spectrum_list_ptr.get()->spectrum(spectrum_index, getBinaryData); } catch (std::runtime_error & error) { - qDebug() << "getQualifiedSpectrumFromPwizMSDataFile error " << error.what() << " " << typeid(error).name(); + qDebug() << "getQualifiedSpectrumFromPwizMSDataFile error " << error.what() << " " << typeid(error).name(); throw ExceptionNotFound(QObject::tr("scan number %1 not found in MS file std::runtime_error :\n%2").arg(scan_num).arg(error.what())); - } + } catch (std::exception & error) { - qDebug() << "getQualifiedSpectrumFromPwizMSDataFile error " << error.what() << " " << typeid(error).name(); + qDebug() << "getQualifiedSpectrumFromPwizMSDataFile error " << error.what() << " " << typeid(error).name(); throw ExceptionNotFound(QObject::tr("scan number %1 not found in MS file :\n%2").arg(scan_num).arg(error.what())); - } + } if (simple_spectrum_pwiz.get() == nullptr) { throw ExceptionNotFound(QObject::tr("scan number %1 not found in MS file : null pointer").arg(scan_num)); } - + qDebug() << "getQualifiedSpectrumFromPwizMSDataFile precursors.size() " << simple_spectrum_pwiz.get()->precursors.size(); if (simple_spectrum_pwiz.get()->precursors.size() > 0) { pwiz::msdata::Precursor & precursor = *(simple_spectrum_pwiz.get()->precursors.begin()); @@ -173,8 +173,8 @@ pappso::QualifiedSpectrum getQualifiedSpectrumFromPwizMSDataFile(pwiz::msdata::M } } - qDebug() << "getQualifiedSpectrumFromPwizMSDataFile msLevel" ; - unsigned int msLevel(QString(simple_spectrum_pwiz->cvParam(pwiz::msdata::MS_ms_level).value.c_str()).toUInt()); + qDebug() << "getQualifiedSpectrumFromPwizMSDataFile msLevel" ; + unsigned int msLevel(QString(simple_spectrum_pwiz->cvParam(pwiz::msdata::MS_ms_level).value.c_str()).toUInt()); pappso_double retentionTime = QString(simple_spectrum_pwiz->scanList.scans[0].cvParam(pwiz::msdata::MS_scan_start_time).value.c_str()).toDouble(); qspectrum.setRtInSeconds(retentionTime); @@ -263,7 +263,21 @@ void SpectrumStore::checkMsRunStatistics(MsRunSp msrun) { if (msrun_var.isNull()) { try { pwiz::msdata::MSDataFile * p_msdatafile = findPwizMSDataFile(msrun); - msrun.get()->setMsRunStatistics(MsRunStatistics::total_spectra, (unsigned int) p_msdatafile->run.spectrumListPtr.get()->size()); + const pwiz::msdata::SpectrumList * p_spectrum_list = p_msdatafile->run.spectrumListPtr.get(); + std::size_t spectrum_list_size = p_spectrum_list->size(); + msrun.get()->setMsRunStatistics(MsRunStatistics::total_spectra, (unsigned int) spectrum_list_size); + + unsigned int count_mslevel[50] = {0}; + for (std::size_t i=0; i < spectrum_list_size; i++) { + pwiz::msdata::SpectrumPtr spectrum = p_spectrum_list->spectrum(i, false); + unsigned int msLevel(QString(spectrum->cvParam(pwiz::msdata::MS_ms_level).value.c_str()).toUInt()); + count_mslevel[msLevel]++; + } + + msrun.get()->setMsRunStatistics(MsRunStatistics::total_spectra, (unsigned int) spectrum_list_size); + msrun.get()->setMsRunStatistics(MsRunStatistics::total_spectra_ms1, (unsigned int) count_mslevel[1]); + msrun.get()->setMsRunStatistics(MsRunStatistics::total_spectra_ms2, (unsigned int) count_mslevel[2]); + msrun.get()->setMsRunStatistics(MsRunStatistics::total_spectra_ms3, (unsigned int) count_mslevel[3]); } catch (pappso::ExceptionNotFound& error) { //no file found, no statistics @@ -297,7 +311,7 @@ pwiz::msdata::MSDataFile * SpectrumStore::findPwizMSDataFile(MsRunSp msrun) { pappso::SpectrumSp SpectrumStore::getSpectrumSpFromMsRunSp(MsRunSp msrun, unsigned int scan_num) { pappso::QualifiedSpectrum spectrum; pwiz::msdata::MSDataFile * p_msdatafile = findPwizMSDataFile(msrun); - + if (p_msdatafile == nullptr) { return spectrum.getOriginalSpectrumSp(); }