Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

Bioseq.hh

Go to the documentation of this file.
00001 #ifndef BIOSEQ_HEADER
00002 #define BIOSEQ_HEADER
00003 
00004 // ==== HEADER Bioseq.hh ====
00005 
00011 // 9-Aug-1999. Andras Aszodi
00012 
00013 // ---- COMPATIBILITY NOTES ----
00014 
00015 // ANSI C++ standard only.
00016 
00017 // ==== STANDARD HEADERS ====
00018 
00019 #include <stdlib.h>
00020 
00021 #ifdef _STANDARD_C_PLUS_PLUS
00022 #include <iostream>
00023 #else
00024 #include <iostream.h>
00025 #endif
00026 
00027 #include <string>
00028 using namespace std;
00029 #ifndef NPOS
00030 #define NPOS string::npos
00031 #endif
00032 
00033 // ==== MODULE HEADERS ====
00034 
00035 #include"Monomer.hh"
00036 #include "Rangedimexc.hh"
00037 #include"Bioseqio.hh"
00038 
00039 // ==== CLASSES ====
00040 
00041 namespace RazorBack {
00042 
00049 class Bioseq_: protected Bioseqio_
00050 {
00051     // data
00052     private:
00053     
00054     Monomer_ Monomer;   
00055     bool Nocase;    
00056     string Seq;     
00057     string ID;      
00058     string Title;    
00059     string Annot;   
00060     
00061     // methods
00062     public:
00063     
00069     explicit Bioseq_(Monomer_::Type_ Mt=Monomer_::PROT):
00070             Monomer(Mt), Seq(""), ID(""), Title(""), Annot(""), 
00071             Nocase(false), Bioseqio_() {}
00072 
00077     explicit Bioseq_(const char* Codes):
00078             Monomer(Codes), Seq(""), ID(""), Title(""), Annot(""), 
00079             Nocase(false), Bioseqio_() {}
00080 
00082     Bioseq_(const Bioseq_& B):
00083             Monomer(B.Monomer), Seq(B.Seq), ID(B.ID), Title(B.Title), Annot(B.Annot),
00084             Nocase(B.Nocase), Bioseqio_(B) {}
00085     
00090     const string& id() const { return ID; }
00091     string& id() { return ID; }
00092     void id(const string& I) { ID=I; }
00093     const string& title() const { return Title; }
00094     string& title() { return Title; }
00095     void title(const string& T) { Title=T; }
00096     const string& annot() const { return Annot; }
00097     string& annot() { return Annot; }
00098     void annot(const string& A) { Annot=A; }
00099     bool nocase() const { return Nocase; }
00100     bool nocase(bool N) { bool On=Nocase; Nocase=N; return On; }
00101     
00107     const Monomer_& monomer() const { return Monomer; }
00108     
00113     const string& seq() const { return Seq; }
00114     
00119     virtual
00120     void seq(const string& S)
00121     {
00122         if (!is_legal(S))
00123             cerr<<"\n? Bioseq_::seq(...): Illegal char(s) in sequence\n";
00124         else Seq=S;
00125     }
00126     
00128     size_t length() const { return seq().length(); }
00129     
00131     char operator[](size_t Idx) const { return Seq[Idx]; }
00132     char& operator[](size_t Idx) { return Seq[Idx]; }
00133     
00142     virtual
00143     char at_1(size_t Idx) const;
00144     virtual
00145     bool at_1(size_t Idx, char C);
00146    
00156     const char* at_3(size_t Idx) const;
00157     bool at_3(size_t Idx, const char* Ccc);
00158    
00164     int uppercase();
00165     int lowercase();
00166     
00168     
00176     virtual
00177     bool is_legal(char C) const { return (Monomer.is_legal(C, Nocase)); }
00178     virtual
00179     bool is_legal(const char* Ccc) const { return (Monomer.is_legal(Ccc, Nocase)); }
00180     bool is_legal(const string& S) const;
00181     
00182         // Input-output
00183     
00201     virtual
00202     Errtype_ read_seq(istream& Inf, int Type=Monomer_::USER, int Format=ANYFORMAT);
00203 
00209     virtual
00210     Errtype_ write_seq(ostream& Outf, int Format) const;
00211     
00212     // hidden methods
00213     protected:
00214             
00215     Monomer_& chg_monomer() { return Monomer; }         // non-const access protected
00216     virtual
00217     bool is_legal(int Mt, char C) const;
00218     string& sequence() { return Seq; }
00219     
00220 };
00221 // END OF CLASS Bioseq_
00222 
00223 }   // RazorBack
00224 
00225 // ==== END OF HEADER Bioseq.hh ====
00226 
00227 #endif      // BIOSEQ_HEADER

Generated at Wed Aug 21 09:33:42 2002 for The Razorback C++ Library: Bioinformatics by doxygen1.2.6 written by Dimitri van Heesch, © 1997-2001