Esempio n. 1
0
 public Bookmark ChangeIdentityPath(IdentityPath value)
 {
     return(new Bookmark(this)
     {
         IdentityPath = value ?? IdentityPath.ROOT
     });
 }
Esempio n. 2
0
        public IDictionary <IdentityPath, Quantity> GetTransitionIntensities(SrmSettings srmSettings, int replicateIndex, bool treatMissingAsZero)
        {
            var quantities = new Dictionary <IdentityPath, Quantity>();
            var transitionsToNormalizeAgainst = GetTransitionsToNormalizeAgainst(srmSettings, PeptideDocNode, replicateIndex);

            foreach (var precursor in PeptideDocNode.TransitionGroups)
            {
                if (SkipTransitionGroup(precursor))
                {
                    continue;
                }
                foreach (var transition in precursor.Transitions)
                {
                    if (SkipTransition(srmSettings, transition))
                    {
                        continue;
                    }
                    var quantity = GetTransitionQuantity(srmSettings, transitionsToNormalizeAgainst, NormalizationMethod, replicateIndex, precursor,
                                                         transition, treatMissingAsZero);
                    if (null != quantity)
                    {
                        IdentityPath transitionIdentityPath = new IdentityPath(PeptideGroupDocNode.PeptideGroup,
                                                                               PeptideDocNode.Peptide, precursor.TransitionGroup, transition.Transition);
                        quantities.Add(transitionIdentityPath, quantity);
                    }
                }
            }
            return(quantities);
        }
Esempio n. 3
0
 public void Add(IdentityPath pathPep, PeptideDocNode nodePep)
 {
     foreach (var nodeGroups in nodePep.TransitionGroups)
     {
         Add(pathPep, nodePep, nodeGroups);
     }
 }
Esempio n. 4
0
        protected DocNode DeleteChildren(DocNode parent, IdentityPath identityPath, HashSet <IdentityPath> pathsToDelete)
        {
            var docNodeParent = parent as DocNodeParent;

            if (docNodeParent == null)
            {
                return(parent);
            }
            if (docNodeParent.Children.Count == 0)
            {
                return(parent);
            }
            var newChildren = new List <DocNode>();

            foreach (var child in docNodeParent.Children)
            {
                var childPath = new IdentityPath(identityPath, child.Id);
                if (pathsToDelete.Contains(childPath))
                {
                    continue;
                }
                var newChild = DeleteChildren(child, childPath, pathsToDelete);
                if (newChild != null)
                {
                    newChildren.Add(newChild);
                }
            }
            if (newChildren.Count == 0)
            {
                return(null);
            }
            return(docNodeParent.ChangeChildren(newChildren));
        }
Esempio n. 5
0
        public PeptideGroupDocNode UpdateMoleculeGroup(PeptideGroupDocNode peptideGroupDocNode)
        {
            CheckCancelled();
            AnnotationUpdater updater;
            var identityPath = new IdentityPath(peptideGroupDocNode.PeptideGroup);

            if (_annotationUpdaters.TryGetValue(AnnotationDef.AnnotationTarget.protein, out updater))
            {
                var protein     = new Protein(SkylineDataSchema, identityPath);
                var annotations = updater.UpdateAnnotations(peptideGroupDocNode.Annotations, protein);
                if (!Equals(annotations, peptideGroupDocNode.Annotations))
                {
                    peptideGroupDocNode = (PeptideGroupDocNode)peptideGroupDocNode.ChangeAnnotations(annotations);
                }
            }

            if (!RecurseMolecules)
            {
                return(peptideGroupDocNode);
            }


            var newChildren = peptideGroupDocNode.Molecules
                              .Select(peptideDocNode => UpdateMolecule(identityPath, peptideDocNode)).ToArray();

            if (!ArrayUtil.ReferencesEqual(peptideGroupDocNode.Children, newChildren))
            {
                peptideGroupDocNode = (PeptideGroupDocNode)peptideGroupDocNode.ChangeChildren(newChildren);
            }

            return(peptideGroupDocNode);
        }
Esempio n. 6
0
        private ChromatogramGroupInfo LoadChromatogramInfo(SrmDocument document, ChromatogramSet chromatogramSet, MsDataFileUri filePath,
                                                           IdentityPath precursorIdentityPath, bool loadPoints)
        {
            var measuredResults = document.Settings.MeasuredResults;

            if (null == measuredResults)
            {
                return(null);
            }
            var tolerance        = (float)document.Settings.TransitionSettings.Instrument.MzMatchTolerance;
            var peptideDocNode   = (PeptideDocNode)document.FindNode(precursorIdentityPath.Parent);
            var precursorDocNode = (TransitionGroupDocNode)peptideDocNode.FindNode(precursorIdentityPath.Child);

            ChromatogramGroupInfo[] chromatogramGroupInfos;
            if (!measuredResults.TryLoadChromatogram(chromatogramSet, peptideDocNode, precursorDocNode, tolerance, loadPoints,
                                                     out chromatogramGroupInfos))
            {
                return(null);
            }
            foreach (var chromatogramGroupInfo in chromatogramGroupInfos)
            {
                if (Equals(chromatogramGroupInfo.FilePath, filePath))
                {
                    return(chromatogramGroupInfo);
                }
            }
            return(null);
        }
Esempio n. 7
0
        public PeptideDocNode UpdateMolecule(IdentityPath parent, PeptideDocNode peptideDocNode)
        {
            CheckCancelled();
            AnnotationUpdater updater;

            _annotationUpdaters.TryGetValue(AnnotationDef.AnnotationTarget.peptide, out updater);
            var identityPath = new IdentityPath(parent, peptideDocNode.Peptide);

            if (updater != null)
            {
                var peptide     = new Databinding.Entities.Peptide(SkylineDataSchema, new IdentityPath(parent, peptideDocNode.Peptide));
                var annotations = updater.UpdateAnnotations(peptideDocNode.Annotations, peptide);
                if (!Equals(annotations, peptideDocNode.Annotations))
                {
                    peptideDocNode = (PeptideDocNode)peptideDocNode.ChangeAnnotations(annotations);
                }
            }

            if (!RecursePrecursors)
            {
                return(peptideDocNode);
            }

            var newChildren = peptideDocNode.TransitionGroups.Select(tg => UpdatePrecursor(identityPath, tg)).ToArray();

            if (!ArrayUtil.ReferencesEqual(peptideDocNode.Children, newChildren))
            {
                peptideDocNode = (PeptideDocNode)peptideDocNode.ChangeChildren(newChildren);
            }

            return(peptideDocNode);
        }
Esempio n. 8
0
        public TransitionDocNode UpdateTransition(IdentityPath parent, TransitionDocNode transitionDocNode)
        {
            CheckCancelled();
            AnnotationUpdater updater;

            _annotationUpdaters.TryGetValue(AnnotationDef.AnnotationTarget.transition, out updater);
            IdentityPath identityPath = new IdentityPath(parent, transitionDocNode.Transition);
            var          transition   = new Databinding.Entities.Transition(SkylineDataSchema, identityPath);

            if (updater != null)
            {
                var annotations = updater.UpdateAnnotations(transitionDocNode.Annotations, transition);
                if (!Equals(annotations, transitionDocNode.Annotations))
                {
                    transitionDocNode = (TransitionDocNode)transitionDocNode.ChangeAnnotations(annotations);
                }
            }

            if (_precursorResultUpdater != null)
            {
                var newResults = _transitionResultUpdater.Update(transitionDocNode.Results, transition.Results);
                transitionDocNode = transitionDocNode.ChangeResults(newResults);
            }

            return(transitionDocNode);
        }
        private void PickTransitions(int pepIndex, int[] transIndexes,
                                     string screenshotPromptA = null, int?pageA = null, string screenshotPromptB = null, int?pageB = null)
        {
            var doc       = SkylineWindow.Document;
            var pepPath   = doc.GetPathTo((int)SrmDocument.Level.Molecules, pepIndex);
            var nodeGroup = doc.Peptides.ElementAt(pepIndex).TransitionGroups.First();
            var groupPath = new IdentityPath(pepPath, nodeGroup.TransitionGroup);

            RunUI(() => SkylineWindow.SequenceTree.SelectedPath = groupPath);
            var popupPickList = ShowDialog <PopupPickList>(SkylineWindow.ShowPickChildrenInTest);

            if (screenshotPromptA != null)
            {
                PauseForScreenShot <PopupPickList>(screenshotPromptA, pageA);
            }
            RunUI(() => popupPickList.ApplyFilter(false));  // clear the filter
            if (screenshotPromptB != null)
            {
                PauseForScreenShot <PopupPickList>(screenshotPromptB, pageB);
            }
            RunUI(() =>
            {
                for (int i = 0; i < popupPickList.ItemNames.Count(); i++)
                {
                    popupPickList.SetItemChecked(i, transIndexes.Contains(i));
                }
            });
            OkDialog(popupPickList, popupPickList.OnOk);
            WaitForDocumentChange(doc);
            WaitForGraphs();
        }
Esempio n. 10
0
        public override bool HandleMouseMoveEvent(ZedGraphControl sender, MouseEventArgs mouseEventArgs)
        {
            if (mouseEventArgs.Button != MouseButtons.None)
            {
                return(base.HandleMouseMoveEvent(sender, mouseEventArgs));
            }

            CurveItem nearestCurve;
            int       iNearest;

            if (!FindNearestPoint(new PointF(mouseEventArgs.X, mouseEventArgs.Y), out nearestCurve, out iNearest))
            {
                var axis = GetNearestXAxis(sender, mouseEventArgs);
                if (axis != null)
                {
                    GraphSummary.Cursor = Cursors.Hand;
                    return(true);
                }
                return(false);
            }
            IdentityPath identityPath = GetIdentityPath(nearestCurve, iNearest);

            if (identityPath == null)
            {
                return(false);
            }
            GraphSummary.Cursor = Cursors.Hand;
            return(true);
        }
Esempio n. 11
0
 public bool IsPathSelected(IdentityPath selectedPath, IdentityPath identityPath)
 {
     return(selectedPath != null && identityPath != null &&
            selectedPath.Depth <= (int)SrmDocument.Level.Molecules && identityPath.Depth <= (int)SrmDocument.Level.Molecules &&
            (selectedPath.Depth >= identityPath.Depth && Equals(selectedPath.GetPathTo(identityPath.Depth), identityPath) ||
             selectedPath.Depth <= identityPath.Depth && Equals(identityPath.GetPathTo(selectedPath.Depth), selectedPath)));
 }
Esempio n. 12
0
 public Precursor(SkylineDataSchema dataSchema, IdentityPath identityPath) : base(dataSchema, identityPath)
 {
     _peptide     = new Lazy <Peptide>(() => new Peptide(DataSchema, IdentityPath.Parent));
     _transitions = CachedValue.Create(dataSchema, () => DocNode.Children
                                       .Select(child => new Transition(DataSchema, new IdentityPath(IdentityPath, child.Id))).ToArray());
     _results = CachedValue.Create(dataSchema, MakeResults);
 }
Esempio n. 13
0
 public void SelectPeptide(IdentityPath peptidePath)
 {
     foreach (var regressionGraphPane in GraphSummary.GraphPanes.OfType <RTLinearRegressionGraphPane>())
     {
         regressionGraphPane.SelectPeptide(peptidePath);
     }
 }
Esempio n. 14
0
        protected IEnumerable <IdentityPath> RecurseListingKeys(IdentityPath identityPath, DocNode docNode)
        {
            bool includeThis = AncestorIdentityPaths.Any(ancestoryIdPath => StartsWith(identityPath, ancestoryIdPath));

            if (identityPath.Length == NodeDepth)
            {
                if (includeThis)
                {
                    return(new[] { identityPath });
                }
            }
            var docNodeParent = docNode as DocNodeParent;

            if (null == docNodeParent || identityPath.Length >= NodeDepth)
            {
                return(new IdentityPath[0]);
            }

            var result = new List <IdentityPath>();

            foreach (var child in docNodeParent.Children)
            {
                var childIdentityPath = new IdentityPath(identityPath, child.Id);
                if (!includeThis &&
                    !AncestorIdentityPaths.Any(ancestorIdPath => StartsWith(ancestorIdPath, childIdentityPath)))
                {
                    continue;
                }
                result.AddRange(RecurseListingKeys(childIdentityPath, child));
            }
            return(result);
        }
Esempio n. 15
0
 public Key(SrmDocument document, ChromatogramSet chromatogramSet, MsDataFileUri filePath, IdentityPath precursorIdentityPath)
 {
     _documentReference     = document.ReferenceId;
     _chromatogramSet       = chromatogramSet;
     _filePath              = filePath;
     _precursorIdentityPath = precursorIdentityPath;
 }
