private void TestHistogramRatios <T>(Action showHistogram, int statsStartIndex) where T : SummaryGraphPane
        {
            RunUI(() =>
            {
                showHistogram();
                SkylineWindow.SetAreaCVPointsType(PointsTypePeakArea.targets);
                SkylineWindow.SetNormalizationMethod(NormalizeOption.RatioToFirstStandard(SkylineWindow.Document.Settings));
            });

            WaitForGraphs();

            var graph   = SkylineWindow.GraphPeakArea;
            var toolbar = graph.Toolbar as AreaCVToolbar;

            Assert.IsNotNull(toolbar);

            RunUI(() => toolbar.SetMinimumDetections(2));
            OpenAndChangeAreaCVProperties(graph, p => p.QValueCutoff = double.NaN);

            // Make sure toolbar is there, combo box items are correct and data is correct
            T pane;

            Assert.IsTrue(graph.TryGetGraphPane(out pane));
            Assert.IsTrue(pane.HasToolbar);
            CollectionAssert.AreEqual(new[] { NormalizeOption.DEFAULT.Caption, "Light", "Heavy", "All 15N", NormalizationMethod.EQUALIZE_MEDIANS.NormalizeToCaption, NormalizationMethod.NONE.NormalizeToCaption }, toolbar.NormalizationMethods.ToArray());
            AssertDataCorrect(pane, statsStartIndex++); // Light

            RunUI(() => SkylineWindow.SetNormalizationMethod(NormalizeOption.FromIsotopeLabelType(SkylineWindow.Document.Settings.PeptideSettings.Modifications.RatioInternalStandardTypes[1])));
            WaitForGraphs();
            AssertDataCorrect(pane, statsStartIndex++); // Heavy

            RunUI(() => SkylineWindow.SetNormalizationMethod(NormalizeOption.FromIsotopeLabelType(SkylineWindow.Document.Settings.PeptideSettings.Modifications.RatioInternalStandardTypes[2])));
            WaitForGraphs();
            AssertDataCorrect(pane, statsStartIndex++, allowInvalid: true); // All 15N
        }
예제 #2
0
        private void TestNormalizeToHeavyHistogram()
        {
            RunUI(SkylineWindow.ShowPeakAreaCVHistogram);

            ResetHistogramSettings();

            AreaCVHistogramGraphPane pane;

            Assert.IsTrue(SkylineWindow.GraphPeakArea.TryGetGraphPane(out pane));
            Assert.IsInstanceOfType(pane, typeof(IAreaCVHistogramInfo));

            int startIndex = HISTOGRAM_HEAVY_START;

            AssertDataCorrect(pane, startIndex++);

            RunUI(() => SkylineWindow.SetNormalizationMethod(NormalizeOption.RatioToFirstStandard(SkylineWindow.Document.Settings)));
            AssertDataCorrect(pane, startIndex);
        }
예제 #3
0
        public void RunTestFindNode(RefinementSettings.ConvertToSmallMoleculesMode asSmallMolecules)
        {
            if (asSmallMolecules != RefinementSettings.ConvertToSmallMoleculesMode.none)
            {
                TestDirectoryName = asSmallMolecules.ToString();
            }

            SrmDocument doc = CreateStudy7Doc();

            doc = new RefinementSettings().ConvertToSmallMolecules(doc, TestDirectoryName, asSmallMolecules);
            var displaySettings = new DisplaySettings(new NormalizedValueCalculator(doc), null, false, 0, NormalizeOption.RatioToFirstStandard(doc.Settings)); //, ProteinDisplayMode.ByName);
            // Find every other transition, searching down.
            List <TransitionDocNode> listTransitions = doc.MoleculeTransitions.ToList();
            var pathFound = doc.GetPathTo(0, 0);
            int i;

            for (i = 0; i < doc.MoleculeTransitionCount; i += 2)
            {
                pathFound = doc.SearchDocumentForString(pathFound, String.Format("{0:F04}", listTransitions[i].Mz), displaySettings, false, false);
                Assert.AreEqual(doc.GetPathTo((int)SrmDocument.Level.Transitions, i), pathFound);
            }

            // Test wrapping in search down.
            pathFound = doc.SearchDocumentForString(pathFound, String.Format("{0:F04}", listTransitions[0].Mz), displaySettings, false, false);
            Assert.AreEqual(doc.GetPathTo((int)SrmDocument.Level.Transitions, 0), pathFound);

            // Find every other peptide searching up while for each finding one of its children searching down.
            pathFound = doc.LastNodePath;
            List <PeptideDocNode> listPeptides = new List <PeptideDocNode>();

            listPeptides.AddRange(doc.Molecules);
            List <TransitionGroupDocNode> listTransitionGroups = new List <TransitionGroupDocNode>();

            listTransitionGroups.AddRange(doc.MoleculeTransitionGroups);
            for (int x = doc.MoleculeCount; x > 0; x -= 2)
            {
                // Test case insensitivity.
                pathFound = doc.SearchDocumentForString(pathFound, listPeptides[x - 1].ToString().ToLower(), displaySettings, true, false);
                Assert.AreEqual(doc.GetPathTo((int)SrmDocument.Level.Molecules, x - 1), pathFound);
                // Test parents can find children.
                pathFound = doc.SearchDocumentForString(pathFound, String.Format("{0:F04}", listTransitionGroups[x * 2 - 1].PrecursorMz.Value), displaySettings,
                                                        false, true);
                Assert.AreEqual(doc.GetPathTo((int)SrmDocument.Level.TransitionGroups, x * 2 - 1), pathFound);
                // Test Children can find parents.
                pathFound = doc.SearchDocumentForString(pathFound, listPeptides[x - 1].ToString().ToLower(), displaySettings, true, false);
                Assert.AreEqual(doc.GetPathTo((int)SrmDocument.Level.Molecules, x - 1), pathFound);
            }

            // Test wrapping in search up.
            pathFound = doc.SearchDocumentForString(pathFound, String.Format("{0:F04}", listTransitionGroups[listTransitionGroups.Count - 1].PrecursorMz.Value),
                                                    displaySettings, false, true);
            Assert.AreEqual(doc.GetPathTo((int)SrmDocument.Level.TransitionGroups, listTransitionGroups.Count - 1), pathFound);

            // Test children can find other parents.
            pathFound = doc.SearchDocumentForString(pathFound, listPeptides[0].ToString().ToLowerInvariant(), displaySettings, true, false);
            Assert.AreEqual(doc.GetPathTo((int)SrmDocument.Level.Molecules, 0), pathFound);

            // Test forward and backward searching in succession
            const string heavyText         = "heavy";
            int          countHeavyForward = CountOccurrances(doc, heavyText, displaySettings, false, true);

            Assert.IsTrue(countHeavyForward > 0);
            Assert.AreEqual(countHeavyForward, CountOccurrances(doc, heavyText, displaySettings, true, true));
            // More tests of case insensitive searching
            Assert.AreEqual(0, CountOccurrances(doc, heavyText.ToUpperInvariant(), displaySettings, false, true));
            Assert.AreEqual(countHeavyForward, CountOccurrances(doc, heavyText.ToUpperInvariant(), displaySettings, false, false));
            if (asSmallMolecules != RefinementSettings.ConvertToSmallMoleculesMode.masses_only)
            {
                Assert.AreEqual(1, CountOccurrances(doc, "hgflpr", displaySettings, true, false));
            }

            // Test mismatched transitions finder
            var missmatchFinder = new FindOptions().ChangeCustomFinders(new[] { new MismatchedIsotopeTransitionsFinder() });

            Assert.AreEqual(4, CountOccurrances(doc, missmatchFinder, displaySettings));
            var docRemoved = (SrmDocument)doc.RemoveChild(doc.Children[1]).RemoveChild(doc.Children[2]);

            Assert.AreEqual(0, CountOccurrances(docRemoved, missmatchFinder, displaySettings));
            var refineRemoveHeavy = new RefinementSettings {
                RefineLabelType = IsotopeLabelType.heavy
            };
            var docLight = refineRemoveHeavy.Refine(doc);

            Assert.AreEqual(0, CountOccurrances(docLight, missmatchFinder, displaySettings));
            var refineRemoveLight = new RefinementSettings {
                RefineLabelType = IsotopeLabelType.light
            };
            var docHeavy = refineRemoveLight.Refine(doc);

            Assert.AreEqual(0, CountOccurrances(docHeavy, missmatchFinder, displaySettings));
            var docMulti = ResultsUtil.DeserializeDocument("MultiLabel.sky", GetType());

            docMulti = (new RefinementSettings()).ConvertToSmallMolecules(docMulti, TestContext.TestDir, asSmallMolecules);
            Assert.AreEqual(0, CountOccurrances(docMulti, missmatchFinder, displaySettings));
            var pathTranMultiRemove = docMulti.GetPathTo((int)SrmDocument.Level.Transitions, 7);
            var tranMultiRemove     = docMulti.FindNode(pathTranMultiRemove);
            var docMultiRemoved     = (SrmDocument)docMulti.RemoveChild(pathTranMultiRemove.Parent, tranMultiRemove);

            Assert.AreEqual(2, CountOccurrances(docMultiRemoved, missmatchFinder, displaySettings));
            var tranGroupMultiRemove = docMulti.FindNode(pathTranMultiRemove.Parent);
            var docMultiGroupRemoved = (SrmDocument)
                                       docMulti.RemoveChild(pathTranMultiRemove.Parent.Parent, tranGroupMultiRemove);

            Assert.AreEqual(0, CountOccurrances(docMultiGroupRemoved, missmatchFinder, displaySettings));
        }
예제 #4
0
        private static void ValidateIrtAndLibrary(SrmDocument docAfter)
        {
            int irtStandardCount = 0;

            foreach (var nodePep in docAfter.Peptides) // We don't expect this to work for non-peptide molecules
            {
                if (nodePep.GlobalStandardType == PeptideDocNode.STANDARD_TYPE_IRT)
                {
                    irtStandardCount++;
                }
                else
                {
                    Assert.IsTrue(nodePep.HasLibInfo);
                    foreach (var nodeTran in nodePep.TransitionGroups.SelectMany(g => g.Transitions))
                    {
                        if (!nodeTran.HasLibInfo)
                        {
                            Assert.Fail("Missing library info from {0} - {1}", nodePep, nodeTran.GetDisplayText(new DisplaySettings(
                                                                                                                    new NormalizedValueCalculator(docAfter),
                                                                                                                    nodePep, false, 0, NormalizeOption.RatioToFirstStandard(docAfter.Settings))));
                        }
                    }
                }
            }
            Assert.AreEqual(10, irtStandardCount);
        }