include/objmgr/seq_map_switch.hpp

Go to the documentation of this file.
00001 #ifndef OBJECTS_OBJMGR___SEQ_MAP_SWITCH__HPP
00002 #define OBJECTS_OBJMGR___SEQ_MAP_SWITCH__HPP
00003 
00004 /*  $Id: seq_map_switch.hpp 103491 2007-05-04 17:18:18Z kazimird $
00005 * ===========================================================================
00006 *
00007 *                            PUBLIC DOMAIN NOTICE
00008 *               National Center for Biotechnology Information
00009 *
00010 *  This software/database is a "United States Government Work" under the
00011 *  terms of the United States Copyright Act.  It was written as part of
00012 *  the author's official duties as a United States Government employee and
00013 *  thus cannot be copyrighted.  This software/database is freely available
00014 *  to the public for use. The National Library of Medicine and the U.S.
00015 *  Government have not placed any restriction on its use or reproduction.
00016 *
00017 *  Although all reasonable efforts have been taken to ensure the accuracy
00018 *  and reliability of the software and data, the NLM and the U.S.
00019 *  Government do not and cannot warrant the performance or results that
00020 *  may be obtained by using this software or data. The NLM and the U.S.
00021 *  Government disclaim all warranties, express or implied, including
00022 *  warranties of performance, merchantability or fitness for any particular
00023 *  purpose.
00024 *
00025 *  Please cite the author in any work or product based on this material.
00026 *
00027 * ===========================================================================
00028 *
00029 * Authors:
00030 *           Eugene Vasilchenko
00031 *
00032 * File Description:
00033 *   Working with seq-map switch points
00034 *
00035 */
00036 
00037 #include <objmgr/seq_map.hpp>
00038 #include <objmgr/bioseq_handle.hpp>
00039 #include <objects/seq/seq_id_handle.hpp>
00040 #include <util/range.hpp>
00041 #include <vector>
00042 #include <list>
00043 #include <map>
00044 
00045 BEGIN_NCBI_SCOPE
00046 BEGIN_SCOPE(objects)
00047 
00048 class CSeqMap;
00049 class CBioseq_Handle;
00050 class CSeq_align;
00051 
00052 /** @addtogroup ObjectManagerSequenceRep
00053  *
00054  * @{
00055  */
00056 
00057 class  CSeqMapSwitchPoint : public CObject
00058 {
00059 public:
00060 
00061     // master sequence
00062     CBioseq_Handle  m_Master;
00063     // point in master sequence - coordinate of the first base to the right
00064     TSeqPos         m_MasterPos;
00065 
00066     // first encountered alignment used to calculate this switch point
00067     CConstRef<CSeq_align> m_FirstAlign;
00068 
00069     // point on the segment to the left of current switch point
00070     CSeq_id_Handle  m_LeftId;
00071     TSeqPos         m_LeftPos;
00072     bool            m_LeftMinusStrand;
00073 
00074     // point on the segment to the right of current switch point
00075     CSeq_id_Handle  m_RightId;
00076     TSeqPos         m_RightPos;
00077     bool            m_RightMinusStrand;
00078 
00079     // range of possible positions of the switch point
00080     CRange<TSeqPos> m_MasterRange;
00081     // range of possible positions of the switch point with exact segment match
00082     CRange<TSeqPos> m_ExactMasterRange;
00083 
00084     // information about changes in sequence
00085     //   first - insertions
00086     //   second - deletions
00087     typedef pair<TSeqPos, TSeqPos> TInsertDelete;
00088     // key is offset from the current switch point
00089     typedef map<TSeqPos, TInsertDelete> TDifferences;
00090     TDifferences m_LeftDifferences, m_RightDifferences;
00091 
00092     // all possible changes
00093     TInsertDelete GetDifferences(TSeqPos new_pos, TSeqPos add = 0) const;
00094     // possible change in sequence length
00095     int GetLengthDifference(TSeqPos new_pos, TSeqPos add = 0) const
00096         {
00097             TInsertDelete diff = GetDifferences(new_pos, add);
00098             return diff.first - diff.second;
00099         }
00100     // possible change in sequence bases (sum of insertions and deletions)
00101     int GetSequenceDifference(TSeqPos new_pos, TSeqPos add = 0) const
00102         {
00103             TInsertDelete diff = GetDifferences(new_pos, add);
00104             return diff.first + diff.second;
00105         }
00106 
00107     TSeqPos GetInsert(TSeqPos pos) const;
00108     TSeqPos GetLeftInPlaceInsert(void) const;
00109     TSeqPos GetRightInPlaceInsert(void) const;
00110 
00111     void ChangeSwitchPoint(TSeqPos pos, TSeqPos add);
00112     void InsertInPlace(TSeqPos add_left, TSeqPos add_right);
00113 
00114     bool operator<(const CSeqMapSwitchPoint& p) const
00115         {
00116             _ASSERT(m_Master == p.m_Master);
00117             return m_MasterPos < p.m_MasterPos;
00118         }
00119 };
00120 
00121 /* @} */
00122 
00123 // calculate switch point for two segments specified by align
00124 
00125 CRef<CSeqMapSwitchPoint> GetSwitchPoint(const CBioseq_Handle& seq,
00126                                         const CSeq_align& align);
00127 
00128 typedef vector<CRef<CSeqMapSwitchPoint> > TSeqMapSwitchPoints;
00129 typedef list<CRef<CSeq_align> > TSeqMapSwitchAligns;
00130 
00131 // calculate all sequence switch points using set of Seq-aligns
00132 
00133 TSeqMapSwitchPoints GetAllSwitchPoints(const CBioseq_Handle& seq,
00134                                        const TSeqMapSwitchAligns& aligns);
00135 
00136 // calculate all sequence switch points using set of Seq-aligns from assembly
00137 
00138 TSeqMapSwitchPoints GetAllSwitchPoints(const CBioseq_Handle& seq);
00139 
00140 END_SCOPE(objects)
00141 END_NCBI_SCOPE
00142 
00143 #endif // OBJECTS_OBJMGR___SEQ_MAP_SWITCH__HPP
00144 
00145 

Generated on Sun Dec 6 22:12:44 2009 for NCBI C++ ToolKit by  doxygen 1.4.6
Modified on Mon Dec 07 16:20:47 2009 by modify_doxy.py rev. 173732