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

Go to the SVN repository for this file.

1 /* $Id: process_gene_overlap.hpp 91317 2020-10-08 18:29:47Z grichenk $
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:
27 *
28 * File Description:
29 *
30 * ===========================================================================
31 */
32 
33 #ifndef __process_gene_overlap__hpp__
34 #define __process_gene_overlap__hpp__
35 
36 // ============================================================================
38 // ============================================================================
39  : public CScopedProcess
40 {
41 public:
42  // ------------------------------------------------------------------------
44  // ------------------------------------------------------------------------
45  : CScopedProcess()
46  , m_out( 0 )
47  {};
48 
49  // ------------------------------------------------------------------------
51  // ------------------------------------------------------------------------
52  {
53  };
54 
55  // ------------------------------------------------------------------------
57  const CArgs& args )
58  // ------------------------------------------------------------------------
59  {
61 
62  m_out = args["o"] ? &(args["o"].AsOutputFile()) : &cout;
63  };
64 
65  // ------------------------------------------------------------------------
67  // ------------------------------------------------------------------------
68  {
69  }
70 
71  // ------------------------------------------------------------------------
72  virtual void SeqEntryInitialize(
73  CRef<CSeq_entry>& se )
74  // ------------------------------------------------------------------------
75  {
77  };
78 
79  // ------------------------------------------------------------------------
81  // ------------------------------------------------------------------------
82  {
83  try {
85  const CBioseq& bioseq = *bit;
86  if (bioseq.IsSetInst()) {
87  const CSeq_inst& inst = bioseq.GetInst();
88  if (inst.IsSetMol()) {
89  TSEQ_MOL mol = inst.GetMol();
90  if (mol == CSeq_inst::eMol_aa) {
91  continue;
92  }
93  }
94  }
95 
96  CBioseq_Handle bsh = m_scope->GetBioseqHandle(bioseq);
97  SAnnotSelector sel;
98  sel.SetLimitTSE(bsh.GetTSE_Handle());
99  sel.SetResolveDepth(0);
100 
101  for (CFeat_CI feat_it(bsh, sel); feat_it; ++feat_it) {
102  const CMappedFeat mf = *feat_it;
103  const CSeq_feat& feat = mf.GetOriginalFeature();
104  TestFeatureGeneOverlap( feat );
105  ++m_objectcount;
106  }
107 
108  /*
109  FOR_EACH_SEQANNOT_ON_BIOSEQ ( ait, bioseq ) {
110  const CSeq_annot& annot = **ait;
111  FOR_EACH_SEQFEAT_ON_SEQANNOT ( fit, annot ) {
112  const CSeq_feat& feat = **fit;
113  TestFeatureGeneOverlap( feat );
114  ++m_objectcount;
115  }
116  }
117  VISIT_ALL_FEATURES_WITHIN_SEQENTRY (fit, *m_entry) {
118  const CSeq_feat& feat = *fit;
119  TestFeatureGeneOverlap( feat );
120  ++m_objectcount;
121  }
122  */
123  }
124  }
125  catch (CException& e) {
126  ERR_POST(Error << "error processing seqentry: " << e.what());
127  }
128  };
129 
130 protected:
131  // ------------------------------------------------------------------------
133  const CSeq_feat& f )
134  // ------------------------------------------------------------------------
135  {
136  if ( f.GetData().Which() == CSeqFeatData::e_Gene ) {
137  return;
138  }
139  ++m_objectcount;
140  const CSeq_feat_Base::TLocation& locbase = f.GetLocation();
142  locbase, *m_scope );
143  if ( ! ol ) {
144  return;
145  }
146  const CGene_ref& gene = ol->GetData().GetGene();
147  if (gene.IsSetLocus()) {
148  *m_out << "Gene locus " << gene.GetLocus() << endl;
149  }
150  if (gene.IsSetLocus_tag()) {
151  *m_out << "Gene locus_tag " << gene.GetLocus_tag() << endl;
152  }
153  /*
154  *m_out << SeqLocString( locbase ) << " -> "
155  << SeqLocString( ol->GetLocation() ) << endl;
156  */
157  }
158 
159  // ------------------------------------------------------------------------
160  string SeqLocString( const CSeq_loc& loc )
161  // ------------------------------------------------------------------------
162  {
163  string str;
164  loc.GetLabel(&str);
165  return str;
166  }
167 
168  // ------------------------------------------------------------------------
169  // Data:
170  // ------------------------------------------------------------------------
171 protected:
173 };
174 
175 // ============================================================================
177 // ============================================================================
178  : public CScopedProcess
179 {
180 public:
181  // ------------------------------------------------------------------------
183  // ------------------------------------------------------------------------
184  : CScopedProcess()
185  , m_out( 0 )
186  {};
187 
188  // ------------------------------------------------------------------------
190  // ------------------------------------------------------------------------
191  {
192  };
193 
194  // ------------------------------------------------------------------------
196  const CArgs& args )
197  // ------------------------------------------------------------------------
198  {
200 
201  m_out = args["o"] ? &(args["o"].AsOutputFile()) : &cout;
202  };
203 
204  // ------------------------------------------------------------------------
206  // ------------------------------------------------------------------------
207  {
208  }
209 
210  // ------------------------------------------------------------------------
211  virtual void SeqEntryInitialize(
212  CRef<CSeq_entry>& se )
213  // ------------------------------------------------------------------------
214  {
216  };
217 
218  // ------------------------------------------------------------------------
220  // ------------------------------------------------------------------------
221  {
222  try {
224  const CBioseq& bioseq = *bit;
225  if (bioseq.IsSetInst()) {
226  const CSeq_inst& inst = bioseq.GetInst();
227  if (inst.IsSetMol()) {
228  TSEQ_MOL mol = inst.GetMol();
229  if (mol == CSeq_inst::eMol_aa) {
230  continue;
231  }
232  }
233  }
234 
235  CBioseq_Handle bsh = m_scope->GetBioseqHandle(bioseq);
236  SAnnotSelector sel;
237  sel.SetLimitTSE(bsh.GetTSE_Handle());
238  sel.SetResolveDepth(0);
239 
240  for (CFeat_CI feat_it(bsh, sel); feat_it; ++feat_it) {
241  const CMappedFeat mf = *feat_it;
242  m_featTree.AddFeature(mf);
243  }
244 
245  for (CFeat_CI feat_it(bsh, sel); feat_it; ++feat_it) {
246  const CMappedFeat mf = *feat_it;
247  TestFeatureGeneTree( mf );
248  ++m_objectcount;
249  }
250  }
251  }
252  catch (CException& e) {
253  ERR_POST(Error << "error processing seqentry: " << e.what());
254  }
255  };
256 
257 protected:
258  // ------------------------------------------------------------------------
260  const CMappedFeat mf )
261  // ------------------------------------------------------------------------
262  {
264  return;
265  }
266  ++m_objectcount;
268  if (best) {
269  const CGene_ref& gene = best.GetData().GetGene();
270  if (gene.IsSetLocus()) {
271  *m_out << "Gene locus " << gene.GetLocus() << endl;
272  }
273  if (gene.IsSetLocus_tag()) {
274  *m_out << "Gene locus_tag " << gene.GetLocus_tag() << endl;
275  }
276  }
277  }
278 
279  // ------------------------------------------------------------------------
280  string SeqLocString( const CSeq_loc& loc )
281  // ------------------------------------------------------------------------
282  {
283  string str;
284  loc.GetLabel(&str);
285  return str;
286  }
287 
288  // ------------------------------------------------------------------------
289  // Data:
290  // ------------------------------------------------------------------------
291 protected:
293  feature::CFeatTree m_featTree;
294 };
295 
296 #endif
CArgs –.
Definition: ncbiargs.hpp:379
CBioseq_Handle –.
CFeat_CI –.
Definition: feat_ci.hpp:64
virtual void SeqEntryInitialize(CRef< CSeq_entry > &se)
void ProcessInitialize(const CArgs &args)
void TestFeatureGeneTree(const CMappedFeat mf)
feature::CFeatTree m_featTree
string SeqLocString(const CSeq_loc &loc)
string SeqLocString(const CSeq_loc &loc)
virtual void SeqEntryInitialize(CRef< CSeq_entry > &se)
void TestFeatureGeneOverlap(const CSeq_feat &f)
void ProcessInitialize(const CArgs &args)
CMappedFeat –.
Definition: mapped_feat.hpp:59
void ProcessInitialize(const CArgs &args)
virtual void SeqEntryInitialize(CRef< CSeq_entry > &se)
CRef< CScope > m_scope
CRef< CSeq_entry > m_entry
Definition: process.hpp:114
unsigned int m_objectcount
Definition: process.hpp:108
ESubtype GetSubtype(void) const
namespace ncbi::objects::
Definition: Seq_feat.hpp:58
static const char * str(char *buf, int n)
Definition: stats.c:84
#define ERR_POST(message)
Error posting with file, line number information but without error codes.
Definition: ncbidiag.hpp:186
void Error(CExceptionArgs_Base &args)
Definition: ncbiexpt.hpp:1197
virtual const char * what(void) const noexcept
Standard report (includes full backlog).
Definition: ncbiexpt.cpp:342
void GetLabel(string *label) const
Appends a label suitable for display (e.g., error messages) label must point to an existing string ob...
Definition: Seq_loc.cpp:3467
CMappedFeat GetBestGeneForFeat(const CMappedFeat &feat, CFeatTree *feat_tree=0, const SAnnotSelector *base_sel=0, CFeatTree::EBestGeneType lookup_type=CFeatTree::eBestGene_TreeOnly)
Definition: feature.cpp:3443
CConstRef< CSeq_feat > GetOverlappingGene(const CSeq_loc &loc, CScope &scope, ETransSplicing eTransSplicing=eTransSplicing_Auto)
Definition: sequence.cpp:1366
CBioseq_Handle GetBioseqHandle(const CSeq_id &id)
Get bioseq handle by seq-id.
Definition: scope.cpp:95
const CTSE_Handle & GetTSE_Handle(void) const
Get CTSE_Handle of containing TSE.
const CSeqFeatData & GetData(void) const
const CSeq_feat & GetOriginalFeature(void) const
Get original feature with unmapped location/product.
SAnnotSelector & SetResolveDepth(int depth)
SetResolveDepth sets the limit of subsegment resolution in searching annotations.
SAnnotSelector & SetLimitTSE(const CTSE_Handle &limit)
Limit annotations to those from the TSE only.
IO_PREFIX::ostream CNcbiOstream
Portable alias for ostream.
Definition: ncbistre.hpp:149
bool IsSetLocus_tag(void) const
systematic gene name (e.g., MI0001, ORF0069) Check if a value has been assigned to Locus_tag data mem...
Definition: Gene_ref_.hpp:781
bool IsSetLocus(void) const
Official gene symbol Check if a value has been assigned to Locus data member.
Definition: Gene_ref_.hpp:493
const TLocus_tag & GetLocus_tag(void) const
Get the Locus_tag member data.
Definition: Gene_ref_.hpp:793
const TLocus & GetLocus(void) const
Get the Locus member data.
Definition: Gene_ref_.hpp:505
const TData & GetData(void) const
Get the Data member data.
Definition: Seq_feat_.hpp:925
const TGene & GetGene(void) const
Get the variant data.
const TInst & GetInst(void) const
Get the Inst member data.
Definition: Bioseq_.hpp:336
bool IsSetMol(void) const
Check if a value has been assigned to Mol data member.
Definition: Seq_inst_.hpp:593
bool IsSetInst(void) const
the sequence data Check if a value has been assigned to Inst data member.
Definition: Bioseq_.hpp:324
TMol GetMol(void) const
Get the Mol member data.
Definition: Seq_inst_.hpp:612
EMol
molecule class in living organism
Definition: Seq_inst_.hpp:108
double f(double x_, const double &y_)
Definition: njn_root.hpp:188
#define VISIT_ALL_BIOSEQS_WITHIN_SEQENTRY(Itr, Var)
VISIT_ALL_BIOSEQS_WITHIN_SEQENTRY.
SAnnotSelector –.
Modified on Wed Apr 24 14:10:00 2024 by modify_doxy.py rev. 669887