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

Go to the SVN repository for this file.

1 /* $Id: update_replaced_ec_numbers.cpp 32177 2015-01-14 22:33:07Z 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>
31 #include <wx/msgdlg.h>
33 
36 
37 void CUpdateReplacedECNumbers::apply(objects::CSeq_entry_Handle tse, ICommandProccessor* cmdProcessor, string title)
38 {
39  if (tse)
40  {
42  bool ask_about_invalid = false;
43  bool remove_invalid = false;
44  bool ask_about_unknown = false;
45  bool remove_unknown = false;
46  for (CFeat_CI feat_ci(tse, SAnnotSelector(CSeqFeatData::e_Prot)); feat_ci; ++feat_ci)
47  {
48  const CSeq_feat& orig = feat_ci->GetOriginalFeature();
49 
50  if (orig.IsSetData() && orig.GetData().IsProt())
51  {
52  if (!orig.GetData().GetProt().IsSetEc())
53  continue;
54 
55  CRef<CSeq_feat> new_feat(new CSeq_feat());
56  new_feat->Assign(orig);
57 
58  bool modified = false;
59  CProt_ref::TEc::iterator it = new_feat->SetData().SetProt().SetEc().begin();
60  while (it != new_feat->SetData().SetProt().SetEc().end())
61  {
63  string ec = *it;
65  if (!is_valid)
66  {
67  if (!ask_about_invalid)
68  {
69  int answer = wxMessageBox (_("Remove invalid EC numbers?"), _("Delete Invalid"), wxYES_NO | wxICON_QUESTION);
70  remove_invalid = (answer == wxYES);
71  ask_about_invalid = true;
72  }
73  }
74  else
75  {
76  while (status == CProt_ref::eEC_replaced)
77  {
79  status = CProt_ref::GetECNumberStatus(ec);
80  }
81 
82  if (status == CProt_ref::eEC_unknown)
83  {
84  if (!ask_about_unknown)
85  {
86  int answer = wxMessageBox (_("Remove unknown EC numbers?"), _("Delete Unknown"), wxYES_NO | wxICON_QUESTION);
87  remove_unknown = (answer == wxYES);
88  ask_about_unknown = true;
89  }
90  }
91  }
92 
93  if ((!is_valid && ask_about_invalid && remove_invalid) || (is_valid && ask_about_unknown && remove_unknown && status == CProt_ref::eEC_unknown) || (is_valid && status == CProt_ref::eEC_deleted))
94  {
95  it = new_feat->SetData().SetProt().SetEc().erase(it);
96  modified = true;
97  }
98  else
99  {
100  if (ec != *it)
101  {
102  *it = ec;
103  modified = true;
104  }
105  ++it;
106  }
107  }
108  if (new_feat->SetData().SetProt().SetEc().empty())
109  {
110  new_feat->SetData().SetProt().ResetEc();
111  }
112 
113  if (modified)
114  cmd->AddCommand(*CRef<CCmdChangeSeq_feat>(new CCmdChangeSeq_feat(feat_ci->GetSeq_feat_Handle(), *new_feat)));
115  }
116  }
117  cmdProcessor->Execute(cmd);
118  }
119 }
120 
121 
CFeat_CI –.
Definition: feat_ci.hpp:64
static bool IsValidECNumberFormat(const string &ecno)
Verify correct form of EC number.
Definition: Prot_ref.cpp:257
static const string & GetECNumberReplacement(const string &old_ecno)
Return a replaced EC number's replacement.
Definition: Prot_ref.cpp:204
EECNumberStatus
Enzyme Commission number status.
Definition: Prot_ref.hpp:63
@ eEC_replaced
Obsolete synonym for some other EC number.
Definition: Prot_ref.hpp:66
@ eEC_unknown
Unrecognized; possibly malformed.
Definition: Prot_ref.hpp:68
@ eEC_deleted
Withdrawn, with no (single?) replacement.
Definition: Prot_ref.hpp:67
static EECNumberStatus GetECNumberStatus(const string &ecno)
Determine an EC number's validity and specificity.
Definition: Prot_ref.cpp:190
namespace ncbi::objects::
Definition: Seq_feat.hpp:58
void apply(CSeq_entry_Handle tse, ICommandProccessor *cmdProcessor, string title)
Undo/Redo interface for editing operations.
virtual void Execute(IEditCommand *command, wxWindow *window=0)=0
static bool is_valid(const char *num, int type, CONV_RESULT *cr)
#define _(proto)
Definition: ct_nlmzip_i.h:78
static CS_COMMAND * cmd
Definition: ct_dynamic.c:26
virtual void Assign(const CSerialObject &source, ESerialRecursionMode how=eRecursive)
Set object to copy of another one.
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
void SetData(TData &value)
Assign a value to Data data member.
Definition: Seq_feat_.cpp:94
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
SAnnotSelector –.
USING_SCOPE(objects)
Modified on Wed Jul 24 17:22:22 2024 by modify_doxy.py rev. 669887