public override string ToString() { var sb = new StringBuilder(); // list of protein accession numbers sb.Append(ProteinGroupName); sb.Append("\t"); // genes sb.Append(GlobalVariables.CheckLengthOfOutput(string.Join("|", ListOfProteinsOrderedByAccession.Select(p => p.GeneNames.Select(x => x.Item2).FirstOrDefault())))); sb.Append("\t"); // organisms sb.Append(GlobalVariables.CheckLengthOfOutput(string.Join("|", ListOfProteinsOrderedByAccession.Select(p => p.Organism).Distinct()))); sb.Append("\t"); // list of protein names sb.Append(GlobalVariables.CheckLengthOfOutput(string.Join("|", ListOfProteinsOrderedByAccession.Select(p => p.FullName).Distinct()))); sb.Append("\t"); // list of masses var sequences = ListOfProteinsOrderedByAccession.Select(p => p.BaseSequence).Distinct(); List <double> masses = new List <double>(); foreach (var sequence in sequences) { try { masses.Add(new Proteomics.AminoAcidPolymer.Peptide(sequence).MonoisotopicMass); } catch (System.Exception) { masses.Add(double.NaN); } } sb.Append(GlobalVariables.CheckLengthOfOutput(string.Join("|", masses))); sb.Append("\t"); // number of proteins in group sb.Append("" + Proteins.Count); sb.Append("\t"); // list of unique peptides if (UniquePeptidesOutput != null) { sb.Append(GlobalVariables.CheckLengthOfOutput(UniquePeptidesOutput)); } sb.Append("\t"); // list of shared peptides if (SharedPeptidesOutput != null) { sb.Append(GlobalVariables.CheckLengthOfOutput(SharedPeptidesOutput)); } sb.Append("\t"); // number of peptides if (!DisplayModsOnPeptides) { sb.Append("" + AllPeptides.Select(p => p.BaseSequence).Distinct().Count()); } else { sb.Append("" + AllPeptides.Select(p => p.FullSequence).Distinct().Count()); } sb.Append("\t"); // number of unique peptides if (!DisplayModsOnPeptides) { sb.Append("" + UniquePeptides.Select(p => p.BaseSequence).Distinct().Count()); } else { sb.Append("" + UniquePeptides.Select(p => p.FullSequence).Distinct().Count()); } sb.Append("\t"); // sequence coverage percent sb.Append(GlobalVariables.CheckLengthOfOutput(string.Join("|", SequenceCoverageFraction.Select(p => string.Format("{0:0.#####}", p))))); sb.Append("\t"); // sequence coverage sb.Append(GlobalVariables.CheckLengthOfOutput(string.Join("|", SequenceCoverageDisplayList))); sb.Append("\t"); // sequence coverage with mods sb.Append(GlobalVariables.CheckLengthOfOutput(string.Join("|", SequenceCoverageDisplayListWithMods))); sb.Append("\t"); //Detailed mods information list sb.Append(GlobalVariables.CheckLengthOfOutput(string.Join("|", ModsInfo))); sb.Append("\t"); // MS1 intensity (retrieved from FlashLFQ in the SearchTask) if (IntensitiesByFile != null && FilesForQuantification != null) { foreach (var sampleGroup in FilesForQuantification.GroupBy(p => p.Condition)) { foreach (var sample in sampleGroup.GroupBy(p => p.BiologicalReplicate).OrderBy(p => p.Key)) { // if the samples are fractionated, the protein will only have 1 intensity in the first fraction // and the other fractions will be zero. we could find the first/only fraction with an intensity, // but simply summing the fractions is easier than finding the single non-zero value double summedIntensity = sample.Sum(file => IntensitiesByFile[file]); if (summedIntensity > 0) { sb.Append(summedIntensity); } sb.Append("\t"); } } } // number of PSMs for listed peptides sb.Append("" + AllPsmsBelowOnePercentFDR.Count); sb.Append("\t"); // isDecoy if (IsDecoy) { sb.Append("D"); } else if (IsContaminant) { sb.Append("C"); } else { sb.Append("T"); } sb.Append("\t"); // cumulative target sb.Append(CumulativeTarget); sb.Append("\t"); // cumulative decoy sb.Append(CumulativeDecoy); sb.Append("\t"); // q value sb.Append(QValue); sb.Append("\t"); // best peptide score sb.Append(BestPeptideScore); sb.Append("\t"); // best peptide q value sb.Append(BestPeptideQValue); sb.Append("\t"); return(sb.ToString()); }
public string ToString(IReadOnlyDictionary <string, int> ModstoWritePruned) { var sb = new StringBuilder(); sb.Append(Path.GetFileNameWithoutExtension(FullFilePath)); sb.Append('\t' + ScanNumber.ToString(CultureInfo.InvariantCulture)); sb.Append('\t' + ScanRetentionTime.ToString("F5", CultureInfo.InvariantCulture)); sb.Append('\t' + ScanExperimentalPeaks.ToString("F5", CultureInfo.InvariantCulture)); sb.Append('\t' + TotalIonCurrent.ToString("F5", CultureInfo.InvariantCulture)); sb.Append('\t' + (PrecursorScanNumber.HasValue ? PrecursorScanNumber.Value.ToString(CultureInfo.InvariantCulture) : "unknown")); sb.Append('\t' + ScanPrecursorCharge.ToString("F5", CultureInfo.InvariantCulture)); sb.Append('\t' + ScanPrecursorMonoisotopicPeakMz.ToString("F5", CultureInfo.InvariantCulture)); sb.Append('\t' + ScanPrecursorMass.ToString("F5", CultureInfo.InvariantCulture)); sb.Append('\t' + Score.ToString("F3", CultureInfo.InvariantCulture)); sb.Append("\t" + Resolve(compactPeptides.Select(b => b.Value.Item1)).Item1); // Notch sb.Append('\t' + NumDifferentCompactPeptides.ToString("F5", CultureInfo.InvariantCulture)); if (compactPeptides.First().Value.Item2 != null) { sb.Append("\t" + GlobalVariables.CheckLengthOfOutput(string.Join("|", compactPeptides.Select(b => b.Value.Item2.Count.ToString(CultureInfo.InvariantCulture))))); sb.Append('\t' + Resolve(compactPeptides.SelectMany(b => b.Value.Item2).Select(b => b.BaseSequence)).Item1); sb.Append('\t' + Resolve(compactPeptides.SelectMany(b => b.Value.Item2).Select(b => b.Sequence)).Item1); sb.Append('\t' + Resolve(compactPeptides.SelectMany(b => b.Value.Item2).Select(b => b.EssentialSequence(ModstoWritePruned))).Item1); sb.Append('\t' + Resolve(compactPeptides.SelectMany(b => b.Value.Item2).Select(b => b.allModsOneIsNterminus)).Item1); sb.Append('\t' + Resolve(compactPeptides.SelectMany(b => b.Value.Item2).Select(b => string.Join("|", b.allModsOneIsNterminus.OrderBy(c => c.Key).Where(c => c.Value is ModificationWithMassAndCf).Select(c => (c.Value as ModificationWithMassAndCf).chemicalFormula.Formula)))).Item1); sb.Append('\t' + Resolve(compactPeptides.SelectMany(b => b.Value.Item2).Select(b => b.allModsOneIsNterminus.Select(c => (c.Value as ModificationWithMassAndCf)))).Item1); sb.Append('\t' + Resolve(compactPeptides.SelectMany(b => b.Value.Item2).Select(b => b.NumVariableMods)).Item1); sb.Append('\t' + Resolve(compactPeptides.SelectMany(b => b.Value.Item2).Select(b => b.MissedCleavages.HasValue ? b.MissedCleavages.Value.ToString(CultureInfo.InvariantCulture) : "unknown")).Item1); sb.Append('\t' + Resolve(compactPeptides.SelectMany(b => b.Value.Item2).Select(b => b.MonoisotopicMass)).Item1); sb.Append('\t' + Resolve(compactPeptides.SelectMany(b => b.Value.Item2).Select(b => ScanPrecursorMass - b.MonoisotopicMass)).Item1); sb.Append('\t' + ResolveF2(compactPeptides.SelectMany(b => b.Value.Item2).Select(b => ((ScanPrecursorMass - b.MonoisotopicMass) / b.MonoisotopicMass * 1e6))).Item1); sb.Append('\t' + Resolve(compactPeptides.SelectMany(b => b.Value.Item2).Select(b => b.Protein.Accession)).Item1); sb.Append('\t' + Resolve(compactPeptides.SelectMany(b => b.Value.Item2).Select(b => b.Protein.FullName)).Item1); sb.Append('\t' + Resolve(compactPeptides.SelectMany(b => b.Value.Item2).Select(b => string.Join(", ", b.Protein.GeneNames.Select(d => d.Item1 + ":" + d.Item2)))).Item1); sb.Append('\t' + Resolve(compactPeptides.SelectMany(b => b.Value.Item2).Select(b => b.Protein.Organism)).Item1); sb.Append('\t' + Resolve(compactPeptides.SelectMany(b => b.Value.Item2).Select(b => b.Protein.IsContaminant ? "Y" : "N")).Item1); sb.Append('\t' + Resolve(compactPeptides.SelectMany(b => b.Value.Item2).Select(b => b.Protein.IsDecoy ? "Y" : "N")).Item1); sb.Append('\t' + Resolve(compactPeptides.SelectMany(b => b.Value.Item2).Select(b => b.PeptideDescription)).Item1); sb.Append('\t' + Resolve(compactPeptides.SelectMany(b => b.Value.Item2).Select(b => ("[" + b.OneBasedStartResidueInProtein.ToString(CultureInfo.InvariantCulture) + " to " + b.OneBasedEndResidueInProtein.ToString(CultureInfo.InvariantCulture) + "]"))).Item1); sb.Append('\t' + Resolve(compactPeptides.SelectMany(b => b.Value.Item2).Select(b => b.PreviousAminoAcid.ToString())).Item1); sb.Append('\t' + Resolve(compactPeptides.SelectMany(b => b.Value.Item2).Select(b => b.NextAminoAcid.ToString())).Item1); if (FdrInfo != null && FdrInfo.CalculateEValue) { int theoreticalsSearched = AllScores[0]; sb.Append('\t' + AllScores[0].ToString()); for (int i = 1; i < AllScores.Count; i++) { sb.Append("_" + AllScores[i]); theoreticalsSearched += AllScores[i]; } sb.Append('\t' + theoreticalsSearched.ToString()); } else { sb.Append('\t' + " " + '\t' + " "); } // Unambiguous if (IsDecoy) { sb.Append("\t" + "D"); } else if (compactPeptides.Any(b => b.Value.Item2.Any(c => c.Protein.IsContaminant))) { sb.Append("\t" + "C"); } else { sb.Append("\t" + "T"); } } else { sb.Append('\t' + " " + '\t' + " " + '\t' + " " + '\t' + " " + '\t' + " " + '\t' + " " + '\t' + " " + '\t' + " " + '\t' + " " + '\t' + " " + '\t' + " " + '\t' + " " + '\t' + " " + '\t' + " " + '\t' + " " + '\t' + " " + '\t' + " " + '\t' + " " + '\t' + " " + '\t' + " " + '\t' + " " + '\t' + " " + '\t' + " " + '\t' + " " + '\t' + " "); } if (MatchedIonDictOnlyMatches.Any()) { //Count sb.Append('\t' + string.Join(";", MatchedIonDictOnlyMatches.Select(b => b.Value.Count(c => c > 0)))); //Masses sb.Append('\t' + "["); StringBuilder sbTemp = new StringBuilder(); foreach (var kvp in MatchedIonDictOnlyMatches) { sbTemp.Append("[" + string.Join(",", kvp.Value.Select(b => b.ToString("F5", CultureInfo.InvariantCulture))) + "];"); } sb.Append(GlobalVariables.CheckLengthOfOutput(sbTemp.ToString())); sb.Append("]"); //Mass error Da sb.Append('\t' + "["); sbTemp.Clear(); foreach (var kvp in ProductMassErrorDa) { sbTemp.Append("[" + string.Join(",", kvp.Value.Select(b => b.ToString("F5", CultureInfo.InvariantCulture))) + "];"); } sb.Append(GlobalVariables.CheckLengthOfOutput(sbTemp.ToString())); sb.Append("]"); //Mass error ppm sb.Append('\t' + "["); sbTemp.Clear(); foreach (var kvp in ProductMassErrorPpm) { sbTemp.Append("[" + string.Join(",", kvp.Value.Select(b => b.ToString("F2", CultureInfo.InvariantCulture))) + "];"); } sb.Append(GlobalVariables.CheckLengthOfOutput(sbTemp.ToString())); sb.Append("]"); } else { sb.Append('\t' + " " + '\t' + " " + '\t' + " " + '\t' + " "); } if (LocalizedScores != null) { sb.Append('\t' + GlobalVariables.CheckLengthOfOutput(("[" + string.Join(",", LocalizedScores.Select(b => b.ToString("F3", CultureInfo.InvariantCulture))) + "]"))); sb.Append('\t' + (LocalizedScores.Max() - Score).ToString("F3", CultureInfo.InvariantCulture)); } else { sb.Append('\t' + " " + '\t' + " "); } if (FdrInfo != null) { sb.Append('\t' + FdrInfo.CumulativeTarget.ToString(CultureInfo.InvariantCulture)); sb.Append('\t' + FdrInfo.CumulativeDecoy.ToString(CultureInfo.InvariantCulture)); sb.Append('\t' + FdrInfo.QValue.ToString("F6", CultureInfo.InvariantCulture)); sb.Append('\t' + FdrInfo.CumulativeTargetNotch.ToString(CultureInfo.InvariantCulture)); sb.Append('\t' + FdrInfo.CumulativeDecoyNotch.ToString(CultureInfo.InvariantCulture)); sb.Append('\t' + FdrInfo.QValueNotch.ToString("F6", CultureInfo.InvariantCulture)); if (FdrInfo.CalculateEValue) { sb.Append("\t" + FdrInfo.EValue.ToString("F6", CultureInfo.InvariantCulture)); sb.Append("\t" + FdrInfo.EScore.ToString("F6", CultureInfo.InvariantCulture)); } else { sb.Append('\t' + " " + '\t' + " "); } } else { sb.Append('\t' + " " + '\t' + " " + '\t' + " " + '\t' + " " + '\t' + " " + '\t' + " " + '\t' + " " + '\t' + " "); } return(sb.ToString()); }
public override string ToString() { var sb = new StringBuilder(); // list of protein accession numbers sb.Append(ProteinGroupName); sb.Append("\t"); // genes sb.Append(GlobalVariables.CheckLengthOfOutput(string.Join("|", ListOfProteinsOrderedByAccession.Select(p => p.GeneNames.Select(x => x.Item2).FirstOrDefault())))); sb.Append("\t"); // organisms sb.Append(GlobalVariables.CheckLengthOfOutput(string.Join("|", ListOfProteinsOrderedByAccession.Select(p => p.Organism).Distinct()))); sb.Append("\t"); // list of protein names sb.Append(GlobalVariables.CheckLengthOfOutput(string.Join("|", ListOfProteinsOrderedByAccession.Select(p => p.FullName).Distinct()))); sb.Append("\t"); // list of masses var sequences = ListOfProteinsOrderedByAccession.Select(p => p.BaseSequence).Distinct(); List <double> masses = new List <double>(); foreach (var sequence in sequences) { try { masses.Add(new Proteomics.AminoAcidPolymer.Peptide(sequence).MonoisotopicMass); } catch (System.Exception) { masses.Add(double.NaN); } } sb.Append(GlobalVariables.CheckLengthOfOutput(string.Join("|", masses))); sb.Append("\t"); // number of proteins in group sb.Append("" + Proteins.Count); sb.Append("\t"); // list of unique peptides if (!DisplayModsOnPeptides) { sb.Append(GlobalVariables.CheckLengthOfOutput(string.Join("|", UniquePeptides.Select(p => p.BaseSequence).Distinct()))); } else { sb.Append(GlobalVariables.CheckLengthOfOutput(string.Join("|", UniquePeptides.Select(p => p.FullSequence).Distinct()))); } sb.Append("\t"); // list of shared peptides var SharedPeptides = AllPeptides.Except(UniquePeptides); if (!DisplayModsOnPeptides) { sb.Append(GlobalVariables.CheckLengthOfOutput(string.Join("|", SharedPeptides.Select(p => p.BaseSequence).Distinct()))); } else { sb.Append(GlobalVariables.CheckLengthOfOutput(string.Join("|", SharedPeptides.Select(p => p.FullSequence).Distinct()))); } sb.Append("\t"); // number of peptides if (!DisplayModsOnPeptides) { sb.Append("" + AllPeptides.Select(p => p.BaseSequence).Distinct().Count()); } else { sb.Append("" + AllPeptides.Select(p => p.FullSequence).Distinct().Count()); } sb.Append("\t"); // number of unique peptides if (!DisplayModsOnPeptides) { sb.Append("" + UniquePeptides.Select(p => p.BaseSequence).Distinct().Count()); } else { sb.Append("" + UniquePeptides.Select(p => p.FullSequence).Distinct().Count()); } sb.Append("\t"); // sequence coverage percent sb.Append(GlobalVariables.CheckLengthOfOutput(string.Join("|", SequenceCoverageFraction.Select(p => string.Format("{0:0.#####}", p))))); sb.Append("\t"); // sequence coverage sb.Append(GlobalVariables.CheckLengthOfOutput(string.Join("|", SequenceCoverageDisplayList))); sb.Append("\t"); // sequence coverage with mods sb.Append(GlobalVariables.CheckLengthOfOutput(string.Join("|", SequenceCoverageDisplayListWithMods))); sb.Append("\t"); //Detailed mods information list sb.Append(GlobalVariables.CheckLengthOfOutput(string.Join("|", ModsInfo))); sb.Append("\t"); // MS1 intensity (retrieved from FlashLFQ in the SearchTask) if (IntensitiesByFile != null && FilesForQuantification != null) { foreach (var file in FilesForQuantification) { if (IntensitiesByFile[file] > 0) { sb.Append(IntensitiesByFile[file]); } else { sb.Append(""); } sb.Append("\t"); } } // number of PSMs for listed peptides sb.Append("" + AllPsmsBelowOnePercentFDR.Count); sb.Append("\t"); // isDecoy if (IsDecoy) { sb.Append("D"); } else if (IsContaminant) { sb.Append("C"); } else { sb.Append("T"); } sb.Append("\t"); // cumulative target sb.Append(CumulativeTarget); sb.Append("\t"); // cumulative decoy sb.Append(CumulativeDecoy); sb.Append("\t"); // q value sb.Append(QValue); sb.Append("\t"); // best peptide score sb.Append(BestPeptideScore); sb.Append("\t"); // best peptide q value sb.Append(BestPeptideQValue); sb.Append("\t"); return(sb.ToString()); }
public override string ToString() { var sb = new StringBuilder(); // list of protein accession numbers sb.Append(ProteinGroupName); sb.Append("\t"); // genes sb.Append(GlobalVariables.CheckLengthOfOutput(string.Join("|", ListOfProteinsOrderedByAccession.Select(p => p.GeneNames.Select(x => x.Item2).FirstOrDefault())))); sb.Append("\t"); // organisms sb.Append(GlobalVariables.CheckLengthOfOutput(string.Join("|", ListOfProteinsOrderedByAccession.Select(p => p.Organism).Distinct()))); sb.Append("\t"); // list of protein names sb.Append(GlobalVariables.CheckLengthOfOutput(string.Join("|", ListOfProteinsOrderedByAccession.Select(p => p.FullName).Distinct()))); sb.Append("\t"); // list of masses IDigestionParams digestionParams = new TDdigest(); sb.Append(GlobalVariables.CheckLengthOfOutput(string.Join("|", ListOfProteinsOrderedByAccession.Select(p => p.Digest(digestionParams, new List <ModificationWithMass>(), new List <ModificationWithMass>()).First().MonoisotopicMass).Distinct()))); sb.Append("\t"); // number of proteins in group sb.Append("" + Proteins.Count); sb.Append("\t"); // list of unique peptides if (!DisplayModsOnPeptides) { sb.Append(GlobalVariables.CheckLengthOfOutput(string.Join("|", UniquePeptides.Select(p => p.BaseSequence).Distinct()))); } else { sb.Append(GlobalVariables.CheckLengthOfOutput(string.Join("|", UniquePeptides.Select(p => p.Sequence).Distinct()))); } sb.Append("\t"); // list of shared peptides var SharedPeptides = AllPeptides.Except(UniquePeptides); if (!DisplayModsOnPeptides) { sb.Append(GlobalVariables.CheckLengthOfOutput(string.Join("|", SharedPeptides.Select(p => p.BaseSequence).Distinct()))); } else { sb.Append(GlobalVariables.CheckLengthOfOutput(string.Join("|", SharedPeptides.Select(p => p.Sequence).Distinct()))); } sb.Append("\t"); // number of peptides if (!DisplayModsOnPeptides) { sb.Append("" + AllPeptides.Select(p => p.BaseSequence).Distinct().Count()); } else { sb.Append("" + AllPeptides.Select(p => p.Sequence).Distinct().Count()); } sb.Append("\t"); // number of unique peptides if (!DisplayModsOnPeptides) { sb.Append("" + UniquePeptides.Select(p => p.BaseSequence).Distinct().Count()); } else { sb.Append("" + UniquePeptides.Select(p => p.Sequence).Distinct().Count()); } sb.Append("\t"); // sequence coverage percent sb.Append(GlobalVariables.CheckLengthOfOutput(string.Join("|", SequenceCoveragePercent.Select(p => string.Format("{0:0}" + "%", (p * 100)))))); sb.Append("\t"); // sequence coverage sb.Append(GlobalVariables.CheckLengthOfOutput(string.Join("|", SequenceCoverageDisplayList))); sb.Append("\t"); // sequence coverage with mods sb.Append(GlobalVariables.CheckLengthOfOutput(string.Join("|", SequenceCoverageDisplayListWithMods))); sb.Append("\t"); //Detailed mods information list sb.Append(GlobalVariables.CheckLengthOfOutput(string.Join("|", ModsInfo))); sb.Append("\t"); // MS1 intensity (retrieved from FlashLFQ in the SearchTask) if (IntensitiesByFile != null && FilesForQuantification != null) { for (int i = 0; i < IntensitiesByFile.Length; i++) { if (IntensitiesByFile[i] > 0) { sb.Append(IntensitiesByFile[i]); } else { sb.Append(""); } sb.Append("\t"); } } // number of PSMs for listed peptides sb.Append("" + AllPsmsBelowOnePercentFDR.Count); sb.Append("\t"); // isDecoy if (isDecoy) { sb.Append("D"); } else if (isContaminant) { sb.Append("C"); } else { sb.Append("T"); } sb.Append("\t"); // cumulative target sb.Append(CumulativeTarget); sb.Append("\t"); // cumulative decoy sb.Append(CumulativeDecoy); sb.Append("\t"); // q value sb.Append(QValue); sb.Append("\t"); // best peptide score sb.Append(BestPeptideScore); sb.Append("\t"); // best peptide q value sb.Append(BestPeptideQValue); sb.Append("\t"); return(sb.ToString()); }