PSampMethods.h

Go to the documentation of this file.
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 #include <iostream>
00021 #include <time.h>
00022 #include "PBasic.h"
00023 #include "PChainNavigator.h"
00024 #include "PConstants.h"
00025 #include "PDataCollector.h"
00026 #include "PExtension.h"
00027 #include "PTools.h"
00028 #include "POptimize.h"
00029 #include "PPhiPsiDistribution.h"
00030 #include <string>
00031 #include <list>
00032 #include <vector>
00033 #include <stack>
00034 #include <stdlib.h>
00035 #include <math.h>
00036 #include <map>
00037 
00038 class SpaceRelationship {
00039 
00040   private:
00041         friend class PSampMethods;
00042 
00043         Real angle_c_n_ca;
00044         Real angle_ca_c_n;
00045         Real angle_o_c_n;
00046         Real length_c_n;
00047         Real length_ca_c;
00048         Real length_o_c;
00049 
00050         SpaceRelationship () {
00051                 angle_c_n_ca = ANGLE_C_N_CA;
00052                 angle_ca_c_n = ANGLE_CA_C_N;
00053                 angle_o_c_n = ANGLE_O_C_N;
00054                 length_c_n = LENGTH_C_N;
00055                 length_ca_c = LENGTH_CA_C;
00056                 length_o_c = LENGTH_O_C;
00057         }
00058 
00059         SpaceRelationship (PResidue *res1, PResidue *res2) {
00060                 Vector3 ca1 = res1->getAtomPosition("CA");
00061                 Vector3 c1 = res1->getAtomPosition("C");
00062                 Vector3 o1 = res1->getAtomPosition("O");
00063                 Vector3 n2 = res2->getAtomPosition("N");
00064                 Vector3 ca2 = res2->getAtomPosition("CA");
00065                 angle_c_n_ca = rad2deg*PMath::getAngle(c1-n2, ca2-n2);
00066                 length_c_n = (c1-n2).norm();
00067                 angle_ca_c_n = rad2deg*PMath::getAngle(ca1-c1,n2-c1);
00068                 length_ca_c = (ca1-c1).norm();
00069                 angle_o_c_n = rad2deg*PMath::getAngle(o1-c1,n2-c1);
00070                 length_o_c = (o1-c1).norm();
00071         }
00072 
00073         void print() {
00074                 cout << "angle_c_n_ca = " << angle_c_n_ca << endl;
00075                 cout << "angle_ca_c_n = " << angle_ca_c_n << endl;
00076                 cout << "angle_o_c_n = " << angle_o_c_n << endl;
00077                 cout << "length_c_n = " << length_c_n << endl;
00078                 cout << "length_ca_c = " << length_ca_c << endl;
00079                 cout << "length_o_c = " << length_o_c << endl;
00080         }
00081 }; // end class SapceRelationship
00082 
00083 
00087 class PSampMethods {
00088   public:
00094         static IKSolution RandAndIKClose(PProtein *loop, bool clash_free);
00102         static IKSolution RandAndIKClose(PProtein *loop,const string &pdbFileName, bool clash_free);
00106         static IKSolutions PermuteIK(PProtein *loop, int num_wanted);
00107         
00111         static vector<PProtein*> DeformSampleBackbone(PProtein *orig_protein, int loopSid, int loopEid, int num_wanted, double deform_mag);
00112 
00117         static vector<PProtein*> SeedSampleBackbone (PProtein *protein, int loopSid, int loopEid, int num_wanted=1);
00118 
00122          /* Usage example:
00123          *      map<string,PPhiPsiDistribution> Map = PPhiPsiDistribution::generateRamachandran();
00124          *      PProtein *protein = PDBIO::readFromFile("pdbfiles/135L.pdb");
00125          *      int loopSid=64, loopEid=72;
00126          *      vector<PProtein*> newps = PSampMethods::SeedSampleBackbone(protein,loopSid,loopEid,Map);
00127          *      PProtein *loop = new PProtein(newps[0],loopSid,loopEid);
00128          *      // Write the loop to a pdb file
00129          *      PDBIO::writeToFile(loop,"pdbfiles/135L_seed.pdb");
00130          *      // Add side chain
00131          *      PSampMethods::addSidechain("pdbfiles/135L_seed.pdb","pdbfiles/135L_NoLoop.pdb","/home/scwrl3_lin","pdbfiles/135L_seed_withSC.pdb");
00132          *      // Merge the loop with side chain and the protein
00133          *      PProtein *new_protein = PSampMethods::MergeProtein(loop,protein,loopSid);
00134          *      PDBIO::writeToFile(new_protein,"pdbfiles/135_new.pdb");
00135          */
00136         static vector<PProtein*> SeedSampleBackbone (PProtein *protein, int loopSid, int loopEid, map<string,PPhiPsiDistribution> &distri_map, int num_wanted=1);
00137 
00144         static PProtein* MergeProtein (PProtein *loop, PProtein* original_protein, int startRid);
00145 
00156         static void addSidechain (string loopFile, string boundaryFile, string scwrl3_path, string outLoopFile);
00157 
00158 
00159     private:
00160         static vector<PProtein*> SeedSampleBackboneLoopOnly (PProtein* original_protein, int loopSid, int loopEid, int num_wanted=1);
00161 
00162         static vector<PProtein*> SeedSampleBackboneLoopOnly (PProtein* original_protein, int loopSid, int loopEid, map<string,PPhiPsiDistribution> &distri_map, int num_wanted=1);
00163 
00164         static vector<Real>* generateForwardOpenLoop(PProtein *loopEntire, int collisionFreeResNum);
00165         static vector<Real>* generateForwardOpenLoop (PProtein* loopEntire, int collisionFreeResNum, map<string,PPhiPsiDistribution> &map_distri, vector<string> &aa_names);
00166         static vector<Real>* generateBackwardOpenLoop (PProtein* loop);
00167         static vector<Real>* generateBackwardOpenLoop (PProtein* loop, map<string,PPhiPsiDistribution> &map_distri, vector<string> &aa_names);
00168         static Vector3 computePreCpos (PResidue *res, Real angle, Real bondLength);
00169         static void computeGoal (PResidue *res, SpaceRelationship *sr, Vector3 *endPriorG, Vector3 *endG, Vector3 *endNextG);
00170         static bool IKClose (PProtein* move_loop, Vector3 endPriorG, Vector3 endG, Vector3 endNextG);
00171         static void UpdateProtein(PProtein *p, vector<Real> *positiveAngles, vector<Real> *negativeAngles, bool forwardDir);
00172         static void UpdateProtein(PProtein *p, vector<Real> *angles, bool forwardDir);
00173         static double computeMaxLength (int proteinSize);
00174 
00175 
00176 };
00177 

Generated on Wed May 16 20:22:08 2007 for LoopTK: Protein Loop Kinematic Toolkit by  doxygen 1.5.1