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

Go to the SVN repository for this file.

1 /* $Id: cmd_change_bioseq_set.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: Colleen Bollin and Roman Katargin
27  */
28 
29 
30 #include <ncbi_pch.hpp>
34 #include <objmgr/seq_entry_ci.hpp>
36 #include <objmgr/seq_annot_ci.hpp>
38 
41 
43  : m_BH(bh)
44 {
45  m_Set.Reset(new CBioseq_set());
46  m_Set->Assign(new_set);
47 }
48 
50 {
51  CRef<CBioseq_set> saveSet(new CBioseq_set());
52  saveSet->Assign(*m_BH.GetCompleteBioseq_set());
53 
54  CBioseq_set_EditHandle eh = m_BH.GetEditHandle();
55 
56  if (m_Set->CanGetId()) eh.SetId(m_Set->SetId());
57  else eh.ResetId();
58  if (m_Set->CanGetColl()) eh.SetColl(m_Set->SetColl());
59  else eh.ResetColl();
60  if (m_Set->CanGetLevel()) eh.SetLevel(m_Set->GetLevel());
61  else eh.ResetLevel();
62  if (m_Set->CanGetClass()) eh.SetClass(m_Set->GetClass()); // Level and Class are passed by value. Everything else is passed by reference.
63  else eh.ResetClass();
64  if (m_Set->CanGetRelease()) eh.SetRelease(m_Set->SetRelease());
65  else eh.ResetRelease();
66  if (m_Set->CanGetDate()) eh.SetDate(m_Set->SetDate());
67  else eh.ResetDate();
68  if (m_Set->CanGetDescr()) eh.SetDescr(m_Set->SetDescr());
69  else eh.ResetDescr();
70 
71 
72  // The following has been copied from objtools/cleanup/newcleanupp.cpp
73  while( ! RAW_FIELD_IS_EMPTY_OR_UNSET( *m_BH.GetCompleteBioseq_set(), Seq_set ) ) {
74  CSeq_entry_CI entry_ci( m_BH );
75  CSeq_entry_EditHandle( *entry_ci ).Remove();
76  }
77  EDIT_EACH_SEQENTRY_ON_SEQSET( entry_iter, *m_Set ) {
78  eh.AttachEntry( **entry_iter );
79  }
80 
81  while( ! RAW_FIELD_IS_EMPTY_OR_UNSET( *m_BH.GetCompleteBioseq_set(), Annot ) ) {
82  CSeq_annot_CI annot_ci( m_BH );
83  CSeq_annot_EditHandle( *annot_ci ).Remove();
84  }
85  EDIT_EACH_SEQANNOT_ON_SEQSET( annot_iter, *m_Set ) {
86  eh.AttachAnnot( **annot_iter );
87  }
88 
89  m_Set = saveSet;
90 }
91 
93 {
94  Execute();
95 }
96 
98 {
99  return "Modify Bioseq_set";
100 }
101 
102 
103 
CBioseq_set_EditHandle –.
CBioseq_set_Handle –.
CCmdChangeBioseqSet(const objects::CBioseq_set_Handle &bh, const objects::CBioseq_set &new_set)
objects::CBioseq_set_Handle m_BH
virtual void Execute()
Do the editing action.
virtual void Unexecute()
Undo (opposite to Execute())
CRef< objects::CBioseq_set > m_Set
CSeq_annot_CI –.
CSeq_entry_CI –.
CSeq_entry_Handle –.
USING_SCOPE(objects)
virtual void Assign(const CSerialObject &source, ESerialRecursionMode how=eRecursive)
Set object to copy of another one.
void SetDescr(TDescr &v) const
void SetRelease(TRelease &v) const
void Remove(void) const
Remove current annot.
void SetClass(TClass v) const
void Remove(void) const
Remove this Seq-entry from parent, or scope if it's top level Seq-entry.
void SetId(TId &id) const
void SetColl(TColl &v) const
void SetLevel(TLevel v) const
CSeq_entry_EditHandle AttachEntry(CSeq_entry &entry, int index=-1) const
Attach an existing seq-entry.
void ResetRelease(void) const
CSeq_annot_EditHandle AttachAnnot(CSeq_annot &annot) const
Attach an annotation.
void SetDate(TDate &v) 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
#define EDIT_EACH_SEQENTRY_ON_SEQSET(Itr, Var)
#define EDIT_EACH_SEQANNOT_ON_SEQSET(Itr, Var)
#define RAW_FIELD_IS_EMPTY_OR_UNSET(Var, Fld)
RAW_FIELD_IS_EMPTY_OR_UNSET macro.
Modified on Mon Mar 04 05:11:30 2024 by modify_doxy.py rev. 669887