public void AddData(Peptide peptide, double[] quant, bool ismissingChannel = false) { PSMs++; UniquePeptides.Add(peptide); Peptides.Add(peptide); QuantData.Add(new Tuple <Peptide, double[], bool>(peptide, quant, ismissingChannel)); }
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.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) { 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 ProteinGroup ConstructSubsetProteinGroup(string fullFilePath) { var allPsmsForThisFile = new HashSet <PeptideSpectralMatch>(AllPsmsBelowOnePercentFDR.Where(p => p.FullFilePath.Equals(fullFilePath))); var allPeptidesForThisFile = new HashSet <PeptideWithSetModifications>(allPsmsForThisFile.SelectMany(p => p.BestMatchingPeptides.Select(v => v.Peptide))); var allUniquePeptidesForThisFile = new HashSet <PeptideWithSetModifications>(UniquePeptides.Intersect(allPeptidesForThisFile)); ProteinGroup subsetPg = new ProteinGroup(Proteins, allPeptidesForThisFile, allUniquePeptidesForThisFile) { AllPsmsBelowOnePercentFDR = allPsmsForThisFile, DisplayModsOnPeptides = DisplayModsOnPeptides }; SpectraFileInfo spectraFileInfo = null; if (FilesForQuantification != null) { spectraFileInfo = FilesForQuantification.Where(p => p.FullFilePathWithExtension == fullFilePath).First(); subsetPg.FilesForQuantification = new List <SpectraFileInfo> { spectraFileInfo }; } if (IntensitiesByFile == null) { subsetPg.IntensitiesByFile = null; } else { subsetPg.IntensitiesByFile = new Dictionary <SpectraFileInfo, double> { { spectraFileInfo, IntensitiesByFile[spectraFileInfo] } }; } return(subsetPg); }
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()); }
//Get unique and identified peptides for output //Convert the output if it's a SILAC experiment public void GetIdentifiedPeptidesOutput(List <SilacLabel> labels) { var SharedPeptides = AllPeptides.Except(UniquePeptides); if (labels == null) { //TODO add unit test with displaymodsonpeptides if (!DisplayModsOnPeptides) { UniquePeptidesOutput = GlobalVariables.CheckLengthOfOutput(string.Join("|", UniquePeptides.Select(p => p.BaseSequence).Distinct())); SharedPeptidesOutput = GlobalVariables.CheckLengthOfOutput(string.Join("|", SharedPeptides.Select(p => p.BaseSequence).Distinct())); } else { UniquePeptidesOutput = GlobalVariables.CheckLengthOfOutput(string.Join("|", UniquePeptides.Select(p => p.FullSequence).Distinct())); SharedPeptidesOutput = GlobalVariables.CheckLengthOfOutput(string.Join("|", SharedPeptides.Select(p => p.FullSequence).Distinct())); } } else { if (!DisplayModsOnPeptides) { UniquePeptidesOutput = GlobalVariables.CheckLengthOfOutput(string.Join("|", UniquePeptides.Select(p => SilacConversions.GetAmbiguousLightSequence(p.BaseSequence, labels, true)).Distinct())); SharedPeptidesOutput = GlobalVariables.CheckLengthOfOutput(string.Join("|", SharedPeptides.Select(p => SilacConversions.GetAmbiguousLightSequence(p.BaseSequence, labels, true)).Distinct())); } else { UniquePeptidesOutput = GlobalVariables.CheckLengthOfOutput(string.Join("|", UniquePeptides.Select(p => SilacConversions.GetAmbiguousLightSequence(p.FullSequence, labels, false)).Distinct())); SharedPeptidesOutput = GlobalVariables.CheckLengthOfOutput(string.Join("|", SharedPeptides.Select(p => SilacConversions.GetAmbiguousLightSequence(p.FullSequence, labels, false)).Distinct())); } } }