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

Go to the SVN repository for this file.

1 /* $Id: flat_feature_retrieve_job.cpp 39803 2017-11-07 15:36:58Z katargir $
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: Roman Katargin
27  *
28  * File Description:
29  *
30  */
31 
32 #include <ncbi_pch.hpp>
33 
34 #include <objmgr/util/sequence.hpp>
35 
38 
40 
43 
45 
46 #include <gui/objutils/utils.hpp>
47 #include <objmgr/util/sequence.hpp>
48 
51 
56  CScope& scope,
57  const CSeq_feat& seq_feat,
58  bool getGeneModel)
60  m_Mode(mode), m_Style(style),
61  m_Scope(&scope), m_Feature(&seq_feat), m_GetGeneModel(getGeneModel)
62 {
63 }
64 
66 {
67 }
68 
69 static CMappedFeat s_GetMappedFeat(const CSeq_feat& feat, CScope& scope)
70 {
73  CFeat_CI feat_it(scope, feat.GetLocation(), sel);
74  for ( ; feat_it; ++feat_it) {
75  if (&feat_it->GetOriginalFeature() == &feat) {
76  return *feat_it;
77  }
78  }
79  return CMappedFeat();
80 }
81 
83 {
84 public:
86 private:
88 };
89 
90 
92 {
94  if (!seq) {
95  m_Error.Reset(new CAppJobError("Bioseq not found for the feature"));
96  return eFailed;
97  }
98 
101  ctx->SetEntry(seq.GetParentEntry());
102 
103  CRef<CBioseqContext> bctx(new CBioseqContext(seq, *ctx));
104  ctx->AddSection(bctx);
105 
107  x_AddItem(composite);
108 
110  CFlatFileTextItem* flatFileItem = 0;
112  (new feature::CFeatTree(seq.GetTopLevelEntry()));
113  if (m_Feature->GetData().IsBiosrc()) {
115  if (f) {
116  item.Reset( new CSourceFeatureItem(f, *bctx, full_ft, &m_Feature->GetLocation()) );
117 
118  flatFileItem = new CFlatFileTextItem(item);
119  flatFileItem->SetEditFlags(0);
120  composite->AddItem(new CExpandItem(new CFlatFileFeatureCollapsed(item), flatFileItem, true));
121  }
122 
123  } else {
124  if (m_GetGeneModel) {
125  CSeqFeatData::E_Choice type = m_Feature->GetData().Which();
126  CMappedFeat mapped_feat = s_GetMappedFeat(*m_Feature, *m_Scope);
127  CMappedFeat gene_feat;
128 
129  CBioseq_Handle bsh =
130  m_Scope->GetBioseqHandle(m_Feature->GetLocation());
135 
136  CFeat_CI feat_it(bsh, sel);
137  feature::CFeatTree ft(feat_it);
138 
139  switch(type) {
140  default:
141  gene_feat = ft.GetParent(mapped_feat);
142  break;
143 
145  gene_feat = mapped_feat;
146  break;
147  }
148 
149  if (gene_feat) {
150  list<CMappedFeat> mrna_feats;
151  list<CMappedFeat> cds_feats;
152 
153  feature::GetMrnasForGene(gene_feat, mrna_feats, &ft);
154  if (IsCanceled())
155  return eCanceled;
156 
157  feature::GetCdssForGene(gene_feat, cds_feats, &ft);
158  if (IsCanceled())
159  return eCanceled;
160 
161  item.Reset( new CFeatureItem(gene_feat, *bctx, full_ft, &gene_feat.GetLocation()) );
162 
163  flatFileItem = new CFlatFileTextItem(item);
164  flatFileItem->SetEditFlags(0);
165 
166  composite->AddItem(new CExpandItem(new CFlatFileFeatureCollapsed(item), flatFileItem, true));
167 
168  ITERATE(list<CMappedFeat> , it, mrna_feats) {
170  item.Reset( new CFeatureItem(*it, *bctx, full_ft, &it->GetLocation()) );
171  flatFileItem = new CFlatFileTextItem(item);
172  flatFileItem->SetEditFlags(0);
173 
174  composite->AddItem(new CExpandItem(new CFlatFileFeatureCollapsed(item), flatFileItem, true));
175  }
176 
177  ITERATE(list<CMappedFeat> , it, cds_feats) {
179  item.Reset( new CFeatureItem(*it, *bctx, full_ft, &it->GetLocation()) );
180  flatFileItem = new CFlatFileTextItem(item);
181  flatFileItem->SetEditFlags(0);
182  composite->AddItem(new CExpandItem(new CFlatFileFeatureCollapsed(item), flatFileItem, true));
183  }
184  }
185  else {
186  if (mapped_feat) {
187  item.Reset( new CFeatureItem(mapped_feat, *bctx, full_ft, &m_Feature->GetLocation()) );
188 
189  flatFileItem = new CFlatFileTextItem(item);
190  flatFileItem->SetEditFlags(0);
191 
192  composite->AddItem(new CExpandItem(new CFlatFileFeatureCollapsed(item), flatFileItem, true));
193  }
194  }
195  }
196  else {
198  CFeat_CI iter(*m_Scope, m_Feature->GetLocation(), sel);
199  bctx->GetFeatTree().AddFeatures(iter);
200  for (; iter; ++iter) {
202  item.Reset( new CFeatureItem(*iter, *bctx, full_ft, NULL));
203  flatFileItem = new CFlatFileTextItem(item);
204  flatFileItem->SetEditFlags(0);
205  composite->AddItem(new CExpandItem(new CFlatFileFeatureCollapsed(item), flatFileItem, true));
206  }
207  }
208  }
209 
210  x_CreateResult();
211 
212  return eCompleted;
213 }
214 
static CRef< CScope > m_Scope
CAppJobError Default implementation for IAppJobError - encapsulates a text error message.
feature::CFeatTree & GetFeatTree(void)
Definition: context.hpp:103
CBioseq_Handle –.
void AddItem(ITextItem *item, bool updatePositions=true)
CConstRef –.
Definition: ncbiobj.hpp:1266
CFeat_CI –.
Definition: feat_ci.hpp:64
CRef< objects::CFlatFileContext > m_Ctx
CFeatureCoompositeItem(CFlatFileContext &ctx)
CFlatFeatureRetrieveJob(CTextPanelContext &context, objects::CFlatFileConfig::EMode mode, objects::CFlatFileConfig::EStyle style, objects::CScope &scope, const objects::CSeq_feat &seq_feat, bool getGeneModel)
objects::CFlatFileConfig::EMode m_Mode
objects::CFlatFileConfig::EStyle m_Style
CRef< objects::CScope > m_Scope
CConstRef< objects::CSeq_feat > m_Feature
void SetEditFlags(int flags)
CMappedFeat –.
Definition: mapped_feat.hpp:59
CScope –.
Definition: scope.hpp:92
ESubtype GetSubtype(void) const
namespace ncbi::objects::
Definition: Seq_feat.hpp:58
void x_CheckCancelled() const
void x_AddItem(ITextItem *item)
CRef< CAppJobError > m_Error
struct config config
USING_SCOPE(objects)
static CMappedFeat s_GetMappedFeat(const CSeq_feat &feat, CScope &scope)
CS_CONTEXT * ctx
Definition: t0006.c:12
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
Definition: ncbimisc.hpp:815
#define NULL
Definition: ncbistd.hpp:225
static objects::SAnnotSelector GetAnnotSelector(TAnnotFlags flags=0)
request an annotation selector for a given type
Definition: utils.cpp:167
virtual bool IsCanceled() const override
EJobState
Job states (describe FSM)
Definition: app_job.hpp:86
@ eCanceled
Definition: app_job.hpp:91
@ eCompleted
Definition: app_job.hpp:89
@ eFailed
Definition: app_job.hpp:90
void GetMrnasForGene(const CMappedFeat &gene_feat, list< CMappedFeat > &mrna_feats, CFeatTree *feat_tree=0, const SAnnotSelector *base_sel=0)
Definition: feature.cpp:3384
void GetCdssForGene(const CMappedFeat &gene_feat, list< CMappedFeat > &cds_feats, CFeatTree *feat_tree=0, const SAnnotSelector *base_sel=0)
Definition: feature.cpp:3409
CBioseq_Handle GetBioseqFromSeqLoc(const CSeq_loc &loc, CScope &scope, CScope::EGetBioseqFlag flag=CScope::eGetBioseq_Loaded)
Retrieve the Bioseq Handle from a location.
Definition: sequence.cpp:308
CSeq_entry_Handle GetParentEntry(void) const
Get parent Seq-entry handle.
CSeq_entry_Handle GetTopLevelEntry(void) const
Get top level Seq-entry handle.
SAnnotSelector & IncludeFeatSubtype(TFeatSubtype subtype)
Include feature subtype in the search.
SAnnotSelector & SetFeatType(TFeatType type)
Set feature type (also set annotation type to feat)
const CSeq_loc & GetLocation(void) const
const CSeq_feat & GetOriginalFeature(void) const
Get original feature with unmapped location/product.
SAnnotSelector & IncludeFeatType(TFeatType type)
Include feature type in the search.
void Reset(void)
Reset reference object.
Definition: ncbiobj.hpp:1439
void Reset(void)
Reset reference object.
Definition: ncbiobj.hpp:773
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
const TLocation & GetLocation(void) const
Get the Location member data.
Definition: Seq_feat_.hpp:1117
E_Choice
Choice variants.
const TData & GetData(void) const
Get the Data member data.
Definition: Seq_feat_.hpp:925
mdb_mode_t mode
Definition: lmdb++.h:38
double f(double x_, const double &y_)
Definition: njn_root.hpp:188
SAnnotSelector –.
Definition: type.c:6
static CS_CONTEXT * context
Definition: will_convert.c:21
Modified on Wed Apr 24 14:18:11 2024 by modify_doxy.py rev. 669887