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

new tandem batch process object

parent 09cf46b4
No related branches found
No related tags found
No related merge requests found
......@@ -57,10 +57,11 @@ SET(CPP_FILES
core/identification_sources/identificationxtandemfile.cpp
core/labeling/label.cpp
core/labeling/labelingmethod.cpp
core/tandem_run/tandembatchprocess.cpp
core/msrun.cpp
core/peptidematch.cpp
core/peptidextp.cpp
./core/project.cpp
core/project.cpp
core/proteinmatch.cpp
core/proteinxtp.cpp
core/sequencedatabase.cpp
......
/**
* \file /core/tandem_run/tandembatchprocess.cpp
* \date 5/9/2017
* \author Olivier Langella
* \brief handles execution of a bunch of X!Tandem process
*/
/*******************************************************************************
* Copyright (c) 2017 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/>.
*
* Contributors:
* Olivier Langella <olivier.langella@u-psud.fr> - initial API and implementation
******************************************************************************/
#include "tandembatchprocess.h"
#include <QProcess>
#include <pappsomspp/pappsoexception.h>
#include <QXmlStreamWriter>
#include <QFileInfo>
TandemBatchProcess::TandemBatchProcess(WorkMonitorInterface * p_monitor, const TandemRunBatch & tandem_run_batch) {
_tandem_run_batch = tandem_run_batch;
}
void TandemBatchProcess::prepareXmlDatabaseFile() {
_xml_database_file.setAutoRemove(false);
if (_xml_database_file.open())
{
QXmlStreamWriter * p_out = new QXmlStreamWriter();
p_out->setDevice(&_xml_database_file);
p_out->setAutoFormatting(true);
p_out->writeStartDocument("1.0");
//<?xml version="1.0" encoding="UTF-8"?>
//<bioml label="x! taxon-to-file matching list">
p_out->writeStartElement("bioml");
p_out->writeAttribute("label","x! taxon-to-file matching list");
//<taxon label="usedefined">
p_out->writeStartElement("taxon");
p_out->writeAttribute("label","usedefined");
//<file format="peptide" URL="/gorgone/pappso/jouy/users/Didier/fasta/20170608_Delastours/contaminants_standards.fasta"></file>
//<file format="peptide" URL="/gorgone/pappso/jouy/users/Didier/fasta/20170608_Delastours/Escherichia coli 27J42_WGS_ECOLI_1.fasta"></file>
for (QString fasta_file:_tandem_run_batch._fasta_file_list) {
p_out->writeStartElement("file");
p_out->writeAttribute("format","peptide");
p_out->writeAttribute("URL",fasta_file);
p_out->writeEndElement();
}
//</taxon>
p_out->writeEndElement();
//</bioml>
p_out->writeEndElement();
p_out->writeEndDocument();
_xml_database_file.close();
delete p_out;
} else
{
throw pappso::PappsoException(QObject::tr("error : cannot open the XML database file : %1\n").arg(_xml_database_file.fileName()));
}
}
void TandemBatchProcess::run() {
_preset_file = _tandem_run_batch._preset_file;
prepareXmlDatabaseFile();
for (QString mz_file : _tandem_run_batch._mz_file_list) {
runOne(mz_file);
}
}
void TandemBatchProcess::writeXmlInputFile (QXmlStreamWriter * p_out, const QString & mz_file) {
QFileInfo mz_file_info(mz_file);
//<?xml version="1.0" encoding="UTF-8"?>
p_out->setAutoFormatting(true);
p_out->writeStartDocument("1.0");
//<bioml label="20170405_Delastour_11.xml">
p_out->writeStartElement("bioml");
p_out->writeAttribute("label",mz_file_info.getFilename());
//<note type="heading">Paths</note>
p_out->writeStartElement("note");
p_out->writeAttribute("type","heading");
p_out->writeCharacters("Paths");
p_out->writeEndElement();
//<note type="input" label="list path, default parameters">/gorgone/pappso/tmp/temp_condor_job93294001891239208719639434471283743/QExactive_IAM_4CPU_Classic_ClassicAvecReversed..xml</note>
p_out->writeStartElement("note");
p_out->writeAttribute("type","input");
p_out->writeAttribute("label","list path, default parameters");
p_out->writeCharacters(_preset_file);
p_out->writeEndElement();
//<note type="input" label="list path, taxonomy information">/gorgone/pappso/tmp/temp_condor_job93294001891239208719639434471283743/database.xml</note>
p_out->writeStartElement("note");
p_out->writeAttribute("type","input");
p_out->writeAttribute("label","list path, taxonomy information");
p_out->writeCharacters(_xml_database_file.getFilename());
p_out->writeEndElement();
//<note type="input" label="spectrum, path">/gorgone/pappso/jouy/raw/2017_Qex/20170405_Delastours/20170405_Delastour_11.mzXML</note>
p_out->writeStartElement("note");
p_out->writeAttribute("type","input");
p_out->writeAttribute("label","spectrum, path");
p_out->writeCharacters(mz_file);
p_out->writeEndElement();
//<note type="heading">Protein general</note>
p_out->writeStartElement("note");
p_out->writeAttribute("type","heading");
p_out->writeCharacters("Protein general");
p_out->writeEndElement();
//<note type="input" label="protein, taxon">usedefined</note>
p_out->writeStartElement("note");
p_out->writeAttribute("type","input");
p_out->writeAttribute("label","protein, taxon");
p_out->writeCharacters("usedefined");
p_out->writeEndElement();
//<note type="heading">Output</note>
p_out->writeStartElement("note");
p_out->writeAttribute("type","heading");
p_out->writeCharacters("Output");
p_out->writeEndElement();
//<note type="input" label="output, path">/gorgone/pappso/jouy/users/Didier/Xcal2017/2017_05_04_Delastours/Interrogation_souches_sequencees/Patient27/J42/20170405_Delastour_11.xml</note>
p_out->writeStartElement("note");
p_out->writeAttribute("type","input");
p_out->writeAttribute("label","output, path");
p_out->writeCharacters("usedefined");
p_out->writeEndElement();
//</bioml>
p_out->writeEndElement();
p_out->writeEndDocument();
}
void TandemBatchProcess::runOne(const QString & mz_file) {
QTemporaryFile xml_input_file;
if (xml_input_file.open())
{
QXmlStreamWriter * p_out = new QXmlStreamWriter();
p_out->setDevice(&xml_input_file);
writeXmlInputFile(p_out, mz_file);
xml_input_file.close();
delete p_out;
} else
{
throw pappso::PappsoException(QObject::tr("error : cannot open the XML X!Tandem input file : %1\n").arg(xml_input_file.fileName()));
}
QStringList arguments;
arguments << xml_input_file.fileName();
QProcess * xt_process = new QProcess();
//hk_process->setWorkingDirectory(QFileInfo(_hardklor_exe).absolutePath());
xt_process->start(_tandem_run_batch._tandem_bin_path, arguments);
if (!xt_process->waitForStarted()) {
throw pappso::PappsoException(QObject::tr("X!Tandem process failed to start"));
}
if (!xt_process->waitForFinished(_max_xt_time_ms)) {
throw pappso::PappsoException(QObject::tr("can't wait for X!Tandem process to finish : timeout at %1").arg(_max_xt_time_ms));
}
QByteArray result = xt_process->readAll();
QProcess::ExitStatus Status = xt_process->exitStatus();
if (Status != 0)
{
// != QProcess::NormalExit
throw pappso::PappsoException(QObject::tr("error executing X!Tandem Status != 0 : %1 %2\n%3").arg(_tandem_run_batch._tandem_bin_path).arg(arguments.join(" ").arg(result.toStdString().c_str())));
}
delete xt_process;
}
/**
* \file /core/tandem_run/tandembatchprocess.h
* \date 5/9/2017
* \author Olivier Langella
* \brief handles execution of a bunch of X!Tandem process
*/
/*******************************************************************************
* Copyright (c) 2017 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/>.
*
* Contributors:
* Olivier Langella <olivier.langella@u-psud.fr> - initial API and implementation
******************************************************************************/
#ifndef TANDEMBATCHPROCESS_H
#define TANDEMBATCHPROCESS_H
#include "tandemrunbatch.h"
#include "../../utils/workmonitor.h"
#include <QTemporaryFile>
class TandemBatchProcess
{
public:
TandemBatchProcess(WorkMonitorInterface * p_monitor, const TandemRunBatch & tandem_run_batch);
void run();
private:
void runOne(const QString & mz_file);
void prepareXmlDatabaseFile();
void writeXmlInputFile (QXmlStreamWriter * p_out, const QString & mz_file);
private:
TandemRunBatch _tandem_run_batch;
WorkMonitorInterface * _p_monitor;
QString _preset_file;
int _max_xt_time_ms = (60000 * 60 * 24); //1 day
QTemporaryFile _xml_database_file;
};
#endif // TANDEMBATCHPROCESS_H
/**
* \file /core/tandem_run/tandem_run_batch.cpp
* \file /core/tandem_run/tandemrunbatch.cpp
* \date 2/9/2017
* \author Olivier Langella
* \brief all data needed to run a Tandem batch
......
/**
* \file /core/tandem_run/tandem_run_batch.h
* \file /core/tandem_run/tandemrunbatch.h
* \date 2/9/2017
* \author Olivier Langella
* \brief all data needed to run a Tandem batch
......
......@@ -77,5 +77,6 @@ void IdentificationGroupWidget::doIdentificationGroupGrouped(IdentificationGroup
ui->group_number_display->setText(QString("%1").arg(_p_identification_group->countGroup()));
ui->subgroup_number_display->setText(QString("%1").arg(_p_identification_group->countSubGroup()));
ui->protein_number_display->setText(QString("%1").arg(_p_identification_group->countProteinMatch(ValidationState::grouped)));
_p_identification_group->countPeptideMatch(ValidationState::grouped);
}
}
......@@ -37,6 +37,7 @@
#include "files/xpipfile.h"
#include "mainwindow.h"
#include "project_view/projectwindow.h"
#include "../core/tandem_run/tandembatchprocess.h"
WorkerThread::WorkerThread(MainWindow * p_main_window)
{
......@@ -294,6 +295,9 @@ void WorkerThread::doRunningXtandem(TandemRunBatch tandem_run_batch) {
try {
emit loadingMessage(tr("Running X!Tandem, please wait"));
qDebug() << "WorkerThread::doRunningXtandem tandem_run_batch " << tandem_run_batch._tandem_bin_path;
TandemBatchProcess xt_process (_p_work_monitor, tandem_run_batch);
emit operationFinished();
}
catch (pappso::PappsoException & error) {
......
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