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

Go to the SVN repository for this file.

1 /* $Id: cmd_create_feat.cpp 42389 2019-02-13 19:05:46Z 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>
31 
32 #include <objmgr/seqdesc_ci.hpp>
33 #include <objmgr/seq_entry_ci.hpp>
34 #include <objmgr/feat_ci.hpp>
35 #include <objmgr/seq_annot_ci.hpp>
36 
38 
39 
42 
44 {
45  if (m_Feat->IsSetData() && m_Feat->GetData().IsCdregion() && m_Feat->IsSetProduct()) {
46  CBioseq_Handle bsh;
47  try {
48  bsh = m_seh.GetScope().GetBioseqHandle(m_Feat->GetLocation());
49  }
50  catch (const CException&) {
51  bsh = m_seh.GetScope().GetBioseqHandle(m_Feat->GetProduct());
52  }
53  if (bsh) {
54  CBioseq_set_Handle nuc_parent = bsh.GetParentBioseq_set();
55  if (nuc_parent && nuc_parent.IsSetClass() && nuc_parent.GetClass() == CBioseq_set::eClass_nuc_prot) {
56  m_seh = nuc_parent.GetParentEntry();
57  }
58  }
59  }
60 
63  for (; annot_ci; ++annot_ci) {
64  if ((*annot_ci).IsFtable()) {
65  ftable = *annot_ci;
66  break;
67  }
68  }
69 
70  CSeq_entry_EditHandle eh = m_seh.GetEditHandle();
71 
72  if (!ftable) {
73  CRef<CSeq_annot> new_annot(new CSeq_annot());
74  ftable = m_FTableCreated = eh.AttachAnnot(*new_annot);
75  }
76 
78  m_feh = aeh.AddFeat(*m_Feat);
79 }
80 
82 {
83  m_feh.Remove();
84 
85  if (m_FTableCreated) {
86  m_FTableCreated.Remove();
87  }
88 }
89 
91 {
92  return "Create Feature";
93 }
94 
96 {
97  CSeq_entry_Handle seh = m_bsh.GetSeq_entry_Handle();
98  return CIRef<IEditCommand>(new CCmdCreateFeat(seh, *m_Feat));
99 }
100 
102 {
103  return "Create Feature";
104 }
105 
CBioseq_Handle –.
CBioseq_set_Handle –.
virtual CIRef< IEditCommand > x_CreateActionCmd()
virtual string GetLabel()
CConstRef< objects::CSeq_feat > m_Feat
objects::CBioseq_Handle m_bsh
objects::CSeq_feat_EditHandle m_feh
objects::CSeq_entry_Handle m_seh
virtual string GetLabel()
virtual void Execute()
Do the editing action.
objects::CSeq_annot_EditHandle m_FTableCreated
CConstRef< objects::CSeq_feat > m_Feat
virtual void Unexecute()
Undo (opposite to Execute())
CSeq_annot_CI –.
CSeq_annot_Handle –.
CSeq_entry_Handle –.
CSeq_entry_Handle –.
USING_SCOPE(objects)
TClass GetClass(void) const
CBioseq_set_Handle GetParentBioseq_set(void) const
Return a handle for the parent Bioseq-set, or null handle.
CSeq_annot_EditHandle AttachAnnot(CSeq_annot &annot) const
Attach an annotation.
CSeq_feat_EditHandle AddFeat(const CSeq_feat &new_obj) const
CSeq_entry_Handle GetParentEntry(void) const
Return a handle for the parent seq-entry of the bioseq.
bool IsSetClass(void) const
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
@ eClass_nuc_prot
nuc acid and coded proteins
Definition: Bioseq_set_.hpp:99
#define ftable
Definition: utilfeat.h:37
Modified on Sat Mar 02 10:54:34 2024 by modify_doxy.py rev. 669887