NCBI C++ ToolKit
pw_alignment.cpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 /* $Id: pw_alignment.cpp 45971 2021-01-20 16:32:23Z grichenk $
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  * Authors: Vlad Lebedev, Liangshou Wu
27  *
28  * File Description:
29  * CLayoutPWAlign -- utility class to layout pair-wise alignments
30  */
31 
32 #include <ncbi_pch.hpp>
34 
35 
38 
39 
41  const CSeq_align_Handle& orig_align,
42  const CSeq_align& mapped_align)
43  : CLayoutAlign(aln_mgr, orig_align, mapped_align)
44 {
45 }
46 
47 
48 CLayoutPWAlign::EType CLayoutPWAlign::GetType() const
49 {
50  return eAlignPairwise;
51 }
52 
53 
55 {
56  m_Intervals.clear();
57 
58  const IAlnGraphicDataSource& aln_mgr = GetAlignMgr();
59  CAlnMap::TNumrow anchor = aln_mgr.GetAnchor();
60  TSignedSeqRange range(aln_mgr.GetAlnStart(), aln_mgr.GetAlnStop());
61 
62  for (CAlnMap::TNumrow row = 0 ; row < aln_mgr.GetNumRows(); ++row) {
63  if (row == anchor) {
64  continue; // skip master seq
65  }
66 
67  unique_ptr<IAlnSegmentIterator> p_it(aln_mgr.CreateSegmentIterator(row,
69 
70  for ( IAlnSegmentIterator& it(*p_it); it; ++it ) {
71  const IAlnSegment& seg = *it;
72  const TSignedSeqRange& R = seg.GetRange();
73  TSeqPos start = R.GetFrom();
74  TSeqPos stop = R.GetTo();
75  start = aln_mgr.GetSeqPosFromSeqPos(anchor, row, start);
76  stop = aln_mgr.GetSeqPosFromSeqPos(anchor, row, stop);
77  if (start > stop) {
78  swap(start, stop);
79  }
80  m_Intervals.push_back( TSeqRange(start, stop) );
81  }
82  } // for (CAlnMap::TNumrow ...
83 }
84 
85 
87 
TDim TNumrow
Definition: alnmap.hpp:69
IAlnGraphicDataSource - interface to a data source representing an abstract alignment used in graphic...
virtual TSignedSeqPos GetSeqPosFromSeqPos(TNumrow for_row, TNumrow row, TSeqPos seq_pos) const =0
Alignment segment iterator interface.
@ eSkipGaps
Skip gap segments (show only aligned ranges)
Alignment segment interface.
virtual const TSignedRange & GetRange(void) const =0
Get the selected row range.
virtual TSeqPos GetAlnStart() const =0
virtual TSeqPos GetAlnStop() const =0
virtual IAlnExplorer::TNumrow GetNumRows() const =0
virtual IAlnExplorer::TNumrow GetAnchor() const =0
virtual IAlnSegmentIterator * CreateSegmentIterator(IAlnExplorer::TNumrow, const IAlnExplorer::TSignedRange &, IAlnSegmentIterator::EFlags) const =0
unsigned int TSeqPos
Type for sequence locations and lengths.
Definition: ncbimisc.hpp:875
void swap(NCBI_NS_NCBI::pair_base_member< T1, T2 > &pair1, NCBI_NS_NCBI::pair_base_member< T1, T2 > &pair2)
Definition: ncbimisc.hpp:1508
EType GetType() const
CLayoutPWAlign(CConstRef< IAlnGraphicDataSource > aln_mgr, const objects::CSeq_align_Handle &orig_align, const objects::CSeq_align &mapped_align)
virtual void x_CalcIntervals(void) const
CRange< TSeqPos > TSeqRange
typedefs for sequence ranges
Definition: range.hpp:419
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
range(_Ty, _Ty) -> range< _Ty >
USING_SCOPE(objects)
Modified on Wed Feb 21 09:56:35 2024 by modify_doxy.py rev. 669887