public static void SingleAbsoluteAroundZeroSearchMode() { var result = new SingleAbsoluteAroundZeroSearchMode(2.0); Assert.That(result.Accepts(2.0, 2.0) == 0); result.GetAllowedPrecursorMassIntervalsFromTheoreticalMass(2.0); result.GetAllowedPrecursorMassIntervalsFromObservedMass(2.0); result.ToString(); result.ToProseString(); }
private static MassDiffAcceptor ParseSearchMode(string text) { MassDiffAcceptor massDiffAcceptor = null; try { var split = text.Split(' '); switch (split[1]) { case "dot": double[] massShifts = split[4].Split(',').Select(p => double.Parse(p, CultureInfo.InvariantCulture)).ToArray(); string newString = split[2].Replace("�", ""); double toleranceValue = double.Parse(newString, CultureInfo.InvariantCulture); if (split[3].ToUpperInvariant().Equals("PPM")) { massDiffAcceptor = new DotMassDiffAcceptor(split[0], massShifts, new PpmTolerance(toleranceValue)); } else if (split[3].ToUpperInvariant().Equals("DA")) { massDiffAcceptor = new DotMassDiffAcceptor(split[0], massShifts, new AbsoluteTolerance(toleranceValue)); } break; case "interval": IEnumerable <DoubleRange> doubleRanges = Array.ConvertAll(split[2].Split(';'), b => new DoubleRange(double.Parse(b.Trim(new char[] { '[', ']' }).Split(',')[0], CultureInfo.InvariantCulture), double.Parse(b.Trim(new char[] { '[', ']' }).Split(',')[1], CultureInfo.InvariantCulture))); massDiffAcceptor = new IntervalMassDiffAcceptor(split[0], doubleRanges); break; case "OpenSearch": massDiffAcceptor = new OpenSearchMode(); break; case "daltonsAroundZero": massDiffAcceptor = new SingleAbsoluteAroundZeroSearchMode(double.Parse(split[2], CultureInfo.InvariantCulture)); break; case "ppmAroundZero": massDiffAcceptor = new SinglePpmAroundZeroSearchMode(double.Parse(split[2], CultureInfo.InvariantCulture)); break; default: throw new MetaMorpheusException("Unrecognized search mode type: " + split[1]); } } catch (Exception e) { throw new MetaMorpheusException("Could not parse search mode string: " + e.Message); } return(massDiffAcceptor); }
private static MassDiffAcceptor ParseSearchMode(string text) { MassDiffAcceptor ye = null; var split = text.Split(' '); switch (split[1]) { case "dot": var massShifts = Array.ConvertAll(split[4].Split(','), Double.Parse); var newString = split[2].Replace("�", ""); var toleranceValue = double.Parse(newString, CultureInfo.InvariantCulture); if (split[3].ToUpperInvariant().Equals("PPM")) { ye = new DotMassDiffAcceptor(split[0], massShifts, new PpmTolerance(toleranceValue)); } else if (split[3].ToUpperInvariant().Equals("DA")) { ye = new DotMassDiffAcceptor(split[0], massShifts, new AbsoluteTolerance(toleranceValue)); } break; case "interval": IEnumerable <DoubleRange> doubleRanges = Array.ConvertAll(split[2].Split(','), b => new DoubleRange(double.Parse(b.Trim(new char[] { '[', ']' }).Split(';')[0], CultureInfo.InvariantCulture), double.Parse(b.Trim(new char[] { '[', ']' }).Split(';')[1], CultureInfo.InvariantCulture))); ye = new IntervalMassDiffAcceptor(split[0], doubleRanges); break; case "OpenSearch": ye = new OpenSearchMode(); break; case "daltonsAroundZero": ye = new SingleAbsoluteAroundZeroSearchMode(double.Parse(split[2], CultureInfo.InvariantCulture)); break; case "ppmAroundZero": ye = new SinglePpmAroundZeroSearchMode(double.Parse(split[2], CultureInfo.InvariantCulture)); break; default: throw new MetaMorpheusException("Could not parse search mode string"); } return(ye); }
private (List <PeptideSpectralMatch>, DataPointAquisitionResults) GetDataAcquisitionResults(IMsDataFile <IMsDataScan <IMzSpectrum <IMzPeak> > > myMsDataFile, string currentDataFile, List <ModificationWithMass> variableModifications, List <ModificationWithMass> fixedModifications, List <Protein> proteinList, string taskId, ICommonParameters combinedParameters, Tolerance initPrecTol, Tolerance initProdTol) { var fileNameWithoutExtension = Path.GetFileNameWithoutExtension(currentDataFile); MassDiffAcceptor searchMode; if (initPrecTol is PpmTolerance) { searchMode = new SinglePpmAroundZeroSearchMode(initPrecTol.Value); } else { searchMode = new SingleAbsoluteAroundZeroSearchMode(initPrecTol.Value); } FragmentTypes fragmentTypesForCalibration = FragmentTypes.None; if (combinedParameters.BIons) { fragmentTypesForCalibration = fragmentTypesForCalibration | FragmentTypes.b; } if (combinedParameters.YIons) { fragmentTypesForCalibration = fragmentTypesForCalibration | FragmentTypes.y; } if (combinedParameters.CIons) { fragmentTypesForCalibration = fragmentTypesForCalibration | FragmentTypes.c; } if (combinedParameters.ZdotIons) { fragmentTypesForCalibration = fragmentTypesForCalibration | FragmentTypes.zdot; } var listOfSortedms2Scans = GetMs2Scans(myMsDataFile, currentDataFile, combinedParameters.DoPrecursorDeconvolution, combinedParameters.UseProvidedPrecursorInfo, combinedParameters.DeconvolutionIntensityRatio, combinedParameters.DeconvolutionMaxAssumedChargeState, combinedParameters.DeconvolutionMassTolerance).OrderBy(b => b.PrecursorMass).ToArray(); PeptideSpectralMatch[] allPsmsArray = new PeptideSpectralMatch[listOfSortedms2Scans.Length]; List <ProductType> lp = new List <ProductType>(); if (combinedParameters.BIons) { lp.Add(ProductType.B); } if (combinedParameters.YIons) { lp.Add(ProductType.Y); } if (combinedParameters.CIons) { lp.Add(ProductType.C); } if (combinedParameters.ZdotIons) { lp.Add(ProductType.Zdot); } Log("Searching with searchMode: " + searchMode, new List <string> { taskId, "Individual Spectra Files", fileNameWithoutExtension }); Log("Searching with productMassTolerance: " + initProdTol, new List <string> { taskId, "Individual Spectra Files", fileNameWithoutExtension }); new ClassicSearchEngine(allPsmsArray, listOfSortedms2Scans, variableModifications, fixedModifications, proteinList, lp, searchMode, false, combinedParameters, initProdTol, new List <string> { taskId, "Individual Spectra Files", fileNameWithoutExtension }).Run(); List <PeptideSpectralMatch> allPsms = allPsmsArray.ToList(); Dictionary <CompactPeptideBase, HashSet <PeptideWithSetModifications> > compactPeptideToProteinPeptideMatching = ((SequencesToActualProteinPeptidesEngineResults) new SequencesToActualProteinPeptidesEngine(allPsms, proteinList, fixedModifications, variableModifications, lp, new List <IDigestionParams> { combinedParameters.DigestionParams }, combinedParameters.ReportAllAmbiguity, new List <string> { taskId, "Individual Spectra Files", fileNameWithoutExtension }).Run()).CompactPeptideToProteinPeptideMatching; foreach (var huh in allPsms) { if (huh != null) { huh.MatchToProteinLinkedPeptides(compactPeptideToProteinPeptideMatching); } } allPsms = allPsms.Where(b => b != null).OrderByDescending(b => b.Score).ThenBy(b => b.PeptideMonisotopicMass.HasValue ? Math.Abs(b.ScanPrecursorMass - b.PeptideMonisotopicMass.Value) : double.MaxValue).GroupBy(b => (b.FullFilePath, b.ScanNumber, b.PeptideMonisotopicMass)).Select(b => b.First()).ToList(); new FdrAnalysisEngine(allPsms, searchMode.NumNotches, false, new List <string> { taskId, "Individual Spectra Files", fileNameWithoutExtension }).Run(); List <PeptideSpectralMatch> goodIdentifications = allPsms.Where(b => b.FdrInfo.QValueNotch < 0.01 && !b.IsDecoy && b.FullSequence != null).ToList(); if (!goodIdentifications.Any()) { Warn("No PSMs below 1% FDR observed!"); return(new List <PeptideSpectralMatch>(), null); } var dissociationTypes = MetaMorpheusEngine.DetermineDissociationType(lp); foreach (var psm in allPsms) { var theScan = myMsDataFile.GetOneBasedScan(psm.ScanNumber); double thePrecursorMass = psm.ScanPrecursorMass; foreach (var huh in lp) { var ionMasses = psm.CompactPeptides.First().Key.ProductMassesMightHaveDuplicatesAndNaNs(new List <ProductType> { huh }); Array.Sort(ionMasses); List <double> matchedIonMassesList = new List <double>(); List <double> productMassErrorDaList = new List <double>(); List <double> productMassErrorPpmList = new List <double>(); LocalizationEngine.MatchIons(theScan, initProdTol, ionMasses, matchedIonMassesList, productMassErrorDaList, productMassErrorPpmList, thePrecursorMass, dissociationTypes, false); double[] matchedIonMassesOnlyMatches = matchedIonMassesList.ToArray(); psm.MatchedIonDictOnlyMatches.Add(huh, matchedIonMassesOnlyMatches); psm.ProductMassErrorDa.Add(huh, productMassErrorDaList.ToArray()); psm.ProductMassErrorPpm.Add(huh, productMassErrorPpmList.ToArray()); } } DataPointAquisitionResults currentResult = (DataPointAquisitionResults) new DataPointAcquisitionEngine( goodIdentifications, myMsDataFile, initPrecTol, initProdTol, CalibrationParameters.NumFragmentsNeededForEveryIdentification, CalibrationParameters.MinMS1IsotopicPeaksNeededForConfirmedIdentification, CalibrationParameters.MinMS2IsotopicPeaksNeededForConfirmedIdentification, fragmentTypesForCalibration, new List <string> { taskId, "Individual Spectra Files", fileNameWithoutExtension }).Run(); return(goodIdentifications, currentResult); }