1 #ifndef ALGO_SEQ___ALIGN_CLEANUP__HPP
2 #define ALGO_SEQ___ALIGN_CLEANUP__HPP
3 
4 /*  $Id: align_cleanup.hpp 542379 2017-07-31 13:06:45Z dicuccio $
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  * Authors:  Mike DiCuccio
30  *
31  * File Description:
32  *
33  */
34 
35 #include <corelib/ncbistd.hpp>
36 
37 #include <objmgr/scope.hpp>
38 #include <objects/seqalign/Seq_align.hpp>
39 
40 
41 BEGIN_NCBI_SCOPE
42 BEGIN_SCOPE(objects)
43 
44 /// class CAlignCleanup implements an alignment cleanup utility based on
45 /// the C++ alignment manager.  The primary goal is to remove redundancies
46 /// from any given set of alignment, and generate a cleaned up version of
47 /// these alignments
48 class NCBI_XALGOSEQ_EXPORT CAlignCleanup
49 {
50 public:
51     CAlignCleanup();
52     CAlignCleanup(CScope& scope);
53 
54     typedef list< CConstRef<CSeq_align> > TConstAligns;
55     typedef list< CRef<CSeq_align> >      TAligns;
56 
57     enum EMode {
58         //< use the older (i.e., CAlnVec) alignment manager
59         eAlignVec,
60 
61         //< use the newer (i.e., CAnchoredAln) alignment manager
62         eAnchoredAlign,
63 
64         eDefault = eAnchoredAlign
65     };
66 
67     void Cleanup(const TAligns& aligns_in,
68                  TAligns&       aligns_out,
69                  EMode          mode = eDefault);
70     void Cleanup(const TConstAligns& aligns_in,
71                  TAligns&            aligns_out,
72                  EMode               mode = eDefault);
73 
74 //     // select best query pieces across all subjects
75 //     void CleanupByQuery(const TAligns& aligns_in,
76 //                  TAligns&            aligns_out);
77 
78 
79     /// flags
80     /// these primarity affect the CAlnVec implementation
81 
82     /// Sort input alignments by score before evaluating
SortInputsByScore(bool b)83     void SortInputsByScore(bool b)      { m_SortByScore = b; }
84 
85     /// Permit off-diagonal high-scoring items (particularly ones on
86     /// the opposite strand)
87     ///
88     /// NB: this is a no-op, as it is no longer necessary
AllowTranslocations(bool)89     NCBI_DEPRECATED void AllowTranslocations(bool /*b*/)    { ; }
90 
91     /// Assume that the alignments contains alignments of a sequence to itself
PreserveRows(bool b)92     void PreserveRows(bool b)    { m_PreserveRows = b; }
93 
94     /// Fill any unaligned regions with explicit gaps
FillUnaligned(bool b)95     void FillUnaligned(bool b)    { m_FillUnaligned = b; }
96 
97     static void CreatePairwiseFromMultiple(const CSeq_align& multiple,
98                                            TAligns&          pairwise);
99 
100 private:
101     CRef<CScope> m_Scope;
102     bool m_SortByScore;
103     bool m_PreserveRows;
104     bool m_FillUnaligned;
105 
106     void x_Cleanup_AlignVec(const TConstAligns& aligns_in,
107                             TAligns&            aligns_out);
108     void x_Cleanup_AnchoredAln(const TConstAligns& aligns_in,
109                                TAligns&            aligns_out);
110 };
111 
112 
113 END_SCOPE(objects)
114 END_NCBI_SCOPE
115 
116 #endif  // ALGO_SEQ___ALIGN_CLEANUP__HPP
117