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

Go to the SVN repository for this file.

1 /* $Id: remove_xrefs.hpp 42340 2019-02-05 14:40:28Z asztalos $
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 #ifndef _REMOVE_XREFS_H_
31 #define _REMOVE_XREFS_H_
32 
33 #include <corelib/ncbistd.hpp>
38 
39 
41 
42 template<typename T>
44 {
45 public:
46  static void FindFeatures(objects::CSeq_entry_Handle seh, objects::CSeqFeatData::E_Choice type, CRef<CCmdComposite> cmd);
47  static void ModifyFeature(CRef<objects::CSeq_feat> feat) {T::ModifyFeature(feat);}
48  static void ModifyBioSource(objects::CBioSource& biosource) {T::ModifyBioSource(biosource);}
49  static bool ChangeBioSource(objects::CBioSource& biosource);
50  static void GetDesc(const objects::CSeq_entry& se, objects::CScope& scope, CRef<CCmdComposite> composite);
51  static void FindBioSource(objects::CSeq_entry_Handle tse, CRef<CCmdComposite> composite);
52 };
53 
54 template<typename T>
55 void CRemoveXrefs<T>::FindFeatures(objects::CSeq_entry_Handle seh, objects::CSeqFeatData::E_Choice type, CRef<CCmdComposite> cmd)
56 {
57  for (objects::CFeat_CI feat_ci(seh, objects::SAnnotSelector(type)); feat_ci; ++feat_ci)
58  {
59  const objects::CSeq_feat& orig = feat_ci->GetOriginalFeature();
60  CRef<objects::CSeq_feat> new_feat(new objects::CSeq_feat());
61  new_feat->Assign(orig);
62 
63  if (new_feat->IsSetDbxref())
64  {
65  ModifyFeature(new_feat);
66  cmd->AddCommand(*CRef<CCmdChangeSeq_feat>(new CCmdChangeSeq_feat(feat_ci->GetSeq_feat_Handle(), *new_feat)));
67  }
68  }
69 }
70 
71 template<typename T>
72 bool CRemoveXrefs<T>::ChangeBioSource(objects::CBioSource& biosource)
73 {
74  if (biosource.IsSetOrg() && biosource.GetOrg().IsSetDb())
75  {
76  ModifyBioSource(biosource);
77  return true;
78  }
79  return false;
80 }
81 
83 template<typename T>
84 void CRemoveXrefs<T>::GetDesc(const objects::CSeq_entry& se, objects::CScope& scope, CRef<CCmdComposite> composite)
85 {
87  if ((*it)->IsSource()) {
88  const objects::CSeqdesc& orig_desc = **it;
89  CRef<objects::CSeqdesc> new_desc(new CSeqdesc);
90  new_desc->Assign(orig_desc);
91  if (ChangeBioSource(new_desc->SetSource())) {
92  CRef<CCmdChangeSeqdesc> cmd(new CCmdChangeSeqdesc(scope.GetSeq_entryHandle(se), orig_desc, *new_desc));
93  composite->AddCommand(*cmd);
94  }
95  }
96  }
97 
98  if (se.IsSet()) {
99  FOR_EACH_SEQENTRY_ON_SEQSET(it, se.GetSet()) {
100  GetDesc(**it, scope, composite);
101  }
102  }
103 }
104 
105 template<typename T>
106 void CRemoveXrefs<T>::FindBioSource(objects::CSeq_entry_Handle tse, CRef<CCmdComposite> composite)
107 {
108  GetDesc(*(tse.GetCompleteSeq_entry()), tse.GetScope(), composite);
109 
110  for (objects::CFeat_CI feat_it(tse, objects::SAnnotSelector(objects::CSeqFeatData::e_Biosrc)); feat_it; ++feat_it) {
111  CRef<objects::CSeq_feat> new_feat(new objects::CSeq_feat());
112  new_feat->Assign(feat_it->GetOriginalFeature());
113  if (ChangeBioSource(new_feat->SetData().SetBiosrc())) {
114  CRef<CCmdChangeSeq_feat> cmd(new CCmdChangeSeq_feat(*feat_it, *new_feat));
115  composite->AddCommand(*cmd);
116  }
117  }
118 }
119 
120 class CRemoveDbXrefsFeats : public CRemoveXrefs<CRemoveDbXrefsFeats>
121 {
122 public:
123  static void rm_dbxref_from_feat(objects::CSeq_entry_Handle seh, objects::CSeqFeatData::E_Choice type, ICommandProccessor* cmd_processor);
124  static void ModifyFeature(CRef<objects::CSeq_feat> feat);
125 };
126 
127 class CRemoveDbXrefsBioSource : public CRemoveXrefs<CRemoveDbXrefsBioSource>
128 {
129 public:
130  static void rm_dbxref_from_biosource(objects::CSeq_entry_Handle seh, ICommandProccessor* cmd_processor);
131  static void ModifyBioSource(objects::CBioSource& biosource);
132 };
133 
134 class CRemoveDbXrefsBioSourceAndFeats : public CRemoveXrefs<CRemoveDbXrefsBioSourceAndFeats>
135 {
136 public:
137  static void rm_dbxref_from_biosource_and_feats(objects::CSeq_entry_Handle seh, ICommandProccessor* cmd_processor);
138 };
139 
140 
141 class CRemoveTaxonFeats : public CRemoveXrefs<CRemoveTaxonFeats>
142 {
143 public:
144  static void rm_taxon_from_feats(objects::CSeq_entry_Handle seh, ICommandProccessor* cmd_processor);
145  static void ModifyFeature(CRef<objects::CSeq_feat> feat);
146 };
147 
148 class CRemoveTaxonBioSource : public CRemoveXrefs<CRemoveTaxonBioSource>
149 {
150 public:
151  static void ModifyBioSource(objects::CBioSource& biosource);
152 };
153 
154 class CRemoveTaxonFeatsAndBioSource : public CRemoveXrefs<CRemoveTaxonFeatsAndBioSource>
155 {
156 public:
157  static void rm_taxon_from_feats_and_biosource(objects::CSeq_entry_Handle seh, ICommandProccessor* cmd_processor);
158 };
159 
161 
162 #endif // _REMOVE_XREFS_H_
void AddCommand(IEditCommand &command)
static void rm_dbxref_from_biosource_and_feats(objects::CSeq_entry_Handle seh, ICommandProccessor *cmd_processor)
static void rm_dbxref_from_biosource(objects::CSeq_entry_Handle seh, ICommandProccessor *cmd_processor)
static void ModifyBioSource(objects::CBioSource &biosource)
static void ModifyFeature(CRef< objects::CSeq_feat > feat)
static void rm_dbxref_from_feat(objects::CSeq_entry_Handle seh, objects::CSeqFeatData::E_Choice type, ICommandProccessor *cmd_processor)
static void ModifyBioSource(objects::CBioSource &biosource)
static void rm_taxon_from_feats_and_biosource(objects::CSeq_entry_Handle seh, ICommandProccessor *cmd_processor)
static void rm_taxon_from_feats(objects::CSeq_entry_Handle seh, ICommandProccessor *cmd_processor)
static void ModifyFeature(CRef< objects::CSeq_feat > feat)
static void GetDesc(const objects::CSeq_entry &se, objects::CScope &scope, CRef< CCmdComposite > composite)
static void FindFeatures(objects::CSeq_entry_Handle seh, objects::CSeqFeatData::E_Choice type, CRef< CCmdComposite > cmd)
static void FindBioSource(objects::CSeq_entry_Handle tse, CRef< CCmdComposite > composite)
static bool ChangeBioSource(objects::CBioSource &biosource)
static void ModifyBioSource(objects::CBioSource &biosource)
static void ModifyFeature(CRef< objects::CSeq_feat > feat)
Undo/Redo interface for editing operations.
Include a standard set of the NCBI C++ Toolkit most basic headers.
static CS_COMMAND * cmd
Definition: ct_dynamic.c:26
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
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
USING_SCOPE(objects)
#define FOR_EACH_SEQENTRY_ON_SEQSET(Itr, Var)
FOR_EACH_SEQENTRY_ON_SEQSET EDIT_EACH_SEQENTRY_ON_SEQSET.
#define FOR_EACH_SEQDESC_ON_SEQENTRY(Itr, Var)
FOR_EACH_SEQDESC_ON_SEQENTRY EDIT_EACH_SEQDESC_ON_SEQENTRY.
Definition: type.c:6
Modified on Mon Jun 17 05:04:20 2024 by modify_doxy.py rev. 669887