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 "BlastNPlusSupportTask.h"
23
24 #include <QDomDocument>
25 #include <QFileInfo>
26
27 #include <U2Core/AppContext.h>
28 #include <U2Core/AppResources.h>
29 #include <U2Core/AppSettings.h>
30 #include <U2Core/CreateAnnotationTask.h>
31 #include <U2Core/DocumentModel.h>
32 #include <U2Core/ExternalToolRegistry.h>
33 #include <U2Core/Log.h>
34 #include <U2Core/ProjectModel.h>
35 #include <U2Core/UserApplicationsSettings.h>
36
37 #include "BlastPlusSupport.h"
38
39 namespace U2 {
40
createBlastPlusTask()41 ExternalToolRunTask *BlastNPlusSupportTask::createBlastPlusTask() {
42 QStringList arguments;
43 //arguments <<"-p"<< settings.programName; //taskname
44 // if(!settings.filter.isEmpty()){
45 // arguments <<"-F"<<settings.filter;
46 // }
47 arguments << "-db" << settings.databaseNameAndPath;
48 arguments << "-evalue" << QString::number(settings.expectValue);
49 arguments << "-task" << (settings.megablast ? "megablast" : "blastn");
50 if (settings.wordSize <= 0) {
51 arguments << "-word_size"
52 << "11";
53 } else {
54 arguments << "-word_size" << QString::number(settings.wordSize);
55 }
56
57 if (settings.directStrand == TriState_Yes) {
58 arguments << "-strand"
59 << "plus";
60 } else if (settings.directStrand == TriState_No) {
61 arguments << "-strand"
62 << "minus";
63 }
64 if (!settings.isDefaultCosts) {
65 arguments << "-gapopen" << QString::number(settings.gapOpenCost);
66 arguments << "-gapextend" << QString::number(settings.gapExtendCost);
67 }
68 if (settings.isNucleotideSeq && (!settings.isDefautScores)) {
69 arguments << "-penalty" << QString::number(settings.mismatchPenalty);
70 arguments << "-reward" << QString::number(settings.matchReward);
71 } else {
72 if (!settings.isDefaultMatrix) {
73 assert(false);
74 arguments << "-M" << settings.matrix;
75 }
76 }
77 if (settings.numberOfHits != 0) {
78 arguments << "-culling_limit" << QString::number(settings.numberOfHits); //???
79 }
80 if (!settings.isGappedAlignment) {
81 arguments << "-ungapped";
82 }
83
84 arguments << "-query" << url;
85 if ((settings.xDropoffGA != 30) ||
86 (settings.megablast && settings.xDropoffGA != 20)) {
87 arguments << "-xdrop_gap" << QString::number(settings.xDropoffGA);
88 }
89 if (settings.xDropoffFGA != 100) {
90 arguments << "-xdrop_gap_final" << QString::number(settings.xDropoffFGA);
91 }
92
93 if ((settings.xDropoffUnGA != 20) ||
94 (settings.megablast && settings.xDropoffUnGA != 10)) {
95 arguments << "-xdrop_ungap" << QString::number(settings.xDropoffUnGA);
96 }
97 if (settings.windowSize != 0) {
98 arguments << "-window_size" << QString::number(settings.windowSize);
99 }
100 arguments << "-num_threads" << QString::number(settings.numberOfProcessors);
101 arguments << "-outfmt" << QString::number(settings.outputType); //"5";//Set output file format to xml
102 if (settings.outputOriginalFile.isEmpty()) {
103 arguments << "-out" << url + ".xml";
104 settings.outputOriginalFile = url + ".xml";
105 } else {
106 arguments << "-out" << settings.outputOriginalFile;
107 }
108
109 algoLog.trace("BlastN+ arguments: " + arguments.join(" "));
110 QString workingDirectory = QFileInfo(url).absolutePath();
111 ExternalToolRunTask *toolRunTask = new ExternalToolRunTask(BlastPlusSupport::ET_BLASTN_ID, arguments, new ExternalToolLogParser(), workingDirectory);
112 setListenerForTask(toolRunTask);
113 return toolRunTask;
114 }
115 } // namespace U2
116