Esempio n. 16
0
        public void MultiLabelTypeListTest()
        {
            int         startRev = 0;
            SrmDocument document = new SrmDocument(SrmSettingsList.GetDefault().ChangeTransitionInstrument(inst => inst.ChangeMaxMz(1800)));

            // Add some FASTA
            IdentityPath pathRoot = IdentityPath.ROOT;
            SrmDocument  docFasta = document.ImportFasta(new StringReader(ExampleText.TEXT_FASTA_YEAST_LIB), false, pathRoot, out _);
            const int    initProt = 2, initPep = 26, initTran = 89;

            AssertEx.IsDocumentState(docFasta, ++startRev, initProt, initPep, initTran);

            // Add multiple heavy types
            var settings = docFasta.Settings.ChangePeptideModifications(mods => new PeptideModifications(mods.StaticModifications,
                                                                                                         new[]
            {
                new TypedModifications(LABEL_TYPE13_C, HEAVY_MODS_13_C),
                new TypedModifications(LABEL_TYPE15_N, HEAVY_MODS_15_N)
            }));
            var docMulti = docFasta.ChangeSettings(settings);

            // CONSIDER: make explicit S-Lens, cone voltage, CE etc roundtrip?
            // docMulti.MoleculeTransitionGroups.FirstOrDefault().ChangeExplicitValues(ExplicitTransitionGroupValues.TEST)


            // Make sure transition lists export to various formats and roundtrip
            VerifyExportRoundTrip(new ThermoMassListExporter(docMulti), docFasta);
            // Add Oxidation (M) as a static modification to challenge new mass list importing flexibility
            VerifyExportRoundTrip(new AbiMassListExporter(AddOxidationM(docMulti)), AddOxidationM(docFasta));
            VerifyExportRoundTrip(new AgilentMassListExporter(docMulti), docFasta);
            VerifyExportRoundTrip(new WatersMassListExporter(docMulti), docFasta);
        }
Esempio n. 17
0
        public override int GetHashCode()
        {
            int result = DataSchema.GetHashCode();

            result = result * 397 ^ IdentityPath.GetHashCode();
            return(result);
        }
Esempio n. 18
0
 public Protein(SkylineDataSchema dataSchema, IdentityPath identityPath) : base(dataSchema, identityPath)
 {
     _peptides = CachedValue.Create(dataSchema, () => DocNode.Children
                                    .Select(node => new Peptide(DataSchema, new IdentityPath(IdentityPath, node.Id))).ToArray());
     _results           = CachedValue.Create(dataSchema, MakeProteinResults);
     _proteinAbundances = CachedValue.Create(dataSchema, CalculateProteinAbundances);
 }
Esempio n. 19
0
 protected override void ChangeSelection(int selectedIndex, IdentityPath identityPath)
 {
     if (0 <= selectedIndex && selectedIndex < _graphData.XScalePaths.Length)
     {
         GraphSummary.StateProvider.SelectedPath = _graphData.XScalePaths[selectedIndex];
     }
 }
        protected override void ChangeSelection(int selectedIndex, IdentityPath identityPath)
        {
            if (0 > selectedIndex || selectedIndex >= _replicateGroups.Count)
            {
                return;
            }

            // When the user clicks on the graph, they either intend to change
            // the currently selected replicate, or the currently selected IdentityPath.
            // We want to prevent the UI from drilling in too deep when the user
            // just wants to see a different replicate at the same level currently
            // being viewed (e.g. peptide).
            // Therefore, only change the currently selected IdentityPath if the currently
            // selected Replicate is the last replicate in the ReplicateGroup that they
            // have clicked on.
            var resultIndicesArray = IndexOfReplicate(selectedIndex).ToArray();
            int iSelection         = Array.IndexOf(resultIndicesArray, GraphSummary.ResultsIndex);

            if (iSelection == resultIndicesArray.Length - 1 && !GraphChromatogram.IsSingleTransitionDisplay)
            {
                if (!Equals(GraphSummary.StateProvider.SelectedPath, identityPath))
                {
                    GraphSummary.StateProvider.SelectedPath = identityPath;
                    return;
                }
            }
            // If there is more than one replicate in the group that they
            // have clicked on, then select the next replicate in that group.
            // The user has clicked on a group which does not contain the
            // currently selected replicate, then iSelection will be -1, and
            // the first replicate in that group will be selected.
            int newReplicateIndex = resultIndicesArray[((iSelection + 1) % resultIndicesArray.Length)];

            ChangeSelectedIndex(newReplicateIndex);
        }
Esempio n. 21
0
        public override bool HandleMouseDownEvent(ZedGraphControl sender, MouseEventArgs mouseEventArgs)
        {
            CurveItem nearestCurve;
            int       iNearest;
            var       axis = GetNearestXAxis(sender, mouseEventArgs);

            if (axis != null)
            {
                iNearest = (int)axis.Scale.ReverseTransform(mouseEventArgs.X - axis.MajorTic.Size);
                if (iNearest < 0)
                {
                    return(false);
                }
                ChangeSelection(iNearest, GraphSummary.StateProvider.SelectedPath);
                return(true);
            }
            if (!FindNearestPoint(new PointF(mouseEventArgs.X, mouseEventArgs.Y), out nearestCurve, out iNearest))
            {
                return(false);
            }
            IdentityPath identityPath = GetIdentityPath(nearestCurve, iNearest);

            if (identityPath == null)
            {
                return(false);
            }

            ChangeSelection(iNearest, identityPath);
            return(true);
        }
Esempio n. 22
0
        public ChromatogramGroupInfo GetChromatogramGroupInfo(SrmDocument document,
                                                              ChromatogramSet chromatogramSet, MsDataFileUri filePath,
                                                              IdentityPath precursorIdentityPath, bool loadPoints)
        {
            var key       = new Key(document, chromatogramSet, filePath, precursorIdentityPath);
            var cacheSlot = loadPoints ? _withPoints : _withoutPoints;

            if (cacheSlot != null && Equals(key, cacheSlot.Item1))
            {
                return(cacheSlot.Item2);
            }
            var chromatogramGroupInfo = LoadChromatogramInfo(document, chromatogramSet, filePath, precursorIdentityPath,
                                                             loadPoints);

            cacheSlot = Tuple.Create(key, chromatogramGroupInfo);
            if (loadPoints)
            {
                _withPoints = cacheSlot;
            }
            else
            {
                _withoutPoints = cacheSlot;
            }
            return(chromatogramGroupInfo);
        }
Esempio n. 23
0
        public void NeutralLossListTest()
        {
            TestSmallMolecules = false; // No concept of neutral loss for small molecules

            var phosphoLossMod = new StaticMod("Phospho Loss", "S, T, Y", null, false, "HPO3",
                                               LabelAtoms.None, RelativeRT.Matching, null, null, new[] { new FragmentLoss("H3PO4"), });

            SrmDocument document = new SrmDocument(SrmSettingsList.GetDefault().ChangePeptideModifications(mods =>
                                                                                                           mods.ChangeStaticModifications(new List <StaticMod>(mods.StaticModifications)
            {
                phosphoLossMod
            })));
            IdentityPath path     = IdentityPath.ROOT;
            SrmDocument  docFasta = document.ImportFasta(new StringReader(TEXT_FASTA_YEAST_7), false, path, out path);

            Assert.AreEqual(0, GetLossCount(docFasta, 1));

            // Insert losses into the first transition group
            var pathPeptide  = docFasta.GetPathTo((int)SrmDocument.Level.Molecules, 0);
            var nodePep      = (PeptideDocNode)docFasta.FindNode(pathPeptide);
            var nodeGroup    = (TransitionGroupDocNode)nodePep.Children[0];
            var listChildren = new List <DocNode>(nodeGroup.Children);

            foreach (var nodeTran in nodeGroup.GetTransitions(docFasta.Settings,
                                                              nodePep.ExplicitMods, nodeGroup.PrecursorMz, null, null, null, false))
            {
                if (!nodeTran.HasLoss)
                {
                    continue;
                }

                var tran       = nodeTran.Transition;
                int matchIndex = listChildren.IndexOf(node =>
                                                      Equals(tran, ((TransitionDocNode)node).Transition));
                if (matchIndex == -1)
                {
                    continue;
                }

                while (matchIndex < listChildren.Count &&
                       Equals(tran, ((TransitionDocNode)listChildren[matchIndex]).Transition))
                {
                    matchIndex++;
                }
                listChildren.Insert(matchIndex, nodeTran);
            }

            var docLosses = (SrmDocument)docFasta.ReplaceChild(pathPeptide,
                                                               nodeGroup.ChangeChildren(listChildren));

            int lossCount = GetLossCount(docLosses, 1);

            Assert.IsTrue(lossCount > 0);
            var docRoundTripped = AssertEx.RoundTripTransitionList(new ThermoMassListExporter(docLosses));

            Assert.AreEqual(lossCount, GetLossCount(docRoundTripped, 1));
            docRoundTripped = AssertEx.RoundTripTransitionList(new AgilentMassListExporter(docLosses));
            Assert.AreEqual(lossCount, GetLossCount(docRoundTripped, 1));
        }
Esempio n. 24
0
        protected override void DoTest()
        {
            RunUI(() => SkylineWindow.OpenFile(TestFilesDir.GetTestPath("UpdateGlobalStandardTest.sky")));
            WaitForDocumentLoaded();
            foreach (var fileId in GetAllChromFileInfoIds(SkylineWindow.Document))
            {
                AssertValuesEqual(0, CalculateGlobalStandardArea(SkylineWindow.Document, fileId));
            }
            VerifyCalculatedAreas();

            // Set the first peptide in the document to be the global standard
            IdentityPath globalStandardPath = null;

            RunUI(() =>
            {
                SkylineWindow.SelectedPath = SkylineWindow.Document.GetPathTo((int)SrmDocument.Level.Molecules, 0);
                SkylineWindow.SetStandardType(StandardType.GLOBAL_STANDARD);
                globalStandardPath = SkylineWindow.SelectedPath;
            });
            Assert.AreEqual(StandardType.GLOBAL_STANDARD, ((PeptideDocNode)SkylineWindow.Document.FindNode(globalStandardPath)).GlobalStandardType);
            foreach (var fileId in GetAllChromFileInfoIds(SkylineWindow.Document))
            {
                Assert.AreNotEqual(0, CalculateGlobalStandardArea(SkylineWindow.Document, fileId));
            }
            VerifyCalculatedAreas();
            RunUI(SkylineWindow.Undo);
            VerifyCalculatedAreas();
            RunUI(SkylineWindow.Redo);
            VerifyCalculatedAreas();


            // Choose different peaks for the global standard peptide, and make sure that everyone's are gets
            // updated appropriately.
            RunUI(() => Assert.AreEqual(globalStandardPath, SkylineWindow.SelectedPath));
            foreach (var graphChromatogram in SkylineWindow.GraphChromatograms)
            {
                WaitForGraphs();
                var chromGroupInfo = graphChromatogram.ChromGroupInfos[0];
                for (int iPeak = 0; iPeak < chromGroupInfo.NumPeaks; iPeak++)
                {
                    var globalStandardPeptide = (PeptideDocNode)SkylineWindow.Document.FindNode(globalStandardPath);
                    var transitionGroup       = globalStandardPeptide.TransitionGroups.First();
                    var transition            = transitionGroup.Transitions.First();
                    var chromInfo             = chromGroupInfo.GetAllTransitionInfo(transition, 0, null, TransformChrom.raw).First();
                    var peak = chromInfo.Peaks.Skip(iPeak).First();
                    RunUI(() => graphChromatogram.FirePickedPeak(transitionGroup, transition, new ScaledRetentionTime(peak.RetentionTime)));
                    VerifyCalculatedAreas();
                }
            }

            SetNormalizationMethodsInDocumentGrid();

            var normalizedAreasForm = FindNormalizedAreasForm();

            if (normalizedAreasForm != null)
            {
                OkDialog(normalizedAreasForm, normalizedAreasForm.Close);
            }
        }
Esempio n. 25
0
        private static void CheckTimes(IdentityPath groupPath, int file, int replicate, out double?startTime, out double?endTime)
        {
            var groupNode      = (TransitionGroupDocNode)SkylineWindow.Document.FindNode(groupPath);
            var groupChromInfo = groupNode.Results[file][replicate];

            startTime = groupChromInfo.StartRetentionTime;
            endTime   = groupChromInfo.EndRetentionTime;
        }
Esempio n. 26
0
 private bool IsPathSelected(IdentityPath selectedPath, IdentityPath identityPath)
 {
     if (selectedPath == null || identityPath == null || selectedPath.Depth < identityPath.Depth)
     {
         return(false);
     }
     return(Equals(selectedPath.GetPathTo(identityPath.Depth), identityPath));
 }
 public MassErrorGraphData(SrmDocument document,
                           IdentityPath identityPath,
                           DisplayTypeChrom displayType,
                           ReplicateGroupOp replicateGroupOp,
                           PaneKey paneKey)
     : base(document, identityPath, displayType, replicateGroupOp, paneKey)
 {
 }
