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

Go to the SVN repository for this file.

1 /* $Id: blastkmerresults.hpp 78080 2017-05-24 01:23:19Z ucko $
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: Tom Madden
27  *
28  * File Description:
29  * Results for BLAST-kmer searches
30  *
31  */
32 
33 #ifndef BLAST_KMER_RESULTS_HPP
34 #define BLAST_KMER_RESULTS_HPP
35 
36 
37 #include <corelib/ncbistd.hpp>
43 
44 #include <objmgr/scope.hpp>
45 
46 #include "blastkmerutils.hpp"
47 
49 BEGIN_SCOPE(blast)
50 
51 
52 /// Vector of pairs of seq-ids and scores
53 typedef vector< pair<CRef<CSeq_id>, double> > TBlastKmerScoreVector;
54 
55 /// This class represents the results for one KMER search (one query).
56 /// The structure is filled in after the search is done.
57 /// NOTE: recoverable errors (e.g., query shorter than KMER size) will NOT
58 /// trigger an exception but the CBlastKmerResults for that query will have
59 /// an error or warning. Use the HasError or HasWarning message to check.
61 {
62 public:
63  /// Constructor
64  /// @param query Seq-id of the query
65  /// @param scores Scores of the result
66  /// @param stats Statistics about the results
67  /// @param errs warning and messages
71  CRef<CSeqDB> seqdb,
72  const TQueryMessages& errs);
73 
74  /// Destructor
76  }
77 
78 
79  /// Get the vector of GIs and scores for the matches
81  return m_Scores;
82  }
83 
84  /// Get the results as a TSeqLocVector
85  /// @param tsl TSeqLocVector to fill [in/out]
86  /// @param scope CScope to use in the TSL [in]
87  void GetTSL(TSeqLocVector& tsl, CRef<CScope> scope) const;
88 
89  /// Get the statistics for the search.
90  const BlastKmerStats& GetStats() const {
91  return m_Stats ;
92  }
93 
94  /// Set the statistics
95  /// @param stats structure of ancillary data. Will make deep copy.
96  void SetStats(BlastKmerStats& stats) {
97  m_Stats = stats;
98  }
99 
100  /// Return Query ID
102  return m_QueryId;
103  }
104 
105  /// Accessor for the error/warning messsages for this query
106  /// @param min_severity minimum severity to report errors [in]
107  TQueryMessages GetErrors(int min_severity = eBlastSevError) const;
108 
109  /// Returns true if there are errors among the results for this object
110  bool HasErrors() const;
111  /// Returns true if there are warnings among the results for this object
112  bool HasWarnings() const;
113 
114 private:
115 
116  /// Saves the matches as TBlastKmerScoreVector.
117  /// Also does the lookup of the Seq-id of subject sequences.
118  /// @param scores results to be processed and saved.
119  void x_InitScoreVec(TBlastKmerPrelimScoreVector& scores);
120 
121  /// Query ID.
123 
124  /// Vector of Seq-ids and scores
126 
127  /// Ancillary data
129 
130  /// Database searched
132 
133  /// error/warning messages for this query
135 };
136 
137 /// This class holds one or more CBlastKmerResults
139 {
140 public:
141 
142  /// data type contained by this container
144 
145  /// size_type type definition
146  typedef vector<value_type>::size_type size_type;
147 
148  /// const_iterator type definition
149  typedef vector<value_type>::const_iterator const_iterator;
150 
151  /// iterator type definition
152  typedef vector<value_type>::iterator iterator;
153 
154  /// List of query ids.
155  typedef vector< CConstRef<objects::CSeq_id> > TQueryIdVector;
156 
157  /// Vector of TBlastKmerScoreVector (scores)
158  typedef vector<TBlastKmerPrelimScoreVector> TBlastKmerPrelimScoreVectorSet;
159 
160  /// Vector of KmerStats
161  typedef vector<BlastKmerStats> TBlastKmerStatsVector;
162 
163  /// Default constructor
165 
166  /// Constructor
167  /// @param ids vector of Query IDs
168  /// @param scores vector of TBlastKmerScoreVector
169  /// @param stats vector of Statistics
170  /// @param seqdb CSeqDB object for search.
171  /// @param msg_vec vector of messages and warnings.
175  CRef<CSeqDB> seqdb,
176  TSearchMessages msg_vec);
177 
178  /// Destructor
180  }
181 
182 
184  return *m_Results[i];
185  }
186 
188  return *m_Results[i];
189  }
190 
191  /// Array like acces with CSeq_id indices
192  /// @param ident query sequence id [in]
194 
195  /// Returns the number of queries.
196  size_t GetNumQueries() const { return m_NumQueries;}
197 
198  /// Add an element to m_Results
199  /// @param element to add [in]
200  void push_back(value_type& element);
201 
202 private:
203 
204  /// @param ids vector of Query IDs
205  /// @param scores vector of TBlastKmerScoreVector
206  /// @param stats vector of Statistics
207  /// @param seqdb CSeqDB object for search.
208  /// @param msg_vec vector of messages and warnings.
209  void x_Init(TQueryIdVector& ids,
210  TBlastKmerPrelimScoreVectorSet& scores,
211  TBlastKmerStatsVector& stats,
212  CRef<CSeqDB> seqdb,
213  TSearchMessages msg_vec);
214 
215  /// Vectors of results
216  vector< CRef<CBlastKmerResults> > m_Results;
217 
218  /// Number or queries
219  size_t m_NumQueries;
220 };
221 
222 /// Empty results (use on error)
223 /// @param queryVector Query information.
224 /// @param queryNum zero offset number of query
225 /// @param errMsg error message
226 /// @param severity Severity of messages (e.g., error or warning)
228 MakeEmptyResults(TSeqLocVector& queryVector,
229  int queryNum,
230  const string& errMsg,
231  EBlastSeverity severity=eBlastSevError);
232 
233 END_SCOPE(blast)
235 
236 #endif /* BLAST_KMER_RESULTS_HPP */
Declares the BLAST exception class.
#define NCBI_XBLAST_EXPORT
NULL operations for other cases.
Definition: blast_export.h:65
EBlastSeverity
Blast error message severities .
Definition: blast_message.h:55
@ eBlastSevError
Definition: blast_message.h:58
Declares CBlastScopeSource class to create properly configured CScope objects to invoke the BLAST dat...
vector< pair< CRef< CSeq_id >, double > > TBlastKmerScoreVector
Vector of pairs of seq-ids and scores.
CRef< CBlastKmerResults > MakeEmptyResults(TSeqLocVector &queryVector, int queryNum, const string &errMsg, EBlastSeverity severity=eBlastSevError)
Empty results (use on error)
vector< pair< uint32_t, double > > TBlastKmerPrelimScoreVector
Vector of pairs of database OIDs and scores.
This class holds one or more CBlastKmerResults.
vector< value_type >::size_type size_type
size_type type definition
size_t GetNumQueries() const
Returns the number of queries.
const CBlastKmerResults & operator[](size_type i) const
CRef< CBlastKmerResults > value_type
data type contained by this container
vector< BlastKmerStats > TBlastKmerStatsVector
Vector of KmerStats.
CBlastKmerResults & operator[](size_type i)
vector< CRef< CBlastKmerResults > > m_Results
Vectors of results.
~CBlastKmerResultsSet()
Destructor.
vector< CConstRef< objects::CSeq_id > > TQueryIdVector
List of query ids.
CRef< CBlastKmerResults > operator[](const CSeq_id &ident)
Array like acces with CSeq_id indices.
size_t m_NumQueries
Number or queries.
vector< TBlastKmerPrelimScoreVector > TBlastKmerPrelimScoreVectorSet
Vector of TBlastKmerScoreVector (scores)
vector< value_type >::const_iterator const_iterator
const_iterator type definition
vector< value_type >::iterator iterator
iterator type definition
This class represents the results for one KMER search (one query).
TQueryMessages m_Errors
error/warning messages for this query
BlastKmerStats m_Stats
Ancillary data.
CConstRef< CSeq_id > GetSeqId() const
Return Query ID.
TBlastKmerScoreVector m_Scores
Vector of Seq-ids and scores.
CConstRef< objects::CSeq_id > m_QueryId
Query ID.
CRef< CSeqDB > m_SeqDB
Database searched.
void SetStats(BlastKmerStats &stats)
Set the statistics.
const TBlastKmerScoreVector & GetScores() const
Get the vector of GIs and scores for the matches.
~CBlastKmerResults()
Destructor.
const BlastKmerStats & GetStats() const
Get the statistics for the search.
CObject –.
Definition: ncbiobj.hpp:180
CRef –.
Definition: ncbiobj.hpp:618
Class for the messages for an individual query sequence.
typedef for the messages for an entire BLAST search, which could be comprised of multiple query seque...
Include a standard set of the NCBI C++ Toolkit most basic headers.
#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
int i
double value_type
The numeric datatype used by the parser.
Definition: muParserDef.h:228
Defines BLAST database access classes.
Definition of SSeqLoc structure.
vector< SSeqLoc > TSeqLocVector
Vector of sequence locations.
Definition: sseqloc.hpp:129
Structure for ancillary data on KMER search.
static string query
Modified on Sun Mar 03 03:11:10 2024 by modify_doxy.py rev. 669887