1 /*  $Id: psiblast_args.cpp 571333 2018-09-25 13:30:42Z fongah2 $
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 psiblast_args.cpp
31  * Implementation of the PSI-BLAST command line arguments
32  */
33 #include <ncbi_pch.hpp>
34 #include <algo/blast/blastinput/psiblast_args.hpp>
35 #include <algo/blast/api/psiblast_options.hpp>
36 #include <algo/blast/blastinput/blast_input_aux.hpp>
37 #include <algo/blast/api/phiblast_prot_options.hpp>
38 #include <algo/blast/api/version.hpp>
39 
40 BEGIN_NCBI_SCOPE
41 BEGIN_SCOPE(blast)
42 USING_SCOPE(objects);
43 
CPsiBlastAppArgs()44 CPsiBlastAppArgs::CPsiBlastAppArgs()
45 {
46     bool const kQueryIsProtein = true;
47     bool const kFilterByDefault = false;
48     static const string kProgram("psiblast");
49     CRef<IBlastCmdLineArgs> arg;
50     arg.Reset(new CProgramDescriptionArgs(kProgram,
51                                           "Position-Specific Iterated BLAST"));
52     m_Args.push_back(arg);
53     m_ClientId = kProgram + " " + CBlastVersion().Print();
54 
55     static const char kDefaultTask[] = "psiblast";
56     SetTask(kDefaultTask);
57 
58     m_BlastDbArgs.Reset(new CBlastDatabaseArgs);
59     m_BlastDbArgs->SetIPGFilteringSupport(true);
60     arg.Reset(m_BlastDbArgs);
61     m_Args.push_back(arg);
62 
63     m_StdCmdLineArgs.Reset(new CStdCmdLineArgs);
64     arg.Reset(m_StdCmdLineArgs);
65     m_Args.push_back(arg);
66 
67     arg.Reset(new CGenericSearchArgs(kQueryIsProtein));
68     m_Args.push_back(arg);
69 
70     arg.Reset(new CFilteringArgs(kQueryIsProtein, kFilterByDefault));
71     m_Args.push_back(arg);
72 
73     arg.Reset(new CMatrixNameArg);
74     m_Args.push_back(arg);
75 
76     arg.Reset(new CWordThresholdArg);
77     m_Args.push_back(arg);
78 
79     m_HspFilteringArgs.Reset(new CHspFilteringArgs);
80     arg.Reset(m_HspFilteringArgs);
81     m_Args.push_back(arg);
82 
83     arg.Reset(new CWindowSizeArg);
84     m_Args.push_back(arg);
85 
86     m_QueryOptsArgs.Reset(new CQueryOptionsArgs(kQueryIsProtein));
87     arg.Reset(m_QueryOptsArgs);
88     m_Args.push_back(arg);
89 
90     m_FormattingArgs.Reset(new CFormattingArgs);
91     arg.Reset(m_FormattingArgs);
92     m_Args.push_back(arg);
93 
94     m_MTArgs.Reset(new CMTArgs);
95     arg.Reset(m_MTArgs);
96     m_Args.push_back(arg);
97 
98     m_RemoteArgs.Reset(new CRemoteArgs);
99     arg.Reset(m_RemoteArgs);
100     m_Args.push_back(arg);
101 
102     arg.Reset(new CCompositionBasedStatsArgs);
103     m_Args.push_back(arg);
104 
105     arg.Reset(new CGapTriggerArgs(kQueryIsProtein));
106     m_Args.push_back(arg);
107 
108     m_PsiBlastArgs.Reset(new CPsiBlastArgs(CPsiBlastArgs::eProteinDb));
109     arg.Reset(m_PsiBlastArgs);
110     m_Args.push_back(arg);
111 
112     arg.Reset(new CPssmEngineArgs);
113     m_Args.push_back(arg);
114 
115     arg.Reset(new CPhiBlastArgs);
116     m_Args.push_back(arg);
117 
118     m_DebugArgs.Reset(new CDebugArgs);
119     arg.Reset(m_DebugArgs);
120     m_Args.push_back(arg);
121 }
122 
123 CRef<CBlastOptionsHandle>
x_CreateOptionsHandle(CBlastOptions::EAPILocality locality,const CArgs & args)124 CPsiBlastAppArgs::x_CreateOptionsHandle(CBlastOptions::EAPILocality locality,
125                                         const CArgs& args)
126 {
127     if (args.Exist(kArgPHIPatternFile) && args[kArgPHIPatternFile])
128        return CRef<CBlastOptionsHandle>(new CPHIBlastProtOptionsHandle(locality));
129     else
130        return CRef<CBlastOptionsHandle>(new CPSIBlastOptionsHandle(locality));
131 }
132 
133 size_t
GetNumberOfIterations() const134 CPsiBlastAppArgs::GetNumberOfIterations() const
135 {
136     return m_PsiBlastArgs->GetNumberOfIterations();
137 }
138 
139 CRef<objects::CPssmWithParameters>
GetInputPssm() const140 CPsiBlastAppArgs::GetInputPssm() const
141 {
142     return m_PsiBlastArgs->GetInputPssm();
143 }
144 
145 void
SetInputPssm(CRef<objects::CPssmWithParameters> pssm)146 CPsiBlastAppArgs::SetInputPssm(CRef<objects::CPssmWithParameters> pssm)
147 {
148     m_PsiBlastArgs->SetInputPssm(pssm);
149 }
150 
151 void
SetNumberOfIterations(unsigned int num_iters)152 CPsiBlastAppArgs::SetNumberOfIterations(unsigned int num_iters)
153 {
154     m_PsiBlastArgs->SetNumberOfIterations(num_iters);
155 }
156 
157 int
GetQueryBatchSize() const158 CPsiBlastAppArgs::GetQueryBatchSize() const
159 {
160     bool is_remote = (m_RemoteArgs.NotEmpty() && m_RemoteArgs->ExecuteRemotely());
161     return blast::GetQueryBatchSize(ePSIBlast, m_IsUngapped, is_remote);
162 }
163 
164 bool
SaveCheckpoint() const165 CPsiBlastAppArgs::SaveCheckpoint() const
166 {
167     return m_PsiBlastArgs->RequiresCheckPointOutput();
168 }
169 
170 CNcbiOstream*
GetCheckpointStream()171 CPsiBlastAppArgs::GetCheckpointStream()
172 {
173     return m_PsiBlastArgs->GetCheckPointOutputStream();
174 }
175 
176 bool
SaveAsciiPssm() const177 CPsiBlastAppArgs::SaveAsciiPssm() const
178 {
179     return m_PsiBlastArgs->RequiresAsciiPssmOutput();
180 }
181 
182 CNcbiOstream*
GetAsciiPssmStream()183 CPsiBlastAppArgs::GetAsciiPssmStream()
184 {
185     return m_PsiBlastArgs->GetAsciiMatrixOutputStream();
186 }
187 
188 bool
GetSaveLastPssm() const189 CPsiBlastAppArgs::GetSaveLastPssm() const
190 {
191     return m_PsiBlastArgs->GetSaveLastPssm();
192 }
193 
194 END_SCOPE(blast)
195 END_NCBI_SCOPE
196 
197