Esempio n. 28
0
 public RemovePeakHandler(SkylineWindow skyline, IdentityPath groupPath,
                          TransitionGroupDocNode nodeGroup, TransitionDocNode nodeTran)
 {
     _skyline   = skyline;
     _groupPath = groupPath;
     _nodeGroup = nodeGroup;
     _nodeTran  = nodeTran;
 }
Esempio n. 29
0
            public GraphPointData(PeptideDocNode nodePep, TransitionGroupDocNode nodeGroup, IdentityPath identityPath)
            {
                NodePep      = nodePep;
                NodeGroup    = nodeGroup;
                IdentityPath = identityPath;

                CalcStats(nodePep, nodeGroup);
            }
Esempio n. 30
0
 public Peptide(SkylineDataSchema dataSchema, IdentityPath identityPath)
     : base(dataSchema, identityPath)
 {
     _calibrationCurveFitter = CachedValue.Create(dataSchema,
                                                  () => new CalibrationCurveFitter(GetPeptideQuantifier(), SrmDocument.Settings));
     _precursors = CachedValue.Create(dataSchema, () => DocNode.Children.Select(child => new Precursor(DataSchema, new IdentityPath(IdentityPath, child.Id))).ToArray());
     _results    = CachedValue.Create(dataSchema, MakeResults);
 }
Esempio n. 31
0
        public void IdentityPathTest()
        {
            SimpleIdentity id = new SimpleIdentity();
            IdentityPath pathSimple = new IdentityPath(id);
            Assert.AreEqual(IdentityPath.ROOT, pathSimple.Parent);
            Assert.AreEqual(IdentityPath.ROOT, pathSimple.GetPathTo(-1));
            Assert.AreEqual(id, pathSimple.Child);
            Assert.AreEqual(1, pathSimple.Length);
            Assert.AreEqual(0, pathSimple.Depth);
            AssertEx.ThrowsException<IndexOutOfRangeException>(() => pathSimple.GetPathTo(-2));
            AssertEx.ThrowsException<IndexOutOfRangeException>(() => pathSimple.GetPathTo(1));

            IdentityPath pathRoot = new IdentityPath(new Identity[0]);
            Assert.AreEqual(IdentityPath.ROOT, pathRoot);
            Assert.AreEqual(0, pathRoot.Length);
            Assert.AreEqual(-1, pathRoot.Depth);
            AssertEx.ThrowsException<IndexOutOfRangeException>(() => pathRoot.Child);
            AssertEx.ThrowsException<IndexOutOfRangeException>(() => pathRoot.Parent);

            const int count = 5;

            List<Identity> listId1 = new List<Identity>();
            List<Identity> listId2 = new List<Identity>();
            HashSet<IdentityPath> setPaths = new HashSet<IdentityPath>();

            IdentityPath last = IdentityPath.ROOT;
            for (int i = 0; i < count; i++)
            {
                listId1.Add(new NumericIdentity(i));
                listId2.Add(new NumericIdentity(i));

                IdentityPath path = new IdentityPath(listId1);
                Assert.AreEqual(path, new IdentityPath(listId1));
                Assert.AreNotEqual(path, new IdentityPath(listId2));
                Assert.AreEqual(last, path.Parent);
                Assert.AreSame(listId1[i], path.Child);
                Assert.AreEqual(path, new IdentityPath(path.Parent, path.Child));
                Assert.AreEqual(i, path.Depth);
                Assert.AreEqual(listId1.Count, path.Length);
                Assert.AreSame(path.Child, path.GetIdentity(path.Depth));
                Assert.AreEqual(path.Parent, path.GetPathTo(path.Depth - 1));
                Assert.AreEqual("/" + listId1.ToString("/"), path.ToString());
                for (int j = 0; j < i; j++)
                    Assert.IsTrue(setPaths.Contains(path.GetPathTo(j)));
                setPaths.Add(path);
                last = path;
            }
        }
Esempio n. 32
0
        public static void SelectAndApplyPeak(string modifiedSequence, double? precursorMz, string resultsName, bool subsequent, double rt)
        {
            bool found = false;
            var skylineWindow = Program.MainWindow;
            var doc = skylineWindow.Document;
            IdentityPath identityPath = null;
            foreach (PeptideGroupDocNode nodePepGroup in doc.MoleculeGroups)
            {
                foreach (var nodePep in nodePepGroup.Peptides.Where(nodePep => nodePep.ModifiedSequence.Equals(modifiedSequence)))
                {
                    var nodeTranGroup = precursorMz.HasValue
                        ? nodePep.TransitionGroups.First(tranGroup => Math.Abs(tranGroup.PrecursorMz - precursorMz.Value) < 0.01)
                        : nodePep.TransitionGroups.First();
                    identityPath = new IdentityPath(nodePepGroup.Id, nodePep.Id, nodeTranGroup.Id);
                    IdentityPath path = identityPath;
                    skylineWindow.SelectedPath = path;
                    found = true;
                    break;
                }
                if (found)
                    break;
            }
            if (!found)
            {
                Assert.Fail("Could not find peptide {0}", modifiedSequence);
            }

            found = false;
            var chromatograms = doc.Settings.MeasuredResults.Chromatograms;
            foreach (var chromatogram in chromatograms.Where(chromSet => chromSet.Name.Equals(resultsName)))
            {
                found = true;
                ChromatogramSet chromSet = chromatogram;
                skylineWindow.SelectedResultsIndex = chromatograms.IndexOf(chromSet);
                skylineWindow.ModifyDocument("change peak", document =>
                    document.ChangePeak(identityPath, chromSet.Name, chromSet.MSDataFilePaths.First(), null, rt, UserSet.TRUE));
                break;
            }
            if (!found)
            {
                Assert.Fail("Could not find results {0}", resultsName);
            }
            skylineWindow.ApplyPeak(subsequent);
        }
Esempio n. 33
0
        private static SrmDocument CopyPaste(SrmDocument sourceDoc, IEnumerable<DocNode> nodes, SrmDocument targetDoc, IdentityPath to)
        {
            SetDefaultModifications(targetDoc);
            if(nodes != null)
                sourceDoc = sourceDoc.RemoveAllBut(nodes);

            var stringWriter = new XmlStringWriter();
            using (var writer = new XmlTextWriter(stringWriter) { Formatting = Formatting.Indented })
            {
                XmlSerializer ser = new XmlSerializer(typeof(SrmDocument));
                ser.Serialize(writer, sourceDoc);
            }
            IdentityPath newPath, nextAdd;
            targetDoc = targetDoc.ImportDocumentXml(new StringReader(stringWriter.ToString()),
                                                    null,
                                                    MeasuredResults.MergeAction.remove,
                                                    false,
                                                    null,
                                                    Settings.Default.StaticModList,
                                                    Settings.Default.HeavyModList,
                                                    to,
                                                    out newPath,
                                                    out nextAdd,
                                                    false);
            return targetDoc;
        }
Esempio n. 34
0
 private SrmDocument GetNewDocument(SrmDocument document, bool validating, ref IdentityPath selectedPath)
 {
     int emptyPeptideGroups;
     return GetNewDocument(document, validating, ref selectedPath, out emptyPeptideGroups);
 }
Esempio n. 35
0
        public void RemovePeak(IdentityPath groupPath, TransitionGroupDocNode nodeGroup, TransitionDocNode nodeTran)
        {
            string message = nodeTran == null
                ? string.Format(Resources.SkylineWindow_RemovePeak_Remove_all_peaks_from__0__, ChromGraphItem.GetTitle(nodeGroup))
                : string.Format(Resources.SkylineWindow_RemovePeak_Remove_peak_from__0__, ChromGraphItem.GetTitle(nodeTran));

            ModifyDocument(message, doc => RemovePeakInternal(doc, SelectedResultsIndex, groupPath, nodeGroup, nodeTran));
        }
Esempio n. 36
0
 /// <summary>
 /// Modifies a document in response to a user's mouse dragging on a GraphChromatogram.
 /// </summary>
 private static SrmDocument ChangePeakBounds(SrmDocument document, IEnumerable<ChangedPeakBoundsEventArgs> changes)
 {
     var changedGroupIds = new HashSet<IdentityPath>();
     var peptideChanges = new Dictionary<IdentityPath, ChangedPeakBoundsEventArgs>();
     foreach (var change in changes)
     {
         document = document.ChangePeak(change.GroupPath, change.NameSet, change.FilePath, change.Transition,
             change.StartTime.MeasuredTime, change.EndTime.MeasuredTime, UserSet.TRUE, change.Identified, false);
         changedGroupIds.Add(change.GroupPath);
         if (!peptideChanges.ContainsKey(change.GroupPath.Parent)) {
             var transitionGroup = (TransitionGroupDocNode) document.FindNode(change.GroupPath);
             if (transitionGroup.RelativeRT == RelativeRT.Matching)
             {
                 peptideChanges.Add(change.GroupPath.Parent, change);
             }
         }
     }
     // See if there are any other TransitionGroups that also have RelativeRT matching,
     // and set their peak boundaries to the same.
     foreach (var entry in peptideChanges)
     {
         var peptide = (PeptideDocNode) document.FindNode(entry.Key);
         var change = entry.Value;
         foreach (var transitionGroup in peptide.TransitionGroups)
         {
             if (transitionGroup.RelativeRT != RelativeRT.Matching)
             {
                 continue;
             }
             var groupId = new IdentityPath(entry.Key, transitionGroup.TransitionGroup);
             if (changedGroupIds.Contains(groupId))
             {
                 continue;
             }
             if (null == FindChromInfo(document, transitionGroup, change.NameSet, change.FilePath))
             {
                 continue;
             }
             document = document.ChangePeak(groupId, change.NameSet, change.FilePath, null,
                 change.StartTime.MeasuredTime, change.EndTime.MeasuredTime, UserSet.TRUE, change.Identified, true);
         }
     }
     return document;
 }
Esempio n. 37
0
        private SrmDocument RemovePeakInternal(SrmDocument document, int resultsIndex, IdentityPath groupPath,
            TransitionGroupDocNode nodeGroup, TransitionDocNode nodeTran)
        {
            ChromInfo chromInfo;
            Transition transition;

            if (nodeTran == null)
            {
                chromInfo = GetTransitionGroupChromInfo(nodeGroup, resultsIndex);
                transition = null;
            }
            else
            {
                chromInfo = GetTransitionChromInfo(nodeTran, resultsIndex);
                transition = nodeTran.Transition;
            }
            if (chromInfo == null)
                return document;

            MsDataFileUri filePath;
            string name = GetGraphChromStrings(resultsIndex, chromInfo.FileId, out filePath);
            return name == null
                ? document
                : document.ChangePeak(groupPath, name, filePath, transition, 0, 0, UserSet.TRUE, PeakIdentification.FALSE, false);
        }
