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

Go to the SVN repository for this file.

1 /* $Id: editing_action_misc.cpp 45101 2020-05-29 20:53:24Z 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 #include <ncbi_pch.hpp>
31 #include <objmgr/bioseq_ci.hpp>
35 #include <objects/seq/Seq_data.hpp>
42 
43 
46 
47 
49  : IEditingAction(seh, name)
50 {
51 }
52 
54 {
55  if (!m_TopSeqEntry)
56  return;
57  size_t count = 0;
58  for (CBioseq_CI b_iter(m_TopSeqEntry, objects::CSeq_inst::eMol_na); b_iter; ++b_iter)
59  {
60  CBioseq_Handle bsh = *b_iter;
62  if (m_constraint->Match(bsh))
63  {
64  m_flat_file.clear();
65  CConstRef<CBioseq> bioseq = bsh.GetBioseqCore();
66  if (bioseq)
67  {
68  // generate flat file without the features and sequence for the bioseq
69  try {
70  CFlatFileConfig cfg;
71  cfg.SetFormatGenbank();
72  cfg.SetModeGBench();
73  cfg.SetStyleNormal();
81  CNcbiOstrstream ostr;
82  ffgen->Generate(*bioseq, bsh.GetScope(), ostr);
84  }
85  catch (const CFlatException& e) {
86  LOG_POST("Failed to generate flat file: " << e.GetMsg());
87  m_flat_file.clear();
88  }
89  Modify(action);
90  }
91  }
92  ++count;
93  if (count >= m_max_records)
94  break;
95  }
96 }
97 
99 {
100  Find(action);
101 }
102 
104 {
105  Action(action);
106 }
107 
109 {
110  CEditingActionFlatFile *other = dynamic_cast<CEditingActionFlatFile*>(m_Other);
111  if (other)
112  return true;
113  return false;
114 }
115 
117 {
118  CEditingActionFlatFile *ff_source = dynamic_cast<CEditingActionFlatFile*>(source);
119  if (ff_source)
120  {
121  swap(m_flat_file, ff_source->m_flat_file);
122  }
124 }
125 
127 {
128  return !m_flat_file.empty();
129 }
130 
132 {
133 }
134 
136 {
137  return m_flat_file;
138 }
139 
141 {
142 }
143 
144 
146 {
147  if (field == "GenBank FlatFile")
148  return new CEditingActionFlatFile(seh);
149 
150  return NULL;
151 }
152 
153 
154 
156 
CBioseq_CI –.
Definition: bioseq_ci.hpp:69
CBioseq_Handle –.
virtual bool Match(const string &value)
virtual void ResetValue(void)
virtual void Modify(EActionType action)
virtual string GetValue(void)
virtual void SetValue(const string &value)
CEditingActionFlatFile(CSeq_entry_Handle seh, const string &name="CEditingActionFlatFile")
virtual void SwapContext(IEditingAction *source)
virtual void FindRelated(EActionType action)
virtual bool IsSetValue(void)
virtual void Find(EActionType action)
void SetFormatGenbank(void)
void SkipGenbankBlock(FGenbankBlocks fTGenbankBlocksMask)
void SetStyleNormal(void)
void SetModeGBench(void)
void Generate(const CSeq_entry_Handle &entry, CFlatItemOStream &item_os, const multiout &={})
CNcbiOstrstreamToString class helps convert CNcbiOstrstream to a string Sample usage:
Definition: ncbistre.hpp:802
CSeq_entry_Handle –.
CSeq_entry_Handle m_TopSeqEntry
IEditingAction * m_Other
CSeq_entry_Handle m_CurrentSeqEntry
void Action(EActionType action)
virtual void SwapContext(IEditingAction *source)
CRef< CEditingActionConstraint > m_constraint
USING_SCOPE(objects)
IEditingAction * CreateActionMisc(CSeq_entry_Handle seh, const string &field)
void swap(NCBI_NS_NCBI::pair_base_member< T1, T2 > &pair1, NCBI_NS_NCBI::pair_base_member< T1, T2 > &pair2)
Definition: ncbimisc.hpp:1508
#define NULL
Definition: ncbistd.hpp:225
#define LOG_POST(message)
This macro is deprecated and it's strongly recomended to move in all projects (except tests) to macro...
Definition: ncbidiag.hpp:226
const string & GetMsg(void) const
Get message string.
Definition: ncbiexpt.cpp:461
TBioseqCore GetBioseqCore(void) const
Get bioseq core structure.
CSeq_entry_Handle GetSeq_entry_Handle(void) const
Get parent Seq-entry handle.
CScope & GetScope(void) const
Get scope this handle belongs to.
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
bool IsOssEmpty(CNcbiOstrstream &oss)
Definition: ncbistre.hpp:831
#define kEmptyStr
Definition: ncbistr.hpp:123
const GenericPointer< typename T::ValueType > T2 value
Definition: pointer.h:1227
const CharType(& source)[N]
Definition: pointer.h:1149
The Object manager core.
Utility macros and typedefs for exploring NCBI objects from seq.asn.
Modified on Sun May 05 05:23:20 2024 by modify_doxy.py rev. 669887