00001 /* 00002 LoopTK: Protein Loop Kinematic Toolkit 00003 Copyright (C) 2007 Stanford University 00004 00005 This program is free software; you can redistribute it and/or modify 00006 it under the terms of the GNU General Public License as published by 00007 the Free Software Foundation; either version 2 of the License, or 00008 (at your option) any later version. 00009 00010 This program is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 GNU General Public License for more details. 00014 00015 You should have received a copy of the GNU General Public License along 00016 with this program; if not, write to the Free Software Foundation, Inc., 00017 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 00018 */ 00019 00020 #ifndef PPHIPSIDISTRIBUTION_H 00021 #define PPHIPSIDISTRIBUTION_H 00022 00023 #include <vector> 00024 #include <iostream> 00025 #include <fstream> 00026 #include <math.h> 00027 #include <map> 00028 00029 using namespace std; 00030 00038 class PPhiPsiDistribution { 00039 public: 00040 00041 PPhiPsiDistribution() { } 00061 PPhiPsiDistribution(const vector< vector<double> > &v, const string &name="anything"); 00062 00063 /* 00064 * Prints a human-readable representation of this 00065 * PPhiPsiDistribution to the specified output stream. 00066 * Useful for debugging. 00067 */ 00068 void print(ostream &out) const; 00069 00070 /* 00071 * Given a Phi value <code>phi</code> and Psi value <code>psi</code>, return the probabilty of having them according to 00072 * this distribution. 00073 */ 00074 double getProbPhiPsi (double phi, double psi) const; 00075 00076 /* 00077 * Given a Psi value <code>psiValue</code>, return a distribution of Phi. 00078 * The ith element in the output is the probability of phi in the ith interval given the psi value. 00079 */ 00080 vector<double> getPhiDistribution (double psiValue) const; 00081 00082 /* 00083 * Given a Phi value <code>phiValue</code>, return a distribution of Psi. 00084 * The ith element in the output is the probability of psi in the ith interval given the psi value. 00085 */ 00086 vector<double> getPsiDistribution (double phiValue) const; 00087 00088 /* 00089 * Unconditional probability of Phi. 00090 * The ith element in the output is the probability of phi in the ith interval if we do not have any priori knowledge on psi. 00091 */ 00092 vector<double> getPhiDistribution() const { return PhiDistribution; } 00093 00094 /* 00095 * Unconditional probability of psi. 00096 * The ith element in the output is the probability of psi in the ith interval if we do not have any priori knowledge on phi. 00097 */ 00098 vector<double> getPsiDistribution() const { return PsiDistribution; } 00099 00100 /* 00101 * Return true if the distribution is empty; false otherwise. 00102 */ 00103 bool isEmpty() const { return distribution.empty(); } 00104 00108 int numPhiIntervals() const { return PhiIntervalNum; } 00109 00113 int numPsiIntervals() const { return PsiIntervalNum; } 00114 00115 /* 00116 * Create a Ramachandran distribution using the distribution data in our database. 00117 */ 00118 static map<string,PPhiPsiDistribution> generateRamachandran(); 00119 00120 private: 00121 string AA_Name; 00122 vector< vector<double> > distribution; 00123 vector<double> PhiDistribution; 00124 vector<double> PsiDistribution; 00125 int PhiIntervalNum; 00126 int PsiIntervalNum; 00127 double PhiIntervalSize; 00128 double PsiIntervalSize; 00129 00130 int getPhiIntervalIdx (double phiValue) const; 00131 int getPsiIntervalIdx (double psiValue) const; 00132 }; 00133 00134 #endif