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

Go to the SVN repository for this file.

1 /* $Id: cmd_del_seq_feat.cpp 47378 2023-02-27 20:09:44Z 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: Roman Katargin
27  */
28 
29 
30 #include <ncbi_pch.hpp>
32 #include <objmgr/bio_object_id.hpp>
33 #include <objmgr/seq_annot_ci.hpp>
34 #include <objmgr/feat_ci.hpp>
35 #include <objmgr/bioseq_ci.hpp>
36 
39 
41 {
42  if (m_Orig_feat) {
43  if (m_Orig_feat.IsRemoved())
44  return;
45 
47  m_Saved_feat->Assign(*m_Orig_feat.GetOriginalSeq_feat());
48 
49  m_aeh = m_Orig_feat.GetAnnot().GetEditHandle();
50  m_Parent_handle = m_aeh.GetParentEntry();
51  m_GrandParent_handle = m_Parent_handle.GetParentEntry();
52 
54  feh.Remove();
55  const auto& feat_list = m_aeh.GetSeq_annotCore()->GetData().GetFtable();
56  if (feat_list.empty()) {
57  m_aeh.Remove();
58  }
59  }
60 }
61 
63 {
64  if (!m_Orig_feat.IsRemoved())
65  return;
66 
67  if (m_Saved_feat)
68  {
69  if (!m_aeh.IsRemoved())
70  {
71  m_Orig_feat = m_aeh.AddFeat(*m_Saved_feat);
72  }
73  else
74  {
75  if (!m_Parent_handle) // When there was a delete bioseq command in between which performed a conversion of nuc-prot set to seq and back the entry handle is missing sometimes for an unknown reason
76  {
78  while (seq_ci)
79  {
80  if (seq_ci->IsNa())
81  {
83  break;
84  }
85  ++seq_ci;
86  }
87  }
88 
89  CSeq_annot_EditHandle aeh = m_Parent_handle.AttachAnnot(m_aeh);
91  }
92 
94  }
95 }
96 
98 {
99  return "Delete feature";
100 }
101 
102 
CBioseq_CI –.
Definition: bioseq_ci.hpp:69
objects::CSeq_entry_EditHandle m_Parent_handle
virtual void Unexecute()
Undo (opposite to Execute())
virtual void Execute()
Do the editing action.
objects::CSeq_annot_EditHandle m_aeh
objects::CSeq_entry_EditHandle m_GrandParent_handle
objects::CSeq_feat_Handle m_Orig_feat
virtual string GetLabel()
CRef< objects::CSeq_feat > m_Saved_feat
CSeq_feat_EditHandle –.
namespace ncbi::objects::
Definition: Seq_feat.hpp:58
USING_SCOPE(objects)
CSeq_entry_Handle GetSeq_entry_Handle(void) const
Get parent Seq-entry handle.
void Remove(void) const
Remove the feature from Seq-annot.
CSeq_feat_EditHandle AddFeat(const CSeq_feat &new_obj) const
CSeq_entry_EditHandle GetEditHandle(void) const
Get 'edit' version of handle.
bool IsNa(void) const
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
Modified on Sun Mar 03 03:13:18 2024 by modify_doxy.py rev. 669887