Skip to content
Snippets Groups Projects
tandemcondorprocess.cpp 3.24 KiB
Newer Older
/**
 * \file /core/tandem_run/tandemcondorprocess.cpp
 * \date 5/9/2017
 * \author Olivier Langella
 * \brief handles execution of a bunch of X!Tandem process throught condor job
 */

/*******************************************************************************
* 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
******************************************************************************/

Langella Olivier's avatar
Langella Olivier committed
#include "tandemcondorprocess.h"
#include <QDebug>
#include <pappsomspp/pappsoexception.h>
Langella Olivier's avatar
Langella Olivier committed
TandemCondorProcess::TandemCondorProcess(WorkMonitorInterface * p_monitor, const TandemRunBatch & tandem_run_batch) : TandemBatchProcess(p_monitor, tandem_run_batch) {
    /*
    Universe   = vanilla
    notification   = Error
    Rank       = Mips
    request_memory= 50000
    request_cpus = 1
    Executable = /usr/bin/tandem
    Log        = /gorgone/pappso/tmp/temp_condor_job93294001891239208719639434471283743/submit_condor.log
    Output        = /gorgone/pappso/tmp/temp_condor_job93294001891239208719639434471283743/tandem.$(Process).out
    Error        = /gorgone/pappso/tmp/temp_condor_job93294001891239208719639434471283743/tandem.$(Process).error

    Arguments = /gorgone/pappso/tmp/temp_condor_job93294001891239208719639434471283743/xtandem_param2054956555872858570.xml
    Queue
    */
}

Langella Olivier's avatar
Langella Olivier committed
void TandemCondorProcess::run() {
    qDebug() << "TandeCondorProcess::run begin " << _tandem_run_batch._preset_file;
    _preset_file = _tandem_run_batch._preset_file;

    prepareXmlDatabaseFile();

    std::vector<QTemporaryFile *> input_file_list;

    int i=0;
    _p_monitor->setProgressMaximumValue(_tandem_run_batch._mz_file_list.size());
    for (QString mz_file : _tandem_run_batch._mz_file_list) {


        QTemporaryFile *  p_xml_input_file = new QTemporaryFile();

        input_file_list.push_back(p_xml_input_file);
        p_xml_input_file->setAutoRemove(false);
        if (p_xml_input_file->open())
        {
            QXmlStreamWriter * p_out = new QXmlStreamWriter();
            p_out->setDevice(p_xml_input_file);

            writeXmlInputFile(p_out, mz_file);

            p_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(p_xml_input_file->fileName()));
        }
        i++;
    }
    for (QTemporaryFile *  p_xml_input_file: input_file_list) {
        delete p_xml_input_file;
    }
    qDebug() << "TandeCondorProcess::run end" ;
}