NCBI C++ ToolKit
snp_bitfield.cpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 /* $Id: snp_bitfield.cpp 89853 2020-04-28 13:03:39Z rudnev $
2  * ===========================================================================
3  *
4  * PUBLIC DOMAIN NOTICE
5  * National Center for Biotechnology Information
6  *
7  * This software/database is a "United States Government Work" under the
8  * terms of the United States Copyright Act. It was written as part of
9  * the author's official duties as a United States Government employee and
10  * thus cannot be copyrighted. This software/database is freely available
11  * to the public for use. The National Library of Medicine and the U.S.
12  * Government have not placed any restriction on its use or reproduction.
13  *
14  * Although all reasonable efforts have been taken to ensure the accuracy
15  * and reliability of the software and data, the NLM and the U.S.
16  * Government do not and cannot warrant the performance or results that
17  * may be obtained by using this software or data. The NLM and the U.S.
18  * Government disclaim all warranties, express or implied, including
19  * warranties of performance, merchantability or fitness for any particular
20  * purpose.
21  *
22  * Please cite the author in any work or product based on this material.
23  *
24  * ===========================================================================
25  *
26  * Authors: Melvin Quintos
27  *
28  * File Description:
29  * Provides implementation of CSnpBitfield class. See snp_bitfield.hpp
30  * for class usage.
31  *
32  */
33 
34 #include <ncbi_pch.hpp>
35 
37 
38 #include "snp_bitfield_factory.hpp"
39 
42 
43 ///////////////////////////////////////////////////////////////////////////////
44 // File Globals / typedefs, etc
45 ///////////////////////////////////////////////////////////////////////////////
46 
47 // Used for GetVariationClassString
48 static const char * g_VARIATION_NAMES[] =
49 { "UNKNOWN",
50  "SNV",
51  "INDEL",
52  "HET",
53  "MSAT",
54  "NAMED",
55  "NOVAR",
56  "MIXED",
57  "MNV",
58  "Idenity",
59  "Inversion",
60  "DEL",
61  "INS"
62 };
63 
64 static const char * g_FXN_NAMES[] =
65 {
66  "Unknown",
67  "intron_variant",
68  "splice_donor_variant",
69  "splice_acceptor_variant",
70  "UTR",
71  "synonymous_variant",
72  "nonsense_variant",
73  "missense_variant",
74  "frameshift_variant",
75 
76  // dbSNP 2.0 additions
77  "In Gene", // In gene segment Defined as sequence intervals covered by a gene ID but not having an aligned transcript. FxnCode = 11
78  "2KB_upstream_variant", // In 5' gene region FxnCode = 15
79  "500B_downstream_variant", // In 3' gene region FxnCode = 13
80  "5_prime_UTR_variant", // In 5' UTR Location is in an untranslated region (UTR). FxnCode = 55
81  "3_prime_UTR_variant", // In 3' UTR Location is in an untranslated region (UTR). FxnCode = 53
82  "Multiple", // Has multiple gene functions (i.e. fwd strand 5'near gene, rev strand 3'near gene)
83 
84  "stop_gained",
85  "stop_lost"
86 };
87 
88 
89 ///////////////////////////////////////////////////////////////////////////////
90 // Public Static Methods
91 ///////////////////////////////////////////////////////////////////////////////
93 {
94  return g_VARIATION_NAMES[e];
95 }
96 
98 {
99  return g_FXN_NAMES[e];
100 }
101 
102 
104 {
105  bool compatible = false;
106 
107  // make the value of e1 always lower than e2
108  if (e1 > e2) {
109  EFunctionClass tmp = e1;
110  e1 = e2;
111  e2 = tmp;
112  }
113 
114  // Handle the case of the same function class (silly, but necessary)
115  if (e1 == e2) {
116  compatible = true;
117  }
118  // Handle eUTR case
119  else if(e1 == eUTR) {
120  if (e2 == eInUTR3 || e2 == eInUTR5) {
121  compatible = true;
122  }
123  }
124 
125  return compatible;
126 }
127 
128 ///////////////////////////////////////////////////////////////////////////////
129 // Public Methods
130 ///////////////////////////////////////////////////////////////////////////////
132 {
133  m_bitfield.reset(new CSnpBitfieldNull());
134 }
135 
137 {
138  *this = feat; // reuse operator=
139 }
140 
142 {
143  *this = rhs; // reuse operator=
144 }
145 
147 {
148  if(this == &rhs)
149  return *this;
150 
151  m_bitfield.reset(rhs.m_bitfield->Clone());
152 
153  return *this;
154 }
155 
157 {
158  IEncoding * ptr = CSnpBitfieldFactory::CreateBitfield(feat);
159 
160  m_bitfield.reset(ptr);
161 
162  return *this;
163 }
164 
166 {
167  int v = GetVariationClass();
168  return g_VARIATION_NAMES[v];
169 }
170 
171 #define ADD_FXN_CLASS(fxn_class) if(IsTrue(fxn_class)) { FunctionClassesLst.push_back(g_FXN_NAMES[fxn_class]); }
172 
174 {
175  string sFunctionClasses;
176  list<string> FunctionClassesLst;
177 
178  // a SNP record may have several function classes, so we need to try all of them and
179  // concatenate corresponding strings
195  return NStr::Join(FunctionClassesLst, ",");
196 }
197 
198 ///////////////////////////////////////////////////////////////////////////////
199 // Private Methods
200 ///////////////////////////////////////////////////////////////////////////////
201 
202 
namespace ncbi::objects::
Definition: Seq_feat.hpp:58
static CSnpBitfield::IEncoding * CreateBitfield(const objects::CSeq_feat &feat)
CSnpBitfield is a facade for representing any version of the SNP bitfield.
string GetGenePropertyString() const
std::unique_ptr< IEncoding > m_bitfield
CSnpBitfield & operator=(const CSnpBitfield &rhs)
EVariationClass GetVariationClass() const
const char * GetVariationClassString() const
const char * GetString() const
static bool IsCompatible(EFunctionClass e1, EFunctionClass e2)
static char tmp[3200]
Definition: utf8.c:42
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
static string Join(const TContainer &arr, const CTempString &delim)
Join strings using the specified delimiter.
Definition: ncbistr.hpp:2699
USING_SCOPE(objects)
static const char * g_VARIATION_NAMES[]
static const char * g_FXN_NAMES[]
#define ADD_FXN_CLASS(fxn_class)
Modified on Fri Sep 20 14:57:53 2024 by modify_doxy.py rev. 669887