// FeatureRange.h // Thu Aug 13 14:55:18 PDT 2009 Kevin Karplus // This file contains the definition of the FeatureRangeAlphabet class; // This is derived from the alphabet class, but supports additional // name/value pairs for describing alphabets that divide up a // ResidueFeature into ranges // #ifndef FEATURERANGEALPHABET #define FEATURERANGEALPHABET #include #include // for floor #include "Alphabet/Alphabet.h" class ChainsResiduesAndAtoms; class Conformation; class ResidueFeature; // To make sure that FeatureRangeAlphabet is linked in, // call FeatureRangeAlphabet::classID() somewhere in a program. class FeatureRangeAlphabet : public Alphabet { private: // required stuff for things derived from NamedClass static IdObject ID; static void init_is_a(IdObject *self) { self->add_is_a(Alphabet::classID()); } virtual int read_knowing_type(std::istream &in); virtual void write_knowing_type(std::ostream &out) const; // called to initialize the feature range command table used by // read_knowing_type void init_command_table(void); // command table for reading angle vector alphabets static NameToPtr *CommandTable; // local data string FeatName; // the name of the ResidueFeature, owned by this const ResidueFeature* Feat; // the ResidueFeature itself, // only available in undertaker. int Offset; // the residue index relative to the current residue vector LowEnd; vector HighEnd; // residue r is in class i if LowEnd[i]<=feat(r+Offset)0, then check range as if circle had circumference "modulus": // (x-lo)-modulus*floor((x-lo)/modulus) < (hi-lo)-modulus*floor((hi-lo)/modulus) protected: // read commands for each command static int ReadFeature(std::istream &in, Alphabet *change, AlphabetInputCommand *self); static int ReadModulus(std::istream &in, Alphabet *change, AlphabetInputCommand *self); static int ReadOffset(std::istream &in, Alphabet *change, AlphabetInputCommand *self); static int ReadRange(std::istream &in, Alphabet *change, AlphabetInputCommand *self); // print commands for each command void print_feature(std::ostream &out) const; void print_modulus(std::ostream &out) const; void print_offset(std::ostream &out) const; void print_ranges(std::ostream &out) const; // Note: we constrain alphabets so that // LowEnd[i+1] = HighEnd[i] (mod modulus) // to allow for sanity checks (like no missing classification). // QUESTION: do we want to modify definition to allow holes, // with a default Base used for any uncovered ranges? bool ranges_ok(void) const; public: // required stuff for things derived from NamedClass static IdObject *classID(void) { return &FeatureRangeAlphabet::ID; } virtual IdObject *type(void) const { return &FeatureRangeAlphabet::ID; } FeatureRangeAlphabet(void) { Modulus = 0; } bool in_range(double x, unsigned int r) const { assert(r