public static void SetPep(Identifications identifications, BayesianInversion2D bi) { int n = identifications.Count; for (int i = 0; i < n; i++) { MascotPeptide p = identifications.GetPeptidesAt(i)[0]; p.Pep = bi.GetValue(p.AltScore, Math.Log(p.Sequence.Length)); } identifications.Write(); }
private static void CalcFdr(string[] rawFiles, string decoyPrefix, MascotQueryType type, IProteinSet proteinSet, bool debug, IIdentificationProvider ip) { List <bool> correct = new List <bool>(); List <double> scores = new List <double>(); List <double> seqLen = new List <double>(); for (int i = 0; i < rawFiles.Length; i++) { Identifications ident = ip.GetIdentifications(rawFiles[i], type); int n = ident.Count; for (int j = 0; j < n; j++) { bool c = ident.IsHighestScoringCorrect(j, decoyPrefix, proteinSet); double s = ident.GetHighestAltScore(j); double l = Math.Log(ident.GetBestSequence(j).Length); if (!double.IsNaN(s) && !double.IsInfinity(s)) { correct.Add(c); scores.Add(s); seqLen.Add(l); } } ip.Dispose(); if (correct.Count > 10000000) { break; } } if (correct.Count == 0) { return; } bool write = debug && (type == MascotQueryType.Silac); BayesianInversion2D bi = new BayesianInversion2D(scores.ToArray(), seqLen.ToArray(), correct.ToArray(), write); if (write) { Write(rawFiles, bi); } for (int i = 0; i < rawFiles.Length; i++) { SetPep(ip.GetIdentifications(rawFiles[i], type), bi); ip.Dispose(); } }
private static void Write(string[] rawFiles, BayesianInversion2D bi) { string combinedFolder = rawFiles[0].Substring(0, rawFiles[0].LastIndexOf("\\")) + "\\combined"; for (int len = 6; len <= 80; len++) { double loglen = Math.Log(len); string filename = "scoreDist" + len + ".txt"; StreamWriter writer = new StreamWriter(combinedFolder + "\\" + filename); for (double score = 0; score < 600; score += 0.5) { double pep = bi.GetValue(score, loglen); double forw = bi.GetForwardHist(score, loglen); double reve = bi.GetReverseHist(score, loglen); writer.WriteLine(score + "\t" + pep + "\t" + forw + "\t" + reve); } writer.Close(); } }