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

Go to the SVN repository for this file.

1 /* $Id: gff3_annot_assembler.hpp 88038 2019-11-04 14:08: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, NCBI
27 *
28 * File Description:
29 * Test application for the CFormatGuess component
30 *
31 * ===========================================================================
32 */
33 
34 #ifndef GFF3_ANNOT_ASSEMBLER__HPP
35 #define GFF3_ANNOT_ASSEMBLER__HPP
36 
37 #include <corelib/ncbifile.hpp>
40 
41 #include "feat_annot_assembler.hpp"
42 #include "featid_generator.hpp"
43 #include "gff3_import_data.hpp"
44 
45 class CFeatureMap;
47 
49 BEGIN_objects_SCOPE
50 
51 // ============================================================================
53 // ============================================================================
54 {
55 public:
57 
59 
60  void
62  const std::string& id,
63  CRef<CSeq_feat> pFeature)
64  {
65  auto itExisting = mMap.find(id);
66  if (itExisting != mMap.end()) {
67  return;
68  }
69  mMap[id] = pFeature;
70  };
71 
72 
75  const std::string& id)
76  {
77  auto it = mMap.find(id);
78  if (it == mMap.end()) {
79  return CRef<CSeq_feat>();
80  }
81  return it->second;
82  };
83 
84 private:
85  std::map<std::string, CRef<CSeq_feat>> mMap;
86 };
87 
88 // ============================================================================
90 // ============================================================================
91 {
92 public:
94 
96 
97  void
99  const std::string& id,
100  CRef<CSeq_feat> pFeature)
101  {
102  auto itFeatureVec = mPendingMap.find(id);
103  if (itFeatureVec == mPendingMap.end()) {
104  mPendingMap[id] = vector<CRef<CSeq_feat>>();
105  }
106  auto& feats = mPendingMap[id];
107  auto itFeature = find(feats.begin(), feats.end(), pFeature);
108  if (itFeature == feats.end()) {
109  feats.push_back(pFeature);
110  }
111  };
112 
113  bool
115  const std::string& id,
116  std::vector<CRef<CSeq_feat>>& features)
117  {
118  auto itPending = mPendingMap.find(id);
119  if (itPending == mPendingMap.end()) {
120  return false;
121  }
122  features = itPending->second;
123  return true;
124  };
125 
126  void
128  const std::string& id)
129  {
130  mPendingMap.erase(id);
131  };
132 
133 private:
134  std::map<std::string, std::vector<CRef<CSeq_feat>>> mPendingMap;
135 };
136 
137 
138 // ============================================================================
140  public CFeatAnnotAssembler
141 // ============================================================================
142 {
143 public:
146 
147  virtual ~CGff3AnnotAssembler();
148 
149  void
151  const CFeatImportData&,
152  CSeq_annot&) override;
153 
154  virtual void
156  const CAnnotImportData&,
157  CSeq_annot&) override;
158 
159 private:
160  void
162  const std::string&,
163  const std::string&,
165  CSeq_annot&);
166 
167  void
169  const std::string&,
170  const std::string&,
172  CSeq_annot&);
173 
174  void
176  const std::string&,
177  const std::string&,
179  CSeq_annot&);
180 
181  void
183  const std::string&,
184  const std::string&,
186  CSeq_annot&);
187 
189  CSeq_annot&);
190 
191  static void xMarkLocationPending(
192  CSeq_feat&);
193  static bool xIsLocationPending(
194  const CSeq_feat&);
195  static void xUnmarkLocationPending(
196  CSeq_feat&);
197 
202 };
203 
204 END_objects_SCOPE
206 
207 #endif
virtual void FinalizeAnnot(const CAnnotImportData &, CSeq_annot &) override
static bool xIsLocationPending(const CSeq_feat &)
CGff3PendingFeatureList mPendingFeatures
void xAnnotGenerateXrefs(CSeq_annot &)
static void xUnmarkLocationPending(CSeq_feat &)
void xProcessFeatureDefault(const std::string &, const std::string &, CRef< CSeq_feat >, CSeq_annot &)
void ProcessRecord(const CFeatImportData &, CSeq_annot &) override
CFeatureIdGenerator mIdGenerator
map< string, string > mXrefMap
void xProcessFeatureCds(const std::string &, const std::string &, CRef< CSeq_feat >, CSeq_annot &)
CGff3AnnotAssembler(CImportMessageHandler &)
void xProcessFeatureExon(const std::string &, const std::string &, CRef< CSeq_feat >, CSeq_annot &)
void xProcessFeatureRna(const std::string &, const std::string &, CRef< CSeq_feat >, CSeq_annot &)
static void xMarkLocationPending(CSeq_feat &)
void AddFeature(const std::string &id, CRef< CSeq_feat > pFeature)
std::map< std::string, CRef< CSeq_feat > > mMap
CRef< CSeq_feat > FindFeature(const std::string &id)
bool FindPendingFeatures(const std::string &id, std::vector< CRef< CSeq_feat >> &features)
void AddFeature(const std::string &id, CRef< CSeq_feat > pFeature)
std::map< std::string, std::vector< CRef< CSeq_feat > > > mPendingMap
void MarkFeaturesDone(const std::string &id)
namespace ncbi::objects::
Definition: Seq_feat.hpp:58
string
Definition: cgiapp.hpp:687
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
Defines classes: CDirEntry, CFile, CDir, CSymLink, CMemoryFile, CFileUtil, CFileLock,...
Modified on Wed Jun 19 17:05:42 2024 by modify_doxy.py rev. 669887