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

Go to the SVN repository for this file.

1 #ifndef GPIPE_COMMON___SCORE_LOOKUP__HPP
2 #define GPIPE_COMMON___SCORE_LOOKUP__HPP
3 
4 /* $Id: score_lookup.hpp 54460 2012-05-16 16:54:44Z mozese2 $
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  * Authors: Eyal Mozes
30  *
31  * File Description:
32  *
33  */
34 
35 #include <corelib/ncbiobj.hpp>
36 
38 
39 #include <objmgr/scope.hpp>
40 
43 
44 class CSeq_align;
45 
46 
48 {
49 public:
50  class IScore : public CObject
51  {
52  public:
53  enum EComplexity {
55  eHard
56  };
57 
58  virtual ~IScore() {}
59  virtual double Get(const objects::CSeq_align& align,
60  objects::CScope* scope) const = 0;
61  virtual void PrintHelp(CNcbiOstream &ostr) const = 0;
62  virtual EComplexity GetComplexity() const { return eEasy; }
63  virtual bool IsInteger() const { return false; }
64 
65  /// For any IScore subclasses that have an internal state, this
66  /// function will be called to update it for any alignment that
67  /// matches the filter
68  virtual void UpdateState(const objects::CSeq_align& align) {}
69  };
70 
71  CScoreLookup() { x_Init(); }
72 
73  CScoreLookup(enum blast::EProgram program_type)
74  : CScoreBuilder(program_type) { x_Init(); }
75 
76  CScoreLookup(blast::CBlastOptionsHandle& options)
77  : CScoreBuilder(options) { x_Init(); }
78 
79  /// CScoreLookup uses a scope internally. You can set a scope yourself;
80  /// alternatively, the scope used internally will be a default scope
81  void SetScope(objects::CScope& scope)
82  { m_Scope.Reset(&scope); }
83 
84  objects::CScope& GetScope()
85  { return *m_Scope; }
86 
87  /// Print out the dictionary of recognized score names
88  void PrintDictionary(CNcbiOstream&);
89 
90  /// Help text for score
91  string HelpText(const string &score_name);
92 
93  IScore::EComplexity Complexity(const string &score_name);
94 
95  bool IsIntegerScore(const objects::CSeq_align& align,
96  const string &score_name);
97 
98  /// Get requested score for alignment
99  double GetScore(const objects::CSeq_align& align,
100  const string &score_name);
101 
102  void UpdateState(const objects::CSeq_align& align);
103 
104 private:
105  void x_Init();
106 
107  void x_PrintDictionaryEntry(CNcbiOstream &ostr,
108  const string &score_name);
109 
111 
113  TScoreDictionary m_Scores;
114 
116 };
117 
118 
120 
122 
123 
124 #endif // GPIPE_COMMON___SCORE_LOOKUP__HPP
void SetScope(objects::CScope &scope)
CScoreLookup uses a scope internally.
#define END_SCOPE(ns)
End the previously defined scope.
Definition: ncbistl.hpp:73
EProgram
This enumeration is to evolve into a task/program specific list that specifies sets of default parame...
Definition: blast_types.hpp:56
virtual void UpdateState(const objects::CSeq_align &align)
For any IScore subclasses that have an internal state, this function will be called to update it for ...
CScoreLookup(enum blast::EProgram program_type)
CScoreLookup(blast::CBlastOptionsHandle &options)
set< string > m_ScoresUsed
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:101
virtual EComplexity GetComplexity() const
CRef< objects::CScope > m_Scope
IO_PREFIX::ostream CNcbiOstream
Portable alias for ostream.
Definition: ncbistre.hpp:150
Definition: map.hpp:337
TScoreDictionary m_Scores
virtual bool IsInteger() const
Portable reference counted smart and weak pointers using CWeakRef, CRef, CObject and CObjectEx...
static CRef< CScope > m_Scope
CObject –.
Definition: ncbiobj.hpp:180
map< string, CIRef< IScore > > TScoreDictionary
const TYPE & Get(const CNamedParameterList *param)
objects::CScope & GetScope()
#define BEGIN_SCOPE(ns)
Define a new scope.
Definition: ncbistl.hpp:70
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:98
void Reset(void)
Reset reference object.
Definition: ncbiobj.hpp:746
#define NCBI_XALGOALIGN_EXPORT
Definition: ncbi_export.h:976
Modified on Mon Aug 03 11:37:04 2015 by modify_doxy.py rev. 426318