1 #ifndef __FEATURE_MATCH_HPP__ 2 #define __FEATURE_MATCH_HPP__ 3 4 BEGIN_NCBI_SCOPE 5 BEGIN_SCOPE(objects) 6 7 class CScope; 8 class CMappedFeat; 9 class CSeq_feat; 10 11 enum ENoteCDS { 12 eNoteCDS_No, 13 eNoteCDS_Yes 14 }; 15 16 class CMatchmRNA; 17 class CMatchCDS; 18 class CMatchmRNA; 19 20 class CmRNAAndCDSIndex 21 { 22 public: 23 CmRNAAndCDSIndex(); 24 ~CmRNAAndCDSIndex(); 25 void SetBioseq(const std::vector<CMappedFeat> *feat_list, CScope* scope); 26 CRef<CMatchmRNA> FindMatchmRNA(const CMappedFeat& mrna); 27 bool MatchmRNAToCDSEnd(const CMappedFeat& mrna, unsigned int partial_type); 28 29 private: 30 vector < CRef<CMatchCDS> > m_CdsList; 31 vector < CRef<CMatchmRNA> > m_mRNAList; 32 33 }; 34 35 class CMatchCDS; 36 37 class CMatchFeat : public CObject 38 { 39 public: 40 CMatchFeat(const CMappedFeat &feat); ~CMatchFeat(void)41 ~CMatchFeat(void) {}; 42 GetFeat() const43 const CSeq_feat& GetFeat() const 44 { 45 return *m_feat; 46 } 47 bool operator < (const CMatchFeat& o) const; 48 FastMatchX(const CMatchFeat & o) const49 bool FastMatchX(const CMatchFeat& o) const 50 { 51 if (m_pos_start <= o.m_pos_start && o.m_pos_start <= m_pos_stop) 52 return true; 53 54 if (o.m_pos_start <= m_pos_stop && m_pos_stop <= o.m_pos_stop) 55 return true; 56 57 if (m_pos_start < o.m_pos_start && o.m_pos_stop < m_pos_stop) 58 return true; 59 60 if (o.m_pos_start < m_pos_start && m_pos_stop < o.m_pos_stop) 61 return true; 62 63 return false; 64 } minpos() const65 TSeqPos minpos() const 66 { 67 //return min(m_pos_start, m_pos_stop); 68 return m_pos_start; 69 } maxpos() const70 TSeqPos maxpos() const 71 { 72 //return max(m_pos_start, m_pos_stop); 73 return m_pos_stop; 74 } 75 protected: 76 CConstRef<CSeq_feat> m_feat; 77 private: 78 TSeqPos m_pos_start; 79 TSeqPos m_pos_stop; 80 }; 81 82 83 class CMatchmRNA : public CMatchFeat 84 { 85 public: CMatchmRNA(const CMappedFeat & mrna)86 CMatchmRNA(const CMappedFeat &mrna) : CMatchFeat(mrna), m_AccountedFor(false) {}; ~CMatchmRNA(void)87 ~CMatchmRNA(void) {}; 88 SetCDS(const CSeq_feat & cds)89 void SetCDS(const CSeq_feat& cds) 90 { 91 m_Cds = Ref(&cds); 92 m_AccountedFor = true; 93 } 94 AddCDS(CMatchCDS & cds)95 void AddCDS(CMatchCDS& cds) { m_UnderlyingCDSs.push_back(Ref(&cds)); } IsAccountedFor(void) const96 bool IsAccountedFor(void) const { return m_AccountedFor; } SetAccountedFor(bool val)97 void SetAccountedFor(bool val) { m_AccountedFor = val; } 98 bool MatchesUnderlyingCDS(unsigned int partial_type) const; 99 bool MatchAnyUnderlyingCDS(unsigned int partial_type) const; 100 bool HasCDSMatch(void); 101 102 private: 103 CConstRef<CSeq_feat> m_Cds; 104 vector < CRef<CMatchCDS> > m_UnderlyingCDSs; 105 bool m_AccountedFor; 106 }; 107 108 109 class CMatchCDS : public CMatchFeat 110 { 111 public: CMatchCDS(const CMappedFeat & cds)112 CMatchCDS(const CMappedFeat &cds) : 113 CMatchFeat(cds), 114 m_AssignedMrna(NULL), 115 m_XrefMatch(false), 116 m_NeedsmRNA(true) 117 {}; 118 ~CMatchCDS(void)119 ~CMatchCDS(void) {}; 120 AddmRNA(CMatchmRNA & mrna)121 void AddmRNA(CMatchmRNA& mrna) { m_OverlappingmRNAs.push_back(Ref(&mrna)); } SetXrefMatch(CMatchmRNA & mrna)122 void SetXrefMatch(CMatchmRNA& mrna) { m_XrefMatch = true; m_AssignedMrna = &mrna; } IsXrefMatch(void)123 bool IsXrefMatch(void) { return m_XrefMatch; } HasmRNA(void) const124 bool HasmRNA(void) const { return m_AssignedMrna != NULL; }; 125 NeedsmRNA(void)126 bool NeedsmRNA(void) { return m_NeedsmRNA; } SetNeedsmRNA(bool val)127 void SetNeedsmRNA(bool val) { m_NeedsmRNA = val; } 128 void AssignSinglemRNA(void); 129 int GetNummRNA(bool &loc_unique); 130 GetmRNA(void)131 const CRef<CMatchmRNA> & GetmRNA(void) { return m_AssignedMrna; } 132 133 private: 134 vector < CRef<CMatchmRNA> > m_OverlappingmRNAs; 135 CRef<CMatchmRNA> m_AssignedMrna; 136 bool m_XrefMatch; 137 bool m_NeedsmRNA; 138 }; 139 140 141 142 143 144 145 END_SCOPE(objects) 146 END_NCBI_SCOPE 147 148 #endif 149 150