1 /**
2  * UGENE - Integrated Bioinformatics Tools.
3  * Copyright (C) 2008-2021 UniPro <ugene@unipro.ru>
4  * http://ugene.net
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19  * MA 02110-1301, USA.
20  */
21 
22 #include "Metaphlan2Support.h"
23 
24 #include <QFileInfo>
25 
26 #include <U2Core/U2SafePoints.h>
27 
28 namespace U2 {
29 
30 const QString Metaphlan2Support::TOOL_ID = "USUPP_METAPHLAN2";
31 const QString Metaphlan2Support::TOOL_NAME = "MetaPhlAn2";
32 const QString Metaphlan2Support::UTIL_SCRIPT = "utils/read_fastx.py";
33 
34 //These constants are taken from the 'external_tool_support' project
35 const QString Metaphlan2Support::ET_BOWTIE_2_ALIGNER_ID = "USUPP_BOWTIE2";
36 const QString Metaphlan2Support::ET_PYTHON_ID = "USUPP_PYTHON2";
37 const QString Metaphlan2Support::ET_PYTHON_BIO_ID = "BIO";
38 const QString Metaphlan2Support::ET_PYTHON_NUMPY_ID = "NUMPY";
39 
Metaphlan2Support(const QString & id,const QString & name,const QString & path)40 Metaphlan2Support::Metaphlan2Support(const QString &id, const QString &name, const QString &path)
41     : ExternalTool(id, "metaphlan2", name, path) {
42     validationArguments << "--version";
43 
44     toolKitName = TOOL_NAME;
45     description = tr("<i>MetaPhlAn2 (METAgenomic PHyLogenetic ANalysis)</i> is a tool for profiling the composition of microbial communities (bacteria, archaea, eukaryotes, and viruses) from whole-metagenome shotgun sequencing data.");
46 
47     executableFileName = "metaphlan2.py";
48 
49     toolRunnerProgram = ET_PYTHON_ID;
50     dependencies << ET_PYTHON_ID << ET_PYTHON_BIO_ID << ET_PYTHON_NUMPY_ID << ET_BOWTIE_2_ALIGNER_ID;
51 
52     validMessage = "MetaPhlAn version ";
53     versionRegExp = QRegExp("MetaPhlAn version (\\d+\\.\\d+(\\.\\d+)?(\\-[a-zA-Z]*)?)");
54 }
55 
performAdditionalChecks(const QString & toolPath)56 void Metaphlan2Support::performAdditionalChecks(const QString &toolPath) {
57     QFileInfo file(toolPath);
58     QString utilScriptFullPath = QString("%1/%2").arg(file.absolutePath()).arg(UTIL_SCRIPT);
59     if (!QFileInfo::exists(utilScriptFullPath)) {
60         additionalErrorMesage = tr("%1 script \"%2\" is not present!").arg(TOOL_NAME).arg(UTIL_SCRIPT);
61     }
62 }
63 
64 }    // namespace U2
65