Esempio n. 38
0
        public SrmDocument Import(TextReader reader, IProgressMonitor progressMonitor, long lineCount, bool isMinutes, bool removeMissing = false, bool changePeaks = true)
        {
            var status = new ProgressStatus(Resources.PeakBoundaryImporter_Import_Importing_Peak_Boundaries);
            double timeConversionFactor = isMinutes ? 1.0 : 60.0;
            int linesRead = 0;
            int progressPercent = 0;
            var docNew = (SrmDocument) Document.ChangeIgnoreChangingChildren(true);
            var docReference = docNew;
            var sequenceToNode = new Dictionary<Tuple<string, bool>, IList<IdentityPath>>();
            var fileNameToFileMatch = new Dictionary<string, ChromSetFileMatch>();
            var trackAdjustedResults = new HashSet<ResultsKey>();
            var modMatcher = new ModificationMatcher();
            // Make the dictionary of modified peptide strings to doc nodes and paths
            for (int i = 0; i < Document.MoleculeCount; ++i)
            {
                IdentityPath peptidePath = Document.GetPathTo((int) SrmDocument.Level.Molecules, i);
                PeptideDocNode peptideNode = (PeptideDocNode) Document.FindNode(peptidePath);
                var peptidePair = new Tuple<string, bool>(peptideNode.RawTextId, peptideNode.IsDecoy);
                IList<IdentityPath> idPathList;
                // Each (sequence, isDecoy) pair can be associated with more than one peptide,
                // to handle the case of duplicate peptides in the doucment.
                if (sequenceToNode.TryGetValue(peptidePair, out idPathList))
                {
                    idPathList.Add(peptidePath);
                    sequenceToNode[peptidePair] = idPathList;
                }
                else
                {
                    idPathList = new List<IdentityPath> { peptidePath };
                    sequenceToNode.Add(peptidePair, idPathList);
                }
            }

            // Add annotations as possible columns
            var allFieldNames = new List<string[]>(FIELD_NAMES);
            allFieldNames.AddRange(from def in Document.Settings.DataSettings.AnnotationDefs
                                   where def.AnnotationTargets.Contains(AnnotationDef.AnnotationTarget.precursor_result)
                                   select new[] { def.Name });

            string line = reader.ReadLine();
            linesRead++;
            int[] fieldIndices;
            int fieldsTotal;
            // If we aren't changing peaks, allow start and end time to be missing
            var requiredFields = changePeaks ? REQUIRED_FIELDS : REQUIRED_NO_CHROM;
            char correctSeparator = ReadFirstLine(line, allFieldNames, requiredFields, out fieldIndices, out fieldsTotal);

            while ((line = reader.ReadLine()) != null)
            {
                linesRead++;
                if (progressMonitor != null)
                {
                    if (progressMonitor.IsCanceled)
                        return Document;
                    int progressNew = (int) (linesRead*100/lineCount);
                    if (progressPercent != progressNew)
                    {
                        progressMonitor.UpdateProgress(status = status.ChangePercentComplete(progressNew));
                        progressPercent = progressNew;
                    }
                }
                var dataFields = new DataFields(fieldIndices, line.ParseDsvFields(correctSeparator), allFieldNames);
                if (dataFields.Length != fieldsTotal)
                {
                    throw new IOException(string.Format(Resources.PeakBoundaryImporter_Import_Line__0__field_count__1__differs_from_the_first_line__which_has__2_,
                        linesRead, dataFields.Length, fieldsTotal));
                }
                string modifiedPeptideString = dataFields.GetField(Field.modified_peptide);
                modMatcher.CreateMatches(Document.Settings,
                                        new List<string> {modifiedPeptideString},
                                        Settings.Default.StaticModList,
                                        Settings.Default.HeavyModList);
                // Convert the modified peptide string into a standardized form that
                // converts unimod, names, etc, into masses, eg [+57.0]
                var nodeForModPep = modMatcher.GetModifiedNode(modifiedPeptideString);
                if (nodeForModPep == null)
                {
                    throw new IOException(string.Format(Resources.PeakBoundaryImporter_Import_Peptide_has_unrecognized_modifications__0__at_line__1_, modifiedPeptideString, linesRead));
                }
                nodeForModPep = nodeForModPep.ChangeSettings(Document.Settings, SrmSettingsDiff.ALL);
                modifiedPeptideString = nodeForModPep.RawTextId; // Modified sequence, or custom ion name
                string fileName = dataFields.GetField(Field.filename);
                bool isDecoy = dataFields.IsDecoy(linesRead);
                var peptideIdentifier = new Tuple<string, bool>(modifiedPeptideString, isDecoy);
                int charge;
                bool chargeSpecified = dataFields.TryGetCharge(linesRead, out charge);
                string sampleName = dataFields.GetField(Field.sample_name);

                double? startTime = null;
                double? endTime = null;
                if (changePeaks)
                {
                    startTime = dataFields.GetTime(Field.start_time, Resources.PeakBoundaryImporter_Import_The_value___0___on_line__1__is_not_a_valid_start_time_, linesRead);
                    if (startTime.HasValue)
                        startTime = startTime / timeConversionFactor;
                    endTime = dataFields.GetTime(Field.end_time, Resources.PeakBoundaryImporter_Import_The_value___0___on_line__1__is_not_a_valid_end_time_, linesRead);
                    if (endTime.HasValue)
                        endTime = endTime / timeConversionFactor;
                }

                // Error if only one of startTime and endTime is null
                if (startTime == null && endTime != null)
                    throw new IOException(string.Format(Resources.PeakBoundaryImporter_Import_Missing_start_time_on_line__0_, linesRead));
                if (startTime != null && endTime == null)
                    throw new IOException(string.Format(Resources.PeakBoundaryImporter_Import_Missing_end_time_on_line__0_, linesRead));
                // Add filename to second dictionary if not yet encountered
                ChromSetFileMatch fileMatch;
                if (!fileNameToFileMatch.TryGetValue(fileName, out fileMatch))
                {
                    fileMatch = Document.Settings.MeasuredResults.FindMatchingMSDataFile(MsDataFileUri.Parse(fileName));
                    fileNameToFileMatch.Add(fileName, fileMatch);
                }
                if (fileMatch == null)
                {
                    UnrecognizedFiles.Add(fileName);
                    continue;
                }
                var chromSet = fileMatch.Chromatograms;
                string nameSet = chromSet.Name;
                ChromFileInfoId[] fileIds;
                if (sampleName == null)
                {
                    fileIds = chromSet.MSDataFileInfos.Select(x => x.FileId).ToArray();
                }
                else
                {
                    var sampleFile = chromSet.MSDataFileInfos.FirstOrDefault(info => Equals(sampleName, info.FilePath.GetSampleName()));
                    if (sampleFile == null)
                    {
                        throw new IOException(string.Format(Resources.PeakBoundaryImporter_Import_Sample__0__on_line__1__does_not_match_the_file__2__, sampleName, linesRead, fileName));
                    }
                    fileIds = new[] {sampleFile.FileId};
                }
                // Look up the IdentityPath of peptide in first dictionary
                IList<IdentityPath> pepPaths;
                if (!sequenceToNode.TryGetValue(peptideIdentifier, out pepPaths))
                {
                    UnrecognizedPeptides.Add(modifiedPeptideString);
                    continue;
                }

                // Define the annotations to be added
                var annotations = dataFields.GetAnnotations();
                AnnotationsAdded = annotations.Keys.ToList();

                // Loop over all the transition groups in that peptide to find matching charge,
                // or use all transition groups if charge not specified
                bool foundSample = false;
                foreach (var pepPath in pepPaths)
                {
                    var nodePep = (PeptideDocNode)docNew.FindNode(pepPath);
                    for(int i = 0; i < nodePep.Children.Count; ++i)
                    {
                        var groupRelPath = nodePep.GetPathTo(i);
                        var groupNode = (TransitionGroupDocNode) nodePep.FindNode(groupRelPath);
                        if (!chargeSpecified || charge == groupNode.TransitionGroup.PrecursorCharge)
                        {
                            var groupFileIndices =
                                new HashSet<int>(groupNode.ChromInfos.Select(x => x.FileId.GlobalIndex));
                            // Loop over the files in this groupNode to find the correct sample
                            // Change peak boundaries for the transition group
                            foreach (var fileId in fileIds)
                            {
                                if (groupFileIndices.Contains(fileId.GlobalIndex))
                                {
                                    var groupPath = new IdentityPath(pepPath, groupNode.Id);
                                    // Attach annotations
                                    docNew = docNew.AddPrecursorResultsAnnotations(groupPath, fileId, annotations);
                                    // Change peak
                                    var filePath = chromSet.GetFileInfo(fileId).FilePath;
                                    if (changePeaks)
                                    {
                                        docNew = docNew.ChangePeak(groupPath, nameSet, filePath,
                                            null, startTime, endTime, UserSet.IMPORTED, null, false);
                                    }
                                    // For removing peaks that are not in the file, if removeMissing = true
                                    trackAdjustedResults.Add(new ResultsKey(fileId.GlobalIndex, groupNode.Id));
                                    foundSample = true;
                                }
                            }
                        }
                    }
                }
                if (!foundSample)
                {
                    UnrecognizedChargeStates.Add(new UnrecognizedChargeState(charge, fileName, modifiedPeptideString));
                }
            }
            // Remove peaks from the document that weren't in the file.
            if (removeMissing)
                docNew = RemoveMissing(docNew, trackAdjustedResults, changePeaks);
            // If nothing has changed, return the old Document before ChangeIgnoreChangingChildren was turned off
            if (!ReferenceEquals(docNew, docReference))
                Document = (SrmDocument) Document.ChangeIgnoreChangingChildren(false).ChangeChildrenChecked(docNew.Children);
            return Document;
        }
