NCBI C++ ToolKit
local_search.cpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 /* ===========================================================================
2  *
3  * PUBLIC DOMAIN NOTICE
4  * National Center for Biotechnology Information
5  *
6  * This software/database is a "United States Government Work" under the
7  * terms of the United States Copyright Act. It was written as part of
8  * the author's official duties as a United States Government employee and
9  * thus cannot be copyrighted. This software/database is freely available
10  * to the public for use. The National Library of Medicine and the U.S.
11  * Government have not placed any restriction on its use or reproduction.
12  *
13  * Although all reasonable efforts have been taken to ensure the accuracy
14  * and reliability of the software and data, the NLM and the U.S.
15  * Government do not and cannot warrant the performance or results that
16  * may be obtained by using this software or data. The NLM and the U.S.
17  * Government disclaim all warranties, express or implied, including
18  * warranties of performance, merchantability or fitness for any particular
19  * purpose.
20  *
21  * Please cite the author in any work or product based on this material.
22  *
23  * ===========================================================================
24  *
25  * Author: Christiam Camacho
26  *
27  */
28 
29 /** @file local_search.cpp
30  * This file implements the Uniform Blast Search Interface in terms of
31  * the local BLAST database search class
32  * NOTE: This is OBJECT MANAGER DEPENDANT because of its use of CDbBlast!
33  */
34 
35 #include <ncbi_pch.hpp>
36 
37 // Object includes
43 
44 // Object manager dependencies
47 
48 // BLAST includes
52 #include "psiblast_aux_priv.hpp"
53 
54 /** @addtogroup AlgoBlast
55  *
56  * @{
57  */
58 
60 BEGIN_SCOPE(blast)
61 
62 /// Supporting elements
63 
64 //
65 // Factory
66 //
67 
70 {
71  return CRef<ISeqSearch>(new CLocalSeqSearch());
72 }
73 
76 {
77  return CRef<IPssmSearch>(new CLocalPssmSearch());
78 }
79 
82 {
83  // FIXME: should do some validation for acceptable programs by the
84  // implementation (i.e.: CDbBlast)
86 }
87 
88 //
89 // Seq Search
90 //
91 
92 // NOTE: Local search object is re-created every time it is run.
95 {
96  if ( m_QueryFactory.Empty() ) {
97  NCBI_THROW(CSearchException, eConfigErr, "No queries specified");
98  }
99  if ( m_Database.Empty() ) {
100  NCBI_THROW(CSearchException, eConfigErr, "No database name specified");
101  }
102  if ( !m_SearchOpts ) {
103  NCBI_THROW(CSearchException, eConfigErr, "No options specified");
104  }
105  // This is delayed to this point to guarantee that the options are
106  // populated
107 
109  *m_Database));
110 
111  return m_LocalBlast->Run();
112 }
113 
114 void
116 {
117  m_SearchOpts = opts;
118 }
119 
120 void
122 {
124 }
125 
126 void
128 {
129  m_QueryFactory = query_factory;
130 }
131 
132 //
133 // Psi Search
134 //
135 
136 void
138 {
139  m_SearchOpts = opts;
140 }
141 
142 void
144 {
145  m_Subject = subject;
146 }
147 
148 void
150 {
152  m_Pssm = pssm;
153 }
154 
157 {
158 
160  psi_opts.Reset(dynamic_cast<CPSIBlastOptionsHandle*>(&*m_SearchOpts));
161  if (psi_opts.Empty()) {
162  NCBI_THROW(CBlastException, eInvalidArgument,
163  "Options for CLocalPssmSearch are not PSI-BLAST");
164  }
165 
166  CConstRef<CBioseq> query(&m_Pssm->GetPssm().GetQuery().GetSeq());
167  CRef<IQueryFactory> query_factory(new CObjMgrFree_QueryFactory(query)); /* NCBI_FAKE_WARNING */
168 
170  CPsiBlast psiblast(query_factory, dbadapter, psi_opts);
171  CRef<CSearchResultSet> retval = psiblast.Run();
172 
173  return retval;
174 }
175 
176 END_SCOPE(blast)
178 
179 /* @} */
User-defined methods of the data storage class.
User-defined methods of the data storage class.
EProgram
This enumeration is to evolve into a task/program specific list that specifies sets of default parame...
Definition: blast_types.hpp:56
Defines BLAST error codes (user errors included)
Class to perform a BLAST search on local BLAST databases Note that PHI-BLAST can be run using this cl...
Definition: local_blast.hpp:62
Interface to create a BlastSeqSrc suitable for use in CORE BLAST from a a variety of BLAST database/s...
Local sequence search.
NCBI C++ Object Manager free implementation of IQueryFactory.
Handle to the protein-protein options to the BLAST algorithm.
Runs a single iteration of the PSI-BLAST algorithm on a BLAST database.
Definition: psiblast.hpp:79
CRef –.
Definition: ncbiobj.hpp:618
Exception class.
CRef< CSearchResultSet > Run()
Run the PSI-BLAST engine for one iteration.
Definition: psiblast.cpp:95
virtual CRef< CSearchResultSet > Run()
Run the search.
virtual void SetQueryFactory(CRef< IQueryFactory > query_factory)
Set the factory which will return the queries to search for.
CRef< CLocalBlast > m_LocalBlast
Local database search class.
CRef< CBlastOptionsHandle > m_SearchOpts
Search options.
CConstRef< CSearchDatabase > m_Subject
Subject database.
virtual CRef< ISeqSearch > GetSeqSearch()
Get an object to manage a local sequence search.
CRef< CBlastOptionsHandle > m_SearchOpts
Search configuration.
virtual void SetOptions(CRef< CBlastOptionsHandle > options)
Configure this search.
CRef< objects::CPssmWithParameters > m_Pssm
Search queries.
CRef< CSearchResultSet > Run()
Executes the search.
static CBlastOptionsHandle * Create(EProgram program, EAPILocality locality=CBlastOptions::eLocal)
Creates an options handle object configured with default options for the requested program,...
virtual CRef< CBlastOptionsHandle > GetOptions(EProgram)
Get an options handle for a search of the specified type.
CRef< IQueryFactory > m_QueryFactory
Factory which provides the query data to be populated in m_Queries.
virtual CRef< CSearchResultSet > Run()
Run a single iteration of the search.
virtual CRef< IPssmSearch > GetPssmSearch()
Get an object to manage a remote PSSM search.
CConstRef< CSearchDatabase > m_Database
BLAST database for the search class to use.
static void Pssm(const objects::CPssmWithParameters &pssm, bool require_scores=false)
Perform validation on the PSSM.
virtual void SetQuery(CRef< objects::CPssmWithParameters > pssm)
Set the PSSM with which to search the database.
virtual void SetSubject(CConstRef< CSearchDatabase > subject)
Set the databases to search.
virtual void SetSubject(CConstRef< CSearchDatabase > subject)
Set the databases to search.
virtual void SetOptions(CRef< CBlastOptionsHandle > options)
Configure the search.
#define NCBI_THROW(exception_class, err_code, message)
Generic macro to throw an exception, given the exception class, error code and message string.
Definition: ncbiexpt.hpp:704
bool Empty(void) const THROWS_NONE
Check if CConstRef is empty – not pointing to any object which means having a null value.
Definition: ncbiobj.hpp:1385
void Reset(void)
Reset reference object.
Definition: ncbiobj.hpp:1439
void Reset(void)
Reset reference object.
Definition: ncbiobj.hpp:773
bool Empty(void) const THROWS_NONE
Check if CRef is empty – not pointing to any object, which means having a null value.
Definition: ncbiobj.hpp:719
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define END_SCOPE(ns)
End the previously defined scope.
Definition: ncbistl.hpp:75
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
#define BEGIN_SCOPE(ns)
Define a new scope.
Definition: ncbistl.hpp:72
Implementation of the uniform BLAST search interface for searching locally installed BLAST databases.
The Object manager core.
NOTE: This file contains work in progress and the APIs are likely to change, please do not rely on th...
Declares CPsiBlast, the C++ API for the PSI-BLAST engine.
Declarations of auxiliary functions/classes for PSI-BLAST.
Implementation of the BlastSeqSrc interface using the C++ BLAST databases API.
static string subject
static string query
Modified on Wed May 08 12:12:39 2024 by modify_doxy.py rev. 669887