本文整理汇总了C++中DistanceMatrix::getMatrixWindows方法的典型用法代码示例。如果您正苦于以下问题:C++ DistanceMatrix::getMatrixWindows方法的具体用法?C++ DistanceMatrix::getMatrixWindows怎么用?C++ DistanceMatrix::getMatrixWindows使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DistanceMatrix
的用法示例。
在下文中一共展示了DistanceMatrix::getMatrixWindows方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: minCoord
pair<vector<int>, double> DistanceMatrix::compareAllWindows(DistanceMatrix &_distMat, int choice){
vector<MatrixWindow*> listOther = _distMat.getMatrixWindows();
int length = listMW.size();
int lengthOther = listOther.size();
vector<int> minCoord(2, 0.0);
MatrixWindow *minWindow1 = NULL;
MatrixWindow *minWindow2 = NULL;
double minLikeness= MslTools::doubleMax;
for (int i =0; i<length; i++){//loops through listMW to get comparee
MatrixWindow *win1 = listMW[i];
for (int j=0; j<lengthOther; j++){//loops through listOther to get comparor
MatrixWindow *win2 = listOther[j];
double likeness;
//decides which compare method from MatrixWindow to call
switch(choice){
case standard:
likeness = (*win1).compare((*win2));
break;
case diag:
likeness = (*win1).compareDiagonal((*win2));
break;
case doubleDiag:
likeness = (*win1).compareDoubleDiagonal((*win2));
break;
case minDist:
likeness = (*win1).compareMinDist((*win2));
break;
case minDistRow:
likeness=(*win1).compareMinRow((*win2));
break;
case minDistCol:
likeness=(*win1).compareMinCol((*win2));
break;
default:
cout<<"Invalid argument in function DistanceMatrix::compareAll()."<<endl;
exit(333);
}//end switch
if (likeness<minLikeness && abs(likeness - minLikeness) > 0.001){
cout << "New likeness: "<<likeness<<endl;
minLikeness=likeness;
minWindow1 = win1;
minWindow2 = win2;
minCoord[0]= i;
minCoord[1]=j;
}//endif
win2=NULL;
}//end for on j
win1= NULL;
}//end for on i
pair<vector<int>, double> coordsAndLikeness(minCoord, minLikeness);
minWindow1=NULL;
minWindow2=NULL;
return coordsAndLikeness;
}
示例2: currentResult
vector<DistanceMatrixResult> DistanceMatrix::multiCompareAllWindows(DistanceMatrix &_distMat, int choice, int _numCompare){
/*
//which chains to skip:
map<string, bool> forbiddenIDMat1;
map<string, bool> forbiddenIDMat2;
// Maintain the proper spacing between residues of different matrix window pairs.
map<string,int> properRegisterRow;
map<string,int> properRegisterCol;
map<string,int>::iterator findRegistry;
*/
//get list of MWs to compare
vector<MatrixWindow*> listOther = _distMat.getMatrixWindows();
int length = listMW.size();
int lengthOther = listOther.size();
//vector of objects to return
vector<DistanceMatrixResult> returnVec;
//loop over number of times to compare all
for(int k=0; k<_numCompare; k++){
//minimum windows and indices
MatrixWindow *minWindow1 = NULL;
MatrixWindow *minWindow2 = NULL;
double minLikeness = 1000000;
int minIndex1=0;
int minIndex2=0;
//IDs to skip in the future
string i1IDWin;
string j1IDWin;
string i2IDWin;
string j2IDWin;
//which chains to skip:
map<string, bool> forbiddenIDMat1;
map<string, bool> forbiddenIDMat2;
// Maintain the proper spacing between residues of different matrix window pairs.
map<string,int> properRegisterRow;
map<string,int> properRegisterCol;
map<string,int>::iterator findRegistry;
for (int i =0; i<length; i++){//loops through listMW to get compare
MatrixWindow *win1 = listMW[i];
for (int j=0; j<lengthOther; j++){//loops through listOther to get comparor
MatrixWindow *win2 = listOther[j];
//get the ID (seg or chain) so we can filter ones we want to skip
int i1 = win1->getLeftR();
int j1 = win1->getLeftC();
int i2 = win2->getLeftR();
int j2 = win2->getLeftC();
string i1ID = atomVec[i1]->getSegID();
string j1ID = atomVec[j1]->getSegID();
string i2ID = _distMat.getAtomVector()[i2]->getSegID();
string j2ID = _distMat.getAtomVector()[j2]->getSegID();
if(i1ID=="" || j1ID=="" || i2ID=="" ||j2ID==""){
i1ID = atomVec[i1]->getChainId();
j1ID = atomVec[j1]->getChainId();
i2ID = _distMat.getAtomVector()[i2]->getChainId();
j2ID = _distMat.getAtomVector()[j2]->getChainId();
}//end if
// Skip if both chains are forbidden within a matrix
if (forbiddenIDMat1.find(i1ID+":"+j1ID)!=forbiddenIDMat1.end() || forbiddenIDMat2.find(i2ID+":"+j2ID)!=forbiddenIDMat2.end()) continue;
// Skip if both inter-matrix segids found and if difference in residue number is not the same.
findRegistry = properRegisterRow.find(i1ID+":"+i2ID);
double diffInResidueNumber = atomVec[i1]->getResidueNumber() - _distMat.getAtomVector()[i2]->getResidueNumber();
if (findRegistry != properRegisterRow.end() && findRegistry->second != diffInResidueNumber) continue;
findRegistry = properRegisterCol.find(j1ID+":"+j2ID);
diffInResidueNumber = atomVec[j1]->getResidueNumber() - _distMat.getAtomVector()[j2]->getResidueNumber();
if (findRegistry != properRegisterCol.end() && findRegistry->second != diffInResidueNumber) continue;
double likeness;
//decides which compare method from MatrixWindow to call
switch(choice){
case standard:
likeness = (*win1).compare((*win2));
break;
case diag:
likeness = (*win1).compareDiagonal((*win2));
break;
case doubleDiag:
likeness = (*win1).compareDoubleDiagonal((*win2));
break;
case minDist:
//.........这里部分代码省略.........
示例3: printCompareInfo
//must add segID
void DistanceMatrix::printCompareInfo(DistanceMatrix &_distMat, pair<vector<int>, double> _result, int choice){
//retrieve values from the pair
vector<int> mwIndex(2, 0.0);
mwIndex= _result.first;
double minLikeness = _result.second;
//retrieve the winning Matrix Windows
vector<MatrixWindow*> listMW2 = _distMat.getMatrixWindows();
MatrixWindow *minWindow1 = listMW[mwIndex[0]];
MatrixWindow *minWindow2 = listMW2[mwIndex[1]];
//print information
int i1 = (*minWindow1).getLeftR();
int j1 = (*minWindow1).getLeftC();
int i2 = (*minWindow2).getLeftR();
int j2 = (*minWindow2).getLeftC();
string i1ID = atomVec[i1]->getSegID().c_str();
string j1ID = atomVec[j1]->getSegID().c_str();
string i2ID = _distMat.getAtomVector()[i2]->getSegID().c_str();
string j2ID = _distMat.getAtomVector()[j2]->getSegID().c_str();
if(i1ID=="" || j1ID=="" || i2ID=="" ||j2ID==""){
i1ID = atomVec[i1]->getChainId().c_str();
j1ID = atomVec[j1]->getChainId().c_str();
i2ID = _distMat.getAtomVector()[i2]->getChainId().c_str();
j2ID = _distMat.getAtomVector()[j2]->getChainId().c_str();
}
int i1res = atomVec[i1]->getResidueNumber();
int j1res = atomVec[j1]->getResidueNumber();
int i2res = _distMat.getAtomVector()[i2]->getResidueNumber();
int j2res = _distMat.getAtomVector()[j2]->getResidueNumber();
string PDBname= getFileName(PDBid);
string PDBnameShort = PDBname.substr(0,17);
string PDBname2 = getFileName(_distMat.getPDBid());
string PDBnameShort2 = PDBname2.substr(0,17);
cout<<"Comparing PDBs "<<PDBnameShort<<", "<<PDBnameShort2<<endl;
switch(choice){
case standard:
fprintf(stdout, "Standard compare:\t\tWindow1 %3d,%3d (Residues: %1s%3d, %1s%3d)\tWindow2 %3d,%3d (Residues: %1s%3d, %1s%3d)\t%8.3f\n", i1, j1, i1ID.c_str(), i1res, j1ID.c_str(), j1res, i2, j2, i2ID.c_str(), i2res, j2ID.c_str(), j2res, minLikeness);
break;
case diag:
fprintf(stdout, "Diagonal compare: \t\tWindow1 %3d,%3d (Residues: %1s%3d, %1s%3d)\tWindow2 %3d,%3d (Residues: %1s%3d, %1s%3d)\t%8.3f\n", i1, j1, i1ID.c_str(), i1res, j1ID.c_str(), j1res, i2, j2, i2ID.c_str(), i2res, j2ID.c_str(), j2res, minLikeness);
break;
case doubleDiag:
fprintf(stdout, "Double Diagonal compare: \tWindow1 %3d,%3d (Residues: %1s%3d, %1s%3d)\tWindow2 %3d,%3d (Residues: %1s%3d, %1s%3d)\t%8.3f\n", i1, j1, i1ID.c_str(), i1res, j1ID.c_str(), j1res, i2, j2, i2ID.c_str(), i2res, j2ID.c_str(), j2res, minLikeness);
break;
case minDist:
fprintf(stdout, "Minimum Distance compare: \tWindow1 %3d,%3d (Residues: %1s%3d, %1s%3d)\tWindow2 %3d,%3d (Residues: %1s%3d, %1s%3d)\t%8.3f\n", i1, j1, i1ID.c_str(), i1res, j1ID.c_str(), j1res, i2, j2, i2ID.c_str(), i2res, j2ID.c_str(), j2res, minLikeness);
break;
case minDistRow:
fprintf(stdout, "Minimum Distance Row compare: \tWindow1 %3d,%3d (Residues: %1s%3d, %1s%3d)\tWindow2 %3d,%3d (Residues: %1s%3d, %1s%3d)\t%8.3f\n", i1, j1, i1ID.c_str(), i1res, j1ID.c_str(), j1res, i2, j2, i2ID.c_str(), i2res, j2ID.c_str(), j2res, minLikeness);
break;
case minDistCol:
fprintf(stdout, "Minimum Distance Column compare: \tWindow1 %3d,%3d (Residues: %1s%3d, %1s%3d)\tWindow2 %3d,%3d (Residues: %1s%3d, %1s%3d)\t%8.3f\n", i1, j1, i1ID.c_str(), i1res, j1ID.c_str(), j1res, i2, j2, i2ID.c_str(), i2res, j2ID.c_str(), j2res, minLikeness);
break;
default:
cout<<"Error. Incorrect int value (choice) in DistanceMatrix::printCompareInfo(...)"<<endl;
exit(334);
}//end switch
}
示例4: main
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'){
//.........这里部分代码省略.........