/// <summary> /// Creates a ComplexFragmentIon representing something which has no amino acids from the parent peptide. /// </summary> public static ComplexFragmentIon NewOrphanFragmentIon(TransitionGroup transitionGroup, ExplicitMods explicitMods, Adduct adduct) { var transition = new Transition(transitionGroup, IonType.precursor, transitionGroup.Peptide.Sequence.Length - 1, 0, adduct); return(new ComplexFragmentIon(transition, null, explicitMods?.Crosslinks, true)); }
private static void VerifyAdd(int numStaticMods, int numHeavyMods) { var calc = SkylineWindow.Document.Settings.PeptideSettings.Prediction.RetentionTime.Calculator as RCalcIrt; Assert.IsNotNull(calc); var standards = calc.GetStandardPeptides().Select(SequenceMassCalc.NormalizeModifiedSequence).ToArray(); var peptides = SkylineWindow.Document.PeptideGroups.First().Peptides.ToArray(); Assert.AreEqual(standards.Length, peptides.Length); foreach (var peptide in peptides) { Assert.IsTrue(standards.Contains(peptide.ModifiedTarget)); foreach (var transitionGroup in peptide.TransitionGroups) { var transitions = transitionGroup.Transitions.ToList(); for (var i = 1; i < transitions.Count; i++) { Assert.IsTrue(TransitionGroup.CompareTransitions(transitions[i - 1], transitions[i]) < 0); } } } var mods = SkylineWindow.Document.Settings.PeptideSettings.Modifications; Assert.AreEqual(numStaticMods, mods.StaticModifications.Count); Assert.AreEqual(numHeavyMods, mods.AllHeavyModifications.Count()); }
public void TestCrosslinkModSerialization() { var settings = SrmSettingsList.GetDefault(); var crosslinkerDef = new StaticMod("disulfide", null, null, "-H2") .ChangeCrosslinkerSettings(CrosslinkerSettings.EMPTY); settings = settings.ChangePeptideSettings(settings.PeptideSettings.ChangeModifications( settings.PeptideSettings.Modifications.ChangeStaticModifications(new[] { crosslinkerDef }))); settings = settings.ChangeTransitionSettings(settings.TransitionSettings.ChangeFilter( settings.TransitionSettings.Filter .ChangeFragmentRangeFirstName(TransitionFilter.StartFragmentFinder.ION_1.Name) .ChangeFragmentRangeLastName(@"last ion") .ChangePeptideIonTypes(new[] { IonType.precursor, IonType.y, IonType.b }) )); var mainPeptide = new Peptide("MERCURY"); var transitionGroup = new TransitionGroup(mainPeptide, Adduct.DOUBLY_PROTONATED, IsotopeLabelType.light); var linkedPeptide = new LinkedPeptide(new Peptide("ARSENIC"), 2, null); var crosslinkMod = new ExplicitMod(3, crosslinkerDef).ChangeLinkedPeptide(linkedPeptide); var explicitModsWithCrosslink = new ExplicitMods(mainPeptide, new[] { crosslinkMod }, new TypedExplicitModifications[0]); var transitionGroupDocNode = new TransitionGroupDocNode(transitionGroup, Annotations.EMPTY, settings, explicitModsWithCrosslink, null, ExplicitTransitionGroupValues.EMPTY, null, null, true); var peptideDocNode = new PeptideDocNode(mainPeptide, settings, explicitModsWithCrosslink, null, ExplicitRetentionTimeInfo.EMPTY, new [] { transitionGroupDocNode }, false); peptideDocNode = peptideDocNode.ChangeSettings(settings, SrmSettingsDiff.ALL); Assert.AreNotEqual(0, peptideDocNode.TransitionCount); var peptideGroupDocNode = new PeptideGroupDocNode(new PeptideGroup(), Annotations.EMPTY, "Peptides", null, new [] { peptideDocNode }); var srmDocument = (SrmDocument) new SrmDocument(settings).ChangeChildren(new[] { peptideGroupDocNode }); AssertEx.Serializable(srmDocument); string docXML = null; AssertEx.RoundTrip(srmDocument, ref docXML); Assert.IsNotNull(docXML); }
public void TestCrosslinkGetNeutralFormula() { var mainPeptide = new Peptide("MERCURY"); var srmSettings = SrmSettingsList.GetDefault(); srmSettings = srmSettings.ChangePeptideSettings( srmSettings.PeptideSettings.ChangeModifications(srmSettings.PeptideSettings.Modifications .ChangeStaticModifications(new StaticMod[0]))); var transitionGroup = new TransitionGroup(mainPeptide, Adduct.SINGLY_PROTONATED, IsotopeLabelType.light); var mainTransitionGroupDocNode = new TransitionGroupDocNode(transitionGroup, Annotations.EMPTY, srmSettings, null, null, ExplicitTransitionGroupValues.EMPTY, null, null, false); var unlinkedFormula = mainTransitionGroupDocNode.GetNeutralFormula(srmSettings, null); Assert.AreEqual("C37H61N13O11S2Se", unlinkedFormula.ToString()); var linkedPeptide = new LinkedPeptide(new Peptide("ARSENIC"), 2, null); var linkedPeptideFormula = linkedPeptide.GetNeutralFormula(srmSettings, IsotopeLabelType.light); Assert.AreEqual("C30H53N11O12S", linkedPeptideFormula.ToString()); var crosslinkMod = new StaticMod("disulfide", null, null, "-H2"); var explicitModsWithCrosslink = new ExplicitMods(mainPeptide, new[] { new ExplicitMod(3, crosslinkMod).ChangeLinkedPeptide(linkedPeptide) }, new TypedExplicitModifications[0]); var crosslinkedFormula = mainTransitionGroupDocNode.GetNeutralFormula(srmSettings, explicitModsWithCrosslink); Assert.AreEqual("C67H112N24O23S3Se", crosslinkedFormula.Molecule.ToString()); }
public void TestPermuteComplexIons() { var mainPeptide = new Peptide("MERCURY"); var srmSettings = SrmSettingsList.GetDefault(); var transitionFilter = srmSettings.TransitionSettings.Filter; transitionFilter = transitionFilter .ChangeFragmentRangeFirstName(TransitionFilter.StartFragmentFinder.ION_1.Name) .ChangeFragmentRangeLastName(@"last ion") .ChangePeptideIonTypes(new[] { IonType.precursor, IonType.y, IonType.b }); srmSettings = srmSettings.ChangeTransitionSettings( srmSettings.TransitionSettings.ChangeFilter(transitionFilter)); var transitionGroup = new TransitionGroup(mainPeptide, Adduct.SINGLY_PROTONATED, IsotopeLabelType.light); var crosslinkerDef = new StaticMod("disulfide", "C", null, "-H2"); var linkedPeptide = new LinkedPeptide(new Peptide("ARSENIC"), 6, null); var crosslinkMod = new ExplicitMod(3, crosslinkerDef).ChangeLinkedPeptide(linkedPeptide); var explicitModsWithCrosslink = new ExplicitMods(mainPeptide, new[] { crosslinkMod }, new TypedExplicitModifications[0]); var transitionGroupDocNode = new TransitionGroupDocNode(transitionGroup, Annotations.EMPTY, srmSettings, explicitModsWithCrosslink, null, ExplicitTransitionGroupValues.EMPTY, null, null, false); var choices = transitionGroupDocNode.GetPrecursorChoices(srmSettings, explicitModsWithCrosslink, true) .Cast <TransitionDocNode>().ToArray(); var complexFragmentIons = choices.Select(transition => transition.ComplexFragmentIon.GetName()).ToArray(); Assert.AreNotEqual(0, complexFragmentIons.Length); }
public static string GetLabel(TransitionGroup tranGroup, double precursorMz, string resultsText) { return(string.Format(@"{0}{1}{2}{3}", GetMzLabel(tranGroup, precursorMz), Transition.GetChargeIndicator(tranGroup.PrecursorAdduct), tranGroup.LabelTypeText, resultsText)); }
public void TestSingleAminoAcidLinkedPeptide() { var srmSettings = SrmSettingsList.GetDefault(); var mainPeptide = new Peptide("A"); var staticMod = new StaticMod("crosslinker", null, null, "-C2"); var linkedPeptide = new LinkedPeptide(new Peptide("D"), 0, null); var mainTransitionGroup = new TransitionGroup(mainPeptide, Adduct.SINGLY_PROTONATED, IsotopeLabelType.light); var mainTransitionGroupDocNode = new TransitionGroupDocNode(mainTransitionGroup, Annotations.EMPTY, srmSettings, null, null, ExplicitTransitionGroupValues.EMPTY, null, new TransitionDocNode[0], false); var modsWithoutLinkedPeptide = new ExplicitMods(mainPeptide, new[] { new ExplicitMod(0, staticMod), }, new TypedExplicitModifications[0]); Assert.AreEqual("C3H7NO2", AminoAcidFormulas.Default.GetFormula("A").ToString()); Assert.AreEqual("C3H7NO2", mainTransitionGroupDocNode.GetNeutralFormula(srmSettings, null).Molecule.ToString()); Assert.AreEqual("CH7NO2", mainTransitionGroupDocNode.GetNeutralFormula(srmSettings, modsWithoutLinkedPeptide).Molecule.ToString()); Assert.AreEqual("C4H7NO4", AminoAcidFormulas.Default.GetFormula("D").ToString()); var modsWithLinkedPeptide = new ExplicitMods(mainPeptide, new[] { new ExplicitMod(0, staticMod).ChangeLinkedPeptide(linkedPeptide) }, new TypedExplicitModifications[0]); Assert.AreEqual("C5H14N2O6", mainTransitionGroupDocNode.GetNeutralFormula(srmSettings, modsWithLinkedPeptide).Molecule.ToString()); var mainComplexFragmentIon = new ComplexFragmentIon(new Transition(mainTransitionGroup, IonType.precursor, mainPeptide.Length - 1, 0, Adduct.SINGLY_PROTONATED), null, modsWithLinkedPeptide.Crosslinks); var linkedComplexFragmentIon = new ComplexFragmentIon( new Transition(linkedPeptide.GetTransitionGroup(IsotopeLabelType.light, Adduct.SINGLY_PROTONATED), IonType.precursor, linkedPeptide.Peptide.Length - 1, 0, Adduct.SINGLY_PROTONATED), null, LinkedPeptide.EMPTY_CROSSLINK_STRUCTURE); var complexFragmentIon = mainComplexFragmentIon.AddChild(new ModificationSite(0, staticMod.Name), linkedComplexFragmentIon); var transition = complexFragmentIon.MakeTransitionDocNode(srmSettings, modsWithLinkedPeptide, null); var sequenceMassCalc = new SequenceMassCalc(MassType.Monoisotopic); var expectedMz = sequenceMassCalc.GetPrecursorMass("A") + sequenceMassCalc.GetPrecursorMass("D") - 24 - BioMassCalc.MassProton; Assert.AreEqual(expectedMz, transition.Mz, .00001); }
public void TransitionGroupAddTransition() { tlog.Debug(tag, $"TransitionGroupAddTransition START"); var testingTarget = new TransitionGroup(); Assert.IsNotNull(testingTarget, "Return a null object of FontClient"); Assert.IsInstanceOf <TransitionGroup>(testingTarget, "Should be an instance of TransitionGroup type."); try { using (TransitionBase tb = new TransitionBase()) { tb.TimePeriod = new TimePeriod(300); tb.AlphaFunction = new AlphaFunction(AlphaFunction.BuiltinFunctions.Bounce); testingTarget.AddTransition(tb); } } catch (Exception e) { tlog.Debug(tag, e.Message.ToString()); Assert.Fail("Caught Exception : Failed!"); } testingTarget.Dispose(); tlog.Debug(tag, $"TransitionGroupAddTransition END (OK)"); }
public void TestGetFragmentFormula() { var pepseq = "PEPTIDE"; var sequenceMassCalc = new SequenceMassCalc(MassType.Monoisotopic); var precursor = FragmentedMolecule.EMPTY.ChangeModifiedSequence( new ModifiedSequence(pepseq, new ModifiedSequence.Modification[0], MassType.Monoisotopic)); var peptide = new Peptide(precursor.UnmodifiedSequence); var transitionGroup = new TransitionGroup(peptide, Adduct.SINGLY_PROTONATED, IsotopeLabelType.light); var settings = SrmSettingsList.GetDefault(); var transitionGroupDocNode = new TransitionGroupDocNode(transitionGroup, Annotations.EMPTY, settings, ExplicitMods.EMPTY, null, null, null, new TransitionDocNode[0], false); foreach (var ionType in new[] { IonType.a, IonType.b, IonType.c, IonType.x, IonType.y, IonType.z }) { for (int ordinal = 1; ordinal < pepseq.Length; ordinal++) { var transition = new Transition(transitionGroup, ionType, Transition.OrdinalToOffset(ionType, ordinal, pepseq.Length), 0, Adduct.SINGLY_PROTONATED); var fragment = precursor.ChangeFragmentIon(ionType, ordinal); var actualMassDistribution = FragmentedMolecule.Settings.DEFAULT.GetMassDistribution( fragment.FragmentFormula, 0, 0); var expectedMz = sequenceMassCalc.GetFragmentMass(transition, transitionGroupDocNode.IsotopeDist); if (expectedMz.IsMassH()) { expectedMz = new TypedMass(expectedMz.Value - BioMassCalc.MassProton, expectedMz.MassType & ~MassType.bMassH); } var actualMz = actualMassDistribution.MostAbundanceMass; if (Math.Abs(expectedMz - actualMz) > .001) { Assert.AreEqual(expectedMz, actualMz, .001, "Ion type {0} Ordinal {1}", ionType, ordinal); } } } }
public void TestComplexIonMz() { var srmSettings = SrmSettingsList.GetDefault(); var peptide = new Peptide("DLGEEHFKGLVLIAFSQYLQQCPFDEHVK"); var linkedPeptide = new LinkedPeptide(new Peptide("LVNELTEFAKTCVADESHAGCEK"), 9, null); var transitionGroup = new TransitionGroup(peptide, Adduct.QUADRUPLY_PROTONATED, IsotopeLabelType.light); var crosslinkMod = new StaticMod("linker", "K", null, "C8H10O2"); var explicitMod = new ExplicitMod(7, crosslinkMod).ChangeLinkedPeptide(linkedPeptide); var explicitMods = new ExplicitMods(peptide, new[] { explicitMod }, new List <TypedExplicitModifications>()); var linkedTransition = new Transition(linkedPeptide.GetTransitionGroup(IsotopeLabelType.light, Adduct.SINGLY_PROTONATED), IonType.precursor, linkedPeptide.Peptide.Length - 1, 0, Adduct.SINGLY_PROTONATED); var expectedMzs = new[] { Tuple.Create(IonType.b, 2, 1, 229.1183), Tuple.Create(IonType.b, 10, 3, 1291.2766) }; foreach (var tuple in expectedMzs) { int offset = Transition.OrdinalToOffset(tuple.Item1, tuple.Item2, peptide.Sequence.Length); var transition = new Transition(transitionGroup, tuple.Item1, offset, 0, Adduct.FromChargeProtonated(tuple.Item3)); var complexFragmentIon = new ComplexFragmentIon(transition, null, explicitMods.Crosslinks); if (complexFragmentIon.IncludesAaIndex(explicitMod.IndexAA)) { complexFragmentIon = complexFragmentIon.AddChild(explicitMod.ModificationSite, new ComplexFragmentIon(linkedTransition, null, LinkedPeptide.EMPTY_CROSSLINK_STRUCTURE)); } var complexTransitionDocNode = complexFragmentIon.MakeTransitionDocNode(srmSettings, explicitMods, null); Assert.AreEqual(tuple.Item4, complexTransitionDocNode.Mz, .0001, "{0}{1}{2}", tuple.Item1, tuple.Item2, Transition.GetChargeIndicator(Adduct.FromChargeProtonated(tuple.Item3))); } }
public static string GetTitle(PeptideDocNode peptideDocNode, TransitionGroupDocNode transitionGroupDocNode, IsotopeLabelType labelType) { string libraryNamePrefix = string.Empty; //if (!string.IsNullOrEmpty(libraryNamePrefix)) // libraryNamePrefix += @" - "; TransitionGroup transitionGroup = transitionGroupDocNode.TransitionGroup; string sequence; if (transitionGroup.Peptide.IsCustomMolecule) { sequence = transitionGroupDocNode.CustomMolecule.DisplayName; } else if (peptideDocNode?.ExplicitMods != null && peptideDocNode.ExplicitMods.Crosslinks.Count != 0) { sequence = peptideDocNode.GetCrosslinkedSequence(); } else { sequence = transitionGroup.Peptide.Target.Sequence; } var charge = transitionGroup.PrecursorAdduct.ToString(); // Something like "2" or "-3" for protonation, or "[M+Na]" for small molecules if (transitionGroup.Peptide.IsCustomMolecule) { return(labelType.IsLight ? string.Format(@"{0}{1}{2}", libraryNamePrefix, transitionGroup.Peptide.CustomMolecule.DisplayName, charge) : string.Format(@"{0}{1}{2} ({3})", libraryNamePrefix, sequence, charge, labelType)); } return(labelType.IsLight ? string.Format(Resources.SpectrumGraphItem_Title__0__1__Charge__2__, libraryNamePrefix, sequence, charge) : string.Format(Resources.SpectrumGraphItem_Title__0__1__Charge__2__3__, libraryNamePrefix, sequence, charge, labelType)); }
private static string GetMzLabel(TransitionGroup tranGroup, double precursorMz) { int? massShift = tranGroup.DecoyMassShift; double shift = SequenceMassCalc.GetPeptideInterval(massShift); return(string.Format(@"{0:F04}{1}", precursorMz - shift, Transition.GetDecoyText(massShift))); }
public LibraryRankedSpectrumInfo(SpectrumPeaksInfo info, IsotopeLabelType labelType, TransitionGroup group, SrmSettings settings, string lookupSequence, ExplicitMods lookupMods, IEnumerable <int> charges, IEnumerable <IonType> types, IEnumerable <int> rankCharges, IEnumerable <IonType> rankTypes) : this(info, labelType, group, settings, lookupSequence, lookupMods, charges, types, rankCharges, rankTypes, false, true, -1) { }
protected override TransitionDocNode CreateEmptyNode() { var transitionGroup = new TransitionGroup(new Model.Peptide(null, @"X", null, null, 0), Adduct.SINGLY_PROTONATED, IsotopeLabelType.light); var transition = new Model.Transition(transitionGroup, 0, Adduct.SINGLY_PROTONATED); return(new TransitionDocNode(transition, Annotations.EMPTY, null, TypedMass.ZERO_MONO_MASSH, TransitionDocNode.TransitionQuantInfo.DEFAULT, ExplicitTransitionValues.EMPTY, null)); }
private TransitionGroupDocNode MakeTransitionGroupWithAllPossibleChildren(SrmSettings settings, IsotopeLabelType labelType) { var peptide = new Peptide(TargetInfoObj.LookupSequence); var transitionGroup = new TransitionGroup(peptide, TargetInfoObj.TransitionGroupDocNode.PrecursorAdduct, labelType); var transitionGroupDocNode = new TransitionGroupDocNode(transitionGroup, Annotations.EMPTY, settings, TargetInfoObj.LookupMods, null, ExplicitTransitionGroupValues.EMPTY, null, null, false); var children = transitionGroupDocNode.GetTransitions(settings, TargetInfoObj.LookupMods, transitionGroupDocNode.PrecursorMz, null, null, null, FragmentFilterObj.UseFilter).Cast <DocNode>().ToList(); return((TransitionGroupDocNode)transitionGroupDocNode.ChangeChildren(children)); }
public void TestTransitionGroupDocNodeGetNeutralFormula() { var peptide = new Peptide("PEPTIDE"); var transitionGroup = new TransitionGroup(peptide, Adduct.SINGLY_PROTONATED, IsotopeLabelType.light); var srmSettings = SrmSettingsList.GetDefault(); var transitionGroupDocNode = new TransitionGroupDocNode(transitionGroup, Annotations.EMPTY, srmSettings, null, null, ExplicitTransitionGroupValues.EMPTY, null, null, false); var moleculeOffset = transitionGroupDocNode.GetNeutralFormula(srmSettings, null); Assert.AreEqual("C34H53N7O15", moleculeOffset.Molecule.ToString()); }
private TransitionGroupDocNode CreateChoice(Identity childId, ExplicitMods mods) { TransitionGroup tranGroup = (TransitionGroup)childId; TransitionDocNode[] transitions = DocNode.GetMatchingTransitions( tranGroup, DocSettings, mods); var nodeGroup = new TransitionGroupDocNode(tranGroup, transitions); return(nodeGroup.ChangeSettings(DocSettings, DocNode, mods, SrmSettingsDiff.ALL)); }
public LibraryRankedSpectrumInfo(SpectrumPeaksInfo info, IsotopeLabelType labelType, TransitionGroup group, SrmSettings settings, ExplicitMods lookupMods, bool useFilter, int minPeaks) : this(info, labelType, group, settings, group.Peptide.Sequence, lookupMods, null, // charges null, // types // ReadOnlyCollection enumerators are too slow, and show under a profiler settings.TransitionSettings.Filter.ProductCharges.ToArray(), settings.TransitionSettings.Filter.IonTypes.ToArray(), useFilter, false, minPeaks) { }
private Page CreatePage(Color color, string colorTag, string greyTag) { View pageRoot = new View() { WidthResizePolicy = ResizePolicyType.FillToParent, HeightResizePolicy = ResizePolicyType.FillToParent }; View pageBackground = CreatePageScene(color, colorTag, greyTag); pageBackground.TouchEvent += (object sender, View.TouchEventArgs e) => { if (e.Touch.GetState(0) == PointStateType.Down) { navigator?.PopWithTransition(); } return(true); }; pageRoot.Add(pageBackground); TransitionGroup transitionGroup = new TransitionGroup(); FadeTransition slide = new FadeTransition() { TimePeriod = new TimePeriod(500), AlphaFunction = new AlphaFunction(AlphaFunction.BuiltinFunctions.Default), }; transitionGroup.AddTransition(slide); Page page = new ContentPage() { AppBar = new AppBar() { Title = "Second Page", }, BackgroundColor = new Color(0.7f, 0.9f, 0.8f, 1.0f), Content = pageRoot, AppearingTransition = transitionGroup, DisappearingTransition = new SlideTransition() { TimePeriod = new TimePeriod(500), AlphaFunction = new AlphaFunction(AlphaFunction.BuiltinFunctions.Default), Direction = SlideTransitionDirection.Left }, }; return(page); }
public int CompareTo(ComplexFragmentIon other) { if (IsIonTypePrecursor) { if (!other.IsIonTypePrecursor) { return(-1); } } else if (other.IsIonTypePrecursor) { return(1); } int result = IsOrphan.CompareTo(other.IsOrphan); if (result == 0) { result = TransitionGroup.CompareTransitionIds(Transition, other.Transition); } if (result == 0) { result = Comparer <double?> .Default.Compare(TransitionLosses?.Mass, other.TransitionLosses?.Mass); } if (result != 0) { return(result); } for (int i = 0; i < Children.Count && i < other.Children.Count; i++) { result = Children[i].Key.CompareTo(other.Children[i].Key); if (result == 0) { result = Children[i].Value.CompareTo(other.Children[i].Value); } if (result != 0) { return(result); } } return(Children.Count.CompareTo(other.Children.Count)); }
public void TestTwoAminoAcidLinkedPeptide() { const string modName = "crosslinker"; var srmSettings = SrmSettingsList.GetDefault(); srmSettings = srmSettings.ChangeTransitionSettings(srmSettings.TransitionSettings.ChangeFilter( srmSettings.TransitionSettings.Filter .ChangeFragmentRangeFirstName(TransitionFilter.StartFragmentFinder.ION_1.Name) .ChangeFragmentRangeLastName(@"last ion") .ChangePeptideIonTypes(new[] { IonType.precursor, IonType.y, IonType.b }) )); var mainPeptide = new Peptide("AD"); var staticMod = new StaticMod(modName, null, null, "-C2"); var linkedPeptide = new LinkedPeptide(new Peptide("EF"), 1, null); var mainTransitionGroup = new TransitionGroup(mainPeptide, Adduct.DOUBLY_PROTONATED, IsotopeLabelType.light); var mainTransitionGroupDocNode = new TransitionGroupDocNode(mainTransitionGroup, Annotations.EMPTY, srmSettings, null, null, ExplicitTransitionGroupValues.EMPTY, null, new TransitionDocNode[0], false); var modsWithLinkedPeptide = new ExplicitMods(mainPeptide, new[] { new ExplicitMod(0, staticMod).ChangeLinkedPeptide(linkedPeptide) }, new TypedExplicitModifications[0]); Assert.AreEqual(1, srmSettings.PeptideSettings.Modifications.MaxNeutralLosses); var oneNeutralLossChoices = mainTransitionGroupDocNode.GetTransitions( srmSettings, modsWithLinkedPeptide, mainTransitionGroupDocNode.PrecursorMz, mainTransitionGroupDocNode.IsotopeDist, null, null, true).Select(transition => transition.ComplexFragmentIon.GetName()).ToList(); var modSite = new ModificationSite(0, modName); var expectedFragmentIons = new[] { ComplexFragmentIonName.PRECURSOR.AddChild(modSite, ComplexFragmentIonName.PRECURSOR), ComplexFragmentIonName.PRECURSOR.AddChild(modSite, new ComplexFragmentIonName(IonType.y, 1)), new ComplexFragmentIonName(IonType.y, 1), new ComplexFragmentIonName(IonType.b, 1).AddChild(modSite, new ComplexFragmentIonName(IonType.precursor, 0)), ComplexFragmentIonName.ORPHAN.AddChild(modSite, new ComplexFragmentIonName(IonType.b, 1)), }; CollectionAssert.AreEquivalent(expectedFragmentIons, oneNeutralLossChoices); }
public IEnumerable <TransitionDocNode> GetComplexTransitions(TransitionGroup transitionGroup, double precursorMz, IsotopeDistInfo isotopeDist, Dictionary <double, LibraryRankedSpectrumInfo.RankedMI> transitionRanks, IEnumerable <TransitionDocNode> simpleTransitions, bool useFilter) { var allTransitions = RemoveUnmeasurable(precursorMz, RemoveDuplicates( GetAllComplexTransitions(transitionGroup, isotopeDist, simpleTransitions, useFilter))) .OrderBy(tran => tran.ComplexFragmentIon) .ToList(); IList <TransitionDocNode> ms2transitions; IList <TransitionDocNode> ms1transitions; if (Settings.TransitionSettings.FullScan.IsEnabledMs) { ms2transitions = allTransitions.Where(tran => !tran.IsMs1).ToList(); ms1transitions = allTransitions.Where(tran => tran.IsMs1).ToList(); if (Settings.TransitionSettings.FullScan.IsHighResPrecursor) { ms1transitions = ms1transitions.SelectMany(tran => ExpandPrecursorIsotopes(tran, isotopeDist, useFilter)).ToList(); } } else { ms2transitions = allTransitions; ms1transitions = new TransitionDocNode[0]; } if (useFilter) { if (!Settings.TransitionSettings.Filter.PeptideIonTypes.Contains(IonType.precursor)) { ms1transitions = new TransitionDocNode[0]; } ms2transitions = FilterTransitions(transitionRanks, ms2transitions).ToList(); } return(ms1transitions.Concat(ms2transitions)); }
public static IList <DocNode> GetChoices(TransitionGroupDocNode nodeGroup, SrmSettings settings, ExplicitMods mods, bool useFilter) { TransitionGroup group = nodeGroup.TransitionGroup; SpectrumHeaderInfo libInfo = null; var transitionRanks = new Dictionary <double, LibraryRankedSpectrumInfo.RankedMI>(); group.GetLibraryInfo(settings, mods, useFilter, ref libInfo, transitionRanks); var listChoices = new List <DocNode>(); foreach (TransitionDocNode nodeTran in nodeGroup.GetTransitions(settings, mods, nodeGroup.PrecursorMz, nodeGroup.IsotopeDist, libInfo, transitionRanks, useFilter)) { listChoices.Add(nodeTran); } return(listChoices); }
public void TestIncludesAaIndex() { var peptide = new Peptide("AD"); var transitionGroup = new TransitionGroup(peptide, Adduct.SINGLY_PROTONATED, IsotopeLabelType.light); var precursor = new ComplexFragmentIon(new Transition(transitionGroup, IonType.precursor, peptide.Length - 1, 0, Adduct.SINGLY_PROTONATED), null, LinkedPeptide.EMPTY_CROSSLINK_STRUCTURE); Assert.IsTrue(precursor.IncludesAaIndex(0)); Assert.IsTrue(precursor.IncludesAaIndex(1)); var y1 = new ComplexFragmentIon(new Transition(transitionGroup, IonType.y, Transition.OrdinalToOffset(IonType.y, 1, peptide.Length), 0, Adduct.SINGLY_PROTONATED), null, LinkedPeptide.EMPTY_CROSSLINK_STRUCTURE); Assert.AreEqual(1, y1.Transition.Ordinal); Assert.IsFalse(y1.IncludesAaIndex(0)); Assert.IsTrue(y1.IncludesAaIndex(1)); var b1 = new ComplexFragmentIon(new Transition(transitionGroup, IonType.b, Transition.OrdinalToOffset(IonType.b, 1, peptide.Length), 0, Adduct.SINGLY_PROTONATED), null, LinkedPeptide.EMPTY_CROSSLINK_STRUCTURE); Assert.AreEqual(1, b1.Transition.Ordinal); Assert.IsTrue(b1.IncludesAaIndex(0)); Assert.IsFalse(b1.IncludesAaIndex(1)); }
public void TestCrosslinkPrecursorMz() { var srmSettings = SrmSettingsList.GetDefault(); srmSettings = srmSettings.ChangePeptideSettings( srmSettings.PeptideSettings.ChangeModifications( srmSettings.PeptideSettings.Modifications.ChangeStaticModifications(new StaticMod[0]))); var mainPeptide = new Peptide("WQEGNVFSCSVMHEALHNHYTQK"); var otherPeptide = new Peptide("NQVSLTCLVK"); var linkedPeptide = new LinkedPeptide(otherPeptide, 6, ExplicitMods.EMPTY); var crosslinkMod = new StaticMod("disulfide", "C", null, "-H2").ChangeCrosslinkerSettings(CrosslinkerSettings.EMPTY); var transitionGroup = new TransitionGroup(mainPeptide, Adduct.DOUBLY_PROTONATED, IsotopeLabelType.light); var explicitMod = new ExplicitMod(8, crosslinkMod).ChangeLinkedPeptide(linkedPeptide); var explicitMods = new ExplicitMods(mainPeptide, new[] { explicitMod }, new List <TypedExplicitModifications>()); var transitionGroupDocNode = new TransitionGroupDocNode(transitionGroup, Annotations.EMPTY, srmSettings, explicitMods, null, ExplicitTransitionGroupValues.EMPTY, null, null, false); Assert.AreEqual(1923.9111, transitionGroupDocNode.PrecursorMz, .001); }
public MockTranPeakData(double[] data, IonType ionType = IonType.a, IsotopeLabelType labelType = null, int charge = 2, double?massError = null, double libIntensity = 0, double?isotopeProportion = null) { if (labelType == null) { labelType = IsotopeLabelType.light; } PeakData = new MockPeakData(data, massError) as TPeak; var peptide = new Peptide(null, "AVVAVVA", null, null, 0); var tranGroup = new TransitionGroup(peptide, null, charge, labelType); int offset = ionType == IonType.precursor ? 6 : 0; var isotopeInfo = isotopeProportion == null ? null : new TransitionIsotopeDistInfo(1, (float)isotopeProportion); NodeTran = new TransitionDocNode(new Transition(tranGroup, ionType, offset, 0, charge, null), null, 0, isotopeInfo, new TransitionLibInfo(1, (float)libIntensity)); }
public void TransitionGroupConstructor() { tlog.Debug(tag, $"TransitionGroupConstructor START"); var testingTarget = new TransitionGroup(); Assert.IsNotNull(testingTarget, "Return a null object of FontClient"); Assert.IsInstanceOf <TransitionGroup>(testingTarget, "Should be an instance of TransitionGroup type."); testingTarget.UseGroupTimePeriod = true; tlog.Debug(tag, "UseGroupTimePeriod : " + testingTarget.UseGroupTimePeriod); testingTarget.StepTransition = true; tlog.Debug(tag, "StepTransition : " + testingTarget.StepTransition); testingTarget.UseGroupAlphaFunction = true; tlog.Debug(tag, "UseGroupAlphaFunction : " + testingTarget.UseGroupAlphaFunction); testingTarget.Dispose(); tlog.Debug(tag, $"TransitionGroupConstructor END (OK)"); }
public void TestLooplink() { var peptide = new Peptide("PEPTIDE"); var srmSettings = SrmSettingsList.GetDefault(); var transitionFilter = srmSettings.TransitionSettings.Filter; transitionFilter = transitionFilter .ChangeFragmentRangeFirstName(TransitionFilter.StartFragmentFinder.ION_1.Name) .ChangeFragmentRangeLastName(@"last ion") .ChangePeptideIonTypes(new[] { IonType.precursor, IonType.y, IonType.b }); srmSettings = srmSettings.ChangeTransitionSettings( srmSettings.TransitionSettings.ChangeFilter(transitionFilter)); var transitionGroup = new TransitionGroup(peptide, Adduct.SINGLY_PROTONATED, IsotopeLabelType.light); var crosslinkerDef = new StaticMod("dss", null, null, "C8H10O2"); var linkedPeptide = new LinkedPeptide(null, 5, null); var crosslinkMod = new ExplicitMod(2, crosslinkerDef).ChangeLinkedPeptide(linkedPeptide); var explicitModsWithCrosslink = new ExplicitMods(peptide, new[] { crosslinkMod }, new TypedExplicitModifications[0]); var transitionGroupDocNode = new TransitionGroupDocNode(transitionGroup, Annotations.EMPTY, srmSettings, explicitModsWithCrosslink, null, ExplicitTransitionGroupValues.EMPTY, null, null, false); var modifiedSequence = ModifiedSequence.GetModifiedSequence(srmSettings, peptide.Sequence, explicitModsWithCrosslink, IsotopeLabelType.light); Assert.AreEqual("PEPTIDE-[dss@3-6]", modifiedSequence.FullNames); var choices = transitionGroupDocNode.GetPrecursorChoices(srmSettings, explicitModsWithCrosslink, true) .Cast <TransitionDocNode>().ToArray(); var complexFragmentIons = choices.Select(transition => transition.ComplexFragmentIon.GetName()).ToArray(); // Make sure none of the transitions involve a cleavage in between the two ends of the looplink // PEpTIdE var yOrdinals = complexFragmentIons.Where(ion => ion.IonType == IonType.y).Select(ion => ion.Ordinal) .Distinct().ToList(); var bOrdinals = complexFragmentIons.Where(ion => ion.IonType == IonType.b).Select(ion => ion.Ordinal) .Distinct().ToList(); CollectionAssert.AreEquivalent(new[] { 6, 5, 1 }, yOrdinals); CollectionAssert.AreEquivalent(new[] { 1, 2, 6 }, bOrdinals); }
public MockTranPeakData(double[] data, IonType ionType = IonType.a, IsotopeLabelType labelType = null, int?charge = null, double?massError = null, double libIntensity = 0, double?isotopeProportion = null) { if (labelType == null) { labelType = IsotopeLabelType.light; } PeakData = new MockPeakData(data, massError) as TPeak; var peptide = new Peptide(null, "AVVAVVA", null, null, 0); charge = charge ?? 2; var tranGroup = new TransitionGroup(peptide, Adduct.FromChargeProtonated(charge), labelType); int offset = ionType == IonType.precursor ? 6 : 0; var isotopeInfo = isotopeProportion == null ? null : new TransitionIsotopeDistInfo(1, (float)isotopeProportion); NodeTran = new TransitionDocNode(new Transition(tranGroup, ionType, offset, 0, Adduct.FromChargeProtonated(charge), null), null, TypedMass.ZERO_MONO_MASSH, new TransitionDocNode.TransitionQuantInfo(isotopeInfo, new TransitionLibInfo(1, (float)libIntensity), true)); }
private static string GetMzLabel(TransitionGroup tranGroup, double precursorMz) { int? massShift = tranGroup.DecoyMassShift; double shift = SequenceMassCalc.GetPeptideInterval(massShift); return string.Format("{0:F04}{1}", precursorMz - shift, // Not L10N Transition.GetDecoyText(massShift)); }
private TransitionGroupDocNode GetMoleculeTransitionGroup(SrmDocument document, DataGridViewRow row, Peptide pep, bool requireProductInfo) { var moleculeInfo = ReadPrecursorOrProductColumns(document, row, true); // Re-read the precursor columns if (!document.Settings.TransitionSettings.IsMeasurablePrecursor(moleculeInfo.Mz)) { ShowTransitionError(new PasteError { Column = INDEX_MOLECULE_MZ, Line = row.Index, Message = string.Format(Resources.PasteDlg_GetMoleculeTransitionGroup_The_precursor_m_z__0__is_not_measureable_with_your_current_instrument_settings_, moleculeInfo.Mz) }); return null; } var customIon = moleculeInfo.ToCustomIon(); var isotopeLabelType = moleculeInfo.IsotopeLabelType ?? IsotopeLabelType.light; var group = new TransitionGroup(pep, customIon, moleculeInfo.Charge, isotopeLabelType); try { var tran = GetMoleculeTransition(document, row, pep, group, requireProductInfo); if (tran == null) return null; return new TransitionGroupDocNode(group, document.Annotations, document.Settings, null, null, moleculeInfo.ExplicitTransitionGroupValues, null, new[] {tran}, true); } catch (InvalidDataException e) { ShowTransitionError(new PasteError { Column = INDEX_PRODUCT_MZ, // Don't actually know that mz was the issue, but at least it's the right row, and in the product columns Line = row.Index, Message = e.Message }); return null; } }
private TransitionDocNode GetMoleculeTransition(SrmDocument document, DataGridViewRow row, Peptide pep, TransitionGroup group, bool requireProductInfo) { var massType = document.Settings.TransitionSettings.Prediction.FragmentMassType; var molecule = ReadPrecursorOrProductColumns(document, row, !requireProductInfo); // Re-read the product columns, or copy precursor if (requireProductInfo && molecule == null) { return null; } var ion = molecule.ToCustomIon(); var ionType = (!requireProductInfo || // We inspected the input list and found only precursor info ((ion.MonoisotopicMass.Equals(pep.CustomIon.MonoisotopicMass) && ion.AverageMass.Equals(pep.CustomIon.AverageMass)))) // Same mass, must be a precursor transition ? IonType.precursor : IonType.custom; double mass = ion.GetMass(massType); var transition = new Transition(group, molecule.Charge, null, ion, ionType); var annotations = document.Annotations; if (!string.IsNullOrEmpty(molecule.Note)) { var note = document.Annotations.Note; note = string.IsNullOrEmpty(note) ? molecule.Note : (note + "\r\n" + molecule.Note); // Not L10N annotations = new Annotations(note, document.Annotations.ListAnnotations(), 0); } return new TransitionDocNode(transition, annotations, null, mass, null, null, null); }
public TransitionDocNode[] GetMatchingTransitions(TransitionGroup tranGroup, SrmSettings settings, ExplicitMods explicitMods) { int iMatch = Children.IndexOf(nodeGroup => ((TransitionGroupDocNode)nodeGroup).TransitionGroup.PrecursorCharge == tranGroup.PrecursorCharge); if (iMatch == -1) return null; TransitionGroupDocNode nodeGroupMatching = (TransitionGroupDocNode) Children[iMatch]; // If the matching node is auto-managed, and auto-select is on in the settings, // then returning no transitions should allow transitions to be chosen correctly // automatically. if (nodeGroupMatching.AutoManageChildren && settings.TransitionSettings.Filter.AutoSelect && // Having disconnected libraries can mess up automatic picking settings.PeptideSettings.Libraries.DisconnectedLibraries == null) return null; return tranGroup.GetMatchingTransitions(settings, nodeGroupMatching, explicitMods); }
public static bool IsCustom(IonType type, TransitionGroup parent) { return type == IonType.custom || (type == IonType.precursor && parent.IsCustomIon); }
private static TransitionDocNode[] GetDecoyTransitions(TransitionGroupDocNode nodeGroup, TransitionGroup decoyGroup, bool shiftMass) { var decoyNodeTranList = new List<TransitionDocNode>(); foreach (var nodeTran in nodeGroup.Transitions) { var transition = nodeTran.Transition; int productMassShift = 0; if (shiftMass) productMassShift = GetProductMassShift(); else if (transition.IsPrecursor() && decoyGroup.DecoyMassShift.HasValue) productMassShift = decoyGroup.DecoyMassShift.Value; var decoyTransition = new Transition(decoyGroup, transition.IonType, transition.CleavageOffset, transition.MassIndex, transition.Charge, productMassShift, transition.CustomIon); decoyNodeTranList.Add(new TransitionDocNode(decoyTransition, nodeTran.Losses, 0, nodeTran.IsotopeDistInfo, nodeTran.LibInfo)); } return decoyNodeTranList.ToArray(); }
private static List<TransitionGroupDocNode> GetDecoyGroups(PeptideDocNode nodePep, Peptide decoyPeptide, ExplicitMods mods, IEnumerable<TransitionGroupDocNode> comparableGroups, SrmDocument document, bool shiftMass) { var decoyNodeTranGroupList = new List<TransitionGroupDocNode>(); var chargeToPrecursor = new Tuple<int, TransitionGroupDocNode>[TransitionGroup.MAX_PRECURSOR_CHARGE+1]; foreach (TransitionGroupDocNode nodeGroup in comparableGroups) { var transGroup = nodeGroup.TransitionGroup; int precursorMassShift; TransitionGroupDocNode nodeGroupPrimary = null; var primaryPrecursor = chargeToPrecursor[nodeGroup.TransitionGroup.PrecursorCharge]; if (primaryPrecursor != null) { precursorMassShift = primaryPrecursor.Item1; nodeGroupPrimary = primaryPrecursor.Item2; } else if (shiftMass) { precursorMassShift = GetPrecursorMassShift(); } else { precursorMassShift = TransitionGroup.ALTERED_SEQUENCE_DECOY_MZ_SHIFT; } var decoyGroup = new TransitionGroup(decoyPeptide, transGroup.PrecursorCharge, transGroup.LabelType, false, precursorMassShift); var decoyNodeTranList = nodeGroupPrimary != null ? decoyGroup.GetMatchingTransitions(document.Settings, nodeGroupPrimary, mods) : GetDecoyTransitions(nodeGroup, decoyGroup, shiftMass); var nodeGroupDecoy = new TransitionGroupDocNode(decoyGroup, Annotations.EMPTY, document.Settings, mods, nodeGroup.LibInfo, nodeGroup.ExplicitValues, nodeGroup.Results, decoyNodeTranList, false); decoyNodeTranGroupList.Add(nodeGroupDecoy); if (primaryPrecursor == null) { chargeToPrecursor[transGroup.PrecursorCharge] = new Tuple<int, TransitionGroupDocNode>(precursorMassShift, nodeGroupDecoy); } } return decoyNodeTranGroupList; }
/// <summary> /// Creates a precursor transition /// </summary> /// <param name="group">The <see cref="TransitionGroup"/> which the transition represents</param> /// <param name="massIndex">Isotope mass shift</param> /// <param name="customIon">Non-null if this is a custom transition</param> public Transition(TransitionGroup group, int massIndex, CustomIon customIon = null) : this(group, IonType.precursor, group.Peptide.Length - 1, massIndex, group.PrecursorCharge, null, customIon) { }
private void CompleteTransitionGroup() { var precursorExp = GetBestPrecursorExp(); var transitionGroup = new TransitionGroup(_activePeptide, precursorExp.PrecursorCharge, precursorExp.LabelType, false, precursorExp.MassShift); var transitions = _activeTransitionInfos.ConvertAll(info => { var productExp = info.TransitionExps.Single(exp => Equals(precursorExp, exp.Precursor)).Product; var ionType = productExp.IonType; var ordinal = productExp.FragmentOrdinal; int offset = Transition.OrdinalToOffset(ionType, ordinal, _activePeptide.Sequence.Length); int? massShift = productExp.MassShift; if (massShift == null && precursorExp.MassShift.HasValue) massShift = 0; var tran = new Transition(transitionGroup, ionType, offset, 0, productExp.Charge, massShift); // m/z and library info calculated later return new TransitionDocNode(tran, productExp.Losses, 0, null, null); }); // m/z calculated later var newTransitionGroup = new TransitionGroupDocNode(transitionGroup, CompleteTransitions(transitions)); var currentLibrarySpectrum = !_activeLibraryIntensities.Any() ? null : new SpectrumMzInfo { Key = new LibKey(_activePeptide.Sequence, precursorExp.PrecursorCharge), PrecursorMz = _activePrecursorMz, Label = precursorExp.LabelType, SpectrumPeaks = new SpectrumPeaksInfo(_activeLibraryIntensities.ToArray()) }; _groupLibTriples.Add(new TransitionGroupLibraryIrtTriple(currentLibrarySpectrum, newTransitionGroup, _irtValue, _activePrecursorMz)); _activePrecursorMz = 0; _activePrecursorExps.Clear(); _activeTransitionInfos.Clear(); _activeLibraryIntensities.Clear(); _irtValue = null; }
public static string GetLabel(TransitionGroup tranGroup, double precursorMz, string resultsText) { return string.Format("{0}{1}{2}{3}", GetMzLabel(tranGroup, precursorMz), // Not L10N Transition.GetChargeIndicator(tranGroup.PrecursorCharge), tranGroup.LabelTypeText, resultsText); }
private PeptideDocNode Refine(PeptideDocNode nodePep, SrmDocument document, int bestResultIndex, List<int> acceptedCharges) { int minTrans = MinTransitionsPepPrecursor ?? 0; bool addedGroups = false; var listGroups = new List<TransitionGroupDocNode>(); foreach (TransitionGroupDocNode nodeGroup in nodePep.Children) { if (acceptedCharges != null && !acceptedCharges.Contains(nodeGroup.TransitionGroup.PrecursorCharge)) continue; if (!AddLabelType && RefineLabelType != null && Equals(RefineLabelType, nodeGroup.TransitionGroup.LabelType)) continue; double? peakFoundRatio = nodeGroup.GetPeakCountRatio(bestResultIndex); if (!peakFoundRatio.HasValue) { if (RemoveMissingResults) continue; } else { if (MinPeakFoundRatio.HasValue) { if (peakFoundRatio < MinPeakFoundRatio.Value) continue; } if (MaxPeakFoundRatio.HasValue) { if (peakFoundRatio > MaxPeakFoundRatio.Value) continue; } } TransitionGroupDocNode nodeGroupRefined = nodeGroup; if (AutoPickTransitionsAll && nodeGroup.AutoManageChildren == AutoPickChildrenOff) { nodeGroupRefined = (TransitionGroupDocNode) nodeGroupRefined.ChangeAutoManageChildren(!AutoPickChildrenOff); var settings = document.Settings; if (!settings.TransitionSettings.Filter.AutoSelect && !AutoPickChildrenOff) settings = settings.ChangeTransitionFilter(filter => filter.ChangeAutoSelect(!AutoPickChildrenOff)); nodeGroupRefined = nodeGroupRefined.ChangeSettings(settings, nodePep, nodePep.ExplicitMods, new SrmSettingsDiff(false, false, false, false, true, false)); } nodeGroupRefined = Refine(nodeGroupRefined, bestResultIndex); if (nodeGroupRefined.Children.Count < minTrans) continue; if (peakFoundRatio.HasValue) { if (DotProductThreshold.HasValue) { float? dotProduct = nodeGroupRefined.GetLibraryDotProduct(bestResultIndex); if (dotProduct.HasValue && dotProduct.Value < DotProductThreshold.Value) continue; } if (IdotProductThreshold.HasValue) { float? idotProduct = nodeGroupRefined.GetIsotopeDotProduct(bestResultIndex); if (idotProduct.HasValue && idotProduct.Value < IdotProductThreshold.Value) continue; } } // If this precursor node is going to be added, check to see if it // should be added with another matching isotope label type. var explicitMods = nodePep.ExplicitMods; if (IsLabelTypeRequired(nodePep, nodeGroup, listGroups) && document.Settings.TryGetPrecursorCalc(RefineLabelType, explicitMods) != null) { // CONSIDER: This is a lot like some code in PeptideDocNode.ChangeSettings Debug.Assert(RefineLabelType != null); // Keep ReSharper from warning var tranGroup = new TransitionGroup(nodePep.Peptide, nodeGroup.TransitionGroup.PrecursorCharge, RefineLabelType, false, nodeGroup.TransitionGroup.DecoyMassShift); var settings = document.Settings; // string sequence = nodePep.Peptide.Sequence; TransitionDocNode[] transitions = nodePep.GetMatchingTransitions( tranGroup, settings, explicitMods); var nodeGroupMatch = new TransitionGroupDocNode(tranGroup, Annotations.EMPTY, settings, explicitMods, nodeGroup.LibInfo, nodeGroup.ExplicitValues, null, // results transitions, transitions == null); nodeGroupMatch = nodeGroupMatch.ChangeSettings(settings, nodePep, explicitMods, SrmSettingsDiff.ALL); // Make sure it is measurable before adding it if (settings.TransitionSettings.IsMeasurablePrecursor(nodeGroupMatch.PrecursorMz)) { listGroups.Add(nodeGroupMatch); addedGroups = true; } } listGroups.Add(nodeGroupRefined); } // If groups were added, make sure everything is in the right order. if (addedGroups) listGroups.Sort(Peptide.CompareGroups); // Change the children, but only change auto-management, if the child // identities have changed, not if their contents changed. var childrenNew = listGroups.ToArray(); bool updateAutoManage = !PeptideDocNode.AreEquivalentChildren(nodePep.Children, childrenNew); return (PeptideDocNode) nodePep.ChangeChildrenChecked(childrenNew, updateAutoManage); }
public Transition(TransitionGroup group, IonType type, int? offset, int? massIndex, int charge, int? decoyMassShift, CustomIon customIon = null) { _group = group; IonType = type; CleavageOffset = offset ?? 0; MassIndex = massIndex ?? 0; Charge = charge; DecoyMassShift = decoyMassShift; // Small molecule precursor transition should have same custom ion as parent if (IsPrecursor(type) && group.IsCustomIon) CustomIon = group.CustomIon; else CustomIon = customIon; // Derived values if (!IsCustom(type, group)) { Peptide peptide = group.Peptide; Ordinal = OffsetToOrdinal(type, (int)offset, peptide.Length); AA = (IsNTerminal() ? peptide.Sequence[(int)offset] : peptide.Sequence[(int)offset + 1]); } else { // caller may have passed in offset = group.Peptide.Length - 1, which for custom ions gives -1 CleavageOffset = 0; } Validate(); }
public void Activate() { Window window = NUIApplication.GetDefaultWindow(); Vector2 windowSize = new Vector2((float)(window.Size.Width), (float)(window.Size.Height)); magnification = Math.Min(windowSize.X / baseSize.X, windowSize.Y / baseSize.Y); contentSize = baseSize * magnification; navigator = new Navigator() { WidthResizePolicy = ResizePolicyType.FillToParent, HeightResizePolicy = ResizePolicyType.FillToParent, Transition = new Transition() { TimePeriod = new TimePeriod(400), AlphaFunction = new AlphaFunction(AlphaFunction.BuiltinFunctions.EaseInOutSine), }, }; window.Add(navigator); View mainRoot = new View() { WidthResizePolicy = ResizePolicyType.FillToParent, HeightResizePolicy = ResizePolicyType.FillToParent }; View layoutView = new View() { PositionUsesPivotPoint = true, PivotPoint = PivotPoint.BottomCenter, ParentOrigin = ParentOrigin.BottomCenter, Layout = new LinearLayout() { LinearAlignment = LinearLayout.Alignment.Center, LinearOrientation = LinearLayout.Orientation.Horizontal, CellPadding = new Size(convertSize(60), convertSize(60)), }, Position = new Position(0, -convertSize(30)) }; mainRoot.Add(layoutView); View redButton = CreateButton(TileColor[0], Keywords[0, 0], Keywords[0, 1], redPage); View greenButton = CreateButton(TileColor[1], Keywords[1, 0], Keywords[1, 1], greenPage); View blueButton = CreateButton(TileColor[2], Keywords[2, 0], Keywords[2, 1], bluePage); layoutView.Add(redButton); layoutView.Add(greenButton); layoutView.Add(blueButton); TransitionGroup transitionGroup = new TransitionGroup() { UseGroupAlphaFunction = true, AlphaFunction = new AlphaFunction(AlphaFunction.BuiltinFunctions.EaseInOut), }; SlideTransition slide = new SlideTransition() { TimePeriod = new TimePeriod(400), AlphaFunction = new AlphaFunction(AlphaFunction.BuiltinFunctions.Default), Direction = SlideTransitionDirection.Top }; transitionGroup.AddTransition(slide); FadeTransition fade = new FadeTransition() { Opacity = 0.3f, TimePeriod = new TimePeriod(400), AlphaFunction = new AlphaFunction(AlphaFunction.BuiltinFunctions.Default) }; transitionGroup.AddTransition(fade); ScaleTransition scale = new ScaleTransition() { ScaleFactor = new Vector2(0.3f, 0.3f), TimePeriod = new TimePeriod(400), AlphaFunction = new AlphaFunction(AlphaFunction.BuiltinFunctions.Default) }; transitionGroup.AddTransition(scale); mainPage = new ContentPage() { BackgroundColor = Color.Transparent, Content = mainRoot, DisappearingTransition = new ScaleTransition() { TimePeriod = new TimePeriod(500), AlphaFunction = new AlphaFunction(AlphaFunction.BuiltinFunctions.Default), ScaleFactor = new Vector2(0.5f, 1.5f) }, AppearingTransition = transitionGroup, }; navigator.Push(mainPage); View totalGreyView = new View() { Size = new Size(convertSize(50), convertSize(50)), CornerRadius = convertSize(25), BackgroundColor = ColorGrey, TransitionOptions = new TransitionOptions() { TransitionTag = totalGreyTag, } }; totalGreyView.TouchEvent += (object sender, View.TouchEventArgs e) => { if (e.Touch.GetState(0) == PointStateType.Down) { navigator.PushWithTransition(totalPage); } return(true); }; layoutView.Add(totalGreyView); // ------------------------------------------------------ View totalPageRoot = new View() { WidthResizePolicy = ResizePolicyType.FillToParent, SizeHeight = contentSize.Height, }; View totalLayoutView = new View() { Layout = new GridLayout() { Rows = 2, GridOrientation = GridLayout.Orientation.Vertical, }, PositionUsesPivotPoint = true, PivotPoint = PivotPoint.Center, ParentOrigin = ParentOrigin.Center, }; totalPageRoot.Add(totalLayoutView); for (int i = 0; i < 3; ++i) { View sizeView = new View() { Size = new Size(contentSize.Width / 2.0f, contentSize.Height / 2.0f), }; View smallView = CreatePageScene(TileColor[i], Keywords[i, 0], Keywords[i, 1]); smallView.Scale = new Vector3(0.45f, 0.45f, 1.0f); smallView.PositionUsesPivotPoint = true; smallView.PivotPoint = PivotPoint.Center; smallView.ParentOrigin = ParentOrigin.Center; sizeView.Add(smallView); totalLayoutView.Add(sizeView); } View sizeGreyView = new View() { Size = new Size(contentSize.Width / 2.0f, contentSize.Height / 2.0f), }; View totalGreyReturnView = new View() { PositionUsesPivotPoint = true, PivotPoint = PivotPoint.Center, ParentOrigin = ParentOrigin.Center, Size = new Size(convertSize(70), convertSize(70)), CornerRadius = convertSize(20), BackgroundColor = ColorGrey, TransitionOptions = new TransitionOptions() { TransitionTag = totalGreyTag, } }; sizeGreyView.Add(totalGreyReturnView); totalLayoutView.Add(sizeGreyView); totalGreyReturnView.TouchEvent += (object sender, View.TouchEventArgs e) => { if (e.Touch.GetState(0) == PointStateType.Down) { navigator.PopWithTransition(); } return(true); }; totalPage = new ContentPage() { BackgroundColor = Color.Transparent, Content = totalPageRoot, AppearingTransition = new FadeTransition() { TimePeriod = new TimePeriod(500), AlphaFunction = new AlphaFunction(AlphaFunction.BuiltinFunctions.Default), }, DisappearingTransition = new FadeTransition() { TimePeriod = new TimePeriod(500), AlphaFunction = new AlphaFunction(AlphaFunction.BuiltinFunctions.Default), }, }; }
public SrmDocument ConvertToSmallMolecules(SrmDocument document, ConvertToSmallMoleculesMode mode = ConvertToSmallMoleculesMode.formulas, bool invertCharges = false, bool ignoreDecoys=false) { if (mode == ConvertToSmallMoleculesMode.none) return document; var newdoc = new SrmDocument(document.Settings); var note = new Annotations(TestingConvertedFromProteomic, null, 1); // Mark this as a testing node so we don't sort it newdoc = (SrmDocument)newdoc.ChangeIgnoreChangingChildren(true); // Retain copied results foreach (var peptideGroupDocNode in document.MoleculeGroups) { if (!peptideGroupDocNode.IsProteomic) { newdoc = (SrmDocument)newdoc.Add(peptideGroupDocNode); // Already a small molecule } else { var newPeptideGroup = new PeptideGroup(); var newPeptideGroupDocNode = new PeptideGroupDocNode(newPeptideGroup, peptideGroupDocNode.Annotations.Merge(note), peptideGroupDocNode.Name, peptideGroupDocNode.Description, new PeptideDocNode[0], peptideGroupDocNode.AutoManageChildren); foreach (var mol in peptideGroupDocNode.Molecules) { var peptideSequence = mol.Peptide.Sequence; // Create a PeptideDocNode with the presumably baseline charge and label var precursorCharge = (mol.TransitionGroups.Any() ? mol.TransitionGroups.First().TransitionGroup.PrecursorCharge : 0) * (invertCharges ? -1 : 1); var isotopeLabelType = mol.TransitionGroups.Any() ? mol.TransitionGroups.First().TransitionGroup.LabelType : IsotopeLabelType.light; var moleculeCustomIon = ConvertToSmallMolecule(mode, document, mol, precursorCharge, isotopeLabelType); var precursorCustomIon = moleculeCustomIon; var newPeptide = new Peptide(moleculeCustomIon); var newPeptideDocNode = new PeptideDocNode(newPeptide, newdoc.Settings, null, null, null, null, mol.ExplicitRetentionTime, note, mol.Results, new TransitionGroupDocNode[0], mol.AutoManageChildren); foreach (var transitionGroupDocNode in mol.TransitionGroups) { if (transitionGroupDocNode.IsDecoy) { if (ignoreDecoys) continue; throw new Exception("There is no translation from decoy to small molecules"); // Not L10N } if (transitionGroupDocNode.TransitionGroup.PrecursorCharge != Math.Abs(precursorCharge) || !Equals(isotopeLabelType, transitionGroupDocNode.TransitionGroup.LabelType)) { // Different charges or labels mean different ion formulas precursorCharge = transitionGroupDocNode.TransitionGroup.PrecursorCharge * (invertCharges ? -1 : 1); isotopeLabelType = transitionGroupDocNode.TransitionGroup.LabelType; precursorCustomIon = ConvertToSmallMolecule(mode, document, mol, precursorCharge, isotopeLabelType); } var newTransitionGroup = new TransitionGroup(newPeptide, precursorCustomIon, precursorCharge, isotopeLabelType); // Remove any library info, since for the moment at least small molecules don't support this and it won't roundtrip var resultsNew = RemoveTransitionGroupChromInfoLibraryInfo(transitionGroupDocNode); var newTransitionGroupDocNode = new TransitionGroupDocNode(newTransitionGroup, transitionGroupDocNode.Annotations.Merge(note), document.Settings, null, null, transitionGroupDocNode.ExplicitValues, resultsNew, null, transitionGroupDocNode.AutoManageChildren); var mzShift = invertCharges ? 2.0 * BioMassCalc.MassProton : 0; // We removed hydrogen rather than added Assume.IsTrue((Math.Abs(newTransitionGroupDocNode.PrecursorMz + mzShift - transitionGroupDocNode.PrecursorMz) - Math.Abs(transitionGroupDocNode.TransitionGroup.PrecursorCharge * BioMassCalc.MassElectron)) <= 1E-5); foreach (var transition in transitionGroupDocNode.Transitions) { double mass = 0; var transitionCharge = transition.Transition.Charge * (invertCharges ? -1 : 1); var ionType = IonType.custom; CustomIon transitionCustomIon; double mzShiftTransition = 0; if (transition.Transition.IonType == IonType.precursor) { ionType = IonType.precursor; transitionCustomIon = new DocNodeCustomIon(precursorCustomIon.Formula, string.IsNullOrEmpty(precursorCustomIon.Formula) ? precursorCustomIon.MonoisotopicMass : (double?) null, string.IsNullOrEmpty(precursorCustomIon.Formula) ? precursorCustomIon.AverageMass : (double?) null, SmallMoleculeNameFromPeptide(peptideSequence, transitionCharge)); mzShiftTransition = invertCharges ? 2.0 * BioMassCalc.MassProton : 0; // We removed hydrogen rather than added } else if (transition.Transition.IonType == IonType.custom) { transitionCustomIon = transition.Transition.CustomIon; mass = transitionCustomIon.MonoisotopicMass; } else { // TODO - try to get fragment formula? mass = BioMassCalc.CalculateIonMassFromMz(transition.Mz, transition.Transition.Charge); transitionCustomIon = new DocNodeCustomIon(mass, mass,// We can't really get at mono vs average mass from m/z, but for test purposes this is fine transition.Transition.FragmentIonName); } if (mode == ConvertToSmallMoleculesMode.masses_and_names) { // Discard the formula if we're testing the use of mass-with-names (for matching in ratio calcs) target specification transitionCustomIon = new DocNodeCustomIon(transitionCustomIon.MonoisotopicMass, transitionCustomIon.AverageMass, transition.Transition.FragmentIonName); } else if (mode == ConvertToSmallMoleculesMode.masses_only) { // Discard the formula and name if we're testing the use of mass-only target specification transitionCustomIon = new DocNodeCustomIon(transitionCustomIon.MonoisotopicMass, transitionCustomIon.AverageMass); } var newTransition = new Transition(newTransitionGroup, ionType, null, transition.Transition.MassIndex, transition.Transition.Charge * (invertCharges ? -1 : 1), null, transitionCustomIon); if (ionType == IonType.precursor) { mass = document.Settings.GetFragmentMass(transitionGroupDocNode.TransitionGroup.LabelType, null, newTransition, newTransitionGroupDocNode.IsotopeDist); } var newTransitionDocNode = new TransitionDocNode(newTransition, transition.Annotations.Merge(note), null, mass, transition.IsotopeDistInfo, null, transition.Results); Assume.IsTrue((Math.Abs(newTransitionDocNode.Mz + mzShiftTransition - transition.Mz) - Math.Abs(transitionGroupDocNode.TransitionGroup.PrecursorCharge * BioMassCalc.MassElectron)) <= 1E-5, String.Format("unexpected mz difference {0}-{1}={2}", newTransitionDocNode.Mz , transition.Mz, newTransitionDocNode.Mz - transition.Mz)); // Not L10N newTransitionGroupDocNode = (TransitionGroupDocNode)newTransitionGroupDocNode.Add(newTransitionDocNode); } if (newPeptideDocNode != null) newPeptideDocNode = (PeptideDocNode)newPeptideDocNode.Add(newTransitionGroupDocNode); } newPeptideGroupDocNode = (PeptideGroupDocNode)newPeptideGroupDocNode.Add(newPeptideDocNode); } newdoc = (SrmDocument)newdoc.Add(newPeptideGroupDocNode); } } // No retention time prediction for small molecules (yet?) newdoc = newdoc.ChangeSettings(newdoc.Settings.ChangePeptideSettings(newdoc.Settings.PeptideSettings.ChangePrediction( newdoc.Settings.PeptideSettings.Prediction.ChangeRetentionTime(null)))); return newdoc; }
public Transition(TransitionGroup group, IonType type, int offset, int massIndex, int charge) : this(group, type, offset, massIndex, charge, null) { }
public Transition(TransitionGroup group, int charge, int? massIndex, CustomIon customIon, IonType type=IonType.custom) : this(group, type, null, massIndex, charge, null, customIon) { }