00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
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
00045
00046
00047
00048
00049 <<std::endl;
00050 exit(1) ;
00051 }
00052
00053
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
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
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
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
00140
00141
00142
00143
00144
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
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
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 }