OpenMS
Loading...
Searching...
No Matches
UniProtXMLHandler.h
Go to the documentation of this file.
1// Copyright (c) 2002-present, OpenMS Inc. -- EKU Tuebingen, ETH Zurich, and FU Berlin
2// SPDX-License-Identifier: BSD-3-Clause
3//
4// --------------------------------------------------------------------------
5// $Maintainer: Timo Sachsenberg $
6// $Authors: Timo Sachsenberg $
7// --------------------------------------------------------------------------
8
9#pragma once
10
12#include "UniProtXMLFile.h"
13
14#include <functional>
15#include <string>
16
17namespace OpenMS::Internal
18{
32 public XMLHandler
33 {
34 public:
38 using EntryCallback = std::function<void(UniProtEntry&&)>;
39
54
56 UniProtXMLHandler(const std::string& filename, EntryCallback callback);
57
60
61 void onStartElement(const char16_t* qname, const XMLAttributes& attrs) override;
62 void onEndElement(const char16_t* qname) override;
63 void onCharacters(const char16_t* chars, Size length) override;
64
65 private:
68
70 int depth_{0};
71
75 int entry_depth_{0};
77 int gene_depth_{0};
82
86
88 std::string char_buf_;
89
92
95
100
102 void resetEntry_();
104 void resetFeature_();
105
108 static int parsePosition_(const std::string& attr);
109 };
110
111} // namespace OpenMS::Internal
SAX handler for UniProtKB XML <entry> documents.
Definition UniProtXMLHandler.h:33
int depth_
Depth of the most recent element start, used to scope subtree handling.
Definition UniProtXMLHandler.h:70
void onStartElement(const char16_t *qname, const XMLAttributes &attrs) override
Parsing method for opening tags.
Definition UniProtXMLHandler.cpp:149
std::string char_buf_
Buffer for character data; appended-to in characters(), consumed in endElement().
Definition UniProtXMLHandler.h:88
~UniProtXMLHandler() override
Destructor.
bool gene_name_is_primary_
Whether the next <name> encountered inside the current <gene> subtree is a primary name.
Definition UniProtXMLHandler.h:97
void resetFeature_()
Clear all per-feature state so the next <feature> starts fresh.
Definition UniProtXMLHandler.cpp:132
int organism_depth_
<organism>
Definition UniProtXMLHandler.h:78
bool organism_name_is_scientific_
Whether the next <name> encountered inside the current <organism> subtree is the scientific name.
Definition UniProtXMLHandler.h:99
std::function< void(UniProtEntry &&)> EntryCallback
Definition UniProtXMLHandler.h:38
int gene_depth_
<gene>
Definition UniProtXMLHandler.h:77
int sequence_depth_
<sequence length="..."> (only the canonical sequence; isoform <sequence> ignored)
Definition UniProtXMLHandler.h:81
bool full_name_captured_
Definition UniProtXMLHandler.h:85
CaptureTarget
Definition UniProtXMLHandler.h:43
int feature_depth_
<feature>
Definition UniProtXMLHandler.h:80
EntryCallback callback_
Definition UniProtXMLHandler.h:66
CaptureTarget capture_
Destination for the next buffered run of character data (None == not capturing).
Definition UniProtXMLHandler.h:91
int entry_depth_
<entry>
Definition UniProtXMLHandler.h:75
int recommended_name_depth_
<protein>/<recommendedName>
Definition UniProtXMLHandler.h:76
void resetEntry_()
Clear all per-entry state so the next <entry> starts fresh.
Definition UniProtXMLHandler.cpp:121
UniProtEntry current_entry_
Definition UniProtXMLHandler.h:67
static int parsePosition_(const std::string &attr)
Definition UniProtXMLHandler.cpp:137
UniProtFeature current_feature_
Per-feature working state (used between startElement("feature") and endElement("feature")).
Definition UniProtXMLHandler.h:94
void onEndElement(const char16_t *qname) override
Parsing method for closing tags.
Definition UniProtXMLHandler.cpp:312
int alt_products_depth_
<comment type="alternative products"> (whole subtree skipped)
Definition UniProtXMLHandler.h:79
void onCharacters(const char16_t *chars, Size length) override
Parsing method for character data.
Definition UniProtXMLHandler.cpp:304
Xerces-free, lightweight view over the attribute list of an XML element.
Definition XMLAttributes.h:32
Base class for XML handlers.
Definition XMLHandler.h:42
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition Types.h:97
Namespace used to hide implementation details from users.
Definition BayesianProteinInferenceAlgorithm.h:26
A single <entry> from a UniProtKB XML file, in a parser-neutral form.
Definition UniProtXMLFile.h:48
A single <feature> element from a UniProtKB XML entry.
Definition UniProtXMLFile.h:28