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 87240 2019-08-12 11:18:21Z 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 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 
52 BEGIN_SCOPE(blast)
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 
130 private:
131  /// Pointer to the BlastSeqSrc this object owns and manages
133 
134  /// Pointer to the IBlastSeqInfoSrc
136 
137  /// Object containing BLAST database description
139 
140  /// IQueryFactory containing the subject sequences
142 
143  /// Options to be used when instantiating the subject sequences
145 
146  /// This is initialized ONLY if the m_SubjectFactory is of type
147  /// CObjMgr_QueryFactory, case in which it's not empty. This is needed to
148  /// handle delta sequences as input and it uses the object manager APIs
150 
151  /// This is initialized ONLY if this object represents a BLAST database
152  const string m_DbName;
153 
154  /// Specifies that bl2seq search run in database scan mode (not pairwise)
156 
157  /// Prohibit copy-constructor
159  /// Prohibit assignment operator
161 };
162 
163 inline int
165 {
166  return (m_DbInfo.Empty() ? -1 : m_DbInfo->GetFilteringAlgorithm());
167 }
168 
169 END_SCOPE(BLAST)
171 
172 /* @} */
173 
174 #endif /* ALGO_BLAST_API___LOCAL_DB_ADAPTER__HPP */
175 
#define NCBI_XBLAST_EXPORT
NULL operations for other cases.
Definition: blast_export.h:65
Declaration of ADT to retrieve sequences for the BLAST engine.
Interface to create a BlastSeqSrc suitable for use in CORE BLAST from a a variety of BLAST database/s...
CObject –.
Definition: ncbiobj.hpp:180
Blast Search Subject.
Abstract base class to encapsulate retrieval of sequence identifiers.
string GetDatabaseName() const
Returns the database name if appropriate, else kEmptyStr for subject sequences.
CConstRef< CBlastOptionsHandle > m_OptsHandle
Options to be used when instantiating the subject sequences.
CRef< CSearchDatabase > m_DbInfo
Object containing BLAST database description.
int GetFilteringAlgorithm() const
Accessor for the filtering algorithm ID.
CRef< IBlastSeqInfoSrc > m_SeqInfoSrc
Pointer to the IBlastSeqInfoSrc.
bool IsBlastDb() const
Returns true if this object represents a BLAST database.
TSeqLocVector m_Subjects
This is initialized ONLY if the m_SubjectFactory is of type CObjMgr_QueryFactory, case in which it's ...
int GetFilteringAlgorithm()
Retrieve the database filtering algorithm.
CRef< IQueryFactory > m_SubjectFactory
IQueryFactory containing the subject sequences.
CLocalDbAdapter(const CLocalDbAdapter &)
Prohibit copy-constructor.
bool m_DbScanMode
Specifies that bl2seq search run in database scan mode (not pairwise)
CLocalDbAdapter & operator=(const CLocalDbAdapter &)
Prohibit assignment operator.
const string m_DbName
This is initialized ONLY if this object represents a BLAST database.
BlastSeqSrc * m_SeqSrc
Pointer to the BlastSeqSrc this object owns and manages.
CRef< CSearchDatabase > GetSearchDatabase()
bool IsDbScanMode() const
Returns true if this is not a database but is database scanning mode.
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
#define kEmptyStr
Definition: ncbistr.hpp:123
Defines BLAST database access classes.
Definition of SSeqLoc structure.
vector< SSeqLoc > TSeqLocVector
Vector of sequence locations.
Definition: sseqloc.hpp:129
Complete type definition of Blast Sequence Source ADT.
Definition: blast_seqsrc.c:43
Uniform BLAST Search Interface.
Modified on Fri Sep 20 14:57:44 2024 by modify_doxy.py rev. 669887