NCBI C++ ToolKit
flat_file_generator.hpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 #ifndef OBJTOOLS_FORMAT___FLAT_FILE_GENERATOR__HPP
2 #define OBJTOOLS_FORMAT___FLAT_FILE_GENERATOR__HPP
3 
4 /* $Id: flat_file_generator.hpp 100571 2023-08-11 13:06:42Z gotvyans $
5 * ===========================================================================
6 *
7 * PUBLIC DOMAIN NOTICE
8 * National Center for Biotechnology Information
9 *
10 * This software/database is a "United States Government Work" under the
11 * terms of the United States Copyright Act. It was written as part of
12 * the author's official duties as a United States Government employee and
13 * thus cannot be copyrighted. This software/database is freely available
14 * to the public for use. The National Library of Medicine and the U.S.
15 * Government have not placed any restriction on its use or reproduction.
16 *
17 * Although all reasonable efforts have been taken to ensure the accuracy
18 * and reliability of the software and data, the NLM and the U.S.
19 * Government do not and cannot warrant the performance or results that
20 * may be obtained by using this software or data. The NLM and the U.S.
21 * Government disclaim all warranties, express or implied, including
22 * warranties of performance, merchantability or fitness for any particular
23 * purpose.
24 *
25 * Please cite the author in any work or product based on this material.
26 *
27 * ===========================================================================
28 *
29 * Author: Mati Shomrat
30 *
31 * File Description:
32 * User interface for generating flat file reports from ASN.1
33 *
34 */
35 #include <corelib/ncbistd.hpp>
36 #include <corelib/ncbiobj.hpp>
37 
41 
42 
45 
46 
47 class IFlatTextOStream;
48 class CFlatItemOStream;
49 class CSeq_submit;
50 class CSeq_entry;
51 class CBioseq;
52 class CSeq_loc;
53 class CSeq_entry_Handle;
54 class CBioseq_Handle;
55 class CSeq_id;
56 
57 
59 {
60  CNcbiOstream* m_Os; // all sequence output stream
61  CNcbiOstream* m_On; // nucleotide output stream
62  CNcbiOstream* m_Og; // genomic output stream
63  CNcbiOstream* m_Or; // RNA output stream
64  CNcbiOstream* m_Op; // protein output stream
65  CNcbiOstream* m_Ou; // unknown output stream
66 
67  multiout(CNcbiOstream* os = nullptr, CNcbiOstream* on = nullptr, CNcbiOstream* og = nullptr,
68  CNcbiOstream* or_ = nullptr, CNcbiOstream* op = nullptr, CNcbiOstream* ou = nullptr) :
69  m_Os(os), m_On(on), m_Og(og), m_Or(or_), m_Op(op), m_Ou(ou)
70  {
71  }
72  operator bool() const { return m_Os || m_On || m_Og || m_Or || m_Op || m_Ou; }
73 };
74 
76 {
77 public:
78  // types
80 
81  // constructors
89  CFlatFileConfig::TCustom custom = 0,
91 
92  // destructor
93  ~CFlatFileGenerator(void);
94 
95  // Supply an annotation selector to be used in feature gathering.
96  SAnnotSelector& SetAnnotSelector(void);
97 
98  void SetFeatTree(feature::CFeatTree* tree);
99 
100  void SetSeqEntryIndex(CRef<CSeqEntryIndex> idx);
101  void ResetSeqEntryIndex(void);
102 
103  void Generate(const CSeq_entry_Handle& entry, CFlatItemOStream& item_os, const multiout& = {});
104  void Generate(const CSeq_entry_Handle& entry, CNcbiOstream& os, const multiout& = {});
105  void Generate(const CBioseq_Handle& bsh, CNcbiOstream& os, const multiout& = {});
106  void Generate(const CSeq_submit& submit, CScope& scope, CNcbiOstream& os, const multiout& = {});
107  void Generate(const CBioseq& bioseq, CScope& scope, CNcbiOstream& os, const multiout& = {});
108  void Generate(const CSeq_loc& loc, CScope& scope, CNcbiOstream& os, const multiout& = {});
109  void Generate(const CSeq_id& id, const TRange& range, ENa_strand strand,
110  CScope& scope, CNcbiOstream& os, const multiout& = {});
111 
112  // for use when generating a range of a Seq-submit
113  void SetSubmit(const CSubmit_block& sub) { m_Ctx->SetSubmit(sub); }
114 
115  static string GetSeqFeatText(const CMappedFeat& feat, CScope& scope,
116  const CFlatFileConfig& cfg, CRef<feature::CFeatTree> ftree = null);
117 
118  void x_GetLocation(const CSeq_entry_Handle& entry,
119  TSeqPos from, TSeqPos to, ENa_strand strand, CSeq_loc& loc);
120  CBioseq_Handle x_DeduceTarget(const CSeq_entry_Handle& entry);
121 
122  bool Failed() { return m_Failed; }
123 
124  //void Reset(void);
125 
126  void SetConfig(const CFlatFileConfig& cfg);
127 
128 protected:
130  bool m_Failed;
131 
132  /// Use this class to wrap CFlatItemOStream instances so that they
133  /// check if canceled for every item added
135  {
136  public:
138  CFlatItemOStream & underlying,
139  const ICanceled* pCanceledCallback )
140  : m_pUnderlying(&underlying),
141  m_pCanceledCallback(pCanceledCallback)
142  { }
143 
144  virtual void SetFormatter(IFormatter* formatter);
145  virtual void AddItem (CConstRef<IFlatItem> item);
146 
147  private:
149  // Raw pointer because we do NOT own it
151  };
152 
153  // forbidden
156 };
157 
158 
161 
162 #endif /* OBJTOOLS_FORMAT___FLAT_FILE_GENERATOR__HPP */
CBioseq_Handle –.
CConstRef –.
Definition: ncbiobj.hpp:1266
unsigned int TCustom
Use this class to wrap CFlatItemOStream instances so that they check if canceled for every item added...
CCancelableFlatItemOStreamWrapper(CFlatItemOStream &underlying, const ICanceled *pCanceledCallback)
CFlatFileGenerator & operator=(const CFlatFileGenerator &)
void SetSubmit(const CSubmit_block &sub)
CRange< TSeqPos > TRange
CFlatFileGenerator(const CFlatFileGenerator &)
CRef< CFlatFileContext > m_Ctx
CMappedFeat –.
Definition: mapped_feat.hpp:59
CObject –.
Definition: ncbiobj.hpp:180
CScope –.
Definition: scope.hpp:92
CSeq_entry_Handle –.
Definition: Seq_entry.hpp:56
CSubmit_block –.
Interface for testing cancellation request in a long lasting operation.
Definition: icanceled.hpp:51
Include a standard set of the NCBI C++ Toolkit most basic headers.
static uch flags
#define bool
Definition: bool.h:34
unsigned int TSeqPos
Type for sequence locations and lengths.
Definition: ncbimisc.hpp:875
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define END_SCOPE(ns)
End the previously defined scope.
Definition: ncbistl.hpp:75
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
#define BEGIN_SCOPE(ns)
Define a new scope.
Definition: ncbistl.hpp:72
IO_PREFIX::ostream CNcbiOstream
Portable alias for ostream.
Definition: ncbistre.hpp:149
#define NCBI_FORMAT_EXPORT
Definition: ncbi_export.h:496
ENa_strand
strand of nucleic acid
Definition: Na_strand_.hpp:64
range(_Ty, _Ty) -> range< _Ty >
mdb_mode_t mode
Definition: lmdb++.h:38
Portable reference counted smart and weak pointers using CWeakRef, CRef, CObject and CObjectEx.
static Format format
Definition: njn_ioutil.cpp:53
SAnnotSelector –.
CNcbiOstream * m_Or
CNcbiOstream * m_On
multiout(CNcbiOstream *os=nullptr, CNcbiOstream *on=nullptr, CNcbiOstream *og=nullptr, CNcbiOstream *or_=nullptr, CNcbiOstream *op=nullptr, CNcbiOstream *ou=nullptr)
CNcbiOstream * m_Os
CNcbiOstream * m_Op
CNcbiOstream * m_Ou
CNcbiOstream * m_Og
Modified on Sat Apr 20 12:22:41 2024 by modify_doxy.py rev. 669887