public static Tuple <double, double, double[]> GetQuality (string pathbase , Universe univ , Universe univ_scrn , string hesstype , double GetHessCoarseResiIter_thres_zeroblk ) { Universe luniv; Func <Hess.HessInfo> GetHessInfo; switch (hesstype) { case "NMA": luniv = univ; GetHessInfo = delegate() { return(Hess.GetHessNMA(luniv, luniv.GetCoords(), tempbase, 16)); }; break; case "scrnNMA": luniv = univ_scrn; GetHessInfo = delegate() { return(Hess.GetHessNMA(luniv, luniv.GetCoords(), tempbase, 16, "CUTOFF 9", "TAPER")); }; break; case "sbNMA": luniv = univ; GetHessInfo = delegate() { return(Hess.GetHessSbNMA(luniv, luniv.GetCoords(), double.PositiveInfinity)); }; break; case "ssNMA": luniv = univ; GetHessInfo = delegate() { return(Hess.GetHessSsNMA(luniv, luniv.GetCoords(), double.PositiveInfinity)); }; break; case "eANM": luniv = univ; GetHessInfo = delegate() { return(Hess.GetHessEAnm(luniv, luniv.GetCoords())); }; break; case "AA-ANM": luniv = univ; GetHessInfo = delegate() { return(Hess.GetHessAnm(luniv, luniv.GetCoords(), 4.5)); }; break; default: throw new HException(); } string pathcache = pathbase + string.Format("{0}.{1}.txt", hesstype, GetHessCoarseResiIter_thres_zeroblk); Tuple <double, double, double[]> corr_wovlp_ovlps; try { corr_wovlp_ovlps = GetQuality(pathcache, luniv, GetHessInfo, GetHessCoarseResiIter_thres_zeroblk); return(corr_wovlp_ovlps); } catch { return(null); } }
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)); }