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

Go to the SVN repository for this file.

1 #ifndef CU_ALIGNMENT_COLLECTION_HPP
2 #define CU_ALIGNMENT_COLLECTION_HPP
9 
12 BEGIN_SCOPE(cd_utils)
13 //encapsulate the operations on a collection of alignments from normal or pending
14 //alignments of multiple CDs
15 
16 class MultipleAlignment;
17 
18 //row=0 is master
20 {
21 public:
22  AlignmentCollection(CCdCore* cd, CCdCore::AlignmentUsage alignUse=CCdCore::USE_PENDING_ALIGNMENT, bool uniqueSeqId=false, bool scoped=true);
24  void AddAlignment(CCdCore* cd, CCdCore::AlignmentUsage alignUse=CCdCore::USE_PENDING_ALIGNMENT, bool uniqueSeqId=false,bool scoped=true);
25  void AddAlignment(const AlignmentCollection& ac);
26 
27  void AddSequence(CCdCore* cd);
28  void AddSequence(const AlignmentCollection& ac);
29 
30  int getNumFamilies() const { return m_numFamilies;}
31  void setNumFamilies(int num) { m_numFamilies = num;}
32  void clear() {m_firstCd = 0; m_seqAligns.clear(); m_rowSources.clear();}
33  CCdCore* getFirstCD() const {return m_firstCd;}
34  int GetNumRows() const;
35  int GetNumPendingRows() const;
36  int GetAlignmentLength(int row=0) const;
37  bool Get_GI_or_PDB_String_FromAlignment(int row, std::string& result) const ;
38  bool GetSeqIDForRow(int row, CRef< CSeq_id >& SeqID) const ;
39  bool GetSeqEntryForRow(int row, CRef<CSeq_entry>& seqEntry)const;
40  string GetDefline(int row) const;
41  bool GetGI(int row, TGi& gi, bool ignorePDBs = true) const;
42  int GetLowerBound(int row) const;
43  int GetUpperBound(int row) const;
44  int FindSeqInterval (const CSeq_interval& seqLoc) const;
45  bool IsPending(int row)const ;
46  bool wasMaster(int row) const;
47  void removeRowSourcesForCD(CCdCore* cd);
48  void addRowSources(const vector<int>& rows, CCdCore* cd, bool scoped=true);
49  const RowSource& GetRowSource(int row) const ;
50  RowSource& GetRowSource(int row);
51  CRef<CSeq_align> getSeqAlign(int row) const{return m_seqAligns[row];}
52  const RowSourceTable& GetRowSourceTable() const {return m_rowSources;};
53  //get all CDs involved in this AlignmentCollection
54  int getCDs(vector<CCdCore*>& cds);
55  //get only CDs whose alignment rows are indlued
56  int getCDsInScope(vector<CCdCore*>& cds);
57  //get CDs which are only used to map row membership of duplicated SeqLoc
58  int getCDsOutofScope(vector<CCdCore*>& cds);
59  bool isCDInScope(CCdCore* cd)const;
60  bool isRowInScope(int row)const;
61  CCdCore* GetLeafDescendentCD(int row, bool includeSelf=false)const;
62  CCdCore* GetScopedLeafCD(int row)const;
63  CCdCore* GetSeniorMemberCD(int row, bool scopedOnly=true)const;
64  void convertFromCDRows(CCdCore* cd, const vector<int>& cdRows, set<int>& colRows)const;
65  void convertToCDRows(const vector<int>& colRows, CDRowsMap& cdRows) const;
66  void mapRows(const AlignmentCollection& ac, const set<int>& rows, set<int>& convertedRows) const;
67  int mapRow(const AlignmentCollection& ac, int row) const;
68  void getAllRowsForCD(CCdCore* cd, vector<int>& colRows)const;
69  bool GetSpeciesForRow(int row, string& species) const;
70  bool GetBioseqForRow(int rowId, CRef< CBioseq >& bioseq);
71  int GetRowsWithSameSeqID(int rowToMatch, vector<int>& rows, bool inclusive = true) const;
72  int GetRowsWithSeqID(const CRef< CSeq_id >& SeqID, vector<int>& rows) const;
73  bool IsStruct(int row);
74  bool IsPdb(int row)const;
75  void GetAllSequences(vector<string>& sequences);
76  string GetSequenceForRow(int row);
77  void GetAlignedResiduesForRow(int row, char*&);
78  void GetAlignedResiduesForAll(char** & ppAlignedResidues, bool forceRecompute) ;
79  bool isInstanceOf(MultipleAlignment* ma);
80  void getNormalRowsNotInChild(vector<int>& childless, bool excludeMaster=false) const;
81  //void makeGuideAlignment(int row, Multiple
82  virtual ~AlignmentCollection();
83 
84  // dih -- I added these for debugging
85  bool AreNonOverlapping() const;
86  bool IsNonOverlapping(const CRef< CSeq_align >& align, int& blockIndex) const;
87  string& getLastError() {return m_err;}
88  //static void EraseRows(CCdCore * pCD,vector < int > & rows) ;
89  //static void CopyRows(CCdCore * pSrCCdCore,CCdCore * pDstCD,vector < int > & rows) ;
90  //static bool GetDenDiagSet(CCdCore * pCD,int row, ncbi::objects::TDendiag* & pDenDiagSet);
91 
92 protected:
93  vector< CRef< CSeq_align > > m_seqAligns; //row=0 holds master
94  //CCdCore::AlignmentUsage m_alignUse;
95  //int m_pendingStart;
99  string m_err;
100 
101  //buffer sequence data to speed up
102  vector<CRef< CBioseq > > m_bioseqs;
104 
105  void addPendingAlignment(CCdCore* cd, bool uniqueSeqId=false, bool scoped=true);
106  void addNormalAlignment(CCdCore* cd, bool uniqueSeqId=false, bool scoped=true);
107 };
108 
109 //all rows in Multiple Alignment should have the same block structure.
110 
112 {
113 public:
114  MultipleAlignment(CCdCore* cd, bool scoped=true);
115  MultipleAlignment(const CDFamily& family);
117 
118  bool setAlignment(const CDFamily& family);
119  bool setAlignment(const CDFamily& family, CDFamilyIterator& start);
120  void setAlignment(CCdCore* cd, bool scoped=true);
121  void setAlignment(CRef<CSeq_align>& seqAlign);
122  bool setAlignment(const AlignmentCollection& ac, int row);
123  bool isBlockAligned() const;
124  //void setAlignment(const MultipleAlignment& malign);
125  int appendAlignment(MultipleAlignment& malign,bool includeUnScoped=true);
126  bool findParentalEquivalent(const cd_utils::BlockModel& bar, int& pRow, bool inputAsChild=true) const;
127  bool findParentalCastible(const cd_utils::BlockModel& bar, int& pRow) const;
128  bool locateChildRow(const cd_utils::BlockModel& childRow, int& pRow) const;
129  const cd_utils::BlockModel& getBlockModel(int row) const;
130  void copyRowSource(int currentRow, const AlignmentCollection& malign, int rowInAc);
131  bool transferToCD(CCdCore* cd =0); //transfer to the first/root cd;
132  bool extractAlignedSubset(const AlignmentCollection& ac, const set<int>& normalRows,
133  int master);
134 
135 private:
136  //to hide the one in the base class
138 
139  void makeBlockTable();
140  int transferOneRow(CCdCore* cd, int row);
141 
142  vector<cd_utils::BlockModel> m_blockTable;
143 };
144 
145 END_SCOPE(cd_utils)
147 #endif
vector< CRef< CBioseq > > m_bioseqs
CRef< CSeq_align > getSeqAlign(int row) const
const RowSourceTable & GetRowSourceTable() const
CCdCore * getFirstCD() const
vector< CRef< CSeq_align > > m_seqAligns
AlignmentUsage
Definition: cuCdCore.hpp:62
@ USE_PENDING_ALIGNMENT
Definition: cuCdCore.hpp:64
void AddAlignment(CCdCore *cd, CCdCore::AlignmentUsage alignUse)
vector< cd_utils::BlockModel > m_blockTable
Definition: map.hpp:338
int GetLowerBound(const CRef< CSeq_align > &seqAlign, bool onMaster)
Definition: cuAlign.cpp:258
int GetUpperBound(const CRef< CSeq_align > &seqAlign, bool onMaster)
Definition: cuAlign.cpp:273
USING_SCOPE(objects)
string
Definition: cgiapp.hpp:687
#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
#define NCBI_CDUTILS_EXPORT
Definition: ncbi_export.h:376
else result
Definition: token2.c:20
Modified on Wed Feb 21 09:54:49 2024 by modify_doxy.py rev. 669887