BioInt  1.02.00
BioInt: An integrative biological object-oriented application framework and interpreter
BioUtilities.h
Go to the documentation of this file.
00001 /****************************************************************************
00002 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00003 The BioBhasha : A Programming Language for Biologist
00004 Version 1.0 (19th December 2001)
00005 Dr. Prasad, B.V.L.S.
00006 Contact: prasadbvls@helixgenomics.com
00007 Version 1.1 (23th January 2003)
00008 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00009 *****************************************************************************/
00010 
00011 #ifndef BIOUTILITIES_H
00012 #define BIOUTILITIES_H
00013 
00014 using namespace std;
00015 
00016 #include <fstream>
00017 #include <vector>
00018 #include <string>
00019 #include <sstream>
00020 #include <algorithm>
00021 #include <cmath>
00022 #include <cstdlib>
00023 #include <iostream>
00024 #include "BioMatrix.h"
00025 
00026 /*****************************************************************************
00027  *
00028  * COMMENTARY on Each Class/Concept: Hows and Whys :
00029  *
00030  * BioUtilities:
00031  *              As the name suggests, this file holds some  global functions
00032  *              which have been most frequently and most extensivly used to 
00033  *              write efficient file parsers, converters etc... and some 
00034  *              very primitive functions like distance, angle, torsion etc.
00035  * *************************************************************************/
00036 
00037 const double PI = 3.14285714285714;
00038 
00039 string toString( const vector<int>& x);
00040 
00041 vector<string> extractDataBlock(ifstream& fin, const string& startStr, const string& endStr);
00042 
00043 bool checkFloat(string val);
00044 
00045 vector<int> processString(string indexstr);
00046 
00047 string rightTrim(const string& a);
00048 
00049 string leftTrim(const string& a);
00050 
00051 string parseStr(const string &st, const string &fill );
00052 
00053 // REVERSING THE GIVEN LARGE STRING
00054 void reverseLargeString(string &st);
00055 
00056 vector<int> getUniqueVectorElements(vector<int>);
00057 vector<float> getUniqueVectorElements(vector<float>);
00058 vector<char> getUniqueVectorElements(vector<char>);
00059 vector<string> getUniqueVectorElements(vector<string>);
00060 vector<string> removeVectorElements(vector<string>,string);
00061 void printVector(vector<string>,char c='\t');
00062 vector<string> splitString(string s, char c='\t');
00063 void BioGetChar();
00064 void BioClear();
00065 
00066 //float getPreciseFloat(double& d);
00067 //float getPreciseFloat(double& d, int pre);
00068 
00069 int stringToInt(const string &);
00070 long stringToLong(const string &);
00071 float stringToFloat(const string &);
00072 double stringToDouble(const string &);
00073 
00074 string toString(const int &);
00075 string toString(const long &);
00076 string toString(const float &);
00077 string toString(const double &);
00078 
00079 string toUpperCase(const string& s);
00080 
00081 string toLowerCase(const string& s);
00082 
00083 string reverseString(const string& s);
00084 
00085 string replaceString(string st, string p1, string rep="",int noRep=-1);
00086 
00087 void align(string,int,int,ostream& =cout);
00088 
00089 void alignLines(string,ostream& =cout,unsigned int len=67);
00090 
00091 float roundNumber(float number, float dec);            
00092 // Delimiter Needs some explanation:
00093 // 1st Argument [string] : string which has to be parsed 
00094 // 2nd Argument [char  ] : delimiter character, ex: ';','.'etc
00095 // 3rd Argument [string&]: return string till the delimiter
00096 // 4th Argument [int   ] : Position in the 1st Argument String, from where 
00097 //                      the parsing should start.
00098 // int Return Value: This give the position of the delimiter and 
00099 // this return integer value can be used to parse the whole string for 
00100 // multiple delimiters within  the string by using recurrence technique.
00101 // This delimiter function is especially useful in Fasta Format for reading
00102 // the First Line with ';' as delimiter to identify the seqId.
00103 
00104 int delimiter(  string , char ,string & , int z = 0);
00105 
00106 string rmBlank(const string& x);
00107 
00108 float toDegrees(const float rad_);
00109 
00110 float toRadians(const float th_);
00111 
00112 float distance( const float x1, const float y1, const float z1, 
00113                 const float x2, const float y2, const float z2);
00114 
00115 
00116 float angle ( const float, const float, const float, 
00117                const float, const float, const float, 
00118                const float, const float, const float); 
00119 
00120 float torsion ( const float , const float, const float,
00121                  const float , const float, const float,
00122                  const float , const float, const float,
00123                  const float , const float, const float);
00124 
00125 float angleBetweenDirectionCosines(float l1, float m1, float n1,
00126                         float l2, float m2, float n2);
00127 
00128 float angleBetweenDirectionCosines(BioMatrix& x1, BioMatrix& x2);
00129 
00130 float determinant(float , float , float ,
00131                    float , float , float ,
00132                    float , float , float );
00133 
00134 float BioDeterminant3by3(BioMatrix&);
00135 BioMatrix BioInverse3by3(BioMatrix& );
00136 
00137 void breakLines(string& s, ostream& = cout);
00138 
00139 void BioShowInBrowser(string fileName_,string browser_="c:/Program\\ Files/Internet\\ Explorer/IEXPLORE.exe");
00140 
00141 void BioShowDnaSubstitutionMatrix(ostream & os = cout);
00142 void BioShowProteinSubstitutionMatrix(ostream & os = cout);
00143 
00144 void BioShowAcidicAminoAcids(ostream& os = cout);
00145 
00146 void BioShowBasicAminoAcids(ostream& os = cout);
00147 
00148 void BioShowPolarAminoAcids(ostream& os = cout);
00149 
00150 void BioShowNonPolarAminoAcids(ostream& os = cout);
00151 
00152 void BioShowAminoAcidAmbiguityCode(ostream& os = cout);
00153 
00154 void BioShowNucleicAcidAmbiguityCode(ostream& os = cout);
00155 
00156 void BioShowFTKs(ostream& os  = cout);
00157 
00158 void BioShowFTQs(ostream& os = cout);
00159 
00160 void BioShowNucleicAcidProperties(ostream& os = cout);
00161 
00162 void BioShowAminoAcidProperties(ostream& os = cout);
00163 
00164 
00165 void BioShowSpaceGroupNames(ostream& os = cout);
00166 
00167 void BioShowStandardCodonTable(ostream& os = cout);
00168 
00169 void BioShowAmbiguousRestrictionEnzymes(ostream& os = cout);
00170 
00171 
00172 void BioShowUnAmbiguousRestrictionEnzymes(ostream& os = cout);
00173 
00174 void BioShowUniqueAmbiguousRestrictionEnzymes(ostream& os = cout);
00175 
00176 void BioShowUniqueUnAmbiguousRestrictionEnzymes(ostream& os = cout);
00177 
00178 #endif
00179 
00180 
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines