1 #ifndef VALIDATOR___VALIDERROR_FORMAT__HPP 2 #define VALIDATOR___VALIDERROR_FORMAT__HPP 3 4 /* $Id: validerror_format.hpp 632625 2021-06-03 17:38:33Z ivanov $ 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: Jonathan Kans, Clifford Clausen, Aaron Ucko...... 30 * 31 * File Description: 32 * Validates CSeq_entries and CSeq_submits 33 * ....... 34 * 35 */ 36 #include <corelib/ncbistd.hpp> 37 #include <corelib/ncbidiag.hpp> 38 #include <serial/objectinfo.hpp> 39 #include <serial/serialbase.hpp> 40 #include <objects/valerr/ValidErrItem.hpp> 41 #include <objects/valerr/ValidError.hpp> 42 #include <objmgr/scope.hpp> 43 44 #include <map> 45 46 47 BEGIN_NCBI_SCOPE 48 BEGIN_SCOPE(objects) 49 50 class CSeq_entry; 51 class CSeq_entry_Handle; 52 class CSeq_submit; 53 class CSeq_annot; 54 class CSeq_annot_Handle; 55 class CUser_object; 56 class CSeq_feat; 57 class CBioSource; 58 class CPubdesc; 59 class CBioseq; 60 class CSeqdesc; 61 class CObjectManager; 62 class CScope; 63 64 BEGIN_SCOPE(validator) 65 66 67 enum ESubmitterFormatErrorGroup { 68 eSubmitterFormatErrorGroup_ConsensusSplice = 0, 69 eSubmitterFormatErrorGroup_BadEcNumberFormat, 70 eSubmitterFormatErrorGroup_BadEcNumberValue, 71 eSubmitterFormatErrorGroup_BadEcNumberProblem, 72 eSubmitterFormatErrorGroup_BadSpecificHost, 73 eSubmitterFormatErrorGroup_BadInstitutionCode, 74 eSubmitterFormatErrorGroup_LatLonCountry, 75 eSubmitterFormatErrorGroup_Default 76 }; 77 78 79 class NCBI_VALIDATOR_EXPORT CValidErrorFormat : public CObject 80 { 81 public: 82 83 // Constructor / Destructor 84 CValidErrorFormat(CObjectManager& objmgr); 85 ~CValidErrorFormat(void); 86 87 ESubmitterFormatErrorGroup GetSubmitterFormatErrorGroup(CValidErrItem::TErrIndex err_code) const; 88 string GetSubmitterFormatErrorGroupTitle(CValidErrItem::TErrIndex err_code) const; 89 string FormatForSubmitterReport(const CValidErrItem& error, CScope& scope) const; 90 string FormatForSubmitterReport(const CValidError& errors, CScope& scope, CValidErrItem::TErrIndex err_code) const; 91 string FormatCategoryForSubmitterReport(const CValidError& errors, CScope& scope, ESubmitterFormatErrorGroup grp) const; 92 vector<unsigned int> GetListOfErrorCodes(const CValidError& errors) const; 93 vector<string> FormatCompleteSubmitterReport(const CValidError& errors, CScope& scope) const; 94 95 // for formatting the objects as presented by the validator 96 static string GetFeatureContentLabel (const CSeq_feat& feat, CRef<CScope> scope); 97 static string GetFeatureBioseqLabel(const CSeq_feat& ft, CRef<CScope> scope, bool suppress_context); 98 static string GetFeatureProductLocLabel(const CSeq_feat& ft, CRef<CScope> scope, bool suppress_context); 99 static string GetFeatureIdLabel(const CSeq_feat& ft); 100 static string GetFeatureIdLabel (const CFeat_id& feat_id); 101 static string GetFeatureLocationLabel(const CSeq_feat& ft, CRef<CScope> scope, bool suppress_context); 102 static string GetFeatureLabel(const CSeq_feat& ft, CRef<CScope> scope, bool suppress_context); 103 static string GetDescriptorContent (const CSeqdesc& ds); 104 static string GetDescriptorLabel(const CSeqdesc& ds, const CSeq_entry& ctx, CRef<CScope> scope, bool suppress_context); 105 static string GetBioseqLabel (CBioseq_Handle bh); 106 static string GetBioseqSetLabel(const CBioseq_set& st, CRef<CScope> scope, bool suppress_context); 107 static string GetObjectLabel(const CObject& obj, const CSeq_entry& ctx, CRef<CScope> scope, bool suppress_context); 108 109 // for suppressing error collection during runtime 110 static void SetSuppressionRules(const CUser_object& user, CValidError& errors); 111 static void SetSuppressionRules(const CSeq_entry& se, CValidError& errors); 112 static void SetSuppressionRules(const CSeq_entry_Handle& se, CValidError& errors); 113 static void SetSuppressionRules(const CSeq_submit& ss, CValidError& errors); 114 static void SetSuppressionRules(const CBioseq& seq, CValidError& errors); 115 static void AddSuppression(CUser_object& user, unsigned int error_code); 116 117 static void AddLocusTags(CValidError& errors, CScope& scope); 118 119 private: 120 // Prohibit copy constructor & assignment operator 121 CValidErrorFormat(const CValidErrorFormat&); 122 CValidErrorFormat& operator= (const CValidErrorFormat&); 123 124 125 string x_FormatConsensusSpliceForSubmitterReport(const CValidErrItem& error, CScope& scope) const; 126 string x_FormatECNumberForSubmitterReport(const CValidErrItem& error, CScope& scope) const; 127 string x_FormatBadSpecificHostForSubmitterReport(const CValidErrItem& error) const; 128 string x_FormatBadInstCodeForSubmitterReport(const CValidErrItem& error) const; 129 string x_FormatLatLonCountryForSubmitterReport(const CValidErrItem& error) const; 130 string x_FormatGenericForSubmitterReport(const CValidErrItem& error, CScope& scope) const; 131 132 static const string& x_GetLocusTag(const CSeq_feat& sf, CScope& scope); 133 134 CRef<CObjectManager> m_ObjMgr; 135 136 }; 137 138 139 // Inline Functions: 140 141 142 END_SCOPE(validator) 143 END_SCOPE(objects) 144 END_NCBI_SCOPE 145 146 #endif /* VALIDATOR___VALIDERROR_FORMAT__HPP */ 147