public override int GetDistance(string refStructure, string modelStructure) { if (!pdbs.molDic.ContainsKey(refStructure) || !pdbs.molDic.ContainsKey(modelStructure)) { return(errorValue); } if (pdbPos == null) { posMOL locPosMol = Optimization.PrepareData(pdbs.molDic[refStructure], pdbs.molDic[modelStructure]); return((int)(Optimization.Rmsd(locPosMol.posmol1, locPosMol.posmol2, false) * 100)); } else { return((int)(Optimization.Rmsd(pdbPos[hashIndex[refStructure]], pdbPos[hashIndex[modelStructure]], false) * 100)); } }
private returnV GetStructAfterRotation(string refStructure, string modelStructure) { float[,] transMatrix = null; float [] cent1 = new float [3]; float [] cent2 = new float [3]; if (!pdbs.molDic.ContainsKey(refStructure) || !pdbs.molDic.ContainsKey(modelStructure)) { return(null); } posMOL locPosMol = Optimization.PrepareData(pdbs.molDic[refStructure], pdbs.molDic[modelStructure], true); //opt.Rmsd(locPosMol.posmol1, locPosMol.posmol2, cent1, cent2, true); /* float [,]mm=new float [3,3]; * * mm[0, 0] = 0; mm[0, 1] = 0; mm[0, 2] = 1; * mm[1, 0] = 1; mm[1, 1] = 0; mm[1, 2] = 0; * mm[2, 0] = 0; mm[2, 1] = 1; mm[2, 2] = 0; * * float [,]test=Optimization.MultMatrixTrans(locPosMol.posmol1, mm);*/ transMatrix = Optimization.TransMatrix(locPosMol.posmol2, locPosMol.posmol1); //transMatrix = opt.TransMatrix(locPosMol.posmol1, test); if (transMatrix == null) { return(null); } // float[,] akk = Optimization.MultMatrixTrans(test, transMatrix); transMatrix = Optimization.MultMatrixTrans(locPosMol.posmol2, transMatrix); returnV r = new returnV(); r.x = transMatrix; r.y = locPosMol.atoms; return(r); //return Optimization.MultMatrixTrans(test, transMatrix); //return akk; //return opt.posMolRot; //return opt.TransMatrix(opt.posMol1, opt.posMol2); }
public override int GetDistance(string refStructure, string modelStructure) { KeyValuePair <List <int>, float[, ]> bestpair = default(KeyValuePair <List <int>, float[, ]>); if (!pdbs.molDic.ContainsKey(refStructure) || !pdbs.molDic.ContainsKey(modelStructure)) { return(errorValue); } posMOL locPosMol = Optimization.PrepareData(pdbs.molDic[refStructure], pdbs.molDic[modelStructure]); foreach (var item in segments) { if (locPosMol.posmol1.GetLength(0) < item) { continue; } KeyValuePair <List <int>, float[, ]> seg = FindLongestSegment(item, Threshold, locPosMol.posmol1, locPosMol.posmol2); if (seg.Key != null && (bestpair.Equals(default(KeyValuePair <List <int>, float[, ]>)) || bestpair.Key.Count < seg.Key.Count)) { bestpair = seg; } } if (!bestpair.Equals(default(KeyValuePair <List <int>, float[, ]>))) { if (bestpair.Key == null) { return(0); } else { return(bestpair.Key.Count * 100 / pdbs.molDic[refStructure].molLength); } } return(0); }
public override int GetDistance(string refStructure, string modelStructure) { int seedL = 4; //float maxDist = 3.5f; float maxDist = 5.0f; if (!pdbs.molDic.ContainsKey(refStructure) || !pdbs.molDic.ContainsKey(modelStructure)) { return(errorValue); } posMOL locPosMol = Optimization.PrepareData(pdbs.molDic[refStructure], pdbs.molDic[modelStructure]); KeyValuePair <List <int>, float[, ]> seg = FindLongestSegment(seedL, maxDist, locPosMol.posmol1, locPosMol.posmol2); if (seg.Key == null) { return(0); } float sum = 0; float mDist = maxDist * maxDist; float rmsd = 0; foreach (var item in seg.Key) { float dist = 0; dist = calcDist(locPosMol.posmol1, seg.Value, item); rmsd += dist; dist *= dist; sum += 100 / (1 + dist / mDist); } rmsd /= seg.Key.Count; return(100 - (int)((sum / pdbs.molDic[refStructure].molLength)));//locPosMol.posmol1.GetLength(0))); }
/* public static posMOL PrepareData(MolData mol1, MolData mol2, bool atomList = false) * { * posMOL globPosMol = new posMOL(); * * globPosMol.posmol1 = new float[mol1.mol.Residues.Count, 3]; * globPosMol.posmol2 = new float[mol2.mol.Residues.Count, 3]; * * for (int i = 0; i < mol1.mol.Residues.Count; i++) * { * globPosMol.posmol1[i, 0] = mol1.mol.Residues[i].Atoms[0].Position.X; * globPosMol.posmol1[i, 1] = mol1.mol.Residues[i].Atoms[0].Position.Y; * globPosMol.posmol1[i, 2] = mol1.mol.Residues[i].Atoms[0].Position.Z; * } * for (int i = 0; i < mol2.mol.Residues.Count; i++) * { * globPosMol.posmol2[i, 0] = mol2.mol.Residues[i].Atoms[0].Position.X; * globPosMol.posmol2[i, 1] = mol2.mol.Residues[i].Atoms[0].Position.Y; * globPosMol.posmol2[i, 2] = mol2.mol.Residues[i].Atoms[0].Position.Z; * } * * float[] center = new float[3]; * * CenterMol(globPosMol.posmol1, center); * CenterMol(globPosMol.posmol2, center); * * return globPosMol; * * }*/ public static posMOL PrepareData(MolData mol1, MolData mol2, bool atomList = false) { int count = 0; posMOL globPosMol = new posMOL(); Dictionary <string, int> atomNameMol1 = null; for (int i = 0; i < mol1.mol.Residues.Count; i++) { if (mol1.mol.Residues[i].Atoms.Count > count) { count = mol1.mol.Residues[i].Atoms.Count; } } atomNameMol1 = new Dictionary <string, int>(count); count = 0; for (int i = 0; i < mol1.indexMol.Length; i++) { if (mol1.indexMol[i] != -1 && mol2.indexMol[i] != -1)// && mol1.mol.Residues[mol1.indexMol[i]].ResidueName != 'X' && mol2.mol.Residues[mol2.indexMol[i]].ResidueName != 'X') { atomNameMol1.Clear(); List <Atom> atoms = mol1.mol.Residues[mol1.indexMol[i]].Atoms; for (int j = 0; j < atoms.Count; j++) { atomNameMol1.Add(atoms[j].AtomName, j); } foreach (var item in mol2.mol.Residues[mol2.indexMol[i]].Atoms) { if (atomNameMol1.ContainsKey(item.AtomName)) { count++; } } } } // index1 = mol1.indexMol; //index2 = mol2.indexMol; if (globPosMol.posmol1 == null || count != globPosMol.posmol1.GetLength(0)) { globPosMol.posmol1 = new float[count, 3]; globPosMol.posmol2 = new float[count, 3]; } if (atomList) { globPosMol.atoms = new List <string> [mol1.indexMol.Length]; for (int i = 0; i < mol1.indexMol.Length; i++) { globPosMol.atoms[i] = new List <string>(); } } count = 0; for (int i = 0; i < mol1.indexMol.Length; i++) { if (mol1.indexMol[i] != -1 && mol2.indexMol[i] != -1)// && mol1.mol.Residues[mol1.indexMol[i]].ResidueName != 'X' && mol2.mol.Residues[mol2.indexMol[i]].ResidueName != 'X') { atomNameMol1.Clear(); List <Atom> atoms = mol1.mol.Residues[mol1.indexMol[i]].Atoms; for (int j = 0; j < atoms.Count; j++) { atomNameMol1.Add(atoms[j].AtomName, j); } foreach (var item in mol2.mol.Residues[mol2.indexMol[i]].Atoms) { if (atomNameMol1.ContainsKey(item.AtomName)) { Atom aux = mol1.mol.Residues[mol1.indexMol[i]].Atoms[atomNameMol1[item.AtomName]]; globPosMol.posmol1[count, 0] = aux.Position.X; globPosMol.posmol1[count, 1] = aux.Position.Y; globPosMol.posmol1[count, 2] = aux.Position.Z; globPosMol.posmol2[count, 0] = item.Position.X; globPosMol.posmol2[count, 1] = item.Position.Y; globPosMol.posmol2[count, 2] = item.Position.Z; if (atomList) { globPosMol.atoms[i].Add(item.AtomName); } count++; } } } } float[] center = new float[3]; CenterMol(globPosMol.posmol1, center); CenterMol(globPosMol.posmol2, center); return(globPosMol); }
public static posMOL PrepareData(MolData mol1,MolData mol2,bool atomList=false) { int count=0; posMOL globPosMol = new posMOL(); Dictionary<string, int> atomNameMol1 = null; for (int i = 0; i < mol1.mol.Residues.Count; i++) if (mol1.mol.Residues[i].Atoms.Count > count) count = mol1.mol.Residues[i].Atoms.Count; atomNameMol1 = new Dictionary<string, int>(count); count = 0; for (int i = 0; i < mol1.indexMol.Length; i++) if (mol1.indexMol[i] != -1 && mol2.indexMol[i] != -1)// && mol1.mol.Residues[mol1.indexMol[i]].ResidueName != 'X' && mol2.mol.Residues[mol2.indexMol[i]].ResidueName != 'X') { atomNameMol1.Clear(); List<Atom> atoms = mol1.mol.Residues[mol1.indexMol[i]].Atoms; for (int j = 0; j < atoms.Count;j++ ) atomNameMol1.Add(atoms[j].AtomName, j); foreach (var item in mol2.mol.Residues[mol2.indexMol[i]].Atoms) if (atomNameMol1.ContainsKey(item.AtomName)) count++; } // index1 = mol1.indexMol; //index2 = mol2.indexMol; if (globPosMol.posmol1==null || count != globPosMol.posmol1.GetLength(0)) { globPosMol.posmol1 = new float[count, 3]; globPosMol.posmol2 = new float[count, 3]; } if (atomList) { globPosMol.atoms = new List<string>[mol1.indexMol.Length]; for(int i=0;i<mol1.indexMol.Length;i++) { globPosMol.atoms[i] = new List<string>(); } } count = 0; for (int i = 0; i < mol1.indexMol.Length; i++) if (mol1.indexMol[i] != -1 && mol2.indexMol[i] != -1)// && mol1.mol.Residues[mol1.indexMol[i]].ResidueName != 'X' && mol2.mol.Residues[mol2.indexMol[i]].ResidueName != 'X') { atomNameMol1.Clear(); List<Atom> atoms = mol1.mol.Residues[mol1.indexMol[i]].Atoms; for (int j = 0; j < atoms.Count; j++) atomNameMol1.Add(atoms[j].AtomName, j); foreach (var item in mol2.mol.Residues[mol2.indexMol[i]].Atoms) if (atomNameMol1.ContainsKey(item.AtomName)) { Atom aux = mol1.mol.Residues[mol1.indexMol[i]].Atoms[atomNameMol1[item.AtomName]]; globPosMol.posmol1[count, 0] = aux.Position.X; globPosMol.posmol1[count, 1] = aux.Position.Y; globPosMol.posmol1[count, 2] = aux.Position.Z; globPosMol.posmol2[count, 0] = item.Position.X; globPosMol.posmol2[count, 1] = item.Position.Y; globPosMol.posmol2[count, 2] = item.Position.Z; if(atomList) globPosMol.atoms[i].Add(item.AtomName); count++; } } float[] center = new float[3]; CenterMol(globPosMol.posmol1, center); CenterMol(globPosMol.posmol2, center); return globPosMol; }