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

Go to the SVN repository for this file.

1 #ifndef TABLE2ASN_VALIDATOR_HPP_INCLUDED
2 #define TABLE2ASN_VALIDATOR_HPP_INCLUDED
3 
8 
9 #include "utils.hpp"
10 #include <queue>
11 #include <atomic>
12 #include <mutex>
13 #include <condition_variable>
14 
16 
17 namespace objects
18 {
19  class CSeq_entry;
20  class CBioseq;
21  class CSeq_entry_Handle;
22  class CSeq_submit;
23  class CScope;
24 }
25 namespace NDiscrepancy
26 {
27  class CDiscrepancySet;
28  class CDiscrepancyProduct;
29 }
30 
31 struct SSevStats { // This class holds error counts for a single severity level
33  size_t total{ 0 };
34 };
35 
37 
38 
39 class CValidMessageHandler : public objects::IValidError
40 {
41 public:
42  enum class EMode {
44  Serial
45  };
46 
48  m_Ostr(ostr),
49  m_Mode(mode) {}
50  virtual ~CValidMessageHandler() = default;
51 
52  void AddValidErrItem(
53  EDiagSev sev, // severity
54  unsigned int ec, // error code
55  const string& msg, // specific error message
56  const string& desc, // offending object's description
57  const CSerialObject& obj, // offending object
58  const string& acc, // accession of object.
59  const int ver, // version of object.
60  const string& location = kEmptyStr, // formatted location of object
61  const int seq_offset = 0) override;
62 
63  void AddValidErrItem(
64  EDiagSev sev, // severity
65  unsigned int ec, // error code
66  const string& msg, // specific error message
67  const string& desc, // offending object's description
68  const string& acc, // accession of object.
69  const int ver, // version of object.
70  const string& location = kEmptyStr, // formatted location of object
71  const int seq_offset = 0) override;
72 
74  EDiagSev sev, // severity
75  unsigned int ec, // error code
76  const string& msg, // specific error message
77  const string& desc, // offending object's description
78  const objects::CSeqdesc& seqdesc, // offending object
79  const objects::CSeq_entry& ctx, // place of packaging
80  const string& acc, // accession of object or context.
81  const int ver, // version of object.
82  const int seq_offset = 0) override;
83 
84  void AddValidErrItem(
85  EDiagSev sev, // severity
86  unsigned int ec, // error code
87  const string& msg) override;
88 
90 
91  void Write();
92  void RequestStop();
93 
94  using TPostponed = list<CRef<objects::CValidErrItem>>;
95  const TPostponed& GetPostponed() const;
96  const TValStats& GetStats() { return m_ProcessedStats; }
97 
98 private:
99  void x_LogStats(const objects::CValidErrItem& item);
101 
105 
106  condition_variable m_Cv;
107  mutex m_Mutex;
108  queue<CRef<objects::CValidErrItem>> m_Items;
111 };
112 
113 
114 class CTable2AsnContext;
116 {
117 public:
120 
121  void Clear();
124  CValidMessageHandler& msgHandler);
125 
126  void ValCollect(CRef<objects::CSeq_submit> submit, CRef<objects::CSeq_entry> entry, const string& flags);
128  void ValReportErrors();
129  size_t ValTotalErrors() const;
130 
131  void Cleanup(CRef<objects::CSeq_submit> submit, objects::CSeq_entry_Handle& entry, const string& flags) const;
132  void UpdateECNumbers(objects::CSeq_entry& entry);
133 
134  void CollectDiscrepancies(CRef<objects::CSeq_submit> submit, objects::CSeq_entry_Handle& entry);
135  void ReportDiscrepancies();
136  void ReportDiscrepancies(const string& filename);
137 
138  using TGlobalInfo = objects::validator::CHugeFileValidator::TGlobalInfo;
140  using TValidatorContext = objects::validator::SValidatorContext;
141  shared_ptr<TValidatorContext> GetContextPtr() { return m_val_context; }
142 
143 
144 protected:
147  objects::CSeq_entry_Handle& entry) const;
148  void x_ReportDiscrepancies(TDiscProdRef& discrepancy, std::ostream& ostr) const;
151  {
152  public:
154  total(0){};
156  size_t total;
157  };
159 
160  std::mutex m_discrep_mutex;
162 
163  std::shared_ptr<objects::validator::SValidatorContext> m_val_context;
165  std::list<CRef<objects::CValidError>> m_val_errors;
167  mutable std::mutex m_mutex;
168 };
169 
170 void g_FormatErrItem(const objects::CValidErrItem& item, CNcbiOstream& ostr);
171 
172 void g_FormatValStats(const TValStats& stats, size_t total, CNcbiOstream& ostr);
173 
175 
176 #endif
User-defined methods of the data storage class.
User-defined methods of the data storage class.
CObject –.
Definition: ncbiobj.hpp:180
CRef –.
Definition: ncbiobj.hpp:618
CScope –.
Definition: scope.hpp:92
CSeq_entry_Handle –.
Definition: Seq_entry.hpp:56
Base class for all serializable objects.
Definition: serialbase.hpp:150
std::list< CRef< objects::CValidError > > m_val_errors
const TGlobalInfo & GetGlobalInfo()
void x_ReportDiscrepancies(TDiscProdRef &discrepancy, std::ostream &ostr) const
void UpdateECNumbers(objects::CSeq_entry &entry)
std::shared_ptr< objects::validator::SValidatorContext > m_val_context
void Cleanup(CRef< objects::CSeq_submit > submit, objects::CSeq_entry_Handle &entry, const string &flags) const
objects::validator::SValidatorContext TValidatorContext
objects::validator::CHugeFileValidator::TGlobalInfo TGlobalInfo
void ValReportErrorStats(CNcbiOstream &out)
void CollectDiscrepancies(CRef< objects::CSeq_submit > submit, objects::CSeq_entry_Handle &entry)
CTable2AsnContext * m_context
void ValCollect(CRef< objects::CSeq_submit > submit, CRef< objects::CSeq_entry > entry, const string &flags)
void Validate(CRef< objects::CSeq_submit > pSubmit, CRef< objects::CSeq_entry > pEntry, CValidMessageHandler &msgHandler)
CTable2AsnValidator(CTable2AsnContext &ctx)
shared_ptr< TValidatorContext > GetContextPtr()
TDiscProdRef x_PopulateDiscrepancy(CRef< objects::CSeq_submit > submit, objects::CSeq_entry_Handle &entry) const
const TValStats & GetStats()
CValidMessageHandler(CNcbiOstream &ostr, EMode mode=EMode::Asynchronous)
const TPostponed & GetPostponed() const
void x_AddItemAsync(CRef< objects::CValidErrItem > pItem)
list< CRef< objects::CValidErrItem > > TPostponed
void AddValidErrItem(EDiagSev sev, unsigned int ec, const string &msg, const string &desc, const CSerialObject &obj, const string &acc, const int ver, const string &location=kEmptyStr, const int seq_offset=0) override
void x_LogStats(const objects::CValidErrItem &item)
virtual ~CValidMessageHandler()=default
void AddValidErrItem(EDiagSev sev, unsigned int ec, const string &msg, const string &desc, const objects::CSeqdesc &seqdesc, const objects::CSeq_entry &ctx, const string &acc, const int ver, const int seq_offset=0) override
void AddValidErrItem(CRef< objects::CValidErrItem > pItem) override
queue< CRef< objects::CValidErrItem > > m_Items
Definition: map.hpp:338
static uch flags
std::ofstream out("events_result.xml")
main entry point for tests
CS_CONTEXT * ctx
Definition: t0006.c:12
static const char location[]
Definition: config.c:97
EDiagSev
Severity level for the posted diagnostics.
Definition: ncbidiag.hpp:650
#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 kEmptyStr
Definition: ncbistr.hpp:123
mdb_mode_t mode
Definition: lmdb++.h:38
map< int, size_t > individual
void g_FormatErrItem(const objects::CValidErrItem &item, CNcbiOstream &ostr)
void g_FormatValStats(const TValStats &stats, size_t total, CNcbiOstream &ostr)
Modified on Sun Jun 16 04:31:28 2024 by modify_doxy.py rev. 669887