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         static vector<PProtein*> SeedSampleBackboneWithSidechain (PProtein *protein, int loopSid, int loopEid, string scwrl3_path, int num_wanted=1);
00123 
00127         static vector<PProtein*> SeedSampleBackboneWithSidechainLoopOnly (PProtein *original_protein, int loopSid, int loopEid, string scwrl3_path, int num_wanted=1);
00128 
00129 
00133          /* Usage example:
00134          *      map<string,PPhiPsiDistribution> Map = PPhiPsiDistribution::generateRamachandran();
00135          *      PProtein *protein = PDBIO::readFromFile("pdbfiles/135L.pdb");
00136          *      int loopSid=64, loopEid=72;
00137          *      vector<PProtein*> newps = PSampMethods::SeedSampleBackbone(protein,loopSid,loopEid,Map);
00138          *      PProtein *loop = new PProtein(newps[0],loopSid,loopEid);
00139          *      // Write the loop to a pdb file
00140          *      PDBIO::writeToFile(loop,"pdbfiles/135L_seed.pdb");
00141          *      // Add side chain
00142          *      PSampMethods::addSidechain("pdbfiles/135L_seed.pdb","pdbfiles/135L_NoLoop.pdb","/home/scwrl3_lin","pdbfiles/135L_seed_withSC.pdb");
00143          *      // Merge the loop with side chain and the protein
00144          *      PProtein *new_protein = PSampMethods::MergeProtein(loop,protein,loopSid);
00145          *      PDBIO::writeToFile(new_protein,"pdbfiles/135_new.pdb");
00146          */
00147         static vector<PProtein*> SeedSampleBackbone (PProtein *protein, int loopSid, int loopEid, map<string,PPhiPsiDistribution> &distri_map, int num_wanted=1);
00148 
00154         static vector<PProtein*> SeedSampleBackboneWithSidechain (PProtein *protein, int loopSid, int loopEid, map<string,PPhiPsiDistribution> &distri_map, string scwrl3_path, int num_wanted);
00155 
00160         static vector<PProtein*> SeedSampleBackboneWithSidechainLoopOnly (PProtein* original_protein, int loopSid, int loopEid, map<string,PPhiPsiDistribution> &distri_map, string scwrl3_path, int num_wanted);
00161 
00168         static PProtein* MergeProtein (PProtein *loop, PProtein* original_protein, int startRid);
00169 
00174         static PProtein* MergeProteinByPdbId (PProtein *loop, PProtein* original_protein, int startPdbId);
00175 
00186         static void addSidechain (string loopFile, string boundaryFile, string scwrl3_path, string outLoopFile);
00187 
00188         
00202         static void AddSidechain (string protein_input, int addStart, int addEnd, string scwrl3_path, string protein_output);
00203 
00204         static vector<PProtein*> SeedSampleBackboneLoopOnly (PProtein* original_protein, int loopSid, int loopEid, int num_wanted=1);
00205 
00206         static vector<PProtein*> SeedSampleBackboneLoopOnly (PProtein* original_protein, int loopSid, int loopEid, map<string,PPhiPsiDistribution> &distri_map, int num_wanted=1);
00207 
00216         static PProtein* FillMissingLoop (PProtein *original_p, int start_pdb_id, int end_pdb_id, vector<string> loop_seq);
00217 
00218 
00219     private:
00220         static vector<Real>* generateForwardOpenLoop(PProtein *loopEntire, int collisionFreeResNum);
00221         static vector<Real>* generateForwardOpenLoop (PProtein* loopEntire, int collisionFreeResNum, map<string,PPhiPsiDistribution> &map_distri, vector<string> &aa_names);
00222         static vector<Real>* generateBackwardOpenLoop (PProtein* loop);
00223         static vector<Real>* generateBackwardOpenLoop (PProtein* loop, map<string,PPhiPsiDistribution> &map_distri, vector<string> &aa_names);
00224         static Vector3 computePreCpos (PResidue *res, Real angle, Real bondLength);
00225         static void computeGoal (PResidue *res, SpaceRelationship *sr, Vector3 *endPriorG, Vector3 *endG, Vector3 *endNextG);
00226         static bool IKClose (PProtein* move_loop, Vector3 endPriorG, Vector3 endG, Vector3 endNextG);
00227         static void UpdateProtein(PProtein *p, vector<Real> *positiveAngles, vector<Real> *negativeAngles, bool forwardDir);
00228         static void UpdateProtein(PProtein *p, vector<Real> *angles, bool forwardDir);
00229         static double computeMaxLength (int proteinSize);
00230 
00231 
00232 };
00233 

Generated on Tue Aug 26 16:06:04 2008 for LoopTK: Protein Loop Kinematic Toolkit by  doxygen 1.5.1