NCBI C++ ToolKit
include
objects
seqset
gb_release_file.hpp
Go to the documentation of this file.
Go to the SVN repository for this file.
1
#ifndef UTILS___GB_RELEASE_FILE__HPP
2
#define UTILS___GB_RELEASE_FILE__HPP
3
4
/* $Id: gb_release_file.hpp 97745 2022-08-22 15:10:59Z 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
* File Description:
31
* Utility class for processing Genbank release files.
32
*/
33
34
#include <
corelib/ncbistd.hpp
>
35
#include <
objects/seqset/Seq_entry.hpp
>
36
37
38
BEGIN_NCBI_SCOPE
39
USING_SCOPE
(
objects
);
40
41
/// forward decleration
42
class
CGBReleaseFileImpl
;
43
44
45
/// CGBReleaseFile is a utility class to ease the processing of Genbank
46
/// release files one Seq-entry at a time.
47
/// It shields the user from the underlying I/O hook mechanism.
48
///
49
/// Usage:
50
/// 1. Implement ISeqEntryHandler interface
51
/// 2. Create a CGBReleaseFile with the release file's name
52
/// 3. Register the handler object.
53
/// 4. Call Read(..), the handling method will be called for each Seq-entry.
54
55
/* Another way of using CGBReleaseFile is to use lamba function
56
The example should look like:
57
CGBReleaseFile gbfile(filename);
58
gbfile.RegisterHandler([&your_captcha](CRef<CSeq_entry>& entry) -> bool)
59
{
60
bool success = your_captcha.ProcessEntry(entry);
61
return success;
62
});
63
*/
64
65
class
NCBI_SEQSET_EXPORT
CGBReleaseFile
66
{
67
public
:
68
69
/// Interface for handling Seq-entry objects
70
class
ISeqEntryHandler
71
{
72
public
:
73
/// user code for handling a Seq-entry goes here.
74
/// The return value indicates whethear to continue (true),
75
/// or abort (false) the read.
76
virtual
bool
HandleSeqEntry
(
CRef<CSeq_entry>
& entry) = 0;
77
virtual
~ISeqEntryHandler
(
void
) {};
78
};
79
// alternate approach via lambda or unnamed functions
80
using
TSeqEntryHandler
=std::function<
bool
(
CRef<CSeq_entry>
&)>;
81
82
/// constructors
83
CGBReleaseFile
(
const
string
&
file_name
,
bool
propagate=
false
);
84
85
/// Build a release file on a pre-established object stream
86
/// NOTE: this constructor will take ownership of the object, and it will
87
/// be deleted with this class.
88
CGBReleaseFile
(
CObjectIStream
&
in
,
bool
propagate=
false
);
89
90
/// destructor
91
virtual
~
CGBReleaseFile
(
void
);
92
93
/// Register handler
94
void
RegisterHandler(
ISeqEntryHandler
*
handler
);
95
void
RegisterHandler(
TSeqEntryHandler
handler
);
96
97
/// Read the release file
98
void
Read
(
void
);
99
100
private
:
101
102
CGBReleaseFileImpl
& x_GetImpl(
void
);
103
CRef<CObject>
m_Impl
;
104
};
105
106
107
END_NCBI_SCOPE
108
109
#endif
/// UTILS___GB_RELEASE_FILE__HPP
Seq_entry.hpp
CGBReleaseFileImpl
Definition:
gb_release_file.cpp:54
CGBReleaseFile::ISeqEntryHandler
Interface for handling Seq-entry objects.
Definition:
gb_release_file.hpp:71
CGBReleaseFile::ISeqEntryHandler::~ISeqEntryHandler
virtual ~ISeqEntryHandler(void)
Definition:
gb_release_file.hpp:77
CGBReleaseFile::ISeqEntryHandler::HandleSeqEntry
virtual bool HandleSeqEntry(CRef< CSeq_entry > &entry)=0
user code for handling a Seq-entry goes here.
CGBReleaseFile
CGBReleaseFile is a utility class to ease the processing of Genbank release files one Seq-entry at a ...
Definition:
gb_release_file.hpp:66
CGBReleaseFile::m_Impl
CRef< CObject > m_Impl
Definition:
gb_release_file.hpp:103
CGBReleaseFile::TSeqEntryHandler
std::function< bool(CRef< CSeq_entry > &)> TSeqEntryHandler
Definition:
gb_release_file.hpp:80
CObjectIStream
CObjectIStream –.
Definition:
objistr.hpp:93
CRef< CSeq_entry >
handler
void(*)(CSeq_entry_Handle seh, IWorkbench *wb, const CSerialObject &obj) handler
Definition:
common_commands.cpp:295
ncbistd.hpp
Include a standard set of the NCBI C++ Toolkit most basic headers.
file_name
const char * file_name[]
Definition:
dbapi_bcp_util.hpp:35
bool
#define bool
Definition:
bool.h:34
USING_SCOPE
USING_SCOPE(objects)
Read
void Read(CObjectIStream &in, TObjectPtr object, const CTypeRef &type)
Definition:
serial.cpp:60
END_NCBI_SCOPE
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition:
ncbistl.hpp:103
BEGIN_NCBI_SCOPE
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition:
ncbistl.hpp:100
NCBI_SEQSET_EXPORT
#define NCBI_SEQSET_EXPORT
Definition:
ncbi_export.h:793
objects
Definition:
wiggle_export_job.hpp:44
in
std::istream & in(std::istream &in_, double &x_)
Generated by
1.9.0
Modified on Fri Sep 20 14:57:02 2024 by modify_doxy.py rev. 669887