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

Go to the SVN repository for this file.

1 #ifndef EQUIV_RANGE__HPP
2 #define EQUIV_RANGE__HPP
3 
4 /* $Id: equiv_range.hpp 62779 2014-05-07 16:41:16Z boukn $
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: Nathan Bouk
30  *
31  * File Description:
32  *
33  */
34 
36 #include <objmgr/scope.hpp>
37 #include <util/range.hpp>
38 
39 
40 
42 
44 class CSeq_id;
45 class CSeq_align;
47 
48 class CEquivRange;
49 typedef vector<CEquivRange> TEquivList;
50 
52 {
53 public:
54  CEquivRange() : AlignId(0),SegmtId(0),SplitId(0) { ; }
55 
59  int Intercept;
60  int Matches;
62  vector<TSeqPos> MisMatchSubjtPoints;
63 
64  int AlignId;
65  int SegmtId;
66  int SplitId;
67 
68  bool Empty() const {
69  return (Query.Empty() || Subjt.Empty());
70  }
71 
72  bool NotEmpty() const {
73  return (Query.NotEmpty() && Subjt.NotEmpty());
74  }
75 
76  bool IntersectingWith(const CEquivRange& Other) const {
77  return (Query.IntersectingWith(Other.Query) ||
79  }
80 
81  bool AbuttingWith(const CEquivRange& Other) const {
82  if(Strand != Other.Strand)
83  return false;
84 
85  if (!Query.AbuttingWith(Other.Query) ||
86  !Subjt.AbuttingWith(Other.Subjt))
87  return false;
88 
89 
90  return true;
91  }
92 
93 
94  enum ERelative {
95  eWtf = 0x00,
96  eIntersects = 0x01,
97  eInterQuery = 0x02,
98  eInterSubjt = 0x04,
99  eBefore = 0x10,
100  eAfter = 0x20,
101  eAbove = 0x40,
102  eUnder = 0x80
103  };
104 
105  // How is Check positioned relative to this
106  ERelative CalcRelative(const CEquivRange& Check) const;
108 
109  static TSeqPos Distance(const CEquivRange& A, const CEquivRange& B);
110  static TSeqPos Distance(const TEquivList& A, const TEquivList& B);
111 };
112 
114 {
115 public:
116 
118 
119  bool SplitIntersections(const TEquivList& Originals,
120  TEquivList& Splits);
121  bool MergeAbuttings(const TEquivList& Originals, TEquivList& Merges);
122 
123 
124  void ExtractRangesFromSeqAlign(const objects::CSeq_align& Alignment,
125  TEquivList& Equivs);
126 
127  void CalcMatches(objects::CBioseq_Handle QueryHandle,
128  objects::CBioseq_Handle SubjtHandle,
129  TEquivList& Equivs);
130 
131 private:
135 
136  CEquivRange SliceOnQuery(const CEquivRange& Original, const CRange<TSeqPos>& pQuery);
137  CEquivRange SliceOnSubjt(const CEquivRange& Original, const CRange<TSeqPos>& pSubjt);
138  CEquivRange Merge(const CEquivRange& First, const CEquivRange& Second);
139 
140 };
141 
142 
144 
146 
147 bool operator==(const CEquivRange& A, const CEquivRange& B);
148 bool operator<(const CEquivRange& A, const CEquivRange& B);
149 
150 bool s_SortEquivBySubjt(const CEquivRange& A, const CEquivRange& B);
151 
153 
154 #endif // end EQUIV_RANGE__HPP
void CalcMatches(objects::CBioseq_Handle QueryHandle, objects::CBioseq_Handle SubjtHandle, TEquivList &Equivs)
CEquivRange SliceOnSubjt(const CEquivRange &Original, const CRange< TSeqPos > &pSubjt)
bool MergeAbuttings(const TEquivList &Originals, TEquivList &Merges)
void ExtractRangesFromSeqAlign(const objects::CSeq_align &Alignment, TEquivList &Equivs)
CEquivRange Merge(const CEquivRange &First, const CEquivRange &Second)
CEquivRange SliceOnQuery(const CEquivRange &Original, const CRange< TSeqPos > &pQuery)
bool SplitIntersections(const TEquivList &Originals, TEquivList &Splits)
ERelative CalcRelative(const CEquivRange &Check) const
bool AbuttingWith(const CEquivRange &Other) const
Definition: equiv_range.hpp:81
ERelative CalcRelativeDuo(const CEquivRange &Check) const
bool Empty() const
Definition: equiv_range.hpp:68
static TSeqPos Distance(const CEquivRange &A, const CEquivRange &B)
bool NotEmpty() const
Definition: equiv_range.hpp:72
objects::ENa_strand Strand
Definition: equiv_range.hpp:58
vector< TSeqPos > MisMatchSubjtPoints
Definition: equiv_range.hpp:62
CRange< TSeqPos > Subjt
Definition: equiv_range.hpp:57
CRange< TSeqPos > Query
Definition: equiv_range.hpp:56
bool IntersectingWith(const CEquivRange &Other) const
Definition: equiv_range.hpp:76
bool s_SortEquivBySubjt(const CEquivRange &A, const CEquivRange &B)
bool operator<(const CEquivRange &A, const CEquivRange &B)
string s_RelToStr(CEquivRange::ERelative rel)
vector< CEquivRange > TEquivList
Definition: equiv_range.hpp:48
bool operator==(const CEquivRange &A, const CEquivRange &B)
CNcbiOstream & operator<<(CNcbiOstream &out, const CEquivRange &range)
Definition: equiv_range.cpp:96
std::ofstream out("events_result.xml")
main entry point for tests
unsigned int TSeqPos
Type for sequence locations and lengths.
Definition: ncbimisc.hpp:875
bool NotEmpty(void) const
Definition: range.hpp:152
bool AbuttingWith(const TThisType &r) const
Definition: range.hpp:336
bool IntersectingWith(const TThisType &r) const
Definition: range.hpp:331
bool Empty(void) const
Definition: range.hpp:148
#define END_SCOPE(ns)
End the previously defined scope.
Definition: ncbistl.hpp:75
#define BEGIN_SCOPE(ns)
Define a new scope.
Definition: ncbistl.hpp:72
IO_PREFIX::ostream CNcbiOstream
Portable alias for ostream.
Definition: ncbistre.hpp:149
ENa_strand
strand of nucleic acid
Definition: Na_strand_.hpp:64
range(_Ty, _Ty) -> range< _Ty >
Magic spell ;-) needed for some weird compilers... very empiric.
#define A
#define B
Modified on Fri Sep 20 14:57:49 2024 by modify_doxy.py rev. 669887