Esempio n. 39
0
        /// <summary>
        /// Removes peaks and annotations that were in the document but not in the file, so that all peptide results that were not explicitly imported as part of this file are now blank
        /// </summary>
        /// <param name="docNew">SrmDocument for which missing peaks should be removed</param>
        /// <param name="trackAdjustedResults">List of peaks that were in the imported file</param>
        /// <param name="changePeaks">If true, remove both peaks and annotations.  If false, only remove annotations</param>
        /// <returns></returns>
        private SrmDocument RemoveMissing(SrmDocument docNew, ICollection<ResultsKey> trackAdjustedResults, bool changePeaks)
        {
            var measuredResults = docNew.Settings.MeasuredResults;
            var chromatogramSets = measuredResults.Chromatograms;
            for (int i = 0; i < chromatogramSets.Count; ++i)
            {
                var set = chromatogramSets[i];
                var nameSet = set.Name;
                for (int k = 0; k < docNew.MoleculeCount; ++k)
                {
                    IdentityPath pepPath = docNew.GetPathTo((int)SrmDocument.Level.Molecules, k);
                    var pepNode = (PeptideDocNode)Document.FindNode(pepPath);
                    if (pepNode.IsDecoy)
                        continue;
                    if (pepNode.GlobalStandardType != null)
                        continue;
                    foreach (var groupNode in pepNode.TransitionGroups)
                    {
                        var groupPath = new IdentityPath(pepPath, groupNode.Id);
                        var chromInfos = groupNode.Results[i];
                        if (chromInfos == null)
                            continue;

                        foreach (var groupChromInfo in chromInfos)
                        {
                            if (groupChromInfo == null)
                                continue;
                            var key = new ResultsKey(groupChromInfo.FileId.GlobalIndex, groupNode.Id);
                            if (!trackAdjustedResults.Contains(key))
                            {
                                CountMissing++;
                                var fileId = groupChromInfo.FileId;
                                var fileInfo = set.GetFileInfo(fileId);
                                var filePath = fileInfo.FilePath;
                                // Remove annotations for defs that were imported into the document and were on this peptide prior to import
                                var newAnnotationValues = groupChromInfo.Annotations.ListAnnotations().ToList();
                                newAnnotationValues = newAnnotationValues.Where(a => !AnnotationsAdded.Contains(a.Key)).ToList();
                                var newAnnotations = new Annotations(groupChromInfo.Annotations.Note, newAnnotationValues, groupChromInfo.Annotations.ColorIndex);
                                var newGroupNode = groupNode.ChangePrecursorAnnotations(fileId, newAnnotations);
                                if (!ReferenceEquals(groupNode, newGroupNode))
                                    docNew = (SrmDocument) docNew.ReplaceChild(groupPath.Parent, newGroupNode);
                                // Adjust peaks to null if they weren't in the file
                                if (changePeaks)
                                {
                                    docNew = docNew.ChangePeak(groupPath, nameSet, filePath,
                                        null, null, null, UserSet.IMPORTED, null, false);
                                }
                            }
                        }
                    }
                }
            }
            return docNew;
        }
 private void PickTransitions(int pepIndex, int[] transIndexes,
     string screenshotPromptA = null, int? pageA = null, string screenshotPromptB = null, int? pageB = null)
 {
     var doc = SkylineWindow.Document;
     var pepPath = doc.GetPathTo((int)SrmDocument.Level.Molecules, pepIndex);
     var nodeGroup = doc.Peptides.ElementAt(pepIndex).TransitionGroups.First();
     var groupPath = new IdentityPath(pepPath, nodeGroup.TransitionGroup);
     RunUI(() => SkylineWindow.SequenceTree.SelectedPath = groupPath);
     var popupPickList = ShowDialog<PopupPickList>(SkylineWindow.ShowPickChildrenInTest);
     if (screenshotPromptA != null)
         PauseForScreenShot<PopupPickList>(screenshotPromptA, pageA);
     RunUI(() => popupPickList.ApplyFilter(false));  // clear the filter
     if (screenshotPromptB != null)
         PauseForScreenShot<PopupPickList>(screenshotPromptB, pageB);
     RunUI(() =>
     {
         for (int i = 0; i < popupPickList.ItemNames.Count(); i++)
         {
             popupPickList.SetItemChecked(i, transIndexes.Contains(i));
         }
     });
     OkDialog(popupPickList, popupPickList.OnOk);
     WaitForDocumentChange(doc);
     WaitForGraphs();
 }
        private void ExploreTopPeptides()
        {
            RestoreViewOnScreen(10);

            PauseForScreenShot("Retention Times graph (zoomed to show only healthy)", 10);

            RunUI(() => SkylineWindow.SetIntegrateAll(true));

            PauseForScreenShot("Retention Times graph with integrate all (zoomed to show only healthy)", 11);

            SelectNode(SrmDocument.Level.Molecules, 0);
            RunUI(SkylineWindow.EditDelete); // Delete first peptide

            PauseForScreenShot("Retention Times graph for second peptide", 11);

            RestoreViewOnScreen(12);

            PauseForScreenShot("Peak Areas graph", 12);

            RunUI(() => SkylineWindow.NormalizeAreaGraphTo(AreaNormalizeToView.area_percent_view));

            PauseForScreenShot("Peak Areas graph (normalized to total)", 13);

            RestoreViewOnScreen(13);

            ActivateReplicate("D_103_REP3");

            PauseForScreenShot("Chromatogram graph for D_103_REP3", 13);

            ChangePeakBounds("D_103_REP3", 30.11, 30.43);

            ActivateReplicate("H_162_REP1");

            PauseForScreenShot("Chromatogram graph for H_162_REP1", 14);

            ActivateReplicate("D_108_REP2");

            ChangePeakBounds("D_108_REP2", 30.11, 30.5);

            ActivateReplicate("D_162_REP3");

            RestoreViewOnScreen(15);

            {
                var findDlg = ShowDialog<FindNodeDlg>(SkylineWindow.ShowFindNodeDlg);
                RunUI(() =>
                {
                    findDlg.FindOptions = new FindOptions().ChangeForward(true)
                        .ChangeText(string.Empty)
                        .ChangeCustomFinders(Finders.ListAllFinders().Where(f => f is TruncatedPeakFinder));
                });

                PauseForScreenShot<FindNodeDlg>("Find form", 15);

                RunUI(findDlg.FindAll);

                OkDialog(findDlg, findDlg.Close);

                var findView = WaitForOpenForm<FindResultsForm>();
                int expectedItems = IsFullData ? 457 : 290;
                try
                {
                    WaitForConditionUI(1000, () => findView.ItemCount == expectedItems);
                }
                catch (AssertFailedException)
                {
                    RunUI(() => Assert.AreEqual(expectedItems, findView.ItemCount));
                }

                PauseForScreenShot("Find Results view", 16);
            }

            var documentGrid = ShowDialog<DocumentGridForm>(() => SkylineWindow.ShowDocumentGrid(true));

            AddTruncatedPrecursorsView(documentGrid, true);

            RunUI(() => SkylineWindow.ShowDocumentGrid(false));

            RestoreViewOnScreen(13); // Same layout for chromatogram graphs as before on page 13

            // TODO: Use link clicks in Document Grid
            FindNode("DFATVYVDAVK");
            ActivateReplicate("D_196_REP3");

            PauseForScreenShot("Chromatogram graph", 19);

            RestoreViewOnScreen(10); // Same layout for RT graph as on page 10

            SelectNode(SrmDocument.Level.Molecules, 1);
            ActivateReplicate("D_196_REP3");

            RunUI(() => Assert.AreEqual("R.LGGEEVSVACK.L [237, 247]", SkylineWindow.SelectedNode.Text));

            PauseForScreenShot("Retention Times graph for LGGEEVSVACK peptide", 20);

            RestoreViewOnScreen(12); // Same layout for Peak Areas graph as on page 12

            SelectNode(SrmDocument.Level.Molecules, 1);
            ActivateReplicate("D_196_REP3");

            RunUI(() => SkylineWindow.NormalizeAreaGraphTo(AreaNormalizeToView.none));

            PauseForScreenShot("Peak Areas graph", 21);

            RestoreViewOnScreen(13); // Same layout for chromatogram graphs as before on page 13

            SelectNode(SrmDocument.Level.Molecules, 1);
            ActivateReplicate("D_172_REP2");

            RunUI(() =>
            {
                SkylineWindow.NormalizeAreaGraphTo(AreaNormalizeToView.area_percent_view);
                SkylineWindow.AutoZoomBestPeak();
            });

            PauseForScreenShot("Chromatogram graph zoomed", 22);

            ActivateReplicate("D_138_REP1");

            PauseForScreenShot("Chromatogram graph zoomed - interference", 22);

            SelectNode(SrmDocument.Level.Molecules, 2);
            ActivateReplicate("D_154_REP1");

            PauseForScreenShot("Chromatogram graph zoomed - nice signal", 23);

            RestoreViewOnScreen(12); // Same layout for Peak Areas graph as on page 12

            SelectNode(SrmDocument.Level.Molecules, 2);
            ActivateReplicate("D_154_REP1");

            PauseForScreenShot("Peak Areas graph - consistent abundances", 23);

            RestoreViewOnScreen(13); // Same layout for chromatogram graphs as before on page 13

            SelectNode(SrmDocument.Level.Molecules, 3);
            ActivateReplicate("D_103_REP1");

            RunUI(() =>
            {
                Assert.AreEqual("R.GSYNLQDLLAQAK.L [378, 390]", SkylineWindow.SelectedNode.Text);
                SkylineWindow.AutoZoomNone();
            });

            PauseForScreenShot("Chromatogram graph - langscape", 24);

            ActivateReplicate("D_103_REP3");

            PauseForScreenShot("Chromatogram graph - missing peak", 25);

            RestoreViewOnScreen(12); // Same layout for Peak Areas graph as on page 12

            ActivateReplicate("H_148_REP1");
            WaitForActiveReplicate("H_148_REP1");

            TransitionGroupDocNode nodeGroupRemove = null;
            IdentityPath pathGroupRemove = null;
            RunUI(() =>
            {
                SelectNode(SrmDocument.Level.Molecules, 3);

                var nodePepTree = (PeptideTreeNode)SkylineWindow.SelectedNode;
                nodeGroupRemove = (TransitionGroupDocNode)nodePepTree.DocNode.Children[0];
                pathGroupRemove = new IdentityPath(nodePepTree.Path, nodeGroupRemove.Id);
            });

            WaitForGraphs();

            RemovePeak("D_103_REP3", pathGroupRemove, nodeGroupRemove);

            PauseForScreenShot("Peak Areas graph - removed peak", 25);

            RestoreViewOnScreen(13); // Same layout for chromatogram graphs as before on page 13

            RunUI(() => SelectNode(SrmDocument.Level.Molecules, 3));

            RemovePeak("D_108_REP2", pathGroupRemove, nodeGroupRemove);
            if (IsFullData)
                RemovePeak("H_146_REP2", pathGroupRemove, nodeGroupRemove);
            RemovePeak("H_159_REP2", pathGroupRemove, nodeGroupRemove);
            RemovePeak("H_162_REP3", pathGroupRemove, nodeGroupRemove);

            RunUI(() => SkylineWindow.ActivateReplicate("H_148_REP2"));

            PauseForScreenShot("Chromatogram graph - truncated peak", 26);

            RestoreViewOnScreen(12); // Same layout for Peak Areas graph as on page 12

            SelectNode(SrmDocument.Level.Molecules, 3);

            ChangePeakBounds("H_148_REP2", 31.8, 32.2);
            ChangePeakBounds("H_159_REP3", 31.8, 32.2);
            if (IsFullData)
            {
                ChangePeakBounds("H_160_REP2", 31.8, 32.2);
                ChangePeakBounds("H_161_REP3", 31.8, 32.2);
            }
            ChangePeakBounds("H_162_REP2", 31.8, 32.2);

            ActivateReplicate("H_162_REP3");

            PauseForScreenShot("Peak Areas graph - removed peaks", 26);

            RestoreViewOnScreen(10); // Same layout for RT graph as on page 10

            SelectNode(SrmDocument.Level.Molecules, 3);
            ActivateReplicate("D_103_REP3");

            PauseForScreenShot("Retention Times graph - removed peaks", 27);

            RunUI(() =>
            {
                SelectNode(SrmDocument.Level.Molecules, 4);
                SkylineWindow.EditDelete();
                SelectNode(SrmDocument.Level.Molecules, 4);
                Assert.IsTrue(SkylineWindow.SelectedNode.Text.Contains("TSDQIHFFFAK"));
            });

            PauseForScreenShot("Retention Times graph - strange variance", 27);

            RunUI(() => SkylineWindow.ShowReplicateOrder(SummaryReplicateOrder.time));

            PauseForScreenShot("Retention Times graph - acquired time order", 28);

            RestoreViewOnScreen(13); // Same layout for chromatogram graphs as before on page 13

            SelectNode(SrmDocument.Level.Molecules, 5);
            SelectNode(SrmDocument.Level.Molecules, 6);
            SelectNode(SrmDocument.Level.Molecules, 7);

            ChangePeakBounds("D_108_REP2", 26.8, 27.4);

            PauseForScreenShot("Chromatogram graph - peak truncation", 29);

            ActivateReplicate("H_162_REP3");

            PauseForScreenShot("Chromatogram graph - peak truncation noisy", 29);

            RestoreViewOnScreen(12); // Same layout for Peak Areas graph as on page 12

            FindNode("FGLYSDQMR");

            PauseForScreenShot("Peak Areas graph - inconsistent ion abundance", 29);

            RunUI(SkylineWindow.EditDelete);
        }
Esempio n. 42
0
        private SrmDocument AddProteins(SrmDocument document, ref IdentityPath selectedPath)
        {
            if (tabControl1.SelectedTab != tabPageProteinList)
                return document;

            var backgroundProteome = GetBackgroundProteome(document);
            for (int i = gridViewProteins.Rows.Count - 1; i >= 0; i--)
            {
                var row = gridViewProteins.Rows[i];
                var proteinName = Convert.ToString(row.Cells[colProteinName.Index].Value);
                if (String.IsNullOrEmpty(proteinName))
                {
                    continue;
                }
                var pastedMetadata = new ProteinMetadata(proteinName,
                    Convert.ToString(row.Cells[colProteinDescription.Index].Value),
                    NullForEmpty(Convert.ToString(row.Cells[colProteinPreferredName.Index].Value)),
                    NullForEmpty(Convert.ToString(row.Cells[colProteinAccession.Index].Value)),
                    NullForEmpty(Convert.ToString(row.Cells[colProteinGene.Index].Value)),
                    NullForEmpty(Convert.ToString(row.Cells[colProteinSpecies.Index].Value)));
                FastaSequence fastaSequence = null;
                if (!backgroundProteome.IsNone)
                {
                    ProteinMetadata protdbMetadata;
                    fastaSequence = backgroundProteome.GetFastaSequence(proteinName, out protdbMetadata);
                    // Fill in any gaps in pasted metadata with that in protdb
                    pastedMetadata = pastedMetadata.Merge(protdbMetadata);
                }
                // Strip any whitespace (tab, newline etc) In case it was copied out of a FASTA file
                var fastaSequenceString = new string(Convert.ToString(row.Cells[colProteinSequence.Index].Value).Where(c => !Char.IsWhiteSpace(c)).ToArray());
                if (!string.IsNullOrEmpty(fastaSequenceString))
                {
                        try
                        {
                            if (fastaSequence == null) // Didn't match anything in protdb
                            {
                                fastaSequence = new FastaSequence(pastedMetadata.Name, pastedMetadata.Description,
                                                                  new ProteinMetadata[0], fastaSequenceString);
                            }
                            else
                            {
                                if (fastaSequence.Sequence != fastaSequenceString)
                                {
                                    fastaSequence = new FastaSequence(pastedMetadata.Name, pastedMetadata.Description,
                                                                      fastaSequence.Alternatives, fastaSequenceString);
                                }
                            }
                        }
                        catch (Exception exception)
                        {
                            ShowProteinError(new PasteError
                                                 {
                                                     Line = i,
                                                     Column = colProteinDescription.Index,
                                                     Message = string.Format(Resources.PasteDlg_AddProteins_Invalid_protein_sequence__0__, exception.Message)
                                                 });
                            return null;
                        }
                }
                if (fastaSequence == null)
                {
                    ShowProteinError(
                        new PasteError
                        {
                                             Line = i,
                                Message = backgroundProteome.IsNone
                                        ? Resources.PasteDlg_AddProteins_Missing_protein_sequence
                                        : Resources.PasteDlg_AddProteins_This_protein_was_not_found_in_the_background_proteome_database
                        });
                    return null;
                }
                var description = pastedMetadata.Description;
                if (!string.IsNullOrEmpty(description) && description != fastaSequence.Description)
                {
                    fastaSequence = new FastaSequence(fastaSequence.Name, description, fastaSequence.Alternatives, fastaSequence.Sequence);
                }
                pastedMetadata = pastedMetadata.ChangeName(fastaSequence.Name).ChangeDescription(fastaSequence.Description);  // Make sure these agree
                var nodeGroupPep = new PeptideGroupDocNode(fastaSequence, pastedMetadata, new PeptideDocNode[0]);
                nodeGroupPep = nodeGroupPep.ChangeSettings(document.Settings, SrmSettingsDiff.ALL);
                var to = selectedPath;
                if (to == null || to.Depth < (int)SrmDocument.Level.MoleculeGroups)
                    document = (SrmDocument)document.Add(nodeGroupPep);
                else
                {
                    Identity toId = selectedPath.GetIdentity((int)SrmDocument.Level.MoleculeGroups);
                    document = (SrmDocument)document.Insert(toId, nodeGroupPep);
                }
                selectedPath = new IdentityPath(nodeGroupPep.Id);
            }
            return document;
        }
