int mode_pdb(int argument_c, char **argument_v) { if(argument_c < 2) throw std::invalid_argument("too few commands"); const std::string command(argument_v[1]); if(command == "seq") { if(argument_c < 3) throw std::invalid_argument("too few commands"); const std::string fname(argument_v[2]); PDBReader<vectorT> reader; const auto atoms = reader.read(fname); const auto chains = reader.parse(atoms); SequenceExtractor<vectorT> extr; for(auto iter = chains.cbegin(); iter != chains.cend(); ++iter) std::cout << "chain " << iter->chain_id() << ": " << extr.extract(*iter) << std::endl; return 0; } else { throw std::invalid_argument("command not found"); } }
int main(int argc, char *argv[]){ // Option Parser Options opt = setupOptions(argc,argv); ifstream fs2; //create system and dm for first PDB PDBReader reader; reader.open(opt.inputPDB); reader.read(); reader.close(); System *constSys = new System(reader.getAtoms()); DistanceMatrix constDM; //add CA atoms to the atom vectors for (int j=0; j<constSys->residueSize(); j++){ Residue &tempRes=constSys->getResidue(j); if (tempRes.exists("CA")){ constDM.addAtom(tempRes("CA")); } }//end for on j //fill the DistanceMatrix and set window size constDM.setGeneralWinSize(opt.windowSize); constDM.createDistanceMatrix(); constDM.setIntraChain(opt.intraChainCompare); constDM.setPDBid(opt.inputPDB); constDM.setDebug(opt.debug); //create matrix windows constDM.createMatrixWindows(); delete(constSys); if (constDM.getMatrixWindows().size()==0){ cout<<"Uh-oh.All the windows got filtered in the PDB you wanted to compare against."<<endl; exit(111); } // COMMMENT OUT BEGINS /* //read in list of PDBs to compare to first PDB vector<string> list; ifstream fs; fs.open(opt.pdbList.c_str()); if (fs.fail()){ cerr<<"Cannot open file "<<opt.pdbList<<endl; exit(1); } while(true){ string line; getline(fs, line); if(fs.fail()){ //no more lines to read, quite the while. break; } if(line==""){ continue; } list.push_back(line); } fs.close(); // List of distance matrices, one for each PDB vector<DistanceMatrix> DMVec(list.size()); // A system object for each PDB vector<System*> sysVec(list.size(), NULL); // Create DistanceMatrix and System Objects for list of PDBs for(int i=0; i<list.size(); i++){ cout<<i<<"create sys and dm."<<endl; PDBReader rAv; rAv.open(list[i]); rAv.read(); rAv.close(); sysVec[i] =new System(rAv.getAtoms()); //add CA atoms to the atom vectors for (int j=0; j<sysVec[i]->residueSize(); j++){ Residue &tempRes=sysVec[i]->getResidue(j); if (tempRes.exists("CA")){ //only add CA if it is on a helix string segID = tempRes("CA").getSegID(); //if(segID == "" || segID.at(0) == 'H'){ DMVec[i].addAtom(tempRes("CA")); // } } }//end for on j //fill the DistanceMatrix and set window size DMVec[i].setGeneralWinSize(opt.windowSize); DMVec[i].createDistanceMatrix(); DMVec[i].setIntraChain(opt.intraChainCompare); DMVec[i].setPDBid(list[i]); //create matrix windows DMVec[i].createMatrixWindows(); delete(sysVec[i]); }//end for on i */ // COMMMENT OUT ENDS // NEW BEGINS // load distance matrix database from an external binary file DistanceMatrixDatabase dmd; dmd.load_checkpoint("try.bin"); // List of distance matrices, one for each PDB //************* from now on, all DMVec become pointers ****************// vector<DistanceMatrix *> &DMVec = dmd.getDistanceMatrixList(); /* for (uint i = 0;i < dms.size();i++){ cout << "DM["<<i<<"]: "<<dms[i]->getPDBid()<<endl; } cout << "Done"<<endl; */ //ManageResults to take care of printing/sorting at end ManageDistanceMatrixResults resultManager; for(int i=0; i<DMVec.size(); i++){ cout<< "Trying "<<DMVec[i]->getPDBid()<<" ("<<i<<") # Residues: "<<DMVec.size()<<" Number of MatrixWindows to compare: "<<DMVec[i]->getMatrixWindows().size(); //don't compare if all of the windows got filtered out if (DMVec[i]->getMatrixWindows().size() == 0){ cout << " Sorry Zero Matrix Windows !"<<endl; continue; } cout <<endl; vector<DistanceMatrixResult> resultsToAdd; if(opt.searchCriteria=="standard"){ resultsToAdd = constDM.multiCompareAllWindows(*DMVec[i], DistanceMatrix::standard, opt.numberOfIterations); }//end if if(opt.searchCriteria=="diagonal"){ resultsToAdd = constDM.multiCompareAllWindows(*DMVec[i], DistanceMatrix::diag, opt.numberOfIterations); } if(opt.searchCriteria=="doubleDiagonal"){ resultsToAdd = constDM.multiCompareAllWindows(*DMVec[i], DistanceMatrix::doubleDiag, opt.numberOfIterations); } if(opt.searchCriteria=="minDistance"){ resultsToAdd = constDM.multiCompareAllWindows(*DMVec[i], DistanceMatrix::minDist, opt.numberOfIterations); } if(opt.searchCriteria=="minDistanceRow"){ resultsToAdd = constDM.multiCompareAllWindows(*DMVec[i], DistanceMatrix::minDistRow, opt.numberOfIterations); } bool addFlag = false; for (uint j = 0; j< resultsToAdd.size();j++){ if (opt.likenessTolerance == MslTools::doubleMax || resultsToAdd[j].getLikeness() <= opt.likenessTolerance){ addFlag = true; break; } } if (addFlag && resultsToAdd.size() > 0){ resultManager.addResults(resultsToAdd); } }//end for on i // NEW ENDS cout << "Printing"<<endl; resultManager.setAlignPdbs(opt.alignPdbs); // cout << "hello"<<endl; resultManager.setRmsdTol(opt.rmsdTol); // cout << "hello again"<<endl; resultManager.printResults(); cout << "Done."<<endl; return 0; }
JNIEXPORT void JNICALL Java_jp_sfjp_webglmol_NDKmol_NDKmolActivity_test(JNIEnv *, jobject) { PDBReader pdb; protein = pdb.parsePDB("/mnt/sdcard/2POR-porin.pdb"); __android_log_print(ANDROID_LOG_DEBUG,"Ndkmol","model loaded"); return; }