/* Copyright by Matthias Hoechsmann (C) 2002-2004 ===================================== You may use, copy and distribute this file freely as long as you - do not change the file, - leave this copyright notice in the file, - do not make any profit with the distribution of this file - give credit where credit is due You are not allowed to copy or distribute this file otherwise The commercial usage and distribution of this file is prohibited Please report bugs and suggestions to */ #ifndef _ALIGNMENT_H_ #define _ALIGNMENT_H_ #include #include #include "types.h" #include "algebra.h" #include "ppforest.h" #include "ppforestali.h" template class Alignment { private: struct CSFPair { Uint i; Uint j; Uint k; Uint l; CSFPair(Uint i, Uint j, Uint k, Uint l) : i(i),j(j),k(k),l(l) {}; }; R *m_mtrx; Ulong *m_rowStart; Ulong m_mtrxSize; PPForest *m_ppfx; PPForest *m_ppfy; const Algebra *m_alg; const RNA_Algebra *m_rnaAlg; R m_localOptimum; R m_localSubOptimum; std::list m_localAlis; // holds which alignments are already produced by getOptLocalAlignment double m_suboptimalsPercent; // percentage is stores as a value between 0 and 1 inline R getMtrxVal(Ulong i,Ulong j) const { assert(m_rowStart[i]+jchoice(m_localOptimum,val); // here we calculate local similarity on the fly }; void calculateLocal(const PPForest *ppfx, const PPForest *ppfy,const Algebra &alg, bool noSpeedup=false); void calculateGlobal(const PPForest *ppfx, const PPForest *ppfy,const Algebra &alg, bool noSpeedup=false); Uint backtrack(PPForestAli &ppf,Uint i, Uint j, Uint k, Uint l, Uint &node); public: Alignment(const PPForest *ppfx, const PPForest *ppfy,const Algebra &alg, bool local, bool noSpeedup=false); Alignment(const PPForest *ppfx, const PPForest *ppfy,const RNA_Algebra &rnaAlg); ~Alignment(); R getGlobalOptimum(); /** This function should only be used in conjunction with * similarity based algebras */ double getGlobalOptimumRelative(); inline R getLocalOptimum(){return m_localSubOptimum;}; R getSILOptimum(); void getOptGlobalAlignment(PPForestAli &ppfali); void resetOptLocalAlignment(int suboptimalsPercent=100); bool nextLocalSuboptimum(); void getOptLocalAlignment(PPForestAli &ppfali,Uint &xbasepos, Uint &ybasepos); void getOptSILAlignment(PPForestAli &ppfali,Uint &ybasepos); }; #endif