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

Go to the SVN repository for this file.

1 #ifndef OBJECTS_OBJMGR___SEQ_MAP_SWITCH__HPP
2 #define OBJECTS_OBJMGR___SEQ_MAP_SWITCH__HPP
3 
4 /* $Id: seq_map_switch.hpp 33815 2007-05-04 17:18:18Z kazimird $
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:
30 * Eugene Vasilchenko
31 *
32 * File Description:
33 * Working with seq-map switch points
34 *
35 */
36 
37 #include <objmgr/seq_map.hpp>
38 #include <objmgr/bioseq_handle.hpp>
40 #include <util/range.hpp>
41 #include <vector>
42 #include <list>
43 #include <map>
44 
47 
48 class CSeqMap;
49 class CBioseq_Handle;
50 class CSeq_align;
51 
52 /** @addtogroup ObjectManagerSequenceRep
53  *
54  * @{
55  */
56 
58 {
59 public:
60 
61  // master sequence
63  // point in master sequence - coordinate of the first base to the right
65 
66  // first encountered alignment used to calculate this switch point
68 
69  // point on the segment to the left of current switch point
73 
74  // point on the segment to the right of current switch point
78 
79  // range of possible positions of the switch point
81  // range of possible positions of the switch point with exact segment match
83 
84  // information about changes in sequence
85  // first - insertions
86  // second - deletions
87  typedef pair<TSeqPos, TSeqPos> TInsertDelete;
88  // key is offset from the current switch point
90  TDifferences m_LeftDifferences, m_RightDifferences;
91 
92  // all possible changes
93  TInsertDelete GetDifferences(TSeqPos new_pos, TSeqPos add = 0) const;
94  // possible change in sequence length
95  int GetLengthDifference(TSeqPos new_pos, TSeqPos add = 0) const
96  {
97  TInsertDelete diff = GetDifferences(new_pos, add);
98  return diff.first - diff.second;
99  }
100  // possible change in sequence bases (sum of insertions and deletions)
101  int GetSequenceDifference(TSeqPos new_pos, TSeqPos add = 0) const
102  {
103  TInsertDelete diff = GetDifferences(new_pos, add);
104  return diff.first + diff.second;
105  }
106 
107  TSeqPos GetInsert(TSeqPos pos) const;
108  TSeqPos GetLeftInPlaceInsert(void) const;
109  TSeqPos GetRightInPlaceInsert(void) const;
110 
111  void ChangeSwitchPoint(TSeqPos pos, TSeqPos add);
112  void InsertInPlace(TSeqPos add_left, TSeqPos add_right);
113 
114  bool operator<(const CSeqMapSwitchPoint& p) const
115  {
116  _ASSERT(m_Master == p.m_Master);
117  return m_MasterPos < p.m_MasterPos;
118  }
119 };
120 
121 /* @} */
122 
123 // calculate switch point for two segments specified by align
126  const CSeq_align& align);
127 
128 typedef vector<CRef<CSeqMapSwitchPoint> > TSeqMapSwitchPoints;
129 typedef list<CRef<CSeq_align> > TSeqMapSwitchAligns;
130 
131 // calculate all sequence switch points using set of Seq-aligns
134  const TSeqMapSwitchAligns& aligns);
135 
136 // calculate all sequence switch points using set of Seq-aligns from assembly
139 
142 
143 #endif // OBJECTS_OBJMGR___SEQ_MAP_SWITCH__HPP
CBioseq_Handle –.
CObject –.
Definition: ncbiobj.hpp:180
CRef –.
Definition: ncbiobj.hpp:618
CSeqMap –.
Definition: seq_map.hpp:93
unsigned int TSeqPos
Type for sequence locations and lengths.
Definition: ncbimisc.hpp:875
vector< CRef< CSeqMapSwitchPoint > > TSeqMapSwitchPoints
CRange< TSeqPos > m_MasterRange
pair< TSeqPos, TSeqPos > TInsertDelete
CConstRef< CSeq_align > m_FirstAlign
TSeqMapSwitchPoints GetAllSwitchPoints(const CBioseq_Handle &seq, const TSeqMapSwitchAligns &aligns)
TDifferences m_RightDifferences
CBioseq_Handle m_Master
list< CRef< CSeq_align > > TSeqMapSwitchAligns
bool operator<(const CSeqMapSwitchPoint &p) const
int GetSequenceDifference(TSeqPos new_pos, TSeqPos add=0) const
CSeq_id_Handle m_RightId
CSeq_id_Handle m_LeftId
CRef< CSeqMapSwitchPoint > GetSwitchPoint(const CBioseq_Handle &seq, const CSeq_align &align)
CRange< TSeqPos > m_ExactMasterRange
int GetLengthDifference(TSeqPos new_pos, TSeqPos add=0) const
map< TSeqPos, TInsertDelete > TDifferences
#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
#define NCBI_XOBJMGR_EXPORT
Definition: ncbi_export.h:1307
#define _ASSERT
Modified on Tue May 21 10:57:43 2024 by modify_doxy.py rev. 669887