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

Go to the SVN repository for this file.

1 #ifndef ALGO_COBALT___BASE__HPP
2 #define ALGO_COBALT___BASE__HPP
3 
4 /* $Id: base.hpp 35542 2007-09-24 15:34:03Z papadopo $
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 offical 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 /*****************************************************************************
30 
31 File name: base.hpp
32 
33 Author: Jason Papadopoulos
34 
35 Contents: Definitions used by all COBALT aligner components
36 
37 ******************************************************************************/
38 
39 /// @file base.hpp
40 /// Definitions used by all COBALT aligner components
41 
42 #include <util/range.hpp>
43 
45 BEGIN_SCOPE(cobalt)
46 
47 /// Basic data type for offsets into a sequence. By
48 /// convention, all offsets are zero-based
49 typedef int TOffset;
50 
51 /// Basic type specifying a range on a sequence
52 typedef pair<TOffset, TOffset> TOffsetPair;
53 
54 /// Sufficient extra functionality is needed from CRange
55 /// that it justifies extending the class
56 template<class Position>
57 class CLocalRange : public CRange<Position>
58 {
59 public:
60  typedef CRange<Position> TParent; ///< parent class
61  typedef typename TParent::position_type position_type; ///< underlying type
62  typedef CLocalRange<Position> TThisType; ///< shorthand
63 
64  /// default constructor
66 
67  /// convert offsets into a range
68  /// @param from Start offset
69  /// @param to End offset
70  ///
72  : TParent(from, to) {}
73 
74  /// convert parent class to a range
75  /// @param range Reference to an object of the parent class
76  ///
78  : TParent(range) {}
79 
80  /// Test whether 'this' completely envelops
81  /// a given sequence range
82  /// @param r Range to test for containment
83  /// @return true if 'this' envelops r, false otherwise
84  ///
85  bool Contains(const TThisType& r)
86  {
87  return !TParent::Empty() &&
88  TParent::GetFrom() <= r.GetFrom() &&
89  TParent::GetToOpen() >= r.GetFrom() &&
90  TParent::GetFrom() <= r.GetToOpen() &&
91  TParent::GetToOpen() >= r.GetToOpen();
92  }
93 
94  /// Test whether 'this' represents a sequence range
95  /// strictly less than a given sequence range
96  /// @param r Range to test for disjointness
97  /// @return true if offsets of 'this' are strictly
98  /// below the offsets of r, false otherwise
99  ///
100  bool StrictlyBelow(const TThisType& r)
101  {
102  return TParent::GetToOpen() <= r.TParent::GetFrom();
103  }
104 
105  /// Initialize an empty range
106  ///
107  void SetEmpty()
108  {
109  TParent::Set(TParent::GetPositionMax(), TParent::GetPositionMin());
110  }
111 };
112 
113 /// define for the fundamental building block
114 /// of sequence ranges
116 
117 /// The aligner internally works only with the
118 /// ncbistdaa alphabet
119 static const int kAlphabetSize = 28;
120 
121 END_SCOPE(cobalt)
123 
124 #endif // ALGO_COBALT___BASE__HPP
static const int kAlphabetSize
The aligner internally works only with the ncbistdaa alphabet.
Definition: base.hpp:119
int TOffset
Basic data type for offsets into a sequence.
Definition: base.hpp:49
CLocalRange< TOffset > TRange
define for the fundamental building block of sequence ranges
Definition: base.hpp:115
pair< TOffset, TOffset > TOffsetPair
Basic type specifying a range on a sequence.
Definition: base.hpp:52
Sufficient extra functionality is needed from CRange that it justifies extending the class.
Definition: base.hpp:58
CLocalRange()
default constructor
Definition: base.hpp:65
TParent::position_type position_type
underlying type
Definition: base.hpp:61
CLocalRange< Position > TThisType
shorthand
Definition: base.hpp:62
bool StrictlyBelow(const TThisType &r)
Test whether 'this' represents a sequence range strictly less than a given sequence range.
Definition: base.hpp:100
CRange< Position > TParent
parent class
Definition: base.hpp:60
CLocalRange(position_type from, position_type to)
convert offsets into a range
Definition: base.hpp:71
CLocalRange(const TParent &range)
convert parent class to a range
Definition: base.hpp:77
bool Contains(const TThisType &r)
Test whether 'this' completely envelops a given sequence range.
Definition: base.hpp:85
void SetEmpty()
Initialize an empty range.
Definition: base.hpp:107
CRange –.
Definition: Range.hpp:68
bool Empty(const CNcbiOstrstream &src)
Definition: fileutil.cpp:523
TParent::position_type position_type
Definition: range.hpp:391
#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
range(_Ty, _Ty) -> range< _Ty >
double r(size_t dimension_, const Int4 *score_, const double *prob_, double theta_)
Modified on Thu Apr 25 08:21:31 2024 by modify_doxy.py rev. 669887