dixonPart.cpp

Go to the documentation of this file.
00001 //------------------------------------------------------------------------------------//
00002 //
00003 //   make pdb2part
00004 // ../pdb2part.exe  -pdb GLY-10_babel.pdb -out toto -Rbuffer1 3.0 -Rbuffer2 1.5 -withfrag AA -base ../BASE_FRAGMENTS.txt
00005 
00006 //                                                                                    //
00007 //   Copyright (c) 2002                                                               //
00008 //      INRIA                                                                         //
00009 //      54600 VILLERS LES NANCY                                                       //
00010 //      France                                                                        //
00011 //                                                                                    //
00012 //------------------------------------------------------------------------------------//
00013 //                                                                                    //
00014 //                 * NOTICE OF PROPRIETARY INFORMATION *                              //
00015 //                                                                                    //
00016 // The information contained in this file is considered proprietary and the exclusive //
00017 // property of  INRIA. This information may not be disclosed, duplicated              //
00018 // or used, in whole or in part, for  any purpose  whatsoever without express written //
00019 // authorization from INRIA                                                           //
00020 //                                                                                    //
00021 //------------------------------------------------------------------------------------//
00022 //
00023 //  Author : O. Coulaud 
00024 //  Date   : octobre 2002
00025 //
00026 #include <stdlib.h>
00027 #include <algorithm>
00028 #include <sstream>
00029 #include <fstream>
00030 #include <iostream>
00031 //
00032 
00033 #include "config.h"
00034 #include "pdbstruct.h"
00035 #include "fragmentDataBase.h"
00036 #include "AApartition.h"
00037 #include "tools.h"
00038 //
00039 void usage_pdb()
00040 {
00041   std::cout << "Wrong number of arguments, use one of the following two commands " << std::endl  <<std::endl
00042             << "To build a partition based on the AA  for the Divide and Conquer method: "<< std::endl
00043             << "      dixonPart -pdb pdbFileName -out fileName -Rbuffer1 3.0 -Rbuffer2 1.0"<< std::endl << std::endl
00044 //          << "To convert a pdb file in a qci file with information for the partitionning "<<std::endl 
00045 //          << "   of the molecule for the Divide and Conquer method : "<< std::endl
00046 //          << "      pdb2qci -pdb pdbFileName -qci qciFileName -withfrag type"<< std::endl
00047 //          << "           with type = AA     (Amino Acide) "<< std::endl 
00048 //          << "                       FRAG   for fragments in database BASE_FRAGMENTS.txt"<< std::endl <<std::endl
00049             <<std::endl;
00050   exit(1) ;
00051 }
00052 //
00053 //  Le programme principal
00054 //
00055 int main(int argc, char* argv[] ){
00056   //
00057   if(argc < 9 || argc > 13){ usage_pdb() ; }
00058   //
00059   //
00060   const std::string DataBaseDirName(QCPP_DATABASE_PATH_);
00061 
00062   int argPDB=0, argOUT=0 ;
00063   std::string typeOfFragments, dataBaseFileName(DataBaseDirName +"/BASE_FRAGMENTS.dat") ;
00064   bool withFrag = false;
00065   bool useFrag = true;
00066   //  bool useFrag = false;
00067   double Rbuffer1, Rbuffer2;
00068   for ( int a = 1 ; a < argc ; a += 2){
00069      std::cout << a << "  " << argv[a] <<std::endl; 
00070     std::string tmp(argv[a]) ;
00071     if (tmp == "-pdb"){
00072       argPDB = a+1 ;
00073     }
00074     else if(tmp == "-help") {
00075       usage_pdb() ; exit(1) ;
00076     }
00077     else if (tmp == "-out"){
00078       argOUT = a+1 ;
00079     }
00080     else if (tmp == "-withfrag"){
00081       typeOfFragments = argv[a+1] ;
00082       if( !(typeOfFragments == "FRAG" || typeOfFragments == "AA")){
00083         std::cerr << "Argument for -withfrag must be AA or FRAG"<< std::endl;
00084         exit(1) ;
00085       }
00086       withFrag        = true ;
00087     }
00088     else if (tmp == "-base"){
00089       dataBaseFileName.assign(argv[a+1]) ;
00090     }
00091     else if (tmp == "-Rbuffer1"){
00092       Rbuffer1 = atof(argv[a+1]) ;
00093     }
00094     else if (tmp == "-Rbuffer2"){
00095       Rbuffer2 = atof(argv[a+1]) ;
00096     }
00097   }
00098   if(argPDB == 0 ||  argOUT == 0){
00099     usage_pdb();
00100   }
00101   //
00102   //
00103   std::ifstream pdbFile, dataBaseFile ;
00104   std::ofstream outFile ;
00105   std::string pdbFileName(argv[argPDB]), outFileName(argv[argOUT]) ;
00106   //
00107   std::cout << "pdbFileName      : "<<pdbFileName<<std::endl;
00108   std::cout << "outFileName      : "<<outFileName<<std::endl;
00109   std::cout << "dataBaseFileName : "<<dataBaseFileName<<std::endl;
00110   std::cout << "TypeOfFragments  : "<<typeOfFragments<<std::endl;
00111   std::cout << "Radius of Zone1  : "<<Rbuffer1<<std::endl;
00112   std::cout << "Radius of Zone2  : "<<Rbuffer2<<std::endl;
00113 
00114   //
00115   PDBstructure      pdbAtoms ;
00116   FragmentsDataBase fragDataBase ;
00117   //
00118   // Ouverture des fichiers
00119   //
00120   dataBaseFile.open(dataBaseFileName.c_str()) ;
00121   if(  ! dataBaseFile ) {
00122     std::cerr <<" Le fichier "<<dataBaseFileName << " n'existe pas. " <<std::endl;
00123     exit(1) ;}
00124   fragDataBase.read(dataBaseFile);
00125   dataBaseFile.close() ;
00126   //
00127   //  fragDataBase.write() ;
00128   //
00129   pdbFile.open(pdbFileName.c_str()) ;
00130   if(  ! pdbFile  ) {
00131     std::cerr <<" Le fichier "<<pdbFileName << " n'existe pas. " <<std::endl;
00132     exit(1) ;}
00133   //
00134   pdbAtoms.readPDBFile(pdbFile) ; 
00135   pdbFile.close();
00136   //
00137   pdbAtoms.setFragName(fragDataBase,typeOfFragments);
00138   //
00139   //  double axe1[3], axe2[3], axe3[3], gravityCenter[3];
00140   //  buildInnerReperOfMolecule(pdbAtoms,gravityCenter,axe1, axe2, axe3);
00141 
00142 
00143   //
00144   //  Partitonnement en fonction des acides aminés
00145   //
00146   int numberOfPartitions = pdbAtoms.numberOfResidus();
00147   std::cout <<  "  "<<numberOfPartitions<< std::endl;  
00148   //
00149   AAPartition partition(numberOfPartitions,Rbuffer1, Rbuffer2) ;
00150   //
00151   partition.attachAtoms(&pdbAtoms) ;
00152   //
00153   useFrag = false ;
00154   //
00155   partition.partitionate(useFrag);
00156   //
00157   partition.valid();
00158   //
00159   //  La sauvegarde
00160   //
00161   std::string partitionFileName(outFileName);
00162   //
00163   partitionFileName += ".part1" ;
00164   outFile.open(partitionFileName.c_str()) ;
00165   partition.writeInFile(outFile);
00166   outFile.close();
00167   //
00168 
00169   std::string F1(outFileName + ".part2") ;
00170   outFile.open(F1.c_str()) ;
00171   partition.newWriteInFile(outFile);
00172   outFile.close();
00173   //
00174   //  Sauvegarde au format QCI
00175   //
00176   std::string fileName(outFileName) ;
00177   fileName += ".qci" ;
00178   outFile.open(fileName.c_str());
00179   pdbAtoms.writeQCIFile(outFile) ;
00180   outFile.close();
00181   //
00182   std::cout << "end of program dixonPart"<<std::endl ;
00183   return 0 ;
00184 }

Generated on Sat Jan 28 21:07:25 2006 for QC++ by  doxygen 1.4.4