private static List <PsmTsvLine> AssignFDRToTarget(string[] primaryLines, string[] secondaryLines) { List <PsmTsvLine> primaryPsms = ImportPsmtsv.ImportLinesToAggregate(primaryLines); List <PsmTsvLine> secondaryPsms = ImportPsmtsv.ImportLinesToAggregate(secondaryLines); primaryPsms = primaryPsms.OrderByDescending(x => x.score).ToList(); secondaryPsms = secondaryPsms.OrderByDescending(x => x.score).ToList(); int p = 0; int s = 0; int target = 0; int decoy = 0; double qMax = 0; PsmTsvLine decoyLine = secondaryPsms[s]; while (p < primaryPsms.Count) { PsmTsvLine targetLine = primaryPsms[p]; if (targetLine.score > decoyLine.score || s == secondaryPsms.Count) { target++; targetLine.target = target.ToString(); targetLine.decoy = decoy.ToString(); double qValue = (1.0d * decoy / target); qMax = (qMax > qValue) ? qMax : qValue; targetLine.q = qMax.ToString(); p++; } else { decoy++; s++; } } return(primaryPsms); }
public PsmTsvLine AggregateLine(PsmTsvLine secondary) { baseSequence += "|" + secondary.baseSequence; fullSequence += "|" + secondary.fullSequence; accession += "|" + secondary.accession; proteinName += "|" + secondary.proteinName; geneName += "|" + secondary.geneName; return(this); }
private static List <PsmTsvLine> AggregateDifferentDatabaseSearches(string[] primaryLines, string[] secondaryLines) { List <PsmTsvLine> primaryPsms = ImportPsmtsv.ImportLinesToAggregate(primaryLines); List <PsmTsvLine> secondaryPsms = ImportPsmtsv.ImportLinesToAggregate(secondaryLines); List <PsmTsvLine> aggregatedLines = new List <PsmTsvLine>(); int p = 0; int s = 0; while (p < primaryPsms.Count && s < secondaryPsms.Count) { PsmTsvLine psmP = primaryPsms[p]; PsmTsvLine psmS = secondaryPsms[s]; if (psmP.scanNumber < psmS.scanNumber) { aggregatedLines.Add(psmP); p++; } else if (psmP.scanNumber > psmS.scanNumber) { aggregatedLines.Add(psmS); s++; } else { if (psmP.score > psmS.score - 0.001 && psmP.score < psmS.score + 0.001) { aggregatedLines.Add(psmP.AggregateLine(psmS)); } else if (psmP.score > psmS.score) { aggregatedLines.Add(psmP); } else { aggregatedLines.Add(psmS); } p++; s++; } } while (p < primaryPsms.Count) { aggregatedLines.Add(primaryPsms[p]); p++; } while (s < secondaryPsms.Count) { aggregatedLines.Add(primaryPsms[s]); s++; } return(aggregatedLines); }
public static List <PsmTsvLine> Percolate(List <PsmTsvLine> primaryPsms, List <PsmTsvLine> secondaryPsms, double qThreshold, double scoreDifferenceThreshold) { List <PsmTsvLine> aggregatedLines = new List <PsmTsvLine>(); int p = 0; int s = 0; //While loop generates a combined list of primary (normal) and secondary (spliced) psms based on scoreDifferenceThreshold while (p < primaryPsms.Count && s < secondaryPsms.Count) { PsmTsvLine psmP = primaryPsms[p]; PsmTsvLine psmS = secondaryPsms[s]; if (psmP.scanNumber < psmS.scanNumber) { aggregatedLines.Add(psmP); p++; } else if (psmP.scanNumber > psmS.scanNumber) { aggregatedLines.Add(psmS); s++; } else { if (psmP.score > psmS.score - scoreDifferenceThreshold) { aggregatedLines.Add(psmP); } else { psmS.neoType = (Convert.ToDouble(psmP.q) < qThreshold) ? PsmTsvLine.NeoType.DecoySpliced : PsmTsvLine.NeoType.Spliced; //if the beaten score belonged to a gold standard, this is a false discovery aggregatedLines.Add(psmS); } p++; s++; } } //wrap up any leftover psms without scanCounts for (; p < primaryPsms.Count; p++) { aggregatedLines.Add(primaryPsms[p]); } for (; s < secondaryPsms.Count; s++) { aggregatedLines.Add(secondaryPsms[s]); } return(aggregatedLines); }