1 /* $Id: blastn_args.cpp 637473 2021-09-13 18:26:33Z ivanov $
2 * ===========================================================================
3 *
4 * PUBLIC DOMAIN NOTICE
5 * National Center for Biotechnology Information
6 *
7 * This software/database is a "United States Government Work" under the
8 * terms of the United States Copyright Act. It was written as part of
9 * the author's official duties as a United States Government employee and
10 * thus cannot be copyrighted. This software/database is freely available
11 * to the public for use. The National Library of Medicine and the U.S.
12 * Government have not placed any restriction on its use or reproduction.
13 *
14 * Although all reasonable efforts have been taken to ensure the accuracy
15 * and reliability of the software and data, the NLM and the U.S.
16 * Government do not and cannot warrant the performance or results that
17 * may be obtained by using this software or data. The NLM and the U.S.
18 * Government disclaim all warranties, express or implied, including
19 * warranties of performance, merchantability or fitness for any particular
20 * purpose.
21 *
22 * Please cite the author in any work or product based on this material.
23 *
24 * ===========================================================================
25 *
26 * Author: Christiam Camacho
27 *
28 */
29
30 /** @file blastn_args.cpp
31 * Implementation of the BLASTN command line arguments
32 */
33
34 #include <ncbi_pch.hpp>
35 #include <algo/blast/blastinput/blastn_args.hpp>
36 #include <algo/blast/api/disc_nucl_options.hpp>
37 #include <algo/blast/api/blast_exception.hpp>
38 #include <algo/blast/blastinput/blast_input_aux.hpp>
39 #include <algo/blast/api/version.hpp>
40
41 BEGIN_NCBI_SCOPE
42 BEGIN_SCOPE(blast)
43 USING_SCOPE(objects);
44
CBlastnAppArgs()45 CBlastnAppArgs::CBlastnAppArgs()
46 {
47 CRef<IBlastCmdLineArgs> arg;
48 static const char kProgram[] = "blastn";
49 arg.Reset(new CProgramDescriptionArgs(kProgram,
50 "Nucleotide-Nucleotide BLAST"));
51 const bool kQueryIsProtein = false;
52 m_Args.push_back(arg);
53 m_ClientId = string(kProgram) + " " + CBlastVersion().Print();
54
55 static const char kDefaultTask[] = "megablast";
56 SetTask(kDefaultTask);
57 set<string> tasks
58 (CBlastOptionsFactory::GetTasks(CBlastOptionsFactory::eNuclNucl));
59 tasks.erase("vecscreen"); // vecscreen has its own program
60 arg.Reset(new CTaskCmdLineArgs(tasks, kDefaultTask));
61 m_Args.push_back(arg);
62
63 m_BlastDbArgs.Reset(new CBlastDatabaseArgs);
64 m_BlastDbArgs->SetDatabaseMaskingSupport(true);
65 arg.Reset(m_BlastDbArgs);
66 m_Args.push_back(arg);
67
68 m_StdCmdLineArgs.Reset(new CStdCmdLineArgs);
69 arg.Reset(m_StdCmdLineArgs);
70 m_Args.push_back(arg);
71
72 arg.Reset(new CGenericSearchArgs(kQueryIsProtein, false, true,
73 false, false, false));
74 m_Args.push_back(arg);
75
76 arg.Reset(new CNuclArgs);
77 m_Args.push_back(arg);
78
79 arg.Reset(new CDiscontiguousMegablastArgs);
80 m_Args.push_back(arg);
81
82 arg.Reset(new CFilteringArgs(kQueryIsProtein));
83 m_Args.push_back(arg);
84
85 arg.Reset(new CGappedArgs);
86 m_Args.push_back(arg);
87
88 m_HspFilteringArgs.Reset(new CHspFilteringArgs);
89 arg.Reset(m_HspFilteringArgs);
90 m_Args.push_back(arg);
91
92 arg.Reset(new CWindowSizeArg);
93 m_Args.push_back(arg);
94
95 arg.Reset(new COffDiagonalRangeArg);
96 m_Args.push_back(arg);
97
98 arg.Reset(new CMbIndexArgs);
99 m_Args.push_back(arg);
100
101 m_QueryOptsArgs.Reset(new CQueryOptionsArgs(kQueryIsProtein));
102 arg.Reset(m_QueryOptsArgs);
103 m_Args.push_back(arg);
104
105 m_FormattingArgs.Reset(new CFormattingArgs(false, CFormattingArgs::eIsSAM));
106 arg.Reset(m_FormattingArgs);
107 m_Args.push_back(arg);
108
109 m_MTArgs.Reset(new CMTArgs(CThreadable::kMinNumThreads, CMTArgs::eSplitByDB));
110 arg.Reset(m_MTArgs);
111 m_Args.push_back(arg);
112
113 m_RemoteArgs.Reset(new CRemoteArgs);
114 arg.Reset(m_RemoteArgs);
115 m_Args.push_back(arg);
116
117 m_DebugArgs.Reset(new CDebugArgs);
118 arg.Reset(m_DebugArgs);
119 m_Args.push_back(arg);
120 }
121
122 CRef<CBlastOptionsHandle>
x_CreateOptionsHandle(CBlastOptions::EAPILocality locality,const CArgs & args)123 CBlastnAppArgs::x_CreateOptionsHandle(CBlastOptions::EAPILocality locality,
124 const CArgs& args)
125 {
126 _ASSERT(args.Exist(kTask));
127 _ASSERT(args[kTask].HasValue());
128 return x_CreateOptionsHandleWithTask(locality, args[kTask].AsString());
129 }
130
131 int
GetQueryBatchSize() const132 CBlastnAppArgs::GetQueryBatchSize() const
133 {
134 bool is_remote = (m_RemoteArgs.NotEmpty() && m_RemoteArgs->ExecuteRemotely());
135 return blast::GetQueryBatchSize(ProgramNameToEnum(GetTask()), m_IsUngapped, is_remote, false);
136 }
137
138 /// Get the input stream
139 CNcbiIstream&
GetInputStream()140 CBlastnNodeArgs::GetInputStream()
141 {
142 if ( !m_InputStream ) {
143 abort();
144 }
145 return *m_InputStream;
146 }
147 /// Get the output stream
148 CNcbiOstream&
GetOutputStream()149 CBlastnNodeArgs::GetOutputStream()
150 {
151 return m_OutputStream;
152 }
153
CBlastnNodeArgs(const string & input)154 CBlastnNodeArgs::CBlastnNodeArgs(const string & input)
155 {
156 m_InputStream = new CNcbiIstrstream(input);
157 }
158
~CBlastnNodeArgs()159 CBlastnNodeArgs::~CBlastnNodeArgs()
160 {
161 if (m_InputStream) {
162 free(m_InputStream);
163 m_InputStream = NULL;
164 }
165 }
166
167 int
GetQueryBatchSize() const168 CBlastnNodeArgs::GetQueryBatchSize() const
169 {
170 bool is_remote = (m_RemoteArgs.NotEmpty() && m_RemoteArgs->ExecuteRemotely());
171 return blast::GetQueryBatchSize(ProgramNameToEnum(GetTask()), m_IsUngapped, is_remote, false);
172 }
173
174 CRef<CBlastOptionsHandle>
x_CreateOptionsHandle(CBlastOptions::EAPILocality locality,const CArgs & args)175 CBlastnNodeArgs::x_CreateOptionsHandle(CBlastOptions::EAPILocality locality, const CArgs& args)
176 {
177 return CBlastnAppArgs::x_CreateOptionsHandle(locality, args);
178 }
179
180 END_SCOPE(blast)
181 END_NCBI_SCOPE
182
183