1 /* $Id: rpstblastn_args.cpp 631487 2021-05-19 13:44:58Z 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: Jason Papadopoulos
27 *
28 */
29
30 /** @file rpstblastn_args.cpp
31 * Implementation of the RPSTBLASTN command line arguments
32 */
33
34 #include <ncbi_pch.hpp>
35 #include <algo/blast/blastinput/rpstblastn_args.hpp>
36 #include <algo/blast/api/rpstblastn_options.hpp>
37 #include <algo/blast/blastinput/blast_input_aux.hpp>
38 #include <algo/blast/blastinput/rpsblast_args.hpp>
39 #include <algo/blast/api/version.hpp>
40
41 BEGIN_NCBI_SCOPE
42 BEGIN_SCOPE(blast)
43 USING_SCOPE(objects);
44
CRPSTBlastnAppArgs()45 CRPSTBlastnAppArgs::CRPSTBlastnAppArgs()
46 {
47 CRef<IBlastCmdLineArgs> arg;
48 bool const kFilterByDefault = false;
49 static const string kProgram("rpstblastn");
50 arg.Reset(new CProgramDescriptionArgs(kProgram,
51 "Translated Reverse Position Specific BLAST"));
52 const bool kQueryIsProtein = false;
53 const bool kIsRpsBlast = true;
54 const bool kIsCBS2and3Supported = false;
55 m_Args.push_back(arg);
56 m_ClientId = kProgram + " " + CBlastVersion().Print();
57
58 static const char kDefaultTask[] = "rpstblastn";
59 SetTask(kDefaultTask);
60
61 m_BlastDbArgs.Reset(new CBlastDatabaseArgs(false, kIsRpsBlast));
62 arg.Reset(m_BlastDbArgs);
63 m_Args.push_back(arg);
64
65 m_StdCmdLineArgs.Reset(new CStdCmdLineArgs);
66 arg.Reset(m_StdCmdLineArgs);
67 m_Args.push_back(arg);
68
69 // N.B.: query is not protein because the options are applied on the
70 // translated query
71 arg.Reset(new CGenericSearchArgs( !kQueryIsProtein, kIsRpsBlast ));
72 m_Args.push_back(arg);
73
74 arg.Reset(new CGeneticCodeArgs(CGeneticCodeArgs::eQuery));
75 m_Args.push_back(arg);
76
77 // N.B.: query is not protein because the filtering is applied on the
78 // translated query
79 arg.Reset(new CFilteringArgs( !kQueryIsProtein, kFilterByDefault));
80 m_Args.push_back(arg);
81
82 arg.Reset(new CWindowSizeArg);
83 m_Args.push_back(arg);
84
85 arg.Reset(new CGappedArgs);
86 m_Args.push_back(arg);
87
88 m_QueryOptsArgs.Reset(new CQueryOptionsArgs(kQueryIsProtein));
89 arg.Reset(m_QueryOptsArgs);
90 m_Args.push_back(arg);
91
92 m_FormattingArgs.Reset(new CFormattingArgs);
93 arg.Reset(m_FormattingArgs);
94 m_Args.push_back(arg);
95
96 m_MTArgs.Reset(new CRPSBlastMTArgs());
97 arg.Reset(m_MTArgs);
98 m_Args.push_back(arg);
99
100 m_RemoteArgs.Reset(new CRemoteArgs);
101 arg.Reset(m_RemoteArgs);
102 m_Args.push_back(arg);
103
104 m_DebugArgs.Reset(new CDebugArgs);
105 arg.Reset(m_DebugArgs);
106 m_Args.push_back(arg);
107
108 arg.Reset(new CCompositionBasedStatsArgs(kIsCBS2and3Supported, kDfltArgCompBasedStatsRPS ));
109 m_Args.push_back(arg);
110
111 }
112
113 CRef<CBlastOptionsHandle>
x_CreateOptionsHandle(CBlastOptions::EAPILocality locality,const CArgs &)114 CRPSTBlastnAppArgs::x_CreateOptionsHandle(CBlastOptions::EAPILocality locality,
115 const CArgs& /*args*/)
116 {
117 return CRef<CBlastOptionsHandle>(new CRPSTBlastnOptionsHandle(locality));
118 }
119
120 int
GetQueryBatchSize() const121 CRPSTBlastnAppArgs::GetQueryBatchSize() const
122 {
123 bool is_remote = (m_RemoteArgs.NotEmpty() && m_RemoteArgs->ExecuteRemotely());
124 return blast::GetQueryBatchSize(eRPSTblastn, m_IsUngapped, is_remote);
125 }
126
127 /// Get the input stream
128 CNcbiIstream&
GetInputStream()129 CRPSTBlastnAppArgs::GetInputStream()
130 {
131 return CBlastAppArgs::GetInputStream();
132 }
133 /// Get the output stream
134 CNcbiOstream&
GetOutputStream()135 CRPSTBlastnAppArgs::GetOutputStream()
136 {
137 return CBlastAppArgs::GetOutputStream();
138 }
139
140 /// Get the input stream
141 CNcbiIstream&
GetInputStream()142 CRPSTBlastnNodeArgs::GetInputStream()
143 {
144 if ( !m_InputStream ) {
145 abort();
146 }
147 return *m_InputStream;
148 }
149 /// Get the output stream
150 CNcbiOstream&
GetOutputStream()151 CRPSTBlastnNodeArgs::GetOutputStream()
152 {
153 return m_OutputStream;
154 }
155
CRPSTBlastnNodeArgs(const string & input)156 CRPSTBlastnNodeArgs::CRPSTBlastnNodeArgs(const string & input)
157 {
158 m_InputStream = new CNcbiIstrstream(input);
159 }
160
~CRPSTBlastnNodeArgs()161 CRPSTBlastnNodeArgs::~CRPSTBlastnNodeArgs()
162 {
163 if (m_InputStream) {
164 delete m_InputStream;
165 m_InputStream = NULL;
166 }
167 }
168
169 int
GetQueryBatchSize() const170 CRPSTBlastnNodeArgs::GetQueryBatchSize() const
171 {
172 bool is_remote = (m_RemoteArgs.NotEmpty() && m_RemoteArgs->ExecuteRemotely());
173 return blast::GetQueryBatchSize(eRPSTblastn, m_IsUngapped, is_remote);
174 }
175
176 CRef<CBlastOptionsHandle>
x_CreateOptionsHandle(CBlastOptions::EAPILocality locality,const CArgs &)177 CRPSTBlastnNodeArgs::x_CreateOptionsHandle(CBlastOptions::EAPILocality locality,
178 const CArgs& /*args*/)
179 {
180 CRef<CBlastOptionsHandle> retval
181 (new CRPSTBlastnOptionsHandle(locality));
182 return retval;
183 }
184
185 END_SCOPE(blast)
186 END_NCBI_SCOPE
187
188