public static void TestCompIons_MatchIonsScore() { TestDataFile t = new TestDataFile(); Tolerance productMassTolerance = new AbsoluteTolerance(0.01); double precursorMass = 300; //The below theoretical does not accurately represent B-Y ions double[] sorted_theoretical_product_masses_for_this_peptide = new double[] { precursorMass + (2 * Constants.ProtonMass) - 275.1350, precursorMass + (2 * Constants.ProtonMass) - 258.127, precursorMass + (2 * Constants.ProtonMass) - 257.1244, 50, 60, 70, 147.0764, precursorMass + (2 * Constants.ProtonMass) - 147.0764, precursorMass + (2 * Constants.ProtonMass) - 70, precursorMass + (2 * Constants.ProtonMass) - 60, precursorMass + (2 * Constants.ProtonMass) - 50, 257.1244, 258.127, 275.1350 }; //{ 50, 60, 70, 147.0764, 257.1244, 258.127, 275.1350 } List <Product> productsWithLocalizedMassDiff = new List <Product>(); foreach (double d in sorted_theoretical_product_masses_for_this_peptide) { NeutralTerminusFragment frag = new NeutralTerminusFragment(FragmentationTerminus.Both, d, 1, 1); productsWithLocalizedMassDiff.Add(new Product(ProductType.b, frag, 0)); } CommonParameters commonParametersNoComp = new CommonParameters { ProductMassTolerance = new AbsoluteTolerance(0.01) }; CommonParameters commonParametersWithComp = new CommonParameters(productMassTolerance: new AbsoluteTolerance(0.01), addCompIons: true); MsDataScan scan = t.GetOneBasedScan(2); var scanWithMass = new Ms2ScanWithSpecificMass(scan, precursorMass.ToMz(1), 1, "", new CommonParameters()); List <MatchedFragmentIon> matchedIons = MetaMorpheusEngine.MatchFragmentIons(scanWithMass, productsWithLocalizedMassDiff, commonParametersNoComp); List <MatchedFragmentIon> matchedCompIons = MetaMorpheusEngine.MatchFragmentIons(scanWithMass, productsWithLocalizedMassDiff, commonParametersWithComp); matchedCompIons.AddRange(matchedIons); // score when the mass-diff is on this residue double localizedScore = MetaMorpheusEngine.CalculatePeptideScore(scan, matchedIons); double scoreNormal = MetaMorpheusEngine.CalculatePeptideScore(scan, matchedIons); double scoreComp = MetaMorpheusEngine.CalculatePeptideScore(scan, matchedCompIons); Assert.IsTrue(scoreNormal * 2 == scoreComp && scoreComp > scoreNormal + 1); }
/// <summary> /// A product is the individual neutral fragment from an MS dissociation. A fragmentation product here contains one of the two termini (N- or C-). /// The ProductType describes where along the backbone the fragmentaiton occurred (e.g. b-, y-, c-, zdot-). The neutral loss mass (if any) that /// occurred from a mod on the fragment is listed as a mass. Finally the neutral mass of the whole fragment is provided. /// </summary> public Product(ProductType productType, NeutralTerminusFragment terminusFragment, double neutralLoss) { TerminusFragment = terminusFragment; ProductType = productType; this.NeutralLoss = neutralLoss; NeutralMass = DissociationTypeCollection.ProductTypeSpecificFragmentNeutralMass(terminusFragment.NeutralMass, productType) - neutralLoss; }
private static List <MatchedFragmentIon> ReadFragmentIonsFromString(string matchedMzString, string peptideBaseSequence) { var peaks = matchedMzString.Split(MzSplit, StringSplitOptions.RemoveEmptyEntries).Select(v => v.Trim()) .ToList(); peaks.RemoveAll(p => p.Contains("\"")); List <MatchedFragmentIon> matchedIons = new List <MatchedFragmentIon>(); foreach (var peak in peaks) { var split = peak.Split(new char[] { '+', ':' }); string ionTypeAndNumber = split[0]; Match result = IonParser.Match(ionTypeAndNumber); ProductType productType = (ProductType)Enum.Parse(typeof(ProductType), result.Groups[1].Value); int fragmentNumber = int.Parse(result.Groups[2].Value); int z = int.Parse(split[1]); double mz = double.Parse(split[2], CultureInfo.InvariantCulture); double neutralLoss = 0; // check for neutral loss if (ionTypeAndNumber.Contains("-")) { string temp = ionTypeAndNumber.Replace("(", ""); temp = temp.Replace(")", ""); var split2 = temp.Split('-'); neutralLoss = double.Parse(split2[1], CultureInfo.InvariantCulture); } FragmentationTerminus terminus = FragmentationTerminus.None; if (TerminusSpecificProductTypes.ProductTypeToFragmentationTerminus.ContainsKey(productType)) { terminus = TerminusSpecificProductTypes.ProductTypeToFragmentationTerminus[productType]; } int aminoAcidPosition = fragmentNumber; if (terminus == FragmentationTerminus.C) { aminoAcidPosition = peptideBaseSequence.Length - fragmentNumber; } var t = new NeutralTerminusFragment(terminus, mz.ToMass(z) - DissociationTypeCollection.GetMassShiftFromProductType(productType), fragmentNumber, aminoAcidPosition); Product p = new Product(productType, t, neutralLoss); matchedIons.Add(new MatchedFragmentIon(p, mz, 1.0, z)); } return(matchedIons); }