00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #include <stdlib.h>
00024 #include <algorithm>
00025 #include <sstream>
00026 #include <fstream>
00027 #include <iostream>
00028
00029 #include "../../include/config.h"
00030 #include "pdbstruct.h"
00031 #include "fragmentDataBase.h"
00032
00033 void usage()
00034 {
00035 std::cout << "Wrong number of arguments, use one of the following two commands " << std::endl <<std::endl
00036 << "To convert a pdb file in a qci file : "<< std::endl
00037 << " pdb2qci -pdb pdbFileName -qci qciFileName "<< std::endl << std::endl
00038 << "To convert a pdb file in a qci file with information for the partitionning "<<std::endl
00039 << " of the molecule for the Divide and Conquer method : "<< std::endl
00040 << " pdb2qci -pdb pdbFileName -qci qciFileName -withfrag type"<< std::endl
00041 << " with type = AA (Amino Acide) "<< std::endl
00042 << " FRAG for fragments in database BASE_FRAGMENTS.dat"<< std::endl
00043 << " You can also precise a new data base for fragments with option -withDataBase Default is " <<std::endl
00044 << " data base = "<< QCPP_DATABASE_PATH_ <<"/BASE_FRAGMENTS.dat " <<std::endl<<std::endl
00045 <<std::endl;
00046 exit(1) ;
00047 }
00048
00049
00050
00051 int main(int argc, char* argv[] ){
00052
00053 if(argc < 5 || argc > 11){ usage() ; }
00054
00055
00056 int argPDB=0, argQCI=0 ;
00057 std::string typeOfFragments, dataBaseFileName(QCPP_DATABASE_PATH_) ;
00058 dataBaseFileName.append("/BASE_FRAGMENTS.dat") ;
00059 bool withFrag = false;
00060 for ( int a = 1 ; a < argc ; a += 2){
00061 std::string tmp(argv[a]) ;
00062 if (tmp == "-pdb"){
00063 argPDB = a+1 ;
00064 }
00065 else if(tmp == "-help") {
00066 usage() ; exit(1) ;
00067 }
00068 else if (tmp == "-qci"){
00069 argQCI = a+1 ;
00070 }
00071 else if (tmp == "-withfrag"){
00072 typeOfFragments = argv[a+1] ;
00073 if( !(typeOfFragments == "FRAG" || typeOfFragments == "AA")){
00074 std::cerr << "Argument for -withfrag must be AA or FRAG"<< std::endl;
00075 exit(1) ;
00076 }
00077 withFrag = true ;
00078 }
00079 else if (tmp == "-withDataBase"){
00080 dataBaseFileName.assign(argv[a+1]) ;
00081 }
00082 }
00083 if(argPDB == 0 || argQCI == 0){
00084 usage();
00085 }
00086
00087
00088 std::ifstream pdbFile, dataBaseFile ;
00089 std::ofstream qciFile , infoFile;
00090 std::string pdbFileName(argv[argPDB]), qciFileName(argv[argQCI]) ;
00091 PDBstructure pdbAtoms ;
00092 FragmentsDataBase fragDataBase ;
00093
00094
00095
00096 dataBaseFile.open(dataBaseFileName.c_str()) ;
00097 if( ! dataBaseFile ) {
00098 std::cerr <<" Le fichier "<<dataBaseFileName << " n'existe pas. " <<std::endl;
00099 exit(1) ;}
00100 fragDataBase.read(dataBaseFile);
00101 dataBaseFile.close() ;
00102
00103 std::cout << "pdbFileName : "<<pdbFileName<<std::endl;
00104 std::cout << "qciFileName : "<<qciFileName<<std::endl;
00105 std::cout << "dataBaseFileName : "<<dataBaseFileName<<std::endl;
00106 std::cout << "TypeOfFragments : "<<typeOfFragments<<std::endl;
00107
00108
00109
00110 pdbFile.open(pdbFileName.c_str()) ;
00111 if( ! pdbFile ) {
00112 std::cerr <<" File "<<pdbFileName << " doesn't exist. " <<std::endl;
00113 exit(1) ;}
00114
00115 pdbAtoms.readPDBFile(pdbFile) ;
00116 pdbFile.close();
00117
00118 if(withFrag ) {
00119 pdbAtoms.setFragName(fragDataBase,typeOfFragments);
00120 }
00121
00122
00123
00124 qciFile.open(qciFileName.c_str());
00125 pdbAtoms.writeQCIFile(qciFile) ;
00126 qciFile.close();
00127
00128 std::cout << "end of program pdb2qci"<<std::endl ;
00129 return 0 ;
00130 }