/// <summary> /// Links a list of peptides to the features provided if the dataset has knowledge of the sequence file file /// </summary> private void LinkPeptidesToFeatures(string sequencePath, List <UMCLight> aligneeFeatures, double fdr, double idScore) { // Get the peptides associated with this feature set. var peptideReaderY = PeptideReaderFactory.CreateReader(sequencePath); if (peptideReaderY == null) { return; } // Load the peptide Y UpdateStatus("Linking peptides to ms/ms"); var linker = new PeptideMsMsLinker(); var peptides = peptideReaderY.Read(sequencePath).ToList(); var filteredPeptides = peptides.ToList().Where(x => PeptideUtility.PassesCutoff(x, idScore, fdr)).ToList(); var msnSpectra = new List <MSSpectra>(); foreach (var feature in aligneeFeatures) { foreach (var msFeature in feature.MsFeatures) { msnSpectra.AddRange(msFeature.MSnSpectra); } } linker.LinkPeptidesToSpectra(msnSpectra, filteredPeptides); }
private void MatchPeptides(AlignmentDataset datasetX, AlignmentDataset datasetY, Dictionary <int, ScanSummary> scanDataX, Dictionary <int, ScanSummary> scanDataY, IEnumerable <string> names, SpectralOptions options) { // Read data for peptides var reader = PeptideReaderFactory.CreateReader(SequenceFileType.MSGF); var peptidesA = reader.Read(datasetX.PeptideFile); var peptidesB = reader.Read(datasetY.PeptideFile); peptidesA = peptidesA.ToList().Where(x => PeptideUtility.PassesCutoff(x, options.IdScore, options.Fdr)).ToList(); peptidesB = peptidesB.ToList().Where(x => PeptideUtility.PassesCutoff(x, options.IdScore, options.Fdr)).ToList(); var peptideMapX = PeptideUtility.MapWithBestScan(peptidesA); var peptideMapY = PeptideUtility.MapWithBestScan(peptidesB); // Determine the scan extrema var maxX = scanDataX.Aggregate((l, r) => l.Value.Scan > r.Value.Scan ? l : r).Key; var minX = scanDataX.Aggregate((l, r) => l.Value.Scan < r.Value.Scan ? l : r).Key; var maxY = scanDataY.Aggregate((l, r) => l.Value.Scan > r.Value.Scan ? l : r).Key; var minY = scanDataY.Aggregate((l, r) => l.Value.Scan < r.Value.Scan ? l : r).Key; // Then map the peptide sequences to identify True Positive and False Positives var count = (from scanx in peptideMapX.Keys let peptideX = peptideMapX[scanx] from scany in peptideMapY.Keys let peptideY = peptideMapY[scany] let netX = Convert.ToDouble(scanx - minX) / Convert.ToDouble(maxX - minX) let netY = Convert.ToDouble(scany - minY) / Convert.ToDouble(maxY - minY) let net = Convert.ToDouble(netX - netY) where Math.Abs(net) < options.NetTolerance where Math.Abs(peptideX.Mz - peptideY.Mz) < options.MzTolerance where PeptideUtility.PassesCutoff(peptideX, options.IdScore, options.Fdr) && PeptideUtility.PassesCutoff(peptideY, options.IdScore, options.Fdr) && peptideX.Sequence.Equals(peptideY.Sequence) select peptideX).Count(); Console.WriteLine(); foreach (var name in names) { Console.WriteLine(name); } Console.WriteLine(@"Matches - {0}", count); }
/// <summary> /// Get all identifications from a particular identifications file. /// </summary> /// <param name="filePath">The path for the identifications list.</param> /// <returns>A dictionary mapping scan numbers to their respective identifications.</returns> public Dictionary <int, List <Peptide> > GetIdentifications(string filePath) { var sequenceProvider = PeptideReaderFactory.CreateReader(filePath); var peptides = sequenceProvider.Read(filePath); var scanMaps = peptides.CreateScanMaps(); foreach (var scanMap in scanMaps) { if (!this.identifications.ContainsKey(scanMap.Key)) { this.identifications.Add(scanMap.Key, new List <Peptide>()); } this.identifications[scanMap.Key].AddRange(scanMap.Value); } return(scanMaps); }
protected static SpectralAnalysis MatchDatasets(SpectralComparison comparerType, ISpectraProvider readerX, ISpectraProvider readerY, SpectralOptions options, AlignmentDataset datasetX, AlignmentDataset datasetY, List <string> names) { var peptideReader = PeptideReaderFactory.CreateReader(SequenceFileType.MSGF); var finder = new SpectralAnchorPointFinder(); var validator = new SpectralAnchorPointValidator(); var comparer = SpectralComparerFactory.CreateSpectraComparer(comparerType); var filter = SpectrumFilterFactory.CreateFilter(SpectraFilters.TopPercent); var matches = finder.FindAnchorPoints(readerX, readerY, comparer, filter, options); var peptidesX = peptideReader.Read(datasetX.PeptideFile); var peptidesY = peptideReader.Read(datasetY.PeptideFile); validator.ValidateMatches(matches, peptidesX, peptidesY, options); var analysis = new SpectralAnalysis { DatasetNames = names, Matches = matches, Options = options }; return(analysis); }