diff --git a/doc/Rscripts/param_tims_tof.Rmd b/doc/Rscripts/param_tims_tof.Rmd new file mode 100644 index 0000000000000000000000000000000000000000..8001511e3caa73ce2a7dec5c26a2e6d90592ebbd --- /dev/null +++ b/doc/Rscripts/param_tims_tof.Rmd @@ -0,0 +1,198 @@ +--- +title: "timsTOF parameters analysis" +author: "Thomas Renne" +date: "27/04/2020" +output: pdf_document +--- + +```{r setup, include=FALSE} +setwd("~/Documents/params_timsTOF") +library(ggplot2) +library(reshape2) +library(wesanderson) +library(gridExtra) + +data = read.csv("param_tims.csv") +``` + +# Resolution + +```{r include=FALSE} +data.reso = subset(data, Changed.parameter == "resolution") +names(data.reso)[2] <- "reso" + +plot.reso.unique <- function(y.val, y.lab, title){ + ggplot(data.reso, aes(x=reso, y=y.val)) + + geom_point(size=2, color="darkcyan") + + labs(x="resolution", y=y.lab) + + ggtitle(paste(title, "following the resolution parameter"))+ + theme_grey() +} + +plot.reso.multiple <- function(data, y.lab, legend.title, legend.labels, title){ + dm = melt(data, id.var=1) + + ggplot(dm, aes(x=reso, y=value, color=variable)) + + geom_point(size=2) + + labs(x="resolution", y=y.lab) + + scale_color_manual(name=legend.title, + labels=legend.labels, + values=wes_palette(name="Darjeeling1")) + + ggtitle(paste(title, "following the resolution parameter"))+ + theme_grey() +} +``` + +## Information + +- **Number of threads** : 5 +- **Resolution** : 10 000, 20 000, 30 000, 40 000, 50 000 +- **Smooth width** : 2.0 +- **Integration width** : 4 +- **Intensity threshold** : 10.0 + + + +## Graphs + +```{r graphs, echo=FALSE} +########### Time ########### +plot.reso.unique(data.reso$time, "time (min)", "Execution time") + +########### groups ########### +plot.reso.unique(data.reso$nb_groups, "number of groups", "Number of groups") + +########### subgroups ########### +plot.reso.unique(data.reso$nb_subgroups, "number of subgroups", "Number of subgroups") + +########### proteins ########### +plot.reso.unique(data.reso$nb_proteins, "number of proteins", "Number of proteins") + +########### peptides ########### +plot.reso.unique(data.reso$nb_peptides, "number of peptides", "Number of peptides") + +########### fdr ########### +plot.reso.multiple(data.reso[, c(2, 8:10)], "% of FDR", "FDRs", c("PSM", "Peptides", "Proteins"), "Different FDRs") + +########### mass precision ########### +plot.reso.multiple(abs(data.reso[, c(2, 11:13)]), "mass precision", "Statistical description", c("abs(mean)", "abs(median)", "sd"), "Mass-precision description") + +########### Total spectra used ########### +plot.reso.unique(data.reso$total_spectra_used, "Number of spectra used", "Total spectra used") + +########### Total assigned ########### +plot.reso.multiple(data.reso[, c(2, 15:16)], "number", "total assigned", c("total spectra assigned", "total unique assigned"), "Total of spectra and unique assigned") + +########### Percent assigned ########### +plot.reso.unique(data.reso$percent_assignement, "assignment in %", "Percentage of assignment") + +``` + +# Smooth width + +```{r include=FALSE} +data.smooth = subset(data, Changed.parameter == "smooth_width") +names(data.smooth)[2] <- "smooth" + +plot.smooth.unique <- function(data, y.val, y.lab, title){ + ggplot(data, aes(x=smooth, y=y.val)) + + geom_point(size=2, color="darkcyan") + + labs(x="smooth width", y=y.lab) + + ggtitle(paste(title, "following the smooth-width parameter"))+ + theme_grey() +} + +plot.smooth.multiple <- function(data, y.lab, legend.title, legend.labels, title){ + dm = melt(data, id.var=1) + + ggplot(dm, aes(x=smooth, y=value, color=variable)) + + geom_point(size=2) + + labs(x="smooth width", y=y.lab) + + scale_color_manual(name=legend.title, + labels=legend.labels, + values=wes_palette(name="Darjeeling1")) + + ggtitle(paste(title, "following the smooth-width parameter"))+ + theme_grey() +} +``` + +## Information + +- **Number of threads** : 5 +- **Resolution** : 40 000 +- **Smooth width** : 1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0, 10, 20, 50, 100, 200, 500 +- **Integration width** : 4 +- **Intensity threshold** : 10.0 + + + +## Graphs + +```{r graphs_smooth, echo=FALSE} +########### Time ########### +plot.smooth.unique(data.smooth, data.smooth$time, "time (min)", "Execution time") + +########### groups ########### +plot.smooth.unique(data.smooth, data.smooth$nb_groups, "number of groups", "Number of groups") + +########### subgroups ########### +plot.smooth.unique(data.smooth, data.smooth$nb_subgroups, "number of subgroups", "Number of subgroups") + +########### proteins ########### +plot.smooth.unique(data.smooth, data.smooth$nb_proteins, "number of proteins", "Number of proteins") + +########### peptides ########### +plot.smooth.unique(data.smooth, data.smooth$nb_peptides, "number of peptides", "Number of peptides") + +########### fdr ########### +plot.smooth.multiple(data.smooth[, c(2, 8:10)], "% of FDR", "FDRs", c("PSM", "Peptides", "Proteins"), "Different FDRs") + +########### mass precision ########### +plot.smooth.multiple(abs(data.smooth[, c(2, 11:13)]), "mass precision", "Statistical description", c("abs(mean)", "sd", "abs(median)"), "Mass-precision description") + +########### Total spectra used ########### +plot.smooth.unique(data.smooth, data.smooth$total_spectra_used, "Number of spectra used", "Total spectra used") + +########### Total assigned ########### +plot.smooth.multiple(data.smooth[, c(2, 15:16)], "number", "total assigned", c("total spectra assigned", "total unique assigned"), "Total of spectra and unique assigned") + +########### Percent assigned ########### +plot.smooth.unique(data.smooth, data.smooth$percent_assignement, "assignment in %", "Percentage of assignment") + +``` + +## Focused analysis smooth-width [1:50] + +```{r graphs_smooth_focused, echo=FALSE} +data.smooth_f = data.smooth[1:10,] +########### Time ########### +plot.smooth.unique(data.smooth_f, data.smooth_f$time, "time (min)", "Execution time") + +########### groups ########### +plot.smooth.unique(data.smooth_f, data.smooth_f$nb_groups, "number of groups", "Number of groups") + +########### subgroups ########### +plot.smooth.unique(data.smooth_f, data.smooth_f$nb_subgroups, "number of subgroups", "Number of subgroups") + +########### proteins ########### +plot.smooth.unique(data.smooth_f, data.smooth_f$nb_proteins, "number of proteins", "Number of proteins") + +########### peptides ########### +plot.smooth.unique(data.smooth_f, data.smooth_f$nb_peptides, "number of peptides", "Number of peptides") + +########### fdr ########### +plot.smooth.multiple(data.smooth_f[, c(2, 8:10)], "% of FDR", "FDRs", c("PSM", "Peptides", "Proteins"), "Different FDRs") + +########### mass precision ########### +plot.smooth.multiple(abs(data.smooth_f[, c(2, 11:13)]), "mass precision", "Statistical description", c("abs(mean)", "sd", "abs(median)"), "Mass-precision description") + +########### Total spectra used ########### +plot.smooth.unique(data.smooth_f, data.smooth_f$total_spectra_used, "Number of spectra used", "Total spectra used") + +########### Total assigned ########### +plot.smooth.multiple(data.smooth_f[, c(2, 15:16)], "number", "total assigned", c("total spectra assigned", "total unique assigned"), "Total of spectra and unique assigned") + +########### Percent assigned ########### +plot.smooth.unique(data.smooth_f, data.smooth_f$percent_assignement, "assignment in %", "Percentage of assignment") + +``` \ No newline at end of file diff --git a/src/core/tandem_run/tandembatchprocess.cpp b/src/core/tandem_run/tandembatchprocess.cpp index e358539ebb716b11e4fbd922dc01f20f0ce8de93..ccef0589a41eb2267dc5ab456321adc935ed0781 100644 --- a/src/core/tandem_run/tandembatchprocess.cpp +++ b/src/core/tandem_run/tandembatchprocess.cpp @@ -280,16 +280,17 @@ TandemBatchProcess::writeXmlInputFile(QXmlStreamWriter *p_out, p_out->writeAttribute("type", "input"); p_out->writeAttribute("label", "output, path"); if(mz_file_info.completeSuffix() == "tdf") - { - p_out->writeCharacters(QString("%1/%2.xml") - .arg(_tandem_run_batch._output_directory) - .arg(mz_file_info.absoluteDir().dirName())); - } - else{ - p_out->writeCharacters(QString("%1/%2.xml") - .arg(_tandem_run_batch._output_directory) - .arg(mz_file_info.baseName())); - } + { + p_out->writeCharacters(QString("%1/%2.xml") + .arg(_tandem_run_batch._output_directory) + .arg(mz_file_info.absoluteDir().dirName())); + } + else + { + p_out->writeCharacters(QString("%1/%2.xml") + .arg(_tandem_run_batch._output_directory) + .arg(mz_file_info.baseName())); + } p_out->writeEndElement(); // diff --git a/src/core/tandem_run/tandemcondorprocess.cpp b/src/core/tandem_run/tandemcondorprocess.cpp index 12922972ec68185dac10b462b605c500f4486528..50142c0511f9ce717d756146e25af7bd9bfd3a2b 100644 --- a/src/core/tandem_run/tandemcondorprocess.cpp +++ b/src/core/tandem_run/tandemcondorprocess.cpp @@ -247,7 +247,7 @@ TandemCondorProcess::run() else { QSettings settings; - QString tandemwrapper_path = + QString tandemwrapper_path = settings .value("timstof/tandemwrapper_path", "/usr/bin/tandemwrapper") .toString(); diff --git a/src/files/tandemparametersfile.cpp b/src/files/tandemparametersfile.cpp index 65545954e8a518f15c9301028b87f65567cddc2c..6100f0fed7f1d9c15c8ae9f2c19896d70b3d03c6 100644 --- a/src/files/tandemparametersfile.cpp +++ b/src/files/tandemparametersfile.cpp @@ -34,7 +34,7 @@ #include #include #include -#include "../input/xtandemparamsaxhandler.h" + TandemParametersFile::TandemParametersFile(const QString &fasta_source) : _param_source(fasta_source) @@ -55,10 +55,36 @@ TandemParametersFile::~TandemParametersFile() { } const QString -TandemParametersFile::getMethodName() const +TandemParametersFile::getMethodName() { - return _param_source.baseName(); + if(m_fileType == ParamFileType::empty) + { + TandemParameters parameters; + XtandemParamSaxHandler *parser = new XtandemParamSaxHandler(¶meters); + setTandemParametersFileType(parser); + } + // qDebug() << (std::int8_t)m_fileType; + if(m_fileType == ParamFileType::preset) + { + return _param_source.baseName(); + } + else if(m_fileType == ParamFileType::result) + { + return m_presetFileInfo.baseName(); + } + else if(m_fileType == ParamFileType::not_xtandem) + { + throw pappso::PappsoException( + QObject::tr("error : %1 is not a TandemParameters file\n") + .arg(_param_source.fileName())); + } + else // m_fileType == ParamFileType::no_file + { + throw pappso::PappsoException(QObject::tr("error : %1 Doesn't exist'\n") + .arg(_param_source.fileName())); + } } + const QString TandemParametersFile::getFilename() const { @@ -157,7 +183,7 @@ TandemParametersFile::getTandemParameters() simplereader.setErrorHandler(parser); qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__ << " " << _param_source.absoluteFilePath() << "'"; - parameters.setMethodName(getMethodName()); + QFile qfile(_param_source.absoluteFilePath()); QXmlInputSource xmlInputSource(&qfile); @@ -170,7 +196,6 @@ TandemParametersFile::getTandemParameters() // parameters.getValue("spectrum, parent monoisotopic mass error units"); qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__; qfile.close(); - delete parser; } else { @@ -182,39 +207,29 @@ TandemParametersFile::getTandemParameters() QObject::tr("Error reading %1 X!Tandem preset file :\n %2") .arg(_param_source.absoluteFilePath()) .arg(parser->errorString())); - delete parser; } + setTandemParametersFileType(parser); + if(m_fileType == ParamFileType::result) + { + m_presetFileInfo = parser->getTandemPresetFileInfo(); + } + delete parser; + parameters.setMethodName(getMethodName()); return parameters; } bool TandemParametersFile::isTandemPresetFile() { - - if(this->exists()) + getTandemParameters(); + if(m_fileType == ParamFileType::result || m_fileType == ParamFileType::preset) { - - try - { - TandemParameters param = getTandemParameters(); - - if(!m_isTandemParameterFile) - return false; - param.getValue("spectrum, threads"); - } - catch(pappso::ExceptionNotFound &error) - { - if(!m_isTandemParameterFile) - return false; - } - catch(pappso::PappsoException &error) - { - if(!m_isTandemParameterFile) - return false; - } return true; } - return false; + else + { + return false; + } } void @@ -243,3 +258,37 @@ TandemParametersFile::writeXmlParametersFile( p_out->writeEndElement(); p_out->writeEndDocument(); } + +void +TandemParametersFile::setTandemParametersFileType( + XtandemParamSaxHandler *parser) +{ + if(this->exists()) + { + try + { + if(parser->getTandemPresetFileInfo().absoluteFilePath() != "") + { + m_fileType = ParamFileType::result; + } + else + { + m_fileType = ParamFileType::preset; + } + } + catch(pappso::ExceptionNotFound &error) + { + throw pappso::ExceptionNotFound( + QObject::tr("error : %1 Doesn't exist'\n") + .arg(_param_source.fileName())); + m_fileType = ParamFileType::no_file; + } + catch(pappso::PappsoException &error) + { + throw pappso::PappsoException( + QObject::tr("error : %1 Doesn't exist'\n") + .arg(_param_source.fileName())); + m_fileType = ParamFileType::not_xtandem; + } + } +} diff --git a/src/files/tandemparametersfile.h b/src/files/tandemparametersfile.h index 0f766251cdd256f065d0e8136e5f7578c0c47f95..89a6707102d08bab1ce329dd1f1dc9e2f9fca02d 100644 --- a/src/files/tandemparametersfile.h +++ b/src/files/tandemparametersfile.h @@ -33,6 +33,16 @@ #include #include #include "../core/tandem_run/tandemparameters.h" +#include "../input/xtandemparamsaxhandler.h" + +enum class ParamFileType : std::int8_t +{ + preset = 0, ///< Preset file type + result = 1, ///< Result file type + not_xtandem = 2, ///< Not XTandem file type + no_file = 3, ///< No parameters file found + empty = 4 +}; class TandemParametersFile { @@ -43,7 +53,11 @@ class TandemParametersFile TandemParametersFile(const TandemParametersFile &other); ~TandemParametersFile(); - const QString getMethodName() const; + /** @brief return the preset file name + * File name if its a TandemPresetFile + * or "list path, default parameters" value if its a Tandem result + */ + const QString getMethodName(); const QString getFilename() const; const QDir getAbsoluteDir() const; const QString getAbsoluteFilePath() const; @@ -68,8 +82,11 @@ class TandemParametersFile private: void writeXmlParametersFile(QXmlStreamWriter *p_out, const TandemParameters ¶meters) const; + void setTandemParametersFileType(XtandemParamSaxHandler *parser); private: QFileInfo _param_source; bool m_isTandemParameterFile = false; + ParamFileType m_fileType = ParamFileType::empty; + QFileInfo m_presetFileInfo; }; diff --git a/src/gui/lists/ms_identification_run_list_view/engine_detail_view/engine_detail_view.ui b/src/gui/lists/ms_identification_run_list_view/engine_detail_view/engine_detail_view.ui index d1577605766a7619e672d2f14f0820b5933b836c..2833d39ac7842095d4ec828f21d89c61177b0985 100644 --- a/src/gui/lists/ms_identification_run_list_view/engine_detail_view/engine_detail_view.ui +++ b/src/gui/lists/ms_identification_run_list_view/engine_detail_view/engine_detail_view.ui @@ -51,6 +51,19 @@ + + + + + 75 + true + + + + Preset file + + + diff --git a/src/gui/lists/ms_identification_run_list_view/engine_detail_view/enginedetailwindow.cpp b/src/gui/lists/ms_identification_run_list_view/engine_detail_view/enginedetailwindow.cpp index 98ba85290e3d6cfeef3bff40f877771b96e579ac..2b2a56c91fdea39bd0443ebcd196982a80da96c4 100644 --- a/src/gui/lists/ms_identification_run_list_view/engine_detail_view/enginedetailwindow.cpp +++ b/src/gui/lists/ms_identification_run_list_view/engine_detail_view/enginedetailwindow.cpp @@ -77,7 +77,6 @@ EngineDetailWindow::updateDisplay() if(param_file.exists()) { m_xtandem_parameters = param_file.getTandemParameters(); - if(m_identificationEngine->get()->getIdentificationEngineName() == "X!Tandem") { @@ -87,7 +86,8 @@ EngineDetailWindow::updateDisplay() xtandem_view_widget->setAutomaticXTandemParameters( m_xtandem_parameters); - + qDebug() << param_file.getAbsoluteFilePath(); + ui->labelPreset->setText(param_file.getMethodName()); ui->actionedit_X_Tandem_parameters->setEnabled(true); } else @@ -96,7 +96,7 @@ EngineDetailWindow::updateDisplay() QString message = m_identificationEngine->get()->getIdentificationEngineName() + " parameters view isn't implemented\nComming Soon"; - + ui->labelPreset->setText("No preset file found"); no_engine_view_widget = new NoEngineParamWidget(this, message); ui->verticalLayout->insertWidget(1, no_engine_view_widget); } diff --git a/src/gui/widgets/engines_view/xtandemparamwidget.cpp b/src/gui/widgets/engines_view/xtandemparamwidget.cpp index 692cfc77748e4cdb1c8bd8c4359ca79c1d94c098..aa9e4ac9b95e756ce60e9f2211315f808baf3595 100644 --- a/src/gui/widgets/engines_view/xtandemparamwidget.cpp +++ b/src/gui/widgets/engines_view/xtandemparamwidget.cpp @@ -379,7 +379,7 @@ XtandemParamWidget::setSpectrumParameters(TandemParameters xtandem_parameters) xtandem_parameters.getValue("spectrum, fragment mass type")); ui->unitsForFragmentIonMassToleranceMonoisotopicLineEdit->setText( xtandem_parameters.getValue( - "spectrum, fragment monoisotopic mass error units")); + "spectrum, fragment monoisotopic mass error")); ui->fragmentIonMassToleranceMonoisotopicLineEdit->setText( xtandem_parameters.getValue( "spectrum, parent monoisotopic mass error minus")); @@ -489,11 +489,11 @@ XtandemParamWidget::setRefineParameters(TandemParameters xtandem_parameters) ui->alterFixedModifications2LineEdit->setText( xtandem_parameters.getValue("refine, modification mass 2")); - ui->alterFixedModificationsLineEdit->setText( + ui->alterPotentialModificationsLineEdit->setText( xtandem_parameters.getValue("refine, potential modification mass")); - ui->alterFixedModifications1LineEdit->setText( + ui->alterPotentialModifications1LineEdit->setText( xtandem_parameters.getValue("refine, potential modification mass 1")); - ui->alterFixedModifications2LineEdit->setText( + ui->alterPotentialModifications2LineEdit->setText( xtandem_parameters.getValue("refine, potential modification mass 2")); ui->potentialModificationsMotifLineEdit_2->setText( diff --git a/src/input/xtandemparamsaxhandler.cpp b/src/input/xtandemparamsaxhandler.cpp index 1ec88f8813b06b31ef29b11ec7917b4dfaf8f57c..d9b0f43750c0da9a4ef6b37d07c3abb3bad8e13e 100644 --- a/src/input/xtandemparamsaxhandler.cpp +++ b/src/input/xtandemparamsaxhandler.cpp @@ -242,6 +242,10 @@ XtandemParamSaxHandler::endElement_note() { try { + if(_current_label == "list path, default parameters") + { + m_presetFileInfo = QFileInfo(_current_text.simplified()); + } _p_tandem_parameters->setParamLabelValue(_current_label, _current_text.simplified()); } @@ -258,3 +262,9 @@ XtandemParamSaxHandler::endElement_note() } return true; } + +QFileInfo +XtandemParamSaxHandler::getTandemPresetFileInfo() const +{ + return m_presetFileInfo; +} diff --git a/src/input/xtandemparamsaxhandler.h b/src/input/xtandemparamsaxhandler.h index aa1346e5cc61d766ae187be1e26cf0b98d8a2dbb..5a59557cb30a9b34380248c427cefd117652494f 100644 --- a/src/input/xtandemparamsaxhandler.h +++ b/src/input/xtandemparamsaxhandler.h @@ -33,6 +33,7 @@ #include #include #include "../core/tandem_run/tandemparameters.h" +#include class XtandemParamSaxHandler : public QXmlDefaultHandler { @@ -62,6 +63,8 @@ class XtandemParamSaxHandler : public QXmlDefaultHandler bool isTandemParameter() const; + QFileInfo getTandemPresetFileInfo() const; + private: bool startElement_note(QXmlAttributes attributes); bool endElement_note(); @@ -75,4 +78,5 @@ class XtandemParamSaxHandler : public QXmlDefaultHandler QString _current_label; bool m_isTandemParameter = false; + QFileInfo m_presetFileInfo; }; diff --git a/src/resources/model/QExactive_analysis_FDR_nosemi.xml b/src/resources/model/QExactive_analysis_FDR_nosemi.xml old mode 100755 new mode 100644 diff --git a/src/utils/utils.h b/src/utils/utils.h index 7da00ffe0e434e861bc5379f860b4e291370af83..bec695e1c2ccc36a118785952b8b56b297f6dec3 100644 --- a/src/utils/utils.h +++ b/src/utils/utils.h @@ -36,8 +36,7 @@ class Utils static const QString getDatabaseName(ExternalDatabase database); static const QString getXmlDouble(pappso::pappso_double number); static const QString checkXtandemVersion(const QString &tandem_bin_path); - static double computeFdr(std::size_t count_decoy, - std::size_t count_target); + static double computeFdr(std::size_t count_decoy, std::size_t count_target); static pappso::AaModificationP guessAaModificationPbyMonoisotopicMassDelta(pappso::pappso_double mass); static pappso::AaModificationP