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

Go to the SVN repository for this file.

1 /* $Id: gff_base_columns.cpp 99211 2023-02-27 16:15:10Z ludwigf $
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  * Author: Frank Ludwig
27  *
28  * File Description:
29  * GFF file reader
30  *
31  */
32 
33 #include <ncbi_pch.hpp>
34 #include <corelib/ncbistd.hpp>
35 #include <objects/seq/so_map.hpp>
43 
47 
49 
50 BEGIN_objects_SCOPE // namespace ncbi::objects::
51 
52 unsigned int CGffBaseColumns::msNextId = 0;
53 
54 // ============================================================================
56 // ============================================================================
57  mSeqId(""),
58  m_uSeqStart(0),
59  m_uSeqStop(0),
60  m_strSource(""),
61  m_strType(""),
62  m_strNormalizedType(""),
63  m_pdScore(nullptr),
64  m_peStrand(nullptr),
65  m_pePhase(nullptr)
66 {
67 };
68 
69 // ============================================================================
71 // ============================================================================
72  const CGffBaseColumns& rhs):
73  mSeqId(rhs.mSeqId),
74  m_uSeqStart(rhs.m_uSeqStart),
75  m_uSeqStop(rhs.m_uSeqStop),
76  m_strSource(rhs.m_strSource),
77  m_strType(rhs.m_strType),
78  m_strNormalizedType(rhs.m_strNormalizedType),
79  m_pdScore(nullptr),
80  m_peStrand(nullptr),
81  m_pePhase(nullptr)
82 {
83  if (rhs.m_pdScore) {
84  m_pdScore = new double(rhs.Score());
85  }
86  if (rhs.m_peStrand) {
87  m_peStrand = new ENa_strand(rhs.Strand());
88  }
89  if (rhs.m_pePhase) {
90  m_pePhase = new TFrame(rhs.Phase());
91  }
92 };
93 
94 // ============================================================================
96 // ============================================================================
97 {
98  delete m_pdScore;
99  delete m_peStrand;
100  delete m_pePhase;
101 };
102 
103 // ============================================================================
106  SeqIdResolver seqidresolve ) const
107 // ============================================================================
108 {
109  if (!seqidresolve) {
110  seqidresolve = CReadUtil::AsSeqId;
111  }
112  return seqidresolve(Id(), flags, true);
113 }
114 
115 // ============================================================================
118  SeqIdResolver seqidresolve ) const
119 // ============================================================================
120 {
121  CRef<CSeq_loc> pLocation(new CSeq_loc);
122  pLocation->SetInt().SetId(*GetSeqId(flags, seqidresolve));
123  pLocation->SetInt().SetFrom(static_cast<TSeqPos>(SeqStart()));
124  pLocation->SetInt().SetTo(static_cast<TSeqPos>(SeqStop()));
125  if (IsSetStrand()) {
126  pLocation->SetInt().SetStrand(Strand());
127  }
128  return pLocation;
129 }
130 
131 // ----------------------------------------------------------------------------
134  CRef<CSeq_feat> pFeature,
135  SeqIdResolver seqidresolve ) const
136  // ----------------------------------------------------------------------------
137 {
138  if (!xInitFeatureLocation(flags, pFeature, seqidresolve)) {
139  return false;
140  }
141  if (!xInitFeatureData(flags, pFeature)) {
142  return false;
143  }
144  return xInitFeatureId(flags, pFeature);
145 }
146 
147 // ============================================================================
149  TReaderFlags,
150  CRef<CSeq_feat> pFeature ) const
151 // ============================================================================
152 {
153  unsigned int featId = NextId();
154  CRef<CFeat_id> pFeatId(new CFeat_id);
155  pFeatId->SetLocal().SetId(featId);
156  pFeature->SetId(*pFeatId);
157  return true;
158 }
159 
160 // ============================================================================
163  CRef<CSeq_feat> pFeature,
164  SeqIdResolver seqidresolve ) const
165 // ============================================================================
166 {
167  pFeature->SetLocation(*GetSeqLoc(flags, seqidresolve));
168  return true;
169 }
170 
171 // ----------------------------------------------------------------------------
174  CRef<CSeq_feat> pFeature ) const
175  // ----------------------------------------------------------------------------
176 {
177  CSeqFeatData::ESubtype subtype = pFeature->GetData().GetSubtype();
178  if (subtype == CSeqFeatData::eSubtype_cdregion) {
179  CCdregion::EFrame frame = Phase();
180  if (frame == CCdregion::eFrame_not_set) {
181  frame = CCdregion::eFrame_one;
182  }
183  pFeature->SetData().SetCdregion().SetFrame(frame);
184  return true;
185  }
186 
187  return true;
188 }
189 
190 END_objects_SCOPE
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
CFeat_id –.
Definition: Feat_id.hpp:66
ENa_strand * m_peStrand
CRef< CSeq_id > GetSeqId(TReaderFlags, SeqIdResolver=nullptr) const
virtual ~CGffBaseColumns()
virtual bool xInitFeatureId(TReaderFlags, CRef< CSeq_feat >) const
CRef< CSeq_loc > GetSeqLoc(TReaderFlags, SeqIdResolver seqidresolve=nullptr) const
static unsigned int msNextId
virtual bool xInitFeatureData(TReaderFlags, CRef< CSeq_feat >) const
CCdregion::EFrame TFrame
virtual bool InitializeFeature(TReaderFlags, CRef< CSeq_feat >, SeqIdResolver=nullptr) const
double Score() const
virtual bool xInitFeatureLocation(TReaderFlags, CRef< CSeq_feat >, SeqIdResolver=nullptr) const
ENa_strand Strand() const
TFrame Phase() const
static CRef< CSeq_id > AsSeqId(const string &rawId, long flags=0, bool localInts=true)
Convert a raw ID string to a Seq-id, based in given customization flags.
Definition: read_util.cpp:89
Include a standard set of the NCBI C++ Toolkit most basic headers.
static uch flags
unsigned int TSeqPos
Type for sequence locations and lengths.
Definition: ncbimisc.hpp:875
void SetInt(TInt &v)
Definition: Seq_loc.hpp:983
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
TId & SetId(void)
Select the variant.
Definition: Object_id_.hpp:277
TLocal & SetLocal(void)
Select the variant.
Definition: Feat_id_.cpp:140
@ eFrame_not_set
not set, code uses one
Definition: Cdregion_.hpp:95
ENa_strand
strand of nucleic acid
Definition: Na_strand_.hpp:64
#define nullptr
Definition: ncbimisc.hpp:45
static bool GetSeqId(const T &d, set< string > &labels, const string name="", bool detect=false, bool found=false)
Modified on Fri Sep 20 14:57:47 2024 by modify_doxy.py rev. 669887