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 "Metaphlan2Validator.h"
23
24 #include <QDir>
25
26 #include <U2Core/AppContext.h>
27 #include <U2Core/DataPathRegistry.h>
28
29 #include "../ngs_reads_classification/src/NgsReadsClassificationPlugin.h"
30 #include "Metaphlan2WorkerFactory.h"
31
32 namespace U2 {
33 namespace Workflow {
34
validate(const Actor * actor,NotificationsList & notificationList,const QMap<QString,QString> &) const35 bool Metaphlan2Validator::validate(const Actor *actor, NotificationsList ¬ificationList, const QMap<QString, QString> &) const {
36 return validateDatabase(actor, notificationList);
37 }
38
validateDatabase(const Actor * actor,NotificationsList & notificationList) const39 bool Metaphlan2Validator::validateDatabase(const Actor *actor, NotificationsList ¬ificationList) const {
40 const QString dbUrl = actor->getParameter(LocalWorkflow::Metaphlan2WorkerFactory::DB_URL)->getAttributeValueWithoutScript<QString>();
41 CHECK(!dbUrl.isEmpty(), false);
42
43 bool result = true;
44 QDir dbDir(dbUrl);
45 QStringList filterPkl = QStringList() << "*.pkl";
46 QStringList dbPklEntries = dbDir.entryList(filterPkl);
47 if (dbPklEntries.size() != 1) {
48 notificationList << WorkflowNotification(tr("The database folder should contain a single \"*.pkl\" file."), actor->getId());
49 result = false;
50 }
51
52 QStringList filterBt2 = QStringList() << "*.bt2";
53 QStringList dbBt2Entries = dbDir.entryList(filterBt2);
54 if (dbBt2Entries.size() != 6) {
55 notificationList << WorkflowNotification(tr("The database folder should contain six Bowtie2 index files (\"*.bt2\")."), actor->getId());
56 result = false;
57 }
58
59 return result;
60 }
61
62 } // namespace Workflow
63
64 } // namespace U2