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

Go to the SVN repository for this file.

1 #ifndef OBJECTS_OBJMGR_IMPL___HANDLE_RANGE_MAP__HPP
2 #define OBJECTS_OBJMGR_IMPL___HANDLE_RANGE_MAP__HPP
3 
4 /* $Id: handle_range_map.hpp 99486 2023-04-04 20:35:05Z vasilche $
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: Aleksey Grichenko, Michael Kimelman, Eugene Vasilchenko
30  *
31  * File Description:
32  *
33  */
34 
37 #include <corelib/ncbiobj.hpp>
38 #include <map>
39 #include <vector>
40 #include <list>
41 
44 
45 class CSeq_loc;
46 class CSeqMap;
47 class CBioseq_Info;
48 
49 class CMasterSeqSegments : public CObject {
50 public:
51  CMasterSeqSegments(void);
52  CMasterSeqSegments(const CBioseq_Info& seq);
53  ~CMasterSeqSegments(void);
54 
55  void AddSegments(const CSeqMap& seq);
56  int AddSegment(const CSeq_id_Handle& id, bool minus_strand);
57  void AddSegmentId(int idx, const CSeq_id_Handle& id);
58 
59  typedef vector<CSeq_id_Handle> TIds;
60  typedef list< CRef<CSeq_id> > TIds2;
61  void AddSegmentIds(int idx, const TIds& ids);
62  void AddSegmentIds(int idx, const TIds2& ids);
63  void AddSegmentIds(const TIds& ids);
64  void AddSegmentIds(const TIds2& ids);
65 
66  int GetSegmentCount(void) const {
67  return int(m_SegSet.size());
68  }
69  int FindSeg(const CSeq_id_Handle& h) const;
70  bool GetMinusStrand(int seg) const;
71  const CSeq_id_Handle& GetHandle(int seg) const;
72 
73 protected:
74  typedef pair<CSeq_id_Handle, bool> TSeg;
75  typedef vector<TSeg> TSegSet;
77 
80 
81 private:
84 };
85 
86 // Seq_loc substitution for internal use by iterators and data sources
88 {
89 public:
93 
94  CHandleRangeMap(void);
95  ~CHandleRangeMap(void);
96 
100  eCircularRNA
101  };
102  struct SAddState;
103 
104  // Add all ranges for each seq-id from a seq-loc
105  void AddLocation(const CSeq_loc& loc,
106  ETransSplicing trans_splcing = eNoTransSplicing);
107  void AddLocation(const CSeq_loc& loc, SAddState& state);
108  // Add range substituting with handle "h"
109  void AddRange(const CSeq_id_Handle& h,
110  const TRange& range, ENa_strand strand);
111  // Add ranges from "range" with handle "h"
112  void AddRanges(const CSeq_id_Handle& h, const CHandleRange& hr);
113  CHandleRange& AddRanges(const CSeq_id_Handle& h);
114 
115  // Get the ranges map
116  const TLocMap& GetMap(void) const { return m_LocMap; }
117  bool empty(void) const { return m_LocMap.empty(); }
118 
119  void clear(void);
120 
121  // iterate
122  const_iterator begin(void) const { return m_LocMap.begin(); }
123  const_iterator find(const CSeq_id_Handle& idh) const {
124  return m_LocMap.find(idh);
125  }
126  const_iterator end(void) const { return m_LocMap.end(); }
127 
128  bool IntersectingWithLoc(const CSeq_loc& loc) const;
129  bool IntersectingWithMap(const CHandleRangeMap& rmap) const;
130  bool TotalRangeIntersectingWith(const CHandleRangeMap& rmap) const;
131 
132  void AddRange(const CSeq_id& id, TSeqPos from, TSeqPos to,
133  ENa_strand strand = eNa_strand_unknown);
134  void AddRange(const CSeq_id& id,
135  const TRange& range, ENa_strand strand = eNa_strand_unknown);
136 
137  void AddRange(const CSeq_id_Handle& h,
138  const TRange& range, ENa_strand strand,
139  SAddState& state);
140  void AddRange(const CSeq_id& id,
141  const TRange& range, ENa_strand strand,
142  SAddState& state);
143  void AddRange(const CSeq_id& id,
144  TSeqPos from, TSeqPos to, ENa_strand strand,
145  SAddState& state);
146 
147  void SetMasterSeq(const CMasterSeqSegments* master_seq) {
148  m_MasterSeq = master_seq;
149  }
150 
151 private:
152  // Split the location and add range lists to the locmap
153  void x_ProcessLocation(const CSeq_loc& loc);
154 
157 };
158 
159 
162 
163 #endif // OBJECTS_OBJMGR_IMPL___HANDLE_RANGE_MAP__HPP
CHandleRange::TRange TRange
map< CSeq_id_Handle, CHandleRange > TLocMap
void SetMasterSeq(const CMasterSeqSegments *master_seq)
const_iterator begin(void) const
void x_ProcessLocation(const CSeq_loc &loc)
CConstRef< CMasterSeqSegments > m_MasterSeq
const_iterator find(const CSeq_id_Handle &idh) const
const TLocMap & GetMap(void) const
TLocMap::const_iterator const_iterator
bool empty(void) const
const_iterator end(void) const
vector< TSeg > TSegSet
int AddSegment(const CSeq_id_Handle &id, bool minus_strand)
bool GetMinusStrand(int seg) const
CMasterSeqSegments(const CMasterSeqSegments &)
list< CRef< CSeq_id > > TIds2
vector< CSeq_id_Handle > TIds
int GetSegmentCount(void) const
void operator=(const CMasterSeqSegments &)
void AddSegments(const CSeqMap &seq)
void AddSegmentIds(int idx, const TIds &ids)
void AddSegmentId(int idx, const CSeq_id_Handle &id)
map< CSeq_id_Handle, int > TId2Seg
int FindSeg(const CSeq_id_Handle &h) const
const CSeq_id_Handle & GetHandle(int seg) const
pair< CSeq_id_Handle, bool > TSeg
CObject –.
Definition: ncbiobj.hpp:180
CSeqMap –.
Definition: seq_map.hpp:93
unsigned int TSeqPos
Type for sequence locations and lengths.
Definition: ncbimisc.hpp:875
ETransSplicing
Convenience functions for popular overlapping types.
Definition: sequence.hpp:579
#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
ENa_strand
strand of nucleic acid
Definition: Na_strand_.hpp:64
@ eNa_strand_unknown
Definition: Na_strand_.hpp:65
unsigned int
A callback function used to compare two keys in a database.
Definition: types.hpp:1210
range(_Ty, _Ty) -> range< _Ty >
Portable reference counted smart and weak pointers using CWeakRef, CRef, CObject and CObjectEx.
Modified on Sun Apr 14 05:24:19 2024 by modify_doxy.py rev. 669887