NCBI C++ ToolKit
local_db_adapter.hpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 /* $Id: local_db_adapter.hpp 68855 2015-09-10 12:56:25Z madden $
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 local_db_adapter.hpp
31  * Declares class which provides internal BLAST database representations to the
32  * internal BLAST APIs
33  */
34 
35 #ifndef ALGO_BLAST_API___LOCAL_DB_ADAPTER_HPP
36 #define ALGO_BLAST_API___LOCAL_DB_ADAPTER_HPP
37 
39 #include <algo/blast/api/uniform_search.hpp> // for CSearchDatabase
40 #include <objtools/blast/seqdb_reader/seqdb.hpp> // for CSeqDB
41 #include <algo/blast/api/sseqloc.hpp> // for TSeqLocVector
42 
43 /** @addtogroup AlgoBlast
44  *
45  * @{
46  */
47 
48 // Forward declaration
49 struct BlastSeqSrc;
50 
53 
54 // Forward declaration
55 class IBlastSeqInfoSrc;
56 
57 /// Interface to create a BlastSeqSrc suitable for use in CORE BLAST from a
58 /// a variety of BLAST database/subject representations
60 {
61 public:
62  /// Constructor
63  /// @param dbinfo
64  /// Description of BLAST database
65  CLocalDbAdapter(const CSearchDatabase& dbinfo);
66 
67  /// Constructor
68  /// @param subject_sequences
69  /// Set of sequences which should be used as subjects
70  /// @param opts_handle
71  /// Options to be used (needed to create the ILocalQueryData)
72  /// @param dbscan_mode Database search mode (as opposed to pairwise)
73  CLocalDbAdapter(CRef<IQueryFactory> subject_sequences,
75  bool dbscan_mode=false);
76 
77  /// Constructor taking custom BlastSeqSrc and IBlastSeqInfoSrc objects
78  /// @param seqSrc
79  /// Custom BlastSeqSrc implementation provided by the user
80  /// @param seqInfoSrc
81  /// Custom IBlastSeqInfoSrc implementation provided by the user
83  CRef<IBlastSeqInfoSrc> seqInfoSrc);
84 
85  /// Destructor
86  virtual ~CLocalDbAdapter();
87 
88  /// This method should be called so that if the implementation has an
89  /// internal "bookmark" of the chunks of the database it has assigned to
90  /// different threads, this can be reset at the start of a PSI-BLAST
91  /// iteration (or when reusing the same object to iterate over the
92  /// database/subjects when the query is split).
93  /// This method should be called before calling MakeSeqSrc() to
94  /// ensure proper action on retrieving the BlastSeqSrc (in some cases it
95  /// might cause a re-construction of the underlying BlastSeqSrc
96  /// implementation). Note that in some cases, this operation might not apply
97  void ResetBlastSeqSrcIteration();
98 
99  /// Retrieves or constructs the BlastSeqSrc
100  /// @note ownership of the constructed object is handled by this class
101  BlastSeqSrc* MakeSeqSrc();
102 
103  /// Retrieves or constructs the IBlastSeqInfoSrc
104  /// @note ownership of the constructed object is handled by this class
105  IBlastSeqInfoSrc* MakeSeqInfoSrc();
106 
107  /// Retrieve the database filtering algorithm
108  /// @returns -1 if not none was used, otherwise the filtering algorithm ID
109  int GetFilteringAlgorithm();
110 
111  /// Retrieve the database filtering id from key
112  /// @returns kEmptyStr if not none was found, otherwise the filtering algorithm key
113  string GetFilteringAlgorithmKey();
114 
115 
116  /// Returns true if this object represents protein or nucleotide sequences
117  bool IsProtein() const;
118 
119  /// Returns the database name if appropriate, else kEmptyStr for subject
120  /// sequences
121  string GetDatabaseName() const { return m_DbName; }
122 
123  /// Returns true if this object represents a BLAST database
124  bool IsBlastDb() const { return m_DbName != kEmptyStr; }
125 
126  /// Returns true if this is not a database but is database scanning mode
127  bool IsDbScanMode() const { return m_DbScanMode; }
128 
129 private:
130  /// Pointer to the BlastSeqSrc this object owns and manages
132 
133  /// Pointer to the IBlastSeqInfoSrc
135 
136  /// Object containing BLAST database description
138 
139  /// IQueryFactory containing the subject sequences
141 
142  /// Options to be used when instantiating the subject sequences
144 
145  /// This is initialized ONLY if the m_SubjectFactory is of type
146  /// CObjMgr_QueryFactory, case in which it's not empty. This is needed to
147  /// handle delta sequences as input and it uses the object manager APIs
149 
150  /// This is initialized ONLY if this object represents a BLAST database
151  const string m_DbName;
152 
153  /// Specifies that bl2seq search run in database scan mode (not pairwise)
155 
156  /// Prohibit copy-constructor
158  /// Prohibit assignment operator
159  CLocalDbAdapter & operator=(const CLocalDbAdapter&);
160 };
161 
162 inline int
164 {
165  return (m_DbInfo.Empty() ? -1 : m_DbInfo->GetFilteringAlgorithm());
166 }
167 
168 END_SCOPE(BLAST)
170 
171 /* @} */
172 
173 #endif /* ALGO_BLAST_API___LOCAL_DB_ADAPTER__HPP */
174 
BlastSeqSrc * m_SeqSrc
Pointer to the BlastSeqSrc this object owns and manages.
Blast Search Subject.
#define END_SCOPE(ns)
End the previously defined scope.
Definition: ncbistl.hpp:73
Complete type definition of Blast Sequence Source ADT.
Definition: blast_seqsrc.c:43
#define NCBI_XBLAST_EXPORT
NULL operations for other cases.
Definition: blast_export.h:65
CRef< IQueryFactory > m_SubjectFactory
IQueryFactory containing the subject sequences.
TSeqLocVector m_Subjects
This is initialized ONLY if the m_SubjectFactory is of type CObjMgr_QueryFactory, case in which it's ...
#define kEmptyStr
Definition: ncbistr.hpp:120
bool IsDbScanMode() const
Returns true if this is not a database but is database scanning mode.
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:101
CRef< IBlastSeqInfoSrc > m_SeqInfoSrc
Pointer to the IBlastSeqInfoSrc.
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:702
Declaration of ADT to retrieve sequences for the BLAST engine.
bool IsBlastDb() const
Returns true if this object represents a BLAST database.
Abstract base class to encapsulate retrieval of sequence identifiers.
vector< SSeqLoc > TSeqLocVector
Vector of sequence locations.
Definition: sseqloc.hpp:129
Interface to create a BlastSeqSrc suitable for use in CORE BLAST from a a variety of BLAST database/s...
CRef< CSearchDatabase > m_DbInfo
Object containing BLAST database description.
Definition of SSeqLoc structure.
int GetFilteringAlgorithm()
Retrieve the database filtering algorithm.
bool m_DbScanMode
Specifies that bl2seq search run in database scan mode (not pairwise)
string GetDatabaseName() const
Returns the database name if appropriate, else kEmptyStr for subject sequences.
CObject –.
Definition: ncbiobj.hpp:180
CConstRef< CBlastOptionsHandle > m_OptsHandle
Options to be used when instantiating the subject sequences.
int GetFilteringAlgorithm() const
Accessor for the filtering algorithm ID.
#define BEGIN_SCOPE(ns)
Define a new scope.
Definition: ncbistl.hpp:70
Uniform BLAST Search Interface.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:98
const string m_DbName
This is initialized ONLY if this object represents a BLAST database.
Modified on Wed Apr 26 17:46:58 2017 by modify_doxy.py rev. 533848