// SeqWeight.h // Kevin Karplus // 23 Oct 1995 // Sequence weighting techniques applied to blocks (no insertions) // // Note: linking SeqWeight.o into an executable makes the table of // SequenceWeightObject available, preloaded with three methods // FlatWeight // HenikoffWeight // EntropyWeight // See the .cc file for details #ifndef SeqWeight_H #define SeqWeight_H class alignment; // forward reference, use readBlocks.h to get full spec #include "Utilities/log2.h" #include "Regularizer/Regularizer.h" #include "NamedClass/NameToPtr.h" // for look up table for named sequence weight methods typedef void (*SequenceWeightFcn)(alignment&b, float bits_to_save, ostream *weight_file, Regularizer* r, float extra_param, float clip_total_to); // function for setting the weights of sequences in a block // specifies number of bits to save // takes an arbitrary "float" parameter, and an optional // target regularizer (if weighting depends on regularizer) // The optional weight_file gets the weights in a format suitable // for SAM's sequeince weight input. class SequenceWeightObject: public NamedObject { SequenceWeightFcn Function; static NameToPtr* WeighterTable; private: inline void AddName(OptionIfOld opt=ErrorIfOld) { if (!WeighterTable) { WeighterTable=new NameToPtr(79); WeighterTable->ignore_case(); } WeighterTable->AddName(this, opt); } public: SequenceWeightObject(const char *nm, SequenceWeightFcn fun, const char* hlp) : NamedObject(nm,hlp) { Function=fun; AddName(); } inline static const SequenceWeightObject* find_name(const char* name) { return dynamic_cast (WeighterTable->FindOldName(name, ZeroIfNew)); } inline static NameToPtr* weighter_table(void) { return WeighterTable; } inline SequenceWeightFcn fcn(void) const {return Function;} void execute(alignment&b, int interface_num=0, ostream* weight_file=0) const; // picks up paramters from Globals }; // For both HenikoffWeight and EntropyWeight, only normal characters // (not wildcards or gaps) are used. // There are ways to handle wildcards in both schemes, but it wasn't // thought to be worth the effort for the relatively few wildcards // found in the databases. // CHANGE LOG: // 9 April 2004 Kevin Karplus // Changed include for move of log2.h to Utilities/ // 24 May 2004 Kevin Karplus // inlined simple functions #endif