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

Go to the SVN repository for this file.

1 /* $Id: bedgraph_writer.hpp 93574 2021-04-30 16:19:19Z stakhovv $
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: Frank Ludwig
27  *
28  * File Description: Formatter, Genbank to BED.
29  *
30  */
31 
32 #ifndef OBJTOOLS_WRITERS___BEDGRAPH_WRITER__HPP
33 #define OBJTOOLS_WRITERS___BEDGRAPH_WRITER__HPP
34 
37 
39 BEGIN_objects_SCOPE
40 
41 // ============================================================================
42 /// CWriterBase implementation that will render given Genbank objects in the
43 /// BED file format (http://http://genome.ucsc.edu/FAQ/FAQformat#format1).
44 ///
45 /// When assigned from typical Genbank annotations, only locations will be
46 /// generated. Multi-interval Genbank features will be broken up into multiple
47 /// single interval BED feature records. Block parameters could be used to
48 /// encode multi-interval BED records but this is currently not supported.
49 /// [[I will ad support though upon request]]
50 ///
52  public CWriterBase
53 // ============================================================================
54 {
55 public:
56  /// Constructor.
57  /// @param scope
58  /// scope to be used for ID reference resolution (it's OK to create one
59  /// on the fly).
60  /// @param ostr
61  /// stream objects should be written to.
62  /// @param colCount
63  /// number of columns per output record. Each record in a BED file must
64  /// have the same number of columns. Hence the writer will truncate or
65  /// extend all records to colCount output columns.
66  /// @param flags
67  /// any output customization flags.
68  ///
70  CScope& scope,
71  CNcbiOstream& ostr,
72  unsigned int colCount=12,
73  unsigned int flags=fNormal );
74 
75  virtual ~CBedGraphWriter();
76 
77  /// Write a raw Seq-annot to the internal output stream.
78  /// The Seq-annot is expected to contain a feature table. If so, each
79  /// feature will to formatted as a single BED record.
80  /// @param annot
81  /// the Seq-annot object to be written.
82  /// @param name
83  /// parameter describing the object. Handling will be format specific
84  /// @param descr
85  /// parameter describing the object. Handling will be format specific
86  /// @return
87  /// true if the Seq-annot was processed.
88  /// false if the Seq-annot did not contain a feature table.
89  ///
90  bool WriteAnnot(
91  const CSeq_annot&,
92  const string& = "",
93  const string& = "");
94 
95 protected:
96  bool xWriteAnnotGraphs(
97  const CBedTrackRecord&,
98  const CSeq_annot&);
99 
100  bool xWriteSingleGraph(
101  const CBedTrackRecord&,
102  const CSeq_graph&);
103 
104  bool xWriteSingleGraphInt(
105  const CBedTrackRecord&,
106  const CSeq_graph&);
107 
108  bool xWriteSingleGraphReal(
109  const CBedTrackRecord&,
110  const CSeq_graph&);
111 
112  bool xWriteSingleGraphByte(
113  const CBedTrackRecord&,
114  const CSeq_graph&);
115 
116 
117  bool xWriteAnnotFeatureTable(
118  const CBedTrackRecord&,
119  const CSeq_annot&);
120 
121  bool xWriteSingleFeature(
122  const CBedTrackRecord&,
123  const CSeq_feat&);
124 
125 
126  bool xWriteAnnotSeqTable(
127  const CBedTrackRecord&,
128  const CSeq_annot&);
129 
131  unsigned int m_colCount;
132 };
133 
134 END_objects_SCOPE
136 
137 #endif // OBJTOOLS_WRITERS___BEDGRAPH_WRITER__HPP
CWriterBase implementation that will render given Genbank objects in the BED file format (http://http...
unsigned int m_colCount
Encapsulation of a track line in the BED file format.
CScope –.
Definition: scope.hpp:92
namespace ncbi::objects::
Definition: Seq_feat.hpp:58
Defines and provides stubs for a general interface to a variety of file formatters.
Definition: writer.hpp:81
virtual bool WriteAnnot(const CSeq_annot &, const string &="", const string &="")
Write a raw Seq-annot to the internal output stream.
Definition: writer.hpp:116
static uch flags
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
IO_PREFIX::ostream CNcbiOstream
Portable alias for ostream.
Definition: ncbistre.hpp:149
#define NCBI_XOBJWRITE_EXPORT
Definition: ncbi_export.h:1347
Modified on Tue May 28 05:49:55 2024 by modify_doxy.py rev. 669887