BioInt  1.02.00
BioInt: An integrative biological object-oriented application framework and interpreter
BioResidue.h
Go to the documentation of this file.
00001 /****************************************************************************
00002 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00003 The BioBhasha : The Biologist's Programming Language 
00004 Version 1.0 (19th December 2001)
00005 Prasad, B.V.L.S.
00006 Contact: burrashiva@yahoo.com
00007 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00008 *****************************************************************************/
00009 #ifndef BIORESIDUE_H
00010 #define BIORESIDUE_H
00011 
00012 #include "BioAtom.h"
00013 #include "BioAminoAcidLibrary.h"
00014 
00015 /*****************************************************************************
00016  *
00017  * COMMENTARY on Each Class/Concept: Hows and Whys :
00018  *
00019  * BioResidue:
00020  *              A group of Atoms make a Molecule. In the case of Proteins, 
00021  *              it is a Residue or AminoAcid, or in the case of DNA/RNA, it 
00022  *              is a Nucleotide or in the case of Carbohydrates, it is a
00023  *              monosaccharide. 
00024  *              From this, A Residue "CONTAINS" a group of Atoms or 
00025  *              a Residue "AGGREGATES"  Atoms.
00026  *              Hence, BioResidue "Has-A" BioAtom or a BioResidue "Has-A"
00027  *              BioAtoms.
00028  *              The Number of Atoms varies from AminoAcid to AminoAcid, 
00029  *              from Nucleotide to Nucleotide and mono-saccharide to mono-
00030  *              -saccharide. Hence, vector<T> container has been used. 
00031  *              Vector is a Container, it belongs to Standard Template
00032  *              Library Provided with C++. It is one of the most widely 
00033  *              test, verified and efficiently written template. There
00034  *              are many Manipulative Methods which make it very suitable
00035  *              where Number of Elements is not known. It dynamically 
00036  *              allocates memory for the job. 
00037  *              While Parsing a file,the number of Atoms and the 
00038  *              number of Residues is not known as it is very much dependent
00039  *              on the Protein/DNA which is being parsed. 
00040  *              Hence to accomodate such a situation, one has to use
00041  *              DMA(Dynamic Memory Allocation). At this juncture, using vector
00042  *              of BioAtom Class is ideal. Irrespective of number Of Atoms in 
00043  *              the Residue or Number of Residues in the Protein, it allocates
00044  *              automatically the memory.
00045  *              BioResidue, hence is a group of BioAtoms and many operations can 
00046  *              be on the data encapsulated in BioResidue. 
00047  *              For a BioResidue, the ResidueName and ResidueNumber are unique.
00048  *              This criteria is used in many logical expressions, hence care
00049  *              should be taken to keep the residueName and residueNumber same
00050  *              per residue. 
00051  ******************************************************************************/
00052 class BioResidue
00053 {
00054 
00055         vector < BioAtom > atom;
00056         string residueName_;
00057         long residueNumber_;
00058 
00059            friend bool operator >(const BioResidue& , const BioResidue&);
00060            friend bool operator <(const BioResidue& , const BioResidue&);
00061            friend bool operator ==(const BioResidue& , const BioResidue&);
00062 
00063 
00064 public:
00065 // Default Constructor ... Kept this for formality...I hope this is least used...
00066 // very rarely this would be useful..
00067         BioResidue();
00068         ~BioResidue();
00069         BioResidue& operator=(const BioResidue& r);
00070         BioResidue(const BioResidue& r);
00071 
00072 
00073 // Similar to the Corresponding Constructor of BioAtom, this also takes a set of 
00074 // first residue only from the PDB file provided as the argument. 
00075 // In this the parsing stops when the residue number and residue name are not 
00076 // equal to the ones which have been pushed into the "atom" vector container.
00077         BioResidue(const string&);
00078 // A Residue should have minimum, one atom information.For such situations, the following 
00079 // constructor is very useful for instantiation. Normal HOH/WATER information in 
00080 // PDB file has only one Oxygen information. But its a Molecule having 3 Atoms, 
00081 // 1 Oxygen and 2 Hydrogens.  Hence Water molecule should be considered as a residue. 
00082 // the argument sequence follows the PDB format except the last argument. 
00083 // the last argument: string: is provided to give flexibility in altering the RECORD name.
00084         BioResidue(unsigned long,string, string,long,float, float, float, float, float,string );
00085 
00086 //This constructor is useful mostly when a set of Atom coordinates are already loaded. 
00087 //Its needed to qualify the group of Atoms, at that point, all the group of atoms can 
00088 //be held with a residueName and residueNumber. 
00089   BioResidue(const string& resname_,vector<BioAtom>, const long resnum_ = 0);
00090 
00091 // to get residueName and residueNumber
00092         string getResidueName() const ;
00093         long getResidueNumber() const ;
00094         unsigned int getNumberOfAtoms() const ;
00095                  int getAtomIndex(const string& ) const ; 
00096 
00097 // to get the last atom ..in General, set,get, show,  push, find verbs are used to access
00098 // the data encapsulated.
00099         unsigned long getLastAtomNumber() const ;
00100         string getLastAtomName() const ;
00101 
00102 // this returns the last atom which ever has been added to the vector atom, during reading 
00103 // the file. 
00104         BioAtom getLastAtom();
00105 
00106         void setResidueName(string res_name) ;
00107         void setResidueNumber ( long res_num)  ;
00108 // this is very useful to add a set of Atom information to a residue.
00109 // This Method is used to populate the vector atom under some logical conditions.
00110         void pushAtom(const BioAtom&);
00111 
00112 // this overloaded Method is especially used when populating a Residue through a PDB
00113 // file.
00114         void pushAtom(const unsigned long atnumber,const string& atname,
00115                       const float x1, const float y1, const float z1,
00116                       const float oc1, const float bf1,string rec);
00117 
00118 // this Method is used to erase Hydrogen Atoms present in the PDB file, if it is 
00119 // Neutron Diffraction Data or Hydrogens are Generated through Xplor or CNS or any other
00120 // Package. The Important thing to note is that the erased Hydrogen set of Atoms are 
00121 // returned as BioResidue type which will not Modify the data which has been entered at
00122 // first.i.e Data is Safe.  
00123         BioResidue eraseHydrogen();
00124 
00125 // these 2 Methods are very very important in the sense, the user is given the ability
00126 // to access the atom which he/she is interested in, either through giving the atomIndex
00127 // or just by giving the AtomName , for example getAtom("CA") or getAtom(0) for accessing 
00128 // the first atom information from the residue information;
00129         BioAtom getAtom(string);
00130         BioAtom getAtom(unsigned int ) const;
00131 
00132         bool findAtom(const string& aa) ;
00133 
00134         BioPoint getCentroid();
00135         
00136 
00137 // this Method prints the contents of the Residue in a PDB format, with an optional 
00138 // Chain Id... If the user wants, he/she can redirect into a file through instantiating 
00139 // a proper output file stream.
00140         void showResidue(ostream& = cout,char = 'A'); 
00141         friend ostream& operator<<(ostream& os, BioResidue& ip);
00142 
00143 // the user has to give the valid atomNames present in the Residue.
00144         float getTorsionAngle(string, string, string, string);
00145         float getTorsionAngle(int , int , int , int );
00146         
00147         float getDistance(int , float ,float ,float);
00148         float getDistance(const string& ,float,float, float);
00149 
00150         float getDistance(const string&, const BioAtom& );
00151         float getDistance(int , const BioAtom& );
00152 
00153 // this gives the Chi[1,2,3,4,5] Torsion angles  of the Residue under consideration. 
00154 // this also can be written to file as explained above.  By default it will print 
00155 // to the console or standard Output.
00156         void showChiAngles(ostream& = cout);
00157         void chiAngles(ostream& = cout);
00158 
00159 
00160 };
00161 
00162 #endif
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines