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

Go to the SVN repository for this file.

1 #ifndef SNP_INFO__HPP
2 #define SNP_INFO__HPP
3 
4 /* $Id: snp_info.hpp 72475 2016-05-10 14:39:30Z 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: Eugene Vasilchenko
30 *
31 * File Description:
32 * SNP Seq-annot object information
33 *
34 */
35 
36 #include <corelib/ncbiobj.hpp>
37 #include <corelib/ncbi_limits.hpp>
39 
40 #include <util/range.hpp>
41 
44 
45 class CSeq_entry;
46 class CSeq_feat;
47 class CSeq_annot;
48 class CSeq_annot_Info;
50 class CSeq_point;
51 class CSeq_interval;
52 
54 {
55 public:
57 
58  TSeqPos GetFrom(void) const;
59  TSeqPos GetTo(void) const;
60  bool PlusStrand(void) const;
61  bool MinusStrand(void) const;
62 
63  bool IsRemoved(void) const;
64 
65  bool operator<(const SSNP_Info& snp) const;
66  bool operator<(TSeqPos end_position) const;
67 
68  bool NoMore(const TRange& range) const;
69  bool NotThis(const TRange& range) const;
70 
71  // type of SNP feature returned by parsing method
72  enum ESNP_Type {
92  eSNP_Type_last
93  };
94  // names of types for logging
95  static const char* const s_SNP_Type_Label[eSNP_Type_last];
96 
97  // parser, if returned value is eSNP_Simple, then
98  // other members are filled and can be stored.
99  ESNP_Type ParseSeq_feat(const CSeq_feat& feat,
100  CSeq_annot_SNP_Info& annot_info);
101  // restore Seq-feat object from parsed info.
103  CreateSeq_feat(const CSeq_annot_SNP_Info& annot_info) const;
104 
105  void UpdateSeq_feat(CRef<CSeq_feat>& seq_feat,
106  const CSeq_annot_SNP_Info& annot_info) const;
107  void UpdateSeq_feat(CRef<CSeq_feat>& seq_feat,
108  CRef<CSeq_point>& seq_point,
109  CRef<CSeq_interval>& seq_interval,
110  const CSeq_annot_SNP_Info& annot_info) const;
111 
112  CRef<CSeq_feat> x_CreateSeq_feat(void) const;
113  void x_UpdateSeq_featData(CSeq_feat& feat,
114  const CSeq_annot_SNP_Info& annot_info) const;
115  void x_UpdateSeq_feat(CSeq_feat& feat,
116  const CSeq_annot_SNP_Info& annot_info) const;
117  void x_UpdateSeq_feat(CSeq_feat& feat,
118  CRef<CSeq_point>& seq_point,
119  CRef<CSeq_interval>& seq_interval,
120  const CSeq_annot_SNP_Info& annot_info) const;
121 
122  typedef int TSNPId;
124  enum {
125  kMax_PositionDelta = kMax_UI1
126  };
128  enum {
129  kNo_CommentIndex = kMax_UI1,
130  kMax_CommentIndex = kNo_CommentIndex - 1
131  };
132  typedef Uint1 TWeight;
133  enum {
134  fwWeightQual = 1 << 0,
135  fwWeightExt = 1 << 1,
136  fWeightFlagBits = 2,
137  kMax_Weight = kMax_UI1>>fWeightFlagBits
138  };
140  enum {
141  kNo_ExtraIndex = kMax_UI2,
142  kMax_ExtraIndex = kNo_ExtraIndex - 1
143  };
145  enum {
146  kNo_QualityCodesIndex = kMax_UI2,
147  kMax_QualityCodesIndex = kNo_QualityCodesIndex - 1
148  };
149  enum {
150  kMax_AllelesCount = 4
151  };
153  enum {
154  kNo_AlleleIndex = kMax_UI2,
155  kMax_AlleleIndex = kNo_AlleleIndex - 1
156  };
157 
158  typedef Uint1 TFlags;
159  enum FFlags {
160  fRemoved = 1 << 0,
161  fPlusStrand = 1 << 1,
162  fMinusStrand = 1 << 2,
163  fFuzzLimTr = 1 << 3,
164  fAlleleReplace = 1 << 4,
165  fQualityCodesStr = 1 << 5,
166  fQualityCodesOs = 1 << 6,
167  fQualityCodesMask = fQualityCodesStr | fQualityCodesOs
168  };
169 
170  bool HasAlleles(void) const;
171  size_t GetAllelesCount(void) const;
172  TAlleleIndex GetAlleleStrIndex(size_t index) const;
173  TExtraIndex GetExtraIndex(void) const;
174  CUser_field::TData::E_Choice GetQualityCodesWhich(void) const;
175  TQualityCodesIndex GetQualityCodesStrIndex(void) const;
176  TQualityCodesIndex GetQualityCodesOsIndex(void) const;
177 
178  bool HasLabel(const CSeq_annot_SNP_Info& info) const;
179  string GetLabel(const CSeq_annot_SNP_Info& info) const;
180 
189  TAlleleIndex m_AllelesIndices[kMax_AllelesCount];
190 };
191 
192 /////////////////////////////////////////////////////////////////////////////
193 // SSNP_Info
194 /////////////////////////////////////////////////////////////////////////////
195 
196 inline
198 {
199  return m_ToPosition - m_PositionDelta;
200 }
201 
202 
203 inline
205 {
206  return m_ToPosition;
207 }
208 
209 
210 inline
211 bool SSNP_Info::PlusStrand(void) const
212 {
213  return (m_Flags & fPlusStrand) != 0;
214 }
215 
216 
217 inline
218 bool SSNP_Info::MinusStrand(void) const
219 {
220  return (m_Flags & fMinusStrand) != 0;
221 }
222 
223 
224 inline
225 bool SSNP_Info::IsRemoved(void) const
226 {
227  return (m_Flags & fRemoved) != 0;
228 }
229 
230 
231 inline
232 bool SSNP_Info::operator<(const SSNP_Info& snp) const
233 {
234  return m_ToPosition < snp.m_ToPosition;
235 }
236 
237 
238 inline
239 bool SSNP_Info::operator<(TSeqPos to_position) const
240 {
241  return m_ToPosition < to_position;
242 }
243 
244 inline
245 bool operator<(TSeqPos end_position, const SSNP_Info& snp)
246 {
247  return end_position < snp.m_ToPosition;
248 }
249 
250 
251 inline
252 bool SSNP_Info::NoMore(const TRange& range) const
253 {
255  range.GetToOpen()) + kMax_PositionDelta;
256 }
257 
258 
259 inline
260 bool SSNP_Info::NotThis(const TRange& range) const
261 {
262  return GetFrom() >= range.GetToOpen();
263 }
264 
265 
266 inline
267 bool SSNP_Info::HasAlleles(void) const
268 {
269  return m_AllelesIndices[0] != kNo_AlleleIndex;
270 }
271 
272 
273 inline
275 {
276  _ASSERT(index < GetAllelesCount());
277  return m_AllelesIndices[index];
278 }
279 
280 
281 inline
283 {
284  return HasAlleles();
285 }
286 
287 
288 inline
290 {
291  return m_ExtraIndex;
292 }
293 
294 
295 inline
297 {
299  return m_QualityCodesIndex;
300 }
301 
302 
303 inline
305 {
307  return m_QualityCodesIndex;
308 }
309 
310 
313 
314 
315 #endif // SNP_INFO__HPP
316 
Definition: Seq_entry.hpp:56
namespace ncbi::objects::
Definition: Seq_feat.hpp:58
unsigned int TSeqPos
Type for sequence locations and lengths.
Definition: ncbimisc.hpp:875
const TSeqPos kInvalidSeqPos
Define special value for invalid sequence position.
Definition: ncbimisc.hpp:878
string GetLabel(const CSeq_id &id)
uint8_t Uint1
1-byte (8-bit) unsigned integer
Definition: ncbitype.h:99
#define kMax_UI2
Definition: ncbi_limits.h:216
uint16_t Uint2
2-byte (16-bit) unsigned integer
Definition: ncbitype.h:101
#define kMax_UI1
Definition: ncbi_limits.h:213
#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
E_Choice
Choice variants.
static MDB_envinfo info
Definition: mdb_load.c:37
range(_Ty, _Ty) -> range< _Ty >
Portable reference counted smart and weak pointers using CWeakRef, CRef, CObject and CObjectEx.
T min(T x_, T y_)
bool operator<(TSeqPos end_position, const SSNP_Info &snp)
Definition: snp_info.hpp:245
CRange< TSeqPos > TRange
Definition: snp_info.hpp:56
TExtraIndex GetExtraIndex(void) const
Definition: snp_info.hpp:289
@ kNo_AlleleIndex
Definition: snp_info.hpp:154
bool IsRemoved(void) const
Definition: snp_info.hpp:225
Uint1 TCommentIndex
Definition: snp_info.hpp:127
bool NoMore(const TRange &range) const
Definition: snp_info.hpp:252
TExtraIndex m_ExtraIndex
Definition: snp_info.hpp:187
TSNPId m_SNP_Id
Definition: snp_info.hpp:182
Uint2 TAlleleIndex
Definition: snp_info.hpp:152
int TSNPId
Definition: snp_info.hpp:122
@ kMax_PositionDelta
Definition: snp_info.hpp:125
TAlleleIndex m_AllelesIndices[kMax_AllelesCount]
Definition: snp_info.hpp:189
TQualityCodesIndex m_QualityCodesIndex
Definition: snp_info.hpp:188
Uint1 TFlags
Definition: snp_info.hpp:158
TSeqPos m_ToPosition
Definition: snp_info.hpp:181
TAlleleIndex GetAlleleStrIndex(size_t index) const
Definition: snp_info.hpp:274
bool NotThis(const TRange &range) const
Definition: snp_info.hpp:260
TSeqPos GetFrom(void) const
Definition: snp_info.hpp:197
TQualityCodesIndex GetQualityCodesStrIndex(void) const
Definition: snp_info.hpp:296
@ eSNP_Complex_LocationGiIsBad
Definition: snp_info.hpp:80
@ eSNP_Complex_LocationIsNotPoint
Definition: snp_info.hpp:78
@ eSNP_Bad_WrongTextId
Definition: snp_info.hpp:75
@ eSNP_Complex_IdCountIsNotOne
Definition: snp_info.hpp:83
@ eSNP_Complex_CommentIndexOverflow
Definition: snp_info.hpp:77
@ eSNP_Bad_WrongMemberSet
Definition: snp_info.hpp:74
@ eSNP_Complex_AlleleCountTooLarge
Definition: snp_info.hpp:86
@ eSNP_Complex_WeightBadValue
Definition: snp_info.hpp:87
@ eSNP_Complex_QAdataIndexOverflow
Definition: snp_info.hpp:91
@ eSNP_Complex_WeightCountIsNotOne
Definition: snp_info.hpp:88
@ eSNP_Complex_LocationStrandIsBad
Definition: snp_info.hpp:81
@ eSNP_Complex_AlleleTooBig
Definition: snp_info.hpp:84
@ eSNP_Complex_NoPlaceForQAdata
Definition: snp_info.hpp:90
@ eSNP_Complex_IdCountTooLarge
Definition: snp_info.hpp:82
@ eSNP_Complex_LocationIsNotGi
Definition: snp_info.hpp:79
@ eSNP_Complex_AlleleIndexOverflow
Definition: snp_info.hpp:85
@ eSNP_Complex_CommentTooBig
Definition: snp_info.hpp:76
@ eSNP_Simple
Definition: snp_info.hpp:73
@ eSNP_Complex_BadQAdata
Definition: snp_info.hpp:89
Uint1 TPositionDelta
Definition: snp_info.hpp:123
bool HasLabel(const CSeq_annot_SNP_Info &info) const
Definition: snp_info.hpp:282
TPositionDelta m_PositionDelta
Definition: snp_info.hpp:184
Uint1 TWeight
Definition: snp_info.hpp:132
TWeight m_Weight
Definition: snp_info.hpp:186
bool MinusStrand(void) const
Definition: snp_info.hpp:218
Uint2 TExtraIndex
Definition: snp_info.hpp:139
bool HasAlleles(void) const
Definition: snp_info.hpp:267
TSeqPos GetTo(void) const
Definition: snp_info.hpp:204
bool operator<(const SSNP_Info &snp) const
Definition: snp_info.hpp:232
size_t GetAllelesCount(void) const
TQualityCodesIndex GetQualityCodesOsIndex(void) const
Definition: snp_info.hpp:304
@ fMinusStrand
Definition: snp_info.hpp:162
@ fQualityCodesStr
Definition: snp_info.hpp:165
@ fQualityCodesOs
Definition: snp_info.hpp:166
bool PlusStrand(void) const
Definition: snp_info.hpp:211
TCommentIndex m_CommentIndex
Definition: snp_info.hpp:185
Uint2 TQualityCodesIndex
Definition: snp_info.hpp:144
TFlags m_Flags
Definition: snp_info.hpp:183
#define _ASSERT
Modified on Wed Sep 04 14:59:32 2024 by modify_doxy.py rev. 669887