Esempio n. 43
0
        private SrmDocument AddTransitionList(SrmDocument document, ref IdentityPath selectedPath)
        {
            if (tabControl1.SelectedTab != tabPageTransitionList)
                return document;
            if (IsMolecule)
            {
                // Save the current column order to settings
                var active = new List<string>();
                for (int order = 0; order < gridViewTransitionList.Columns.Count; order++)
                {
                    for (int gridcol = 0; gridcol < gridViewTransitionList.Columns.Count; gridcol++)
                    {
                        var dataGridViewColumn = gridViewTransitionList.Columns[gridcol];
                        if (dataGridViewColumn.DisplayIndex == order)
                        {
                            if (dataGridViewColumn.Visible)
                                active.Add(dataGridViewColumn.Name);
                            break;
                        }
                    }
                }
                Settings.Default.CustomMoleculeTransitionInsertColumnsList = active;

                // We will accept a completely empty product list as meaning
                // "these are all precursor transitions"
                var requireProductInfo = false;
                for (var i = 0; i < gridViewTransitionList.RowCount - 1; i++)
                {
                    var row = gridViewTransitionList.Rows[i];
                    var productMz = row.Cells[INDEX_PRODUCT_MZ].Value;
                    var productFormula = row.Cells[INDEX_PRODUCT_FORMULA].Value;
                    var productCharge = row.Cells[INDEX_PRODUCT_CHARGE].Value;
                    if ((productMz != null && productMz.ToString().Length > 0) ||
                        (productFormula != null && productFormula.ToString().Length > 0) ||
                        (productCharge != null && productCharge.ToString().Length > 0))
                    {
                        requireProductInfo = true; // Product list is not completely empty
                        break;
                    }
                }

                // For each row in the grid, add to or begin MoleculeGroup|Molecule|TransitionList tree
                for(int i = 0; i < gridViewTransitionList.RowCount - 1; i ++)
                {
                    DataGridViewRow row = gridViewTransitionList.Rows[i];
                    var precursor = ReadPrecursorOrProductColumns(document, row, true); // Get molecule values
                    if (precursor == null)
                        return null;
                    if (requireProductInfo && ReadPrecursorOrProductColumns(document, row, false) == null)
                    {
                        return null;
                    }
                    var charge = precursor.Charge;
                    var precursorMonoMz = BioMassCalc.CalculateIonMz(precursor.MonoMass, charge);
                    var precursorAverageMz = BioMassCalc.CalculateIonMz(precursor.AverageMass, charge);

                    // Preexisting molecule group?
                    bool pepGroupFound = false;
                    foreach (var pepGroup in document.MoleculeGroups)
                    {
                        var pathPepGroup = new IdentityPath(pepGroup.Id);
                        if (Equals(pepGroup.Name, Convert.ToString(row.Cells[INDEX_MOLECULE_GROUP].Value)))
                        {
                            // Found a molecule group with the same name - can we find an existing transition group to which we can add a transition?
                            pepGroupFound = true;
                            bool pepFound = false;
                            foreach (var pep in pepGroup.SmallMolecules)
                            {
                                var pepPath = new IdentityPath(pathPepGroup, pep.Id);
                                var ionMonoMz = BioMassCalc.CalculateIonMz(pep.CustomIon.MonoisotopicMass, charge);
                                var ionAverageMz = BioMassCalc.CalculateIonMz(pep.CustomIon.AverageMass, charge);
                                // Match existing molecule if same name (if any) and same formula (if any) and similar m/z at the precursor charge
                                // (we don't just check mass since we don't have a tolerance value for that)
                                // Or same name If any) and identical formula when stripped of labels
                                // Or same name, no formula, and different isotope labels
                                if (Equals(pep.CustomIon.Name, precursor.Name) &&
                                    ((Equals(pep.CustomIon.Formula, precursor.Formula) &&
                                    Math.Abs(ionMonoMz - precursorMonoMz) <= document.Settings.TransitionSettings.Instrument.MzMatchTolerance &&
                                    Math.Abs(ionAverageMz - precursorAverageMz) <= document.Settings.TransitionSettings.Instrument.MzMatchTolerance) ||
                                    (!Equals(pep.CustomIon.Formula, precursor.Formula) &&
                                    Equals(pep.CustomIon.UnlabeledFormula, BioMassCalc.MONOISOTOPIC.StripLabelsFromFormula(precursor.Formula))) ||
                                    (string.IsNullOrEmpty(pep.CustomIon.Formula) && string.IsNullOrEmpty(precursor.Formula) &&
                                    !pep.TransitionGroups.Any(t => Equals(t.TransitionGroup.LabelType, precursor.IsotopeLabelType??IsotopeLabelType.light))) ))
                                {
                                    pepFound = true;
                                    bool tranGroupFound = false;
                                    foreach (var tranGroup in pep.TransitionGroups)
                                    {
                                        var pathGroup = new IdentityPath(pepPath, tranGroup.Id);
                                        if (Math.Abs(tranGroup.PrecursorMz - precursor.Mz) <= document.Settings.TransitionSettings.Instrument.MzMatchTolerance)
                                        {
                                            tranGroupFound = true;
                                            var tranFound = false;
                                            try
                                            {
                                                var tranNode = GetMoleculeTransition(document, row, pep.Peptide, tranGroup.TransitionGroup, requireProductInfo);
                                                if (tranNode == null)
                                                    return null;
                                                foreach (var tran in tranGroup.Transitions)
                                                {
                                                    if (Equals(tranNode.Transition.CustomIon,tran.Transition.CustomIon))
                                                    {
                                                        tranFound = true;
                                                        break;
                                                    }
                                                }
                                                if (!tranFound)
                                                {
                                                    document = (SrmDocument) document.Add(pathGroup, tranNode);
                                                }
                                            }
                                            catch (InvalidDataException e)
                                            {
                                                // Some error we didn't catch in the basic checks
                                                ShowTransitionError(new PasteError
                                                {
                                                    Column = 0,
                                                    Line = row.Index,
                                                    Message = e.Message
                                                });
                                                return null;
                                            }
                                            break;
                                        }
                                    }
                                    if (!tranGroupFound)
                                    {
                                        var node = GetMoleculeTransitionGroup(document, row, pep.Peptide, requireProductInfo);
                                        if (node == null)
                                            return null;
                                        document =
                                            (SrmDocument)
                                                document.Add(pepPath, node);
                                    }
                                    break;
                                }
                            }
                            if (!pepFound)
                            {
                                var node = GetMoleculePeptide(document, row, pepGroup.PeptideGroup, requireProductInfo);
                                if (node == null)
                                    return null;
                                document =
                                    (SrmDocument)
                                        document.Add(pathPepGroup,node);
                            }
                            break;
                        }
                    }
                    if (!pepGroupFound)
                    {
                        var node = GetMoleculePeptideGroup(document, row, requireProductInfo);
                        if (node == null)
                            return null;
                        IdentityPath first;
                        IdentityPath next;
                        document =
                                document.AddPeptideGroups(new[] {node}, false,null
                                    , out first,out next);
                    }
                }
            }
            else
            {
                var backgroundProteome = GetBackgroundProteome(document);
                var sbTransitionList = new StringBuilder();
                var dictNameSeq = new Dictionary<string, FastaSequence>();
                // Add all existing FASTA sequences in the document to the name to seq dictionary
                // Including named peptide lists would cause the import code to give matching names
                // in this list new names (e.g. with 1, 2, 3 appended).  In this code, the names
                // are intended to be merged.
                foreach (var nodePepGroup in document.Children.Cast<PeptideGroupDocNode>().Where(n => !n.IsPeptideList))
                {
                    if (!dictNameSeq.ContainsKey(nodePepGroup.Name))
                        dictNameSeq.Add(nodePepGroup.Name, (FastaSequence) nodePepGroup.PeptideGroup);
                }

                // Check for simple errors and build strings for import
                for (int i = 0; i < gridViewTransitionList.Rows.Count; i++)
                {
                    var row = gridViewTransitionList.Rows[i];
                    var peptideSequence = Convert.ToString(row.Cells[colTransitionPeptide.Index].Value);
                    var proteinName = Convert.ToString(row.Cells[colTransitionProteinName.Index].Value);
                    var precursorMzText = Convert.ToString(row.Cells[colTransitionPrecursorMz.Index].Value);
                    var productMzText = Convert.ToString(row.Cells[colTransitionProductMz.Index].Value);
                    if (string.IsNullOrEmpty(peptideSequence) && string.IsNullOrEmpty(proteinName))
                    {
                        continue;
                    }
                    if (string.IsNullOrEmpty(peptideSequence))
                    {
                        ShowTransitionError(new PasteError
                        {
                            Column = colTransitionPeptide.Index,
                            Line = i,
                            Message = Resources.PasteDlg_ListPeptideSequences_The_peptide_sequence_cannot_be_blank
                        });
                        return null;
                    }
                    if (!FastaSequence.IsExSequence(peptideSequence))
                    {
                        ShowTransitionError(new PasteError
                        {
                            Column = colTransitionPeptide.Index,
                            Line = i,
                            Message = Resources.PasteDlg_ListPeptideSequences_This_peptide_sequence_contains_invalid_characters
                        });
                        return null;
                    }
                    double mz;
                    if (!double.TryParse(precursorMzText, out mz))
                    {
                        ShowTransitionError(new PasteError
                        {
                            Column = colTransitionPrecursorMz.Index,
                            Line = i,
                            Message = Resources.PasteDlg_AddTransitionList_The_precursor_m_z_must_be_a_number_
                        });
                        return null;
                    }
                    if (!double.TryParse(productMzText, out mz))
                    {
                        ShowTransitionError(new PasteError
                        {
                            Column = colTransitionProductMz.Index,
                            Line = i,
                            Message = Resources.PasteDlg_AddTransitionList_The_product_m_z_must_be_a_number_
                        });
                        return null;
                    }

                    const char sep = TRANSITION_LIST_SEPARATOR;
                    // Add columns in order specified by TRANSITION_LIST_COL_INDICES
                    sbTransitionList
                        .Append(proteinName).Append(sep)
                        .Append(peptideSequence).Append(sep)
                        .Append(precursorMzText).Append(sep)
                        .Append(productMzText).AppendLine();
                    // Build FASTA sequence text in cases where it is known
                    if (!dictNameSeq.ContainsKey(proteinName))
                    {
                        var fastaSeq = backgroundProteome.GetFastaSequence(proteinName);
                        if (fastaSeq != null)
                            dictNameSeq.Add(proteinName, fastaSeq);
                    }
                }

                if (sbTransitionList.Length == 0)
                    return document;

                // Do the actual import into PeptideGroupDocNodes
                IEnumerable<PeptideGroupDocNode> peptideGroupDocNodes;
                try
                {
                    List<TransitionImportErrorInfo> errorList;
                    List<MeasuredRetentionTime> irtPeptides;
                    List<SpectrumMzInfo> librarySpectra;
                    var inputs = new MassListInputs(sbTransitionList.ToString(), LocalizationHelper.CurrentCulture, TRANSITION_LIST_SEPARATOR);
                    var importer = new MassListImporter(document, inputs);
                    // TODO: support long-wait broker
                    peptideGroupDocNodes = importer.Import(null,
                        TRANSITION_LIST_COL_INDICES,
                        dictNameSeq,
                        out irtPeptides,
                        out librarySpectra,
                        out errorList);
                    if (errorList.Any())
                    {
                        var firstError = errorList[0];
                        if (firstError.Row.HasValue)
                        {
                            throw new LineColNumberedIoException(firstError.ErrorMessage, firstError.Row.Value, firstError.Column ?? -1);
                        }
                        else
                        {
                            throw new InvalidDataException(firstError.ErrorMessage);
                        }
                    }
                }
                catch (LineColNumberedIoException x)
                {
                    var columns = new[]
                    {
                        colTransitionProteinName,
                        colPeptideSequence,
                        colTransitionPrecursorMz,
                        colTransitionProductMz
                    };

                    ShowTransitionError(new PasteError
                    {
                        Column = x.ColumnIndex >= 0 ? columns[x.ColumnIndex].Index : 0,
                        Line = (int) x.LineNumber - 1,
                        Message = x.PlainMessage
                    });
                    return null;
                }
                catch (InvalidDataException x)
                {
                    ShowTransitionError(new PasteError
                    {
                        Message = x.Message
                    });
                    return null;
                }

                // Insert the resulting nodes into the document tree, merging when possible
                bool after = false;
                foreach (var nodePepGroup in peptideGroupDocNodes)
                {
                    PeptideGroupDocNode nodePepGroupExist = FindPeptideGroupDocNode(document, nodePepGroup);
                    if (nodePepGroupExist != null)
                    {
                        var nodePepGroupNew = nodePepGroupExist.Merge(nodePepGroup);
                        if (!ReferenceEquals(nodePepGroupExist, nodePepGroupNew))
                            document = (SrmDocument) document.ReplaceChild(nodePepGroupNew);

                    }
                    else
                    {
                        // Add to the end, if no insert node
                        var to = selectedPath;
                        if (to == null || to.Depth < (int) SrmDocument.Level.MoleculeGroups)
                            document = (SrmDocument) document.Add(nodePepGroup);
                        else
                        {
                            Identity toId = selectedPath.GetIdentity((int) SrmDocument.Level.MoleculeGroups);
                            document = (SrmDocument) document.Insert(toId, nodePepGroup, after);
                        }
                        selectedPath = new IdentityPath(nodePepGroup.Id);
                        // All future insertions should be after, to avoid reversing the list
                        after = true;
                    }
                }
            }
            return document;
        }
