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

Go to the SVN repository for this file.

1 #ifndef OBJECTS_ALNMGR___ALNMATCH__HPP
2 #define OBJECTS_ALNMGR___ALNMATCH__HPP
3 
4 /* $Id: alnmatch.hpp 78930 2017-07-31 13:06:45Z dicuccio $
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: Kamen Todorov, NCBI
30 *
31 * File Description:
32 * Alignment matches
33 *
34 */
35 
36 
38 
39 
41 
42 BEGIN_objects_SCOPE // namespace ncbi::objects::
43 
44 
45 class CAlnMixMatch;
46 
47 
49 {
50 public:
51 
52  /// Typedefs
53  typedef int (*TCalcScoreMethod)(const string& s1,
54  const string& s2,
55  bool s1_is_prot,
56  bool s2_is_prot,
57  int gene_code1,
58  int gene_code2);
59 
60  typedef vector<CRef<CAlnMixMatch> > TMatches;
61 
62  enum EAddFlags {
63  // Determine score of each aligned segment in the process of mixing
64  // (only makes sense if scope was provided at construction time)
65  fCalcScore = 0x01,
66 
67  // Force translation of nucleotide rows
68  // This will result in an output Dense-seg that has Widths,
69  // no matter if the whole alignment consists of nucleotides only.
70  fForceTranslation = 0x02,
71 
72  // Used for mapping sequence to itself
73  fPreserveRows = 0x04
74  };
75  typedef int TAddFlags; // binary OR of EMergeFlags
76 
77 
78  /// Constructor
80  TCalcScoreMethod calc_score = 0);
81 
82 
83  /// Container accessors
84  const TMatches& Get() const { return m_Matches; };
85  TMatches& Set() { return m_Matches; };
86 
87 
88  /// "Add" a Dense-seg to the existing matches. This would create
89  /// and add new mathces that correspond to the relations in the
90  /// given Dense-seg
91  void Add(const CDense_seg& ds, TAddFlags flags = 0);
92 
93 
94  /// Modifying algorithms
95  void SortByScore();
96  void SortByChainScore();
97 
98 
99 private:
100 
101  friend class CAlnMixMerger;
102 
103  static bool x_CompareScores (const CRef<CAlnMixMatch>& match1,
104  const CRef<CAlnMixMatch>& match2);
105  static bool x_CompareChainScores(const CRef<CAlnMixMatch>& match1,
106  const CRef<CAlnMixMatch>& match2);
107 
108 
109  size_t m_DsCnt;
118 };
119 
120 
121 
122 class CAlnMixMatch : public CObject
123 {
124 public:
126  : m_Score(0), m_ChainScore(0),
127  m_AlnSeq1(0), m_AlnSeq2(0),
128  m_Start1(0), m_Start2(0),
130  {}
132  : CObject(), m_Score(0), m_ChainScore(0),
133  m_AlnSeq1(0), m_AlnSeq2(0),
134  m_Start1(0), m_Start2(0),
136  {
137  *this = match;
138  }
140  {
141  if ( this != &match ) {
142  m_Score = match.m_Score;
143  m_ChainScore = match.m_ChainScore;
144  m_AlnSeq1 = match.m_AlnSeq1;
145  m_AlnSeq2 = match.m_AlnSeq2;
146  m_Start1 = match.m_Start1;
147  m_Start2 = match.m_Start2;
148  m_Len = match.m_Len;
149  m_StrandsDiffer = match.m_StrandsDiffer;
150  m_DsIdx = match.m_DsIdx;
151  if ( m_AlnSeq1 )
152  m_MatchIter1 = match.m_MatchIter1;
153  if ( m_AlnSeq2 )
154  m_MatchIter2 = match.m_MatchIter2;
155  }
156  return *this;
157  }
158 
159  bool IsGood(const CAlnMixSeq::TMatchList& list,
160  CAlnMixSeq::TMatchList::const_iterator iter) const
161  {
162  ITERATE ( CAlnMixSeq::TMatchList, it, list ) {
163  if ( iter == it )
164  return true;
165  }
166  return iter == list.end();
167  }
168  bool IsGood(void) const
169  {
171  return false;
173  return false;
174  return true;
175  }
176 
181  int m_DsIdx;
182  CAlnMixSeq::TMatchList::iterator m_MatchIter1, m_MatchIter2;
183 };
184 
185 
186 
187 END_objects_SCOPE // namespace ncbi::objects::
188 
190 
191 #endif // OBJECTS_ALNMGR___ALNMATCH__HPP
#define false
Definition: bool.h:36
CAlnMixSeq::TMatchList::iterator m_MatchIter1
Definition: alnmatch.hpp:182
CAlnMixSeq * m_AlnSeq1
Definition: alnmatch.hpp:178
TSeqPos m_Start2
Definition: alnmatch.hpp:179
CAlnMixMatch(const CAlnMixMatch &match)
Definition: alnmatch.hpp:131
int m_ChainScore
Definition: alnmatch.hpp:177
bool IsGood(const CAlnMixSeq::TMatchList &list, CAlnMixSeq::TMatchList::const_iterator iter) const
Definition: alnmatch.hpp:159
CAlnMixSeq * m_AlnSeq2
Definition: alnmatch.hpp:178
TSeqPos m_Start1
Definition: alnmatch.hpp:179
CAlnMixMatch(void)
Definition: alnmatch.hpp:125
CAlnMixMatch & operator=(const CAlnMixMatch &match)
Definition: alnmatch.hpp:139
TSeqPos m_Len
Definition: alnmatch.hpp:179
bool IsGood(void) const
Definition: alnmatch.hpp:168
CAlnMixSeq::TMatchList::iterator m_MatchIter2
Definition: alnmatch.hpp:182
bool m_StrandsDiffer
Definition: alnmatch.hpp:180
bool & m_ContainsNA
Definition: alnmatch.hpp:117
vector< CRef< CAlnMixMatch > > TMatches
Definition: alnmatch.hpp:60
TCalcScoreMethod x_CalculateScore
Definition: alnmatch.hpp:114
bool & m_ContainsAA
Definition: alnmatch.hpp:116
CRef< CScope > m_Scope
Definition: alnmatch.hpp:110
CAlnMixSequences::TSeqs & m_Seqs
Definition: alnmatch.hpp:113
TMatches & Set()
Definition: alnmatch.hpp:85
const TMatches & Get() const
Container accessors.
Definition: alnmatch.hpp:84
CRef< CAlnMixSequences > m_AlnMixSequences
Definition: alnmatch.hpp:112
size_t m_DsCnt
Definition: alnmatch.hpp:109
TAddFlags m_AddFlags
Definition: alnmatch.hpp:115
TMatches m_Matches
Definition: alnmatch.hpp:111
CAlnMixMatches::TCalcScoreMethod TCalcScoreMethod
Definition: alnmerger.hpp:62
TMatchList m_MatchList
Definition: alnseq.hpp:165
list< CAlnMixMatch * > TMatchList
Definition: alnseq.hpp:145
vector< CRef< CAlnMixSeq > > TSeqs
Definition: alnseq.hpp:65
CObject –.
Definition: ncbiobj.hpp:180
static uch flags
unsigned int TSeqPos
Type for sequence locations and lengths.
Definition: ncbimisc.hpp:875
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
Definition: ncbimisc.hpp:815
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
#define NCBI_XALNMGR_EXPORT
Definition: ncbi_export.h:1065
unsigned int
A callback function used to compare two keys in a database.
Definition: types.hpp:1210
static int match(register const pcre_uchar *eptr, register const pcre_uchar *ecode, const pcre_uchar *mstart, int offset_top, match_data *md, eptrblock *eptrb, unsigned int rdepth)
Definition: pcre_exec.c:513
Modified on Mon Feb 26 04:00:07 2024 by modify_doxy.py rev. 669887