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

Go to the SVN repository for this file.

1 /* $Id: gene_feats_from_xrefs.cpp 37875 2017-02-27 13:40:33Z filippov $
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: Igor Filippov
27  */
28 
29 
30 #include <ncbi_pch.hpp>
33 #include <objmgr/feat_ci.hpp>
34 #include <objmgr/scope.hpp>
35 #include <objmgr/util/feature.hpp>
39 
40 #include <wx/msgdlg.h>
41 
43 
45 
46 
48 {
49  int answer = wxMessageBox(_("Remove original Xref?"), _("Remove xrefs after creating Genes"), wxYES_NO | wxICON_QUESTION);
50  bool remove_xref = (answer == wxYES);
51 
52  CRef<CCmdComposite> cmd(new CCmdComposite("Gene Features from Xrefs"));
53  for (CFeat_CI feat_ci(seh); feat_ci; ++feat_ci)
54  {
55  const CSeq_feat& orig = feat_ci->GetOriginalFeature();
56  CRef<CSeq_feat> changed_feat(new CSeq_feat);
57  changed_feat->Assign(orig);
58  bool modified = false;
59  EDIT_EACH_SEQFEATXREF_ON_SEQFEAT(xref, *changed_feat)
60  {
61  if ((*xref)->IsSetData() && (*xref)->GetData().IsGene())
62  {
63  CRef<CSeq_feat> new_feat(new CSeq_feat());
64 
66  data->Assign((*xref)->GetData());
67  new_feat->SetData(*data);
68 
69  CRef<CSeq_loc> loc(new CSeq_loc());
70  loc->Assign(orig.GetLocation());
71  new_feat->SetLocation(*loc);
73 
74  if (orig.IsSetPseudo() && orig.GetPseudo())
75  new_feat->SetPseudo(true);
76 
78  cmd->AddCommand(*CRef<CCmdCreateFeat>(new CCmdCreateFeat(parent, *new_feat)));
79  if (remove_xref)
80  {
81  ERASE_SEQFEATXREF_ON_SEQFEAT(xref, *changed_feat);
82  modified = true;
83  }
84  }
85  }
86  if (modified)
87  {
88  if (changed_feat->IsSetXref() && changed_feat->GetXref().empty())
89  changed_feat->ResetXref();
90  cmd->AddCommand(*CRef< CCmdChangeSeq_feat >(new CCmdChangeSeq_feat(feat_ci->GetSeq_feat_Handle(),*changed_feat)));
91  }
92  }
93  return cmd;
94 }
95 
97 {
98  CRef<CCmdComposite> cmd(new CCmdComposite("Gene Xrefs From Features"));
99  for (CFeat_CI feat_ci(seh); feat_ci; ++feat_ci)
100  {
101  CSeq_feat_Handle fh = feat_ci->GetSeq_feat_Handle();
103  continue;
104 
105  CMappedFeat gene = feature::GetBestGeneForFeat(*feat_ci);
106  if (!gene)
107  continue;
108  const CSeq_feat& feat = gene.GetMappedFeature();
109  if (!feat.IsSetData() || !feat.GetData().IsGene())
110  continue;
111 
112  const CSeq_feat& orig = feat_ci->GetOriginalFeature();
113  CRef<CSeq_feat> changed_feat(new CSeq_feat);
114  changed_feat->Assign(orig);
115  CRef<CGene_ref> gene_ref(new CGene_ref);
116  gene_ref->Assign(feat.GetData().GetGene());
117  changed_feat->SetGeneXref(*gene_ref);
118 
119  cmd->AddCommand(*CRef< CCmdChangeSeq_feat >(new CCmdChangeSeq_feat(fh,*changed_feat)));
120  }
121  return cmd;
122 }
123 
@ eExtreme_Biological
5' and 3'
Definition: Na_strand.hpp:62
CFeat_CI –.
Definition: feat_ci.hpp:64
static CRef< CCmdComposite > GetCommand(CSeq_entry_Handle seh)
static CRef< CCmdComposite > GetCommand(CSeq_entry_Handle seh)
CMappedFeat –.
Definition: mapped_feat.hpp:59
CSeq_entry_Handle –.
CSeq_feat_Handle –.
namespace ncbi::objects::
Definition: Seq_feat.hpp:58
void SetGeneXref(CGene_ref &value)
Definition: Seq_feat.cpp:192
#define _(proto)
Definition: ct_nlmzip_i.h:78
static CS_COMMAND * cmd
Definition: ct_dynamic.c:26
char data[12]
Definition: iconv.c:80
USING_SCOPE(ncbi::objects)
virtual void Assign(const CSerialObject &source, ESerialRecursionMode how=eRecursive)
Set object to copy of another one.
bool IsPartialStart(ESeqLocExtremes ext) const
check start or stop of location for e_Lim fuzz
Definition: Seq_loc.cpp:3222
virtual void Assign(const CSerialObject &source, ESerialRecursionMode how=eRecursive)
Override Assign() to incorporate cache invalidation.
Definition: Seq_loc.cpp:337
bool IsPartialStop(ESeqLocExtremes ext) const
Definition: Seq_loc.cpp:3251
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
CBioseq_Handle GetBioseqHandle(const CSeq_id &id)
Get bioseq handle by seq-id.
Definition: scope.cpp:95
CSeq_entry_Handle GetSeq_entry_Handle(void) const
Get parent Seq-entry handle.
CScope & GetScope(void) const
Get scope this handle belongs to.
CSeqFeatData::ESubtype GetFeatSubtype(void) const
const CSeq_feat & GetMappedFeature(void) const
Feature mapped to the master sequence.
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
bool IsSetData(void) const
the specific data Check if a value has been assigned to Data data member.
Definition: Seq_feat_.hpp:913
void SetLocation(TLocation &value)
Assign a value to Location data member.
Definition: Seq_feat_.cpp:131
void SetPartial(TPartial value)
Assign a value to Partial data member.
Definition: Seq_feat_.hpp:971
bool IsSetXref(void) const
cite other relevant features Check if a value has been assigned to Xref data member.
Definition: Seq_feat_.hpp:1296
bool IsGene(void) const
Check if variant Gene is selected.
const TData & GetData(void) const
Get the Data member data.
Definition: Seq_feat_.hpp:925
void SetData(TData &value)
Assign a value to Data data member.
Definition: Seq_feat_.cpp:94
void SetPseudo(TPseudo value)
Assign a value to Pseudo data member.
Definition: Seq_feat_.hpp:1374
const TGene & GetGene(void) const
Get the variant data.
const TXref & GetXref(void) const
Get the Xref member data.
Definition: Seq_feat_.hpp:1308
void ResetXref(void)
Reset Xref data member.
Definition: Seq_feat_.cpp:182
where boath are integers</td > n< td ></td > n</tr > n< tr > n< td > tse</td > n< td > optional</td > n< td > String</td > n< td class=\"description\"> TSE option controls what blob is orig
Utility macros and typedefs for exploring NCBI objects from seqfeat.asn.
#define ERASE_SEQFEATXREF_ON_SEQFEAT(Itr, Var)
ERASE_SEQFEATXREF_ON_SEQFEAT.
#define EDIT_EACH_SEQFEATXREF_ON_SEQFEAT(Itr, Var)
Modified on Mon Jul 15 05:32:00 2024 by modify_doxy.py rev. 669887