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

Go to the SVN repository for this file.

1 /* $Id: validerror_align.hpp 101299 2023-11-28 18:18:38Z 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  * Author: Jonathan Kans, Clifford Clausen, Aaron Ucko......
27  *
28  * File Description:
29  * Privae classes and definition for the validator
30  * .......
31  *
32  */
33 
34 #ifndef VALIDATOR___VALIDERROR_ALIGN__HPP
35 #define VALIDATOR___VALIDERROR_ALIGN__HPP
36 
37 #include <corelib/ncbistd.hpp>
39 
40 #include <objmgr/scope.hpp>
44 
49 
52 
53 class CDense_diag;
54 class CDense_seg;
55 class CSeq_align_set;
56 
57 BEGIN_SCOPE(validator)
58 
59 // ============================ Validate SeqAlign ============================
60 
61 
63 {
64 public:
66  ~CValidError_align() override;
67 
68  void ValidateSeqAlign(const CSeq_align& align, int order = -1);
69 
70  struct TSegmentGap {
71  size_t seg_num; size_t align_pos; string label;
72  TSegmentGap(size_t _seg_num, size_t _align_pos, string _label)
73  : seg_num(_seg_num), align_pos(_align_pos), label(_label) {}
74  };
75  typedef vector<TSegmentGap> TSegmentGapV;
76 
81 
82  static TSegmentGapV FindSegmentGaps(const TPacked& packed);
83  static TSegmentGapV FindSegmentGaps(const TDenseg& std_segs);
84  static TSegmentGapV FindSegmentGaps(const TStd& denseg, CScope* scope);
85  static TSegmentGapV FindSegmentGaps(const TDendiag& dendiags);
86 
87 private:
89 
90  void x_ValidateAlignPercentIdentity(const CSeq_align& align, bool internal_gaps);
91  static bool AlignmentScorePercentIdOk(const CSeq_align& align);
92  static bool IsTpaAlignment(const CDense_seg& denseg, CScope& scope);
93  static bool IsTpaAlignment(const CSparseAln& sparse_aln, CScope& scope);
94  void x_ValidateDendiag(const TDendiag& dendiags, const CSeq_align& align);
95  void x_ValidateDenseg(const TDenseg& denseg, const CSeq_align& align);
96  void x_ValidateStd(const TStd& stdsegs, const CSeq_align& align);
97  void x_ValidatePacked(const TPacked& packed, const CSeq_align& align);
98 
99  // Check if dimension is valid
100  template <typename T>
101  bool x_ValidateDim(T& obj, const CSeq_align& align, size_t part = 0);
102 
103  // Check if the strand is consistent in SeqAlignment of global
104  // or partial type
105  void x_ValidateStrand(const TDenseg& denseg, const CSeq_align& align);
106  void x_ValidateStrand(const TStd& std_segs, const CSeq_align& align);
107 
108  // Check if an alignment is FASTA-like.
109  // Alignment is FASTA-like if all gaps are at the end with dimensions > 2.
110  void x_ValidateFastaLike(const TDenseg& denseg, const CSeq_align& align);
111 
112  // Check if there is a gap for all sequences in a segment.
113  void x_ReportSegmentGaps(const TSegmentGapV& seggaps, const CSeq_align& align);
114  void x_ValidateSegmentGap(const TDenseg& denseg, const CSeq_align& align);
115  void x_ValidateSegmentGap(const TPacked& packed, const CSeq_align& align);
116  void x_ValidateSegmentGap(const TStd& std_segs, const CSeq_align& align);
117  void x_ValidateSegmentGap(const TDendiag& dendiags, const CSeq_align& align);
118 
119  // Validate SeqId in sequence alignment.
120  void x_ValidateSeqId(const CSeq_align& align);
121  void x_GetIds(const CSeq_align& align, vector< CRef< CSeq_id > >& ids);
122 
123  // Check segment length, start and end point in Dense_seg, Dense_diag
124  // and Std_seg
125  void x_ReportAlignErr(const CSeq_align& align, const CSeq_id& id, const CSeq_id& id_context,
126  size_t segment, size_t pos,
127  EErrType et, EDiagSev sev, const string& prefix, const string& message);
128  void x_ReportSumLenStart(const CSeq_align& align, const CSeq_id& id, const CSeq_id& id_context, size_t segment, size_t pos);
129  void x_ReportStartMoreThanBiolen(const CSeq_align& align, const CSeq_id& id, const CSeq_id& id_context, size_t segment, size_t pos);
130  void x_ValidateSeqLength(const TDenseg& denseg, const CSeq_align& align);
131  void x_ValidateSeqLength(const TPacked& packed, const CSeq_align& align);
132  void x_ValidateSeqLength(const TStd& std_segs, const CSeq_align& align);
133  void x_ValidateSeqLength(const CDense_diag& dendiag, size_t dendiag_num,
134  const CSeq_align& align);
135 };
136 
137 
138 END_SCOPE(validator)
141 
142 #endif /* VALIDATOR___VALIDERROR_ALIGN__HPP */
User-defined methods of the data storage class.
EErrType
CScope –.
Definition: scope.hpp:92
Sparse alignment.
Definition: sparse_aln.hpp:51
CSeq_align::C_Segs::TDisc TDisc
CSeq_align::C_Segs::TDenseg TDenseg
CSeq_align::C_Segs::TDendiag TDendiag
CSeq_align::C_Segs::TPacked TPacked
CSeq_align::C_Segs::TStd TStd
vector< TSegmentGap > TSegmentGapV
Include a standard set of the NCBI C++ Toolkit most basic headers.
#define T(s)
Definition: common.h:230
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 END_SCOPE(ns)
End the previously defined scope.
Definition: ncbistl.hpp:75
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
#define BEGIN_SCOPE(ns)
Define a new scope.
Definition: ncbistl.hpp:72
static const char label[]
list< CRef< CStd_seg > > TStd
Definition: Seq_align_.hpp:196
CSeq_align_set TDisc
Definition: Seq_align_.hpp:198
list< CRef< CDense_diag > > TDendiag
Definition: Seq_align_.hpp:194
static const char * prefix[]
Definition: pcregrep.c:405
TSegmentGap(size_t _seg_num, size_t _align_pos, string _label)
Modified on Wed Dec 06 07:13:11 2023 by modify_doxy.py rev. 669887