Esempio n. 44
0
        public SrmDocument AddFasta(SrmDocument document, ref IdentityPath selectedPath, out int emptyPeptideGroups)
        {
            emptyPeptideGroups = 0;
            var text = TbxFasta.Text;
            if (text.Length == 0)
            {
                return document;
            }
            if (!text.StartsWith(">")) // Not L10N
            {
                ShowFastaError(new PasteError
                {
                    Message = Resources.ImportFastaHelper_AddFasta_This_must_start_with____,
                    Column = 0,
                    Length = 1,
                    Line = 0,
                });
                return null;
            }
            string[] lines = text.Split('\n');
            int lastNameLine = -1;
            int aa = 0;
            for (int i = 0; i < lines.Length; i++)
            {
                string line = lines[i];
                if (line.StartsWith(">")) // Not L10N
                {
                    if (line.Trim().Length == 1)
                    {
                        ShowFastaError(new PasteError
                        {
                            Message = Resources.ImportFastaHelper_AddFasta_There_is_no_name_for_this_protein,
                            Column = 0,
                            Line = i,
                            Length = 1
                        });
                        return null;
                    }
                    if (!CheckSequence(aa, lastNameLine, lines))
                        return null;
                    lastNameLine = i;
                    aa = 0;
                    continue;
                }

                for (int column = 0; column < line.Length; column++)
                {
                    char c = line[column];
                    if (AminoAcid.IsExAA(c))
                        aa++;
                    else if (!Char.IsWhiteSpace(c) && c != '*')
                    {
                        ShowFastaError(new PasteError
                        {
                            Message =
                                String.Format(Resources.ImportFastaHelper_AddFasta___0___is_not_a_capital_letter_that_corresponds_to_an_amino_acid_, c),
                            Column = column,
                            Line = i,
                            Length = 1,
                        });
                        return null;
                    }
                }
            }

            if (!CheckSequence(aa, lastNameLine, lines))
                return null;

            var importer = new FastaImporter(document, false);
            try
            {
                var reader = new StringReader(TbxFasta.Text);
                IdentityPath to = selectedPath;
                IdentityPath firstAdded, nextAdd;
                // TODO: support long-wait broker
                document = document.AddPeptideGroups(importer.Import(reader, null, -1), false,
                    to, out firstAdded, out nextAdd);
                emptyPeptideGroups = importer.EmptyPeptideGroupCount;
                selectedPath = firstAdded;
            }
            catch (Exception exception)
            {
                ShowFastaError(new PasteError
                {
                    Message = Resources.ImportFastaHelper_AddFasta_An_unexpected_error_occurred__ + exception.Message + " (" + exception.GetType() + ")" // Not L10N
                });
                return null;
            }
            return document;
        }
Esempio n. 45
0
 public SrmDocument ConvertToExplicitRetentionTimes(SrmDocument document, double timeOffset, double winOffset)
 {
     for (bool changing = true; changing;)
     {
         changing = false;
         foreach (var peptideGroupDocNode in document.MoleculeGroups)
         {
             var pepGroupPath = new IdentityPath(IdentityPath.ROOT, peptideGroupDocNode.Id);
             foreach (var nodePep in peptideGroupDocNode.Molecules)
             {
                 var pepPath = new IdentityPath(pepGroupPath, nodePep.Id);
                 var rt = nodePep.AverageMeasuredRetentionTime;
                 if (rt.HasValue)
                 {
                     double? rtWin = document.Settings.PeptideSettings.Prediction.MeasuredRTWindow;
                     var explicitRetentionTimeInfo = new ExplicitRetentionTimeInfo(rt.Value+timeOffset, rtWin+winOffset);
                     if (!explicitRetentionTimeInfo.Equals(nodePep.ExplicitRetentionTime))
                     {
                         document = (SrmDocument)document.ReplaceChild(pepPath.Parent, nodePep.ChangeExplicitRetentionTime(explicitRetentionTimeInfo));
                         changing = true;
                         break;
                     }
                 }
             }
             if (changing)
                 break;
         }
     }
     return document;
 }
Esempio n. 46
0
 private static void CheckTimes(IdentityPath groupPath, int file, int replicate, out double? startTime, out double? endTime)
 {
     var groupNode = (TransitionGroupDocNode)SkylineWindow.Document.FindNode(groupPath);
     var groupChromInfo = groupNode.Results[file][replicate];
     startTime = groupChromInfo.StartRetentionTime;
     endTime = groupChromInfo.EndRetentionTime;
 }
Esempio n. 47
0
 public Bookmark(IdentityPath identityPath, ChromFileInfoId chromFileInfoId, int optStep)
 {
     IdentityPath = identityPath ?? IdentityPath.ROOT;
     ChromFileInfoId = chromFileInfoId;
     OptStep = optStep;
 }
        private void ChangePeakBounds(string chromName,
            double startDisplayTime,
            double endDisplayTime)
        {
            Assert.IsTrue(startDisplayTime < endDisplayTime,
                string.Format("Start time {0} must be less than end time {1}.", startDisplayTime, endDisplayTime));

            ActivateReplicate(chromName);

            WaitForGraphs();

            RunUIWithDocumentWait(() => // adjust integration
            {
                var graphChrom = SkylineWindow.GetGraphChrom(chromName);

                var nodeGroupTree = SkylineWindow.SequenceTree.GetNodeOfType<TransitionGroupTreeNode>();
                IdentityPath pathGroup;
                if (nodeGroupTree != null)
                    pathGroup = nodeGroupTree.Path;
                else
                {
                    var nodePepTree = SkylineWindow.SequenceTree.GetNodeOfType<PeptideTreeNode>();
                    pathGroup = new IdentityPath(nodePepTree.Path, nodePepTree.ChildDocNodes[0].Id);
                }
                var listChanges = new List<ChangedPeakBoundsEventArgs>
                {
                    new ChangedPeakBoundsEventArgs(pathGroup,
                        null,
                        graphChrom.NameSet,
                        graphChrom.ChromGroupInfos[0].FilePath,
                        graphChrom.GraphItems.First().GetNearestDisplayTime(startDisplayTime),
                        graphChrom.GraphItems.First().GetNearestDisplayTime(endDisplayTime),
                        PeakIdentification.ALIGNED,
                        PeakBoundsChangeType.both)
                };
                graphChrom.SimulateChangedPeakBounds(listChanges);
            });
            WaitForGraphs();
        }
Esempio n. 49
0
 /// <summary>
 /// Modifies a document in response to the user clicking on a peak in the GraphChromatogram.
 /// </summary>
 private static SrmDocument PickPeak(SrmDocument document, PickedPeakEventArgs e)
 {
     document = document.ChangePeak(e.GroupPath, e.NameSet, e.FilePath, e.TransitionId, e.RetentionTime.MeasuredTime, UserSet.TRUE);
     var activeTransitionGroup = (TransitionGroupDocNode) document.FindNode(e.GroupPath);
     if (activeTransitionGroup.RelativeRT != RelativeRT.Matching)
     {
         return document;
     }
     var activeChromInfo = FindChromInfo(document, activeTransitionGroup, e.NameSet, e.FilePath);
     var peptide = (PeptideDocNode) document.FindNode(e.GroupPath.Parent);
     // See if there are any other transition groups that should have their peak bounds set to the same value
     foreach (var transitionGroup in peptide.TransitionGroups)
     {
         if (transitionGroup.RelativeRT != RelativeRT.Matching)
         {
             continue;
         }
         var groupPath = new IdentityPath(e.GroupPath.Parent, transitionGroup.TransitionGroup);
         if (Equals(groupPath, e.GroupPath))
         {
             continue;
         }
         var chromInfo = FindChromInfo(document, transitionGroup, e.NameSet, e.FilePath);
         if (null == chromInfo)
         {
             continue;
         }
         document = document.ChangePeak(groupPath, e.NameSet, e.FilePath, null,
             activeChromInfo.StartRetentionTime, activeChromInfo.EndRetentionTime, UserSet.TRUE, activeChromInfo.Identified, true);
     }
     return document;
 }
        private void RemovePeak(string chromName, IdentityPath pathGroupRemove, TransitionGroupDocNode nodeGroupRemove)
        {
            RunUI(() =>
            {
                int resultsIndex = GetChromIndex(chromName);
                SkylineWindow.ActivateReplicate(chromName);
                Assert.AreEqual(resultsIndex, SkylineWindow.SelectedResultsIndex);
                SkylineWindow.RemovePeak(pathGroupRemove, nodeGroupRemove, null);

                // Confirm that peak has been removed from the right replicate
                var nodeGroupAfter = SkylineWindow.DocumentUI.FindNode(pathGroupRemove) as TransitionGroupDocNode;
                Assert.IsNotNull(nodeGroupAfter);
                Assert.AreSame(nodeGroupRemove.Id, nodeGroupAfter.Id);

                Assert.IsNotNull(nodeGroupRemove.Results[resultsIndex]);
                Assert.IsTrue(nodeGroupRemove.Results[resultsIndex][0].Area.HasValue);
                Assert.IsNotNull(nodeGroupAfter.Results[resultsIndex]);
                Assert.IsFalse(nodeGroupAfter.Results[resultsIndex][0].Area.HasValue);
            });
        }
Esempio n. 51
0
 public RemovePeakHandler(SkylineWindow skyline, IdentityPath groupPath,
     TransitionGroupDocNode nodeGroup, TransitionDocNode nodeTran)
 {
     _skyline = skyline;
     _groupPath = groupPath;
     _nodeGroup = nodeGroup;
     _nodeTran = nodeTran;
 }
 private void ExportWithExplicitCollisionEnergyValues(string pathList)
 {
     var original = SkylineWindow.Document;
     var refine = new RefinementSettings();
     var document = refine.ConvertToSmallMolecules(original);
     for (var loop = 0; loop < 2; loop++)
     {
         SkylineWindow.SetDocument(document, SkylineWindow.Document);
         var exportMethodDlg = ShowDialog<ExportMethodDlg>(() => SkylineWindow.ShowExportMethodDialog(ExportFileType.List));
         RunUI(() =>
         {
             exportMethodDlg.InstrumentType = ExportInstrumentType.THERMO_QUANTIVA;
             exportMethodDlg.OptimizeType = ExportOptimize.CE;
             exportMethodDlg.MethodType = ExportMethodType.Standard;
         });
         RunUI(() => exportMethodDlg.OkDialog(pathList));
         WaitForClosedForm(exportMethodDlg);
         var actual = File.ReadAllLines(pathList);
         if (loop == 1)
         {
             // Explicit CE values
             Assert.AreEqual(document.MoleculeTransitionCount+1, actual.Length); // Should be just one line per transition, and a header
             break;
         }
         else
         {
             Assert.AreEqual(document.MoleculeTransitionCount*11 + 1, actual.Length); // Multiple steps, and a header
         }
         // Change the current document to use explicit CE values, verify that this changes the output
         var ce = 1;
         for (bool changing = true; changing; )
         {
             changing = false;
             foreach (var peptideGroupDocNode in document.MoleculeGroups)
             {
                 var pepGroupPath = new IdentityPath(IdentityPath.ROOT, peptideGroupDocNode.Id);
                 foreach (var nodePep in peptideGroupDocNode.Molecules)
                 {
                     var pepPath = new IdentityPath(pepGroupPath, nodePep.Id);
                     foreach (var nodeTransitionGroup in nodePep.TransitionGroups)
                     {
                         if (!nodeTransitionGroup.ExplicitValues.CollisionEnergy.HasValue)
                         {
                             var tgPath = new IdentityPath(pepPath, nodeTransitionGroup.Id);
                             document = (SrmDocument)document.ReplaceChild(tgPath.Parent,
                                 nodeTransitionGroup.ChangeExplicitValues(nodeTransitionGroup.ExplicitValues.ChangeCollisionEnergy(ce++)));
                             changing = true;
                             break;
                         }
                     }
                 }
                 if (changing)
                     break;
             }
         }
     }
     SkylineWindow.SetDocument(original, SkylineWindow.Document);
 }
Esempio n. 53
0
 public void SelectPath(IdentityPath focusPath)
 {
     SequenceTree.SelectPath(focusPath);
 }
Esempio n. 54
0
 private bool IsPathSelected(IdentityPath selectedPath, IdentityPath identityPath)
 {
     if (selectedPath.Depth < identityPath.Depth)
     {
         return false;
     }
     return Equals(selectedPath.GetPathTo(identityPath.Depth), identityPath);
 }
Esempio n. 55
0
 private List<DocNode> GetDocNodes(IdentityPath identityPath, SrmDocument document)
 {
     var result = new List<DocNode>();
     while (!identityPath.IsRoot)
     {
         result.Insert(0, document.FindNode(identityPath));
         identityPath = identityPath.Parent;
     }
     return result;
 }
Esempio n. 56
0
        private SrmDocument AddPeptides(SrmDocument document, bool validating, ref IdentityPath selectedPath)
        {
            if (tabControl1.SelectedTab != tabPagePeptideList)
                return document;

            var matcher = new ModificationMatcher();
            var listPeptideSequences = ListPeptideSequences();
            if (listPeptideSequences == null)
                return null;
            try
            {
                matcher.CreateMatches(document.Settings, listPeptideSequences, Settings.Default.StaticModList,
                                      Settings.Default.HeavyModList);
            }
            catch (FormatException e)
            {
                MessageDlg.ShowException(this, e);
                ShowPeptideError(new PasteError
                                     {
                                         Column = colPeptideSequence.Index,
                                         Message = Resources.PasteDlg_AddPeptides_Unable_to_interpret_peptide_modifications
                                     });
                return null;
            }
            var strNameMatches = matcher.FoundMatches;
            if (!validating && !string.IsNullOrEmpty(strNameMatches))
            {
                string message = TextUtil.LineSeparate(Resources.PasteDlg_AddPeptides_Would_you_like_to_use_the_Unimod_definitions_for_the_following_modifications,
                                                        string.Empty, strNameMatches);
                if (MultiButtonMsgDlg.Show(this, message, Resources.PasteDlg_AddPeptides_OK) == DialogResult.Cancel)
                    return null;
            }
            var backgroundProteome = GetBackgroundProteome(document);
            // Insert last to first so that proteins get inserted on top of each other
            // in the order they are added. Peptide insertion into peptide lists needs
            // to be carefully tracked to insert them in the order they are listed in
            // the grid.
            int lastGroupGlobalIndex = 0, lastPeptideIndex = -1;
            for (int i = gridViewPeptides.Rows.Count - 1; i >= 0; i--)
            {
                PeptideGroupDocNode peptideGroupDocNode;
                var row = gridViewPeptides.Rows[i];
                var pepModSequence = Convert.ToString(row.Cells[colPeptideSequence.Index].Value);
                pepModSequence = FastaSequence.NormalizeNTerminalMod(pepModSequence);
                var proteinName = Convert.ToString(row.Cells[colPeptideProtein.Index].Value);
                if (string.IsNullOrEmpty(pepModSequence) && string.IsNullOrEmpty(proteinName))
                    continue;
                if (string.IsNullOrEmpty(proteinName))
                {
                    peptideGroupDocNode = GetSelectedPeptideGroupDocNode(document, selectedPath);
                    if (!IsPeptideListDocNode(peptideGroupDocNode))
                    {
                        peptideGroupDocNode = null;
                    }
                }
                else
                {
                    peptideGroupDocNode = FindPeptideGroupDocNode(document, proteinName);
                }
                if (peptideGroupDocNode == null)
                {
                    if (string.IsNullOrEmpty(proteinName))
                    {
                        peptideGroupDocNode = new PeptideGroupDocNode(new PeptideGroup(),
                                                                      document.GetPeptideGroupId(true), null,
                                                                      new PeptideDocNode[0]);
                    }
                    else
                    {
                        ProteinMetadata metadata = null;
                        PeptideGroup peptideGroup = backgroundProteome.IsNone ? new PeptideGroup()
                            : (backgroundProteome.GetFastaSequence(proteinName, out metadata) ??
                                                    new PeptideGroup());
                        if (metadata != null)
                            peptideGroupDocNode = new PeptideGroupDocNode(peptideGroup, metadata, new PeptideDocNode[0]);
                        else
                            peptideGroupDocNode = new PeptideGroupDocNode(peptideGroup, proteinName,
                                                                      peptideGroup.Description, new PeptideDocNode[0]);
                    }
                    // Add to the end, if no insert node
                    var to = selectedPath;
                    if (to == null || to.Depth < (int)SrmDocument.Level.MoleculeGroups)
                        document = (SrmDocument)document.Add(peptideGroupDocNode);
                    else
                    {
                        Identity toId = selectedPath.GetIdentity((int) SrmDocument.Level.MoleculeGroups);
                        document = (SrmDocument) document.Insert(toId, peptideGroupDocNode);
                    }
                    selectedPath = new IdentityPath(peptideGroupDocNode.Id);
                }
                var peptides = new List<PeptideDocNode>();
                foreach (PeptideDocNode peptideDocNode in peptideGroupDocNode.Children)
                {
                    peptides.Add(peptideDocNode);
                }

                var fastaSequence = peptideGroupDocNode.PeptideGroup as FastaSequence;
                PeptideDocNode nodePepNew;
                if (fastaSequence != null)
                {
                    // Attempt to create node for error checking.
                    nodePepNew = fastaSequence.CreateFullPeptideDocNode(document.Settings,
                                                                        FastaSequence.StripModifications(pepModSequence));
                    if (nodePepNew == null)
                    {
                        ShowPeptideError(new PasteError
                                             {
                                                 Column = colPeptideSequence.Index,
                                                 Line = i,
                                                 Message = Resources.PasteDlg_AddPeptides_This_peptide_sequence_was_not_found_in_the_protein_sequence
                                             });
                        return null;
                    }
                }
                // Create node using ModificationMatcher.
                nodePepNew = matcher.GetModifiedNode(pepModSequence, fastaSequence).ChangeSettings(document.Settings,
                                                                                                  SrmSettingsDiff.ALL);
                // Avoid adding an existing peptide a second time.
                if (!peptides.Contains(nodePep => Equals(nodePep.Key, nodePepNew.Key)))
                {
                    if (nodePepNew.Peptide.FastaSequence != null)
                    {
                        peptides.Add(nodePepNew);
                        peptides.Sort(FastaSequence.ComparePeptides);
                    }
                    else
                    {
                        int groupGlobalIndex = peptideGroupDocNode.PeptideGroup.GlobalIndex;
                        if (groupGlobalIndex == lastGroupGlobalIndex && lastPeptideIndex != -1)
                        {
                            peptides.Insert(lastPeptideIndex, nodePepNew);
                        }
                        else
                        {
                            lastPeptideIndex = peptides.Count;
                            peptides.Add(nodePepNew);
                        }
                        lastGroupGlobalIndex = groupGlobalIndex;
                    }
                    var newPeptideGroupDocNode = new PeptideGroupDocNode(peptideGroupDocNode.PeptideGroup, peptideGroupDocNode.Annotations, peptideGroupDocNode.Name, peptideGroupDocNode.Description, peptides.ToArray(), false);
                    document = (SrmDocument)document.ReplaceChild(newPeptideGroupDocNode);
                }
            }
            if (!validating && listPeptideSequences.Count > 0)
            {
                var pepModsNew = matcher.GetDocModifications(document);
                document = document.ChangeSettings(document.Settings.ChangePeptideModifications(mods => pepModsNew));
                document.Settings.UpdateDefaultModifications(false);
            }
            return document;
        }
Esempio n. 57
0
 public void SelectPeptide(IdentityPath peptidePath)
 {
     foreach (var regressionGraphPane in GraphSummary.GraphPanes.OfType<RTLinearRegressionGraphPane>())
     {
         regressionGraphPane.SelectPeptide(peptidePath);
     }
 }
Esempio n. 58
0
 private SrmDocument GetNewDocument(SrmDocument document, bool validating, ref IdentityPath selectedPath, out int emptyPeptideGroups)
 {
     var fastaHelper = new ImportFastaHelper(tbxFasta, tbxError, panelError);
     if ((document = fastaHelper.AddFasta(document, ref selectedPath, out emptyPeptideGroups)) == null)
     {
         tabControl1.SelectedTab = tabPageFasta;  // To show fasta errors
         return null;
     }
     if ((document = AddProteins(document, ref selectedPath)) == null)
     {
         return null;
     }
     if ((document = AddPeptides(document, validating, ref selectedPath)) == null)
     {
         return null;
     }
     if ((document = AddTransitionList(document, ref selectedPath)) == null)
     {
         return null;
     }
     return document;
 }
 private IEnumerable<Bookmark> FindAll(IdentityPath identityPath, DocNode docNode)
 {
     var results = new List<Bookmark>();
     var transitionGroupDocNode = docNode as TransitionGroupDocNode;
     if (transitionGroupDocNode == null)
     {
         var docNodeParent = docNode as DocNodeParent;
         if (docNodeParent == null)
         {
             return results;
         }
         foreach (var child in docNodeParent.Children)
         {
             results.AddRange(FindAll(new IdentityPath(identityPath, child.Id), child));
         }
         return results;
     }
     if (!transitionGroupDocNode.HasResults)
     {
         return results;
     }
     for (int iReplicate = 0; iReplicate < transitionGroupDocNode.Results.Count; iReplicate++)
     {
         var replicate = transitionGroupDocNode.Results[iReplicate];
         if (replicate == null)
         {
             continue;
         }
         var fileDatas = new Dictionary<FinderChromFileKey, FinderChromFileData>();
         foreach (var transitionGroupChromInfo in replicate)
         {
             FinderChromFileData chromFileData;
             var chromFileKey = new FinderChromFileKey(transitionGroupChromInfo);
             if (!fileDatas.TryGetValue(chromFileKey, out chromFileData))
             {
                 chromFileData = new FinderChromFileData
                                     {
                                         TransitionGroupChromInfo = transitionGroupChromInfo,
                                         MatchingTransitionBookmarks = new List<Bookmark>(),
                                         AllTransitionsMatch = true,
                                     };
                 fileDatas.Add(chromFileKey, chromFileData);
             }
         }
         foreach (var transitionDocNode in transitionGroupDocNode.Transitions)
         {
             if (!transitionDocNode.HasResults || iReplicate >= transitionDocNode.Results.Count)
             {
                 continue;
             }
             var transitionResults = transitionDocNode.Results[iReplicate];
             if (transitionResults == null)
             {
                 continue;
             }
             var transitionId = new IdentityPath(identityPath, transitionDocNode.Id);
             foreach (var chromInfo in transitionResults)
             {
                 FinderChromFileData chromFileData;
                 bool match = MatchTransition(chromInfo) != null;
                 var transitionBookmark = new Bookmark(transitionId, chromInfo.FileId,
                                                       chromInfo.OptimizationStep);
                 var chromFileKey = new FinderChromFileKey(chromInfo);
                 if (!fileDatas.TryGetValue(chromFileKey, out chromFileData))
                 {
                     if (match)
                     {
                         results.Add(transitionBookmark);
                     }
                 }
                 else
                 {
                     if (match)
                     {
                         chromFileData.MatchingTransitionBookmarks.Add(transitionBookmark);
                     }
                     else
                     {
                         chromFileData.AllTransitionsMatch = false;
                     }
                 }
             }
         }
         foreach (var fileDataEntry in fileDatas)
         {
             if (fileDataEntry.Value.AllTransitionsMatch && fileDataEntry.Value.MatchingTransitionBookmarks.Count > 0)
             {
                 var transitionGroupMatch = MatchTransitionGroup(fileDataEntry.Value.TransitionGroupChromInfo);
                 if (transitionGroupMatch != null)
                 {
                     results.Add(new Bookmark(identityPath, fileDataEntry.Value.TransitionGroupChromInfo.FileId, fileDataEntry.Value.TransitionGroupChromInfo.OptimizationStep));
                     continue;
                 }
             }
             results.AddRange(fileDataEntry.Value.MatchingTransitionBookmarks);
         }
     }
     return results;
 }
Esempio n. 60
0
        private PeptideGroupDocNode GetSelectedPeptideGroupDocNode(SrmDocument document, IdentityPath selectedPath)
        {
            var to = selectedPath;
            if (to != null && to.Depth >= (int)SrmDocument.Level.MoleculeGroups)
                return (PeptideGroupDocNode) document.FindNode(to.GetIdentity((int) SrmDocument.Level.MoleculeGroups));

            PeptideGroupDocNode lastPeptideGroupDocuNode = null;
            foreach (PeptideGroupDocNode peptideGroupDocNode in document.MoleculeGroups)
            {
                lastPeptideGroupDocuNode = peptideGroupDocNode;
            }
            return lastPeptideGroupDocuNode;
        }