📄 alnmix.hpp
字号:
/* * =========================================================================== * PRODUCTION $Log: alnmix.hpp,v $ * PRODUCTION Revision 1000.3 2004/06/01 19:38:16 gouriano * PRODUCTION PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.38 * PRODUCTION * =========================================================================== */#ifndef OBJECTS_ALNMGR___ALNMIX__HPP#define OBJECTS_ALNMGR___ALNMIX__HPP/* $Id: alnmix.hpp,v 1000.3 2004/06/01 19:38:16 gouriano Exp $* ===========================================================================** PUBLIC DOMAIN NOTICE* National Center for Biotechnology Information** This software/database is a "United States Government Work" under the* terms of the United States Copyright Act. It was written as part of* the author's official duties as a United States Government employee and* thus cannot be copyrighted. This software/database is freely available* to the public for use. The National Library of Medicine and the U.S.* Government have not placed any restriction on its use or reproduction.** Although all reasonable efforts have been taken to ensure the accuracy* and reliability of the software and data, the NLM and the U.S.* Government do not and cannot warrant the performance or results that* may be obtained by using this software or data. The NLM and the U.S.* Government disclaim all warranties, express or implied, including* warranties of performance, merchantability or fitness for any particular* purpose.** Please cite the author in any work or product based on this material.** ===========================================================================** Author: Kamen Todorov, NCBI** File Description:* Alignment merger**/#include <objtools/alnmgr/alnvec.hpp>#include <objects/seqalign/Seq_align.hpp>#include <serial/iterator.hpp>BEGIN_NCBI_SCOPEBEGIN_objects_SCOPE // namespace ncbi::objects::// forward declarationsclass CScope;class CSeq_id;class CAlnMixSegment;class CAlnMixSeq;class CAlnMixMatch;class NCBI_XALNMGR_EXPORT CAlnMix : public CSeq_align::SSeqIdChooser// Note that SSeqIdChooser derives from CObject, so CAlnMix *is* also a CObject.{public: // constructor CAlnMix(void); CAlnMix(CScope& scope); // destructor ~CAlnMix(void); enum EAddFlags { // ObjMgr is used to identify sequences and obtain a bioseqhandle. // Also used to calc scores and determine the type of molecule fDontUseObjMgr = 0x01, // Determine score of each aligned segment in the process of mixing // (can only be set in addition to fUseObjMgr) fCalcScore = 0x02, // Force translation of nucleotide rows // This will result in an output Dense-seg that has Widths, // no matter if the whole alignment consists of nucleotides only. fForceTranslation = 0x0200 }; typedef int TAddFlags; // binary OR of EMergeFlags void Add(const CDense_seg& ds, TAddFlags flags = 0); void Add(const CSeq_align& aln, TAddFlags flags = 0); enum EMergeFlags { fGen2EST = 0x0001, // otherwise Nucl2Nucl fTruncateOverlaps = 0x0002, // otherwise put on separate rows fNegativeStrand = 0x0004, fTryOtherMethodOnFail = 0x0008, fGapJoin = 0x0010, // join equal len segs gapped on refseq fMinGap = 0x0020, // minimize segs gapped on refseq fSortSeqsByScore = 0x0040, // Seqs with better scoring aligns on top fQuerySeqMergeOnly = 0x0080, // Only put the query seq on same row, // other seqs from diff densegs go to diff rows fFillUnalignedRegions = 0x0100 }; typedef int TMergeFlags; // binary OR of EMergeFlags void Merge(TMergeFlags flags = 0); typedef vector<CConstRef<CDense_seg> > TConstDSs; typedef vector<CConstRef<CSeq_align> > TConstAlns; CScope& GetScope (void) const; const TConstDSs& GetInputDensegs (void) const; const TConstAlns& GetInputSeqAligns(void) const; const CDense_seg& GetDenseg (void) const; const CSeq_align& GetSeqAlign (void) const;private: // Prohibit copy constructor and assignment operator CAlnMix(const CAlnMix& value); CAlnMix& operator=(const CAlnMix& value); // CRef<Seq-id> comparison predicate struct SSeqIds { bool operator() (const CRef<CSeq_id>& id1, const CRef<CSeq_id>& id2) const { return (*id1 < *id2); } }; typedef map<void *, CConstRef<CDense_seg> > TConstDSsMap; typedef map<void *, CConstRef<CSeq_align> > TConstAlnsMap; typedef vector<CAlnMixSeq*> TSeqs; typedef map<CBioseq_Handle, CRef<CAlnMixSeq> > TBioseqHandleMap; typedef map<CRef<CSeq_id>, CRef<CAlnMixSeq>, SSeqIds> TSeqIdMap; typedef vector<CRef<CAlnMixMatch> > TMatches; typedef vector<CAlnMixSegment*> TSegments; typedef vector<CRef<CAlnMixSegment> > TSegmentsContainer; enum ESecondRowFits { eSecondRowFitsOk, eForceSeparateRow, eInconsistentStrand, eInconsistentFrame, eFirstRowOverlapBelow, eFirstRowOverlapAbove, eInconsistentOverlap, eSecondRowOverlap, eSecondRowInconsistency, eIgnoreMatch }; typedef int TSecondRowFits; TSecondRowFits x_SecondRowFits(CAlnMixMatch * match) const; void x_Reset (void); void x_InitBlosum62Map (void); void x_Merge (void); void x_CreateRowsVector (void); void x_CreateSegmentsVector(void); void x_CreateDenseg (void); void x_ConsolidateGaps (TSegmentsContainer& gapped_segs); void x_MinimizeGaps (TSegmentsContainer& gapped_segs); void x_IdentifyAlnMixSeq (CRef<CAlnMixSeq>& aln_seq, const CSeq_id& seq_id); // SChooseSeqId implementation virtual void ChooseSeqId(CSeq_id& id1, const CSeq_id& id2); CRef<CDense_seg> x_ExtendDSWithWidths(const CDense_seg& ds); static bool x_CompareAlnSeqScores (const CAlnMixSeq* aln_seq1, const CAlnMixSeq* aln_seq2); static bool x_CompareAlnMatchScores(const CRef<CAlnMixMatch>& aln_match1, const CRef<CAlnMixMatch>& aln_match2); static bool x_CompareAlnSegIndexes (const CAlnMixSegment* aln_seg1, const CAlnMixSegment* aln_seg2); mutable CRef<CScope> m_Scope; TConstDSs m_InputDSs; TConstAlns m_InputAlns; TConstDSsMap m_InputDSsMap; TConstAlnsMap m_InputAlnsMap; CRef<CDense_seg> m_DS; CRef<CSeq_align> m_Aln; TAddFlags m_AddFlags; TMergeFlags m_MergeFlags; TSeqs m_Seqs; TMatches m_Matches; TSegments m_Segments; TSeqs m_Rows; list<CRef<CAlnMixSeq> > m_ExtraRows; bool m_SingleRefseq; bool m_IndependentDSs; TBioseqHandleMap m_BioseqHandles; TSeqIdMap m_SeqIds; bool m_ContainsAA; bool m_ContainsNA;};//////////////////////////////////////////////////////////////////////////////// Helper Classes /////////////////////////////////////////////////////////////////////////////////class CAlnMixSegment : public CObject{public: // TStarts really belongs in CAlnMixSeq, but had to move here as // part of a workaround for Compaq's compiler's bogus behavior typedef map<TSeqPos, CRef<CAlnMixSegment> > TStarts; typedef map<CAlnMixSeq*, TStarts::iterator> TStartIterators; TSeqPos m_Len; TStartIterators m_StartIts; int m_DSIndex; // used by the truncate algorithm};class CAlnMixSeq : public CObject{public: CAlnMixSeq(void) : m_DS_Count(0), m_Score(0), m_Width(1), m_Frame(-1), m_RefBy(0), m_ExtraRow(0), m_DSIndex(0) {}; typedef CAlnMixSegment::TStarts TStarts; typedef list<CAlnMixMatch *> TMatchList;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -