public static List <Top.Atom> SelectMatchToPdb(this IList <Top.Atom> atoms, IList <Pdb.Atom> pdbatoms) { Dictionary <int, Pdb.Atom> dict = new Dictionary <int, Pdb.Atom>(pdbatoms.Count); foreach (Pdb.Atom pdbatom in pdbatoms) { dict.Add(pdbatom.serial, pdbatom); } List <Top.Atom> select = new List <Top.Atom>(); foreach (Top.Atom atom in atoms) { if (dict.ContainsKey(atom.cgnr)) { Pdb.Atom pdbatom = dict[atom.cgnr]; if ((atom.residu == pdbatom.resName) && (atom.resnr == pdbatom.resSeq)) { HDebug.AssertOr(atom.atom.Trim() == pdbatom.name.Trim() , atom.atom.Trim() == (pdbatom.name.Substring(1) + pdbatom.name[0]).Trim() // (top) HG21 <=> 1HG2 (pdb) ); select.Add(atom); } } } HDebug.Assert(pdbatoms.Count == select.Count); return(select); }
public TextLogger(object writter) { HDebug.AssertOr (writter == null , writter is TextWriter , writter is StringBuilder , writter is List <string> ); this.writter = writter; }
public static MixHessInfo GetHessMixEAnm(Universe univ, IList <Vector> coords, ILinAlg la, IList <ResInfo> lstResAllAtom , bool bAllowAllToCoarse, bool bOnlyCoarseConnBackbone , Tuple <double, double> anmSprcstCutoffAll // all-all , Tuple <double, double> anmSprcstCutoffMix // all/buffer-coarse , Tuple <double, double> anmSprcstCutoffCoarse // coarse-coarse , out string errmsg , bool bGetIntmInfo, string strBkbnReso ) { double anmSprcstAll = anmSprcstCutoffAll.Item1; double anmSprcstMix = anmSprcstCutoffMix.Item1; double anmSprcstCoarse = anmSprcstCutoffCoarse.Item1; double anmCutoffAll = anmSprcstCutoffAll.Item2; double anmCutoffMix = anmSprcstCutoffMix.Item2; double anmCutoffCoarse = anmSprcstCutoffCoarse.Item2; HDebug.Assert(anmCutoffAll >= 0); HDebug.Assert(anmCutoffCoarse >= 0); MixModel.FnGetHess GetHess = delegate(Universe luniv, IList <Vector> lcoords, int[] idxAll, int[] idxBuffer, int[] idxCoarse, int[] idxBackbone) { int size = coords.Count; HashSet <int> setIdxAll = idxAll.HToHashSet(); HashSet <int> setIdxBuffer = idxBuffer.HToHashSet(); HashSet <int> setIdxCoarse = idxCoarse.HToHashSet(); HashSet <int> setIdxBackbone = idxBackbone.HToHashSet(); Matrix anmKij = Matrix.Zeros(size, size); for (int c = 0; c < size; c++) { if (lcoords[c] == null) { continue; } int typec = 0; if (setIdxAll.Contains(c)) { HDebug.Assert(typec == 0); typec = 1; } if (setIdxBuffer.Contains(c)) { HDebug.Assert(typec == 0); typec = 2; } if (setIdxCoarse.Contains(c)) { HDebug.Assert(typec == 0); typec = 3; } HDebug.Assert(typec != 0); for (int r = c + 1; r < size; r++) { if (lcoords[r] == null) { continue; } int typer = 0; if (setIdxAll.Contains(r)) { HDebug.Assert(typer == 0); typer = 1; } if (setIdxBuffer.Contains(r)) { HDebug.Assert(typer == 0); typer = 2; } if (setIdxCoarse.Contains(r)) { HDebug.Assert(typer == 0); typer = 3; } HDebug.Assert(typer != 0); double sprcst; double cutoff; int type0 = Math.Min(typec, typer); int type1 = Math.Max(typec, typer); int type01 = type0 * 10 + type1; switch (type01) { case 11: sprcst = anmSprcstAll; cutoff = anmCutoffAll; break; // All - All case 12: sprcst = anmSprcstAll; cutoff = anmCutoffAll; break; // All - Buffer case 22: sprcst = anmSprcstAll; cutoff = anmCutoffAll; break; // Buffer - Buffer case 33: sprcst = anmSprcstCoarse; cutoff = anmCutoffCoarse; break; // Coarse - Coarse case 23: sprcst = anmSprcstMix; cutoff = anmCutoffMix; break; // Buffer - Coarse case 13: // All - Buffer if (bAllowAllToCoarse == false) { continue; } sprcst = anmSprcstMix; cutoff = anmCutoffMix; break; default: throw new Exception(); } HDebug.Assert(bOnlyCoarseConnBackbone == false); // "true" makes the result bad if (bOnlyCoarseConnBackbone) { bool c_bkbn = setIdxBackbone.Contains(c); bool r_bkbn = setIdxBackbone.Contains(r); if (c_bkbn && r_bkbn) { // special treatment that in-between backbones use only coarse grained onnections. sprcst = anmSprcstCoarse; cutoff = anmCutoffCoarse; } else if ((type01 == 11) || (type01 == 12) || (type01 == 22)) { // do nothing. use the above setting. } else { // all-to-coarse HDebug.AssertOr(type01 == 13, type01 == 23); if (type01 == 33) { HDebug.Assert(type01 != 33); // should be treated by (c_bkbn && r_bkbn) throw new Exception("HDebug.Assert(type01 != 33)"); } continue; } } double cutoff2 = cutoff * cutoff; double dist2 = (coords[c] - coords[r]).Dist2; if (dist2 <= cutoff2) { anmKij[c, r] = sprcst; anmKij[r, c] = sprcst; } } } var hessinfo = Hess.GetHessEAnm(luniv, lcoords, anmKij); return(hessinfo); }; return(MixModel.GetHessMixModel(univ, coords, la, lstResAllAtom, GetHess, out errmsg, bGetIntmInfo, strBkbnReso)); }