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 "BlastXPlusSupportTask.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 *BlastXPlusSupportTask::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 << "3";
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
65 if (!settings.isDefaultCosts) {
66 arguments << "-gapopen" << QString::number(settings.gapOpenCost);
67 arguments << "-gapextend" << QString::number(settings.gapExtendCost);
68 }
69 if (settings.isNucleotideSeq && (!settings.isDefautScores)) {
70 assert(false);
71 arguments << "-penalty" << QString::number(settings.mismatchPenalty);
72 arguments << "-reward" << QString::number(settings.matchReward);
73 } else {
74 if (!settings.isDefaultMatrix) {
75 arguments << "-matrix" << settings.matrix;
76 }
77 }
78 if (settings.numberOfHits != 0) {
79 arguments << "-culling_limit" << QString::number(settings.numberOfHits); //???
80 }
81 if (!settings.isGappedAlignment) {
82 arguments << "-ungapped";
83 }
84
85 arguments << "-query" << url;
86 if (settings.xDropoffGA != 15) {
87 arguments << "-xdrop_gap" << QString::number(settings.xDropoffGA);
88 }
89 if (settings.xDropoffFGA != 25) {
90 arguments << "-xdrop_gap_final" << QString::number(settings.xDropoffFGA);
91 }
92
93 if (settings.xDropoffUnGA != 7) {
94 arguments << "-xdrop_ungap" << QString::number(settings.xDropoffUnGA);
95 }
96 if (!settings.isDefaultThreshold) {
97 arguments << "-threshold" << QString::number(settings.threshold);
98 }
99 if (settings.windowSize != 40) {
100 arguments << "-window_size" << QString::number(settings.windowSize);
101 }
102 if (!settings.compStats.isEmpty()) {
103 arguments << "-comp_based_stats" << settings.compStats;
104 }
105 arguments << "-num_threads" << QString::number(settings.numberOfProcessors);
106 arguments << "-outfmt" << QString::number(settings.outputType); //"5";//Set output file format to xml
107 if (settings.outputOriginalFile.isEmpty()) {
108 arguments << "-out" << url + ".xml";
109 settings.outputOriginalFile = url + ".xml";
110 } else {
111 arguments << "-out" << settings.outputOriginalFile;
112 }
113
114 algoLog.trace("BlastX+ arguments: " + arguments.join(" "));
115 QString workingDirectory = QFileInfo(url).absolutePath();
116 ExternalToolRunTask *runTask = new ExternalToolRunTask(BlastPlusSupport::ET_BLASTX_ID, arguments, new ExternalToolLogParser(), workingDirectory);
117 setListenerForTask(runTask);
118 return runTask;
119 }
120 } // namespace U2
121