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

Go to the SVN repository for this file.

1 #ifndef ALGO_BLAST_API__SEQINFOSRC_SEQDB__HPP
2 #define ALGO_BLAST_API__SEQINFOSRC_SEQDB__HPP
3 
4 /* $Id: seqinfosrc_seqdb.hpp 78040 2017-05-22 15:48:20Z zaretska $
5  * ===========================================================================
6  *
7  * PUBLIC DOMAIN NOTICE
8  * National Center for Biotechnology Information
9  *
10  * This software/database is a "United States Government Work" under the
11  * terms of the United States Copyright Act. It was written as part of
12  * the author's official duties as a United States Government employee and
13  * thus cannot be copyrighted. This software/database is freely available
14  * to the public for use. The National Library of Medicine and the U.S.
15  * Government have not placed any restriction on its use or reproduction.
16  *
17  * Although all reasonable efforts have been taken to ensure the accuracy
18  * and reliability of the software and data, the NLM and the U.S.
19  * Government do not and cannot warrant the performance or results that
20  * may be obtained by using this software or data. The NLM and the U.S.
21  * Government disclaim all warranties, express or implied, including
22  * warranties of performance, merchantability or fitness for any particular
23  * purpose.
24  *
25  * Please cite the author in any work or product based on this material.
26  *
27  * ===========================================================================
28  *
29  * Author: Ilya Dondoshansky
30  *
31  */
32 
33 /** @file seqinfosrc_seqdb.hpp
34  * Defines a concrete strategy for the IBlastSeqInfoSrc interface for
35  * sequence identifiers retrieval from a CSeqDB class.
36  */
37 
41 
42 /** @addtogroup AlgoBlast
43  *
44  * @{
45  */
46 
48 BEGIN_SCOPE(blast)
49 
50 /// Implementation of the IBlastSeqInfoSrc interface to encapsulate retrieval of
51 /// sequence identifiers and lengths from a BLAST database.
53 {
54 public:
55  /// Constructor: includes initializing the CSeqDB object.
56  /// @param dbname Name of the BLAST database [in]
57  /// @param is_protein Is this a protein or nucleotide database? [in]
58  CSeqDbSeqInfoSrc(const string& dbname, bool is_protein);
59 
60  /// Constructor from an already existing CSeqDB object.
61  /// @param seqdb Pointer to the CSeqDB object to use.
62  CSeqDbSeqInfoSrc(ncbi::CSeqDB* seqdb);
63 
64  /// Our destructor
65  virtual ~CSeqDbSeqInfoSrc();
66 
67  /// Sets the filtering algorithm ID used in the search
68  /// @param algo_id filtering algorithm ID [in]
69  void SetFilteringAlgorithmId(int algo_id);
70 
71  /// Retrieve a sequence identifier given its ordinal number.
72  /// @param index the ordinal number to retrieve [in]
73  virtual list< CRef<objects::CSeq_id> > GetId(Uint4 oid) const;
74 
75  /// Method to retrieve the sequence location given its ordinal number.
76  /// @param index the ordinal number to retrieve [in]
77  virtual CConstRef<objects::CSeq_loc> GetSeqLoc(Uint4 oid) const;
78 
79  /// Retrieve sequence length given its ordinal number.
80  /// @param index the ordinal number to retrieve [in]
81  virtual Uint4 GetLength(Uint4 oid) const;
82 
83  /// Returns the size of the underlying container of sequences
84  virtual size_t Size() const;
85 
86  /// Returns true if the subject is restricted by a GI list.
87  virtual bool HasGiList() const;
88 
89  /// Retrieves the subject masks for the corresponding index
90  /// @param index the ordinal number to retrieve [in]
91  /// @param target_range range for which to return masks for. Empty ranges
92  /// indicate that no masks should be retrieved, whole ranges mean that masks
93  /// for the whole sequence should be retrieved [in]
94  /// @param retval the masks will be returned through this parameter [out]
95  /// @return true if there were masks returned in retval, otherwise false.
96  virtual bool GetMasks(Uint4 index,
97  const TSeqRange& target_range,
98  TMaskedSubjRegions& retval) const;
99 
100  /// Retrieves the subject masks for the corresponding index
101  /// @param index the ordinal number to retrieve [in]
102  /// @param target_ranges ranges for which to return masks for. Empty ranges
103  /// indicate that no masks should be retrieved, whole ranges mean that masks
104  /// for the whole sequence should be retrieved [in]
105  /// @param retval the masks will be returned through this parameter [out]
106  /// @return true if there were masks returned in retval, otherwise false.
107  virtual bool GetMasks(Uint4 index,
108  const vector<TSeqRange> & target_ranges,
109  TMaskedSubjRegions& retval) const;
110 
111  /// Return true if the implementation can return anything besides a seq-loc
112  /// for the entire sequence. If in doubt, the implementation must
113  /// return true.
114  virtual bool CanReturnPartialSequence() const {return false;}
115 
116 
117 private:
118  mutable CRef<CSeqDB> m_iSeqDb; ///< BLAST database object
119  /// Filtering algorithm ID used with these subjects, use -1 if not
120  /// applicable
122 
123  /// Friend declaration so that this class can access the CSeqDB object to
124  /// enable partial subject sequence fetching
125  friend class CBlastTracebackSearch;
126 };
127 
128 END_SCOPE(blast)
130 
131 /* @} */
132 
133 #endif /* ALGO_BLAST_API__SEQINFOSRC_SEQDB_HPP */
Defines to provide correct exporting from BLAST DLL in Windows.
#define NCBI_XBLAST_EXPORT
NULL operations for other cases.
Definition: blast_export.h:65
Defines interface for retrieving sequence identifiers.
Implementation of the IBlastSeqInfoSrc interface to encapsulate retrieval of sequence identifiers and...
Abstract base class to encapsulate retrieval of sequence identifiers.
Collection of masked regions for a single query sequence.
Definition: seqlocinfo.hpp:113
int m_FilteringAlgoId
Filtering algorithm ID used with these subjects, use -1 if not applicable.
virtual bool CanReturnPartialSequence() const
Return true if the implementation can return anything besides a seq-loc for the entire sequence.
CRef< CSeqDB > m_iSeqDb
BLAST database object.
const CSeq_id & GetId(const CSeq_loc &loc, CScope *scope)
If all CSeq_ids embedded in CSeq_loc refer to the same CBioseq, returns the first CSeq_id found,...
TSeqPos GetLength(const CSeq_id &id, CScope *scope)
Get sequence length if scope not null, else return max possible TSeqPos.
uint32_t Uint4
4-byte (32-bit) unsigned integer
Definition: ncbitype.h:103
#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
char * dbname(DBPROCESS *dbproc)
Get name of current database.
Definition: dblib.c:6929
Defines BLAST database access classes.
Modified on Sat Apr 13 11:49:00 2024 by modify_doxy.py rev. 669887