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 "TBlastXPlusSupportTask.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 *TBlastXPlusSupportTask::createBlastPlusTask() {
42     QStringList arguments;
43 
44     arguments << "-db" << settings.databaseNameAndPath;
45     arguments << "-evalue" << QString::number(settings.expectValue);
46     if (settings.wordSize <= 0) {
47         arguments << "-word_size"
48                   << "3";
49     } else {
50         arguments << "-word_size" << QString::number(settings.wordSize);
51     }
52 
53     if (settings.directStrand == TriState_Yes) {
54         arguments << "-strand"
55                   << "plus";
56     } else if (settings.directStrand == TriState_No) {
57         arguments << "-strand"
58                   << "minus";
59     }
60 
61     if (settings.isNucleotideSeq && (!settings.isDefautScores)) {
62         assert(false);
63         coreLog.error(tr("Unexpected settings combination"));
64     } else {
65         if (!settings.isDefaultMatrix) {
66             arguments << "-matrix" << settings.matrix;
67         }
68     }
69     if (settings.numberOfHits != 0) {
70         arguments << "-culling_limit" << QString::number(settings.numberOfHits);    //???
71     }
72     arguments << "-query" << url;
73 
74     if (settings.xDropoffUnGA != 7) {
75         arguments << "-xdrop_ungap" << QString::number(settings.xDropoffUnGA);
76     }
77     if (!settings.isDefaultThreshold) {
78         arguments << "-threshold" << QString::number(settings.threshold);
79     }
80     if (settings.windowSize != 40) {
81         arguments << "-window_size" << QString::number(settings.windowSize);
82     }
83     arguments << "-num_threads" << QString::number(settings.numberOfProcessors);
84     arguments << "-outfmt" << QString::number(settings.outputType);    //"5";//Set output file format to xml
85     if (settings.outputOriginalFile.isEmpty()) {
86         arguments << "-out" << url + ".xml";
87         settings.outputOriginalFile = url + ".xml";
88     } else {
89         arguments << "-out" << settings.outputOriginalFile;
90     }
91 
92     algoLog.trace("TBlastX+ arguments: " + arguments.join(" "));
93     QString workingDirectory = QFileInfo(url).absolutePath();
94 
95     ExternalToolRunTask *runTask = new ExternalToolRunTask(BlastPlusSupport::ET_TBLASTX_ID, arguments, new ExternalToolLogParser(), workingDirectory);
96     setListenerForTask(runTask);
97     return runTask;
98 }
99 
100 }    // namespace U2
101