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
 public GraphDataProperties(ReplicateValue group, NormalizeOption normalizeOption, object annotation, int minimumDetections)
 {
     Group             = group;
     NormalizeOption   = normalizeOption;
     Annotation        = annotation;
     MinimumDetections = minimumDetections;
 }
예제 #3
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = (Group != null ? Group.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ NormalizeOption.GetHashCode();
         hashCode = (hashCode * 397) ^ (Annotation != null ? Annotation.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ MinimumDetections;
         return(hashCode);
     }
 }
예제 #4
0
 public AreaCVRefinementSettings(double cvCutoff, double qValueCutoff, int minimumDetections, NormalizeOption normalizeOption,
                                 AreaCVTransitions transitions, int countTransitions, AreaCVMsLevel msLevel)
 {
     CVCutoff          = cvCutoff;
     QValueCutoff      = qValueCutoff;
     MinimumDetections = minimumDetections;
     NormalizeOption   = normalizeOption;
     MsLevel           = msLevel;
     Transitions       = transitions;
     CountTransitions  = countTransitions;
     Annotation        = null;
     Group             = null;
 }
예제 #5
0
 public AreaCVGraphSettings(GraphTypeSummary graphType, NormalizeOption normalizeOption, ReplicateValue group, object annotation, PointsTypePeakArea pointsType, double qValueCutoff,
                            double cvCutoff, int minimumDetections, double binwidth, AreaCVMsLevel msLevel, AreaCVTransitions transitions, int countTransitions)
 {
     GraphType         = graphType;
     NormalizeOption   = normalizeOption;
     Group             = group;
     Annotation        = annotation;
     PointsType        = pointsType;
     QValueCutoff      = qValueCutoff;
     CVCutoff          = cvCutoff;
     MinimumDetections = minimumDetections;
     BinWidth          = binwidth;
     MsLevel           = msLevel;
     Transitions       = transitions;
     CountTransitions  = countTransitions;
 }
예제 #6
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = MsLevel.GetHashCode();
         hashCode = (hashCode * 397) ^ (int)Transitions;
         hashCode = (hashCode * 397) ^ CountTransitions;
         hashCode = (hashCode * 397) ^ NormalizeOption.GetHashCode();
         hashCode = (hashCode * 397) ^ (Group != null ? Group.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Annotation != null ? Annotation.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (int)PointsType;
         hashCode = (hashCode * 397) ^ QValueCutoff.GetHashCode();
         hashCode = (hashCode * 397) ^ CVCutoff.GetHashCode();
         hashCode = (hashCode * 397) ^ MinimumDetections;
         return(hashCode);
     }
 }
예제 #7
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);
        }
예제 #8
0
        public void OnUpdateGraph()
        {
            // CONSIDER: Need a better guarantee that this ratio index matches the
            //           one in the sequence tree, but at least this will keep the UI
            //           from crashing with IndexOutOfBoundsException.
            var settings = GraphSummary.DocumentUIContainer.DocumentUI.Settings;

            GraphSummary.NormalizeOption = NormalizeOption.Constrain(settings, GraphSummary.NormalizeOption);

            var pane = GraphSummary.GraphPanes.FirstOrDefault();

            switch (GraphSummary.Type)
            {
            case GraphTypeSummary.replicate:
            case GraphTypeSummary.peptide:
                GraphSummary.DoUpdateGraph(this, GraphSummary.Type);
                break;

            case GraphTypeSummary.histogram:
                if (!(pane is AreaCVHistogramGraphPane))
                {
                    GraphSummary.GraphPanes = new[] { new AreaCVHistogramGraphPane(GraphSummary) }
                }
                ;
                break;

            case GraphTypeSummary.histogram2d:
                if (!(pane is AreaCVHistogram2DGraphPane))
                {
                    GraphSummary.GraphPanes = new[] { new AreaCVHistogram2DGraphPane(GraphSummary) }
                }
                ;
                break;
            }

            if (!ReferenceEquals(GraphSummary.GraphPanes.FirstOrDefault(), pane))
            {
                var disposable = pane as IDisposable;
                if (disposable != null)
                {
                    disposable.Dispose();
                }
            }
        }
예제 #9
0
            private IEnumerable <GraphDataProperties> GetPropertyVariants(AreaCVGraphSettings graphSettings)
            {
                SrmDocument document;

                lock (_cacheInfo)
                {
                    document = _cacheInfo.Document;
                }

                var annotationsArray = AnnotationHelper.GetPossibleAnnotations(document, graphSettings.Group);

                // Add an entry for All
                var annotations = annotationsArray.Concat(new string[] { null }).ToList();

                var normalizationMethods = new List <NormalizeOption>(NormalizeOption.AvailableNormalizeOptions(document).Prepend(NormalizeOption.NONE));

                // First cache the histograms for the current annotation
                if (annotations.Remove(graphSettings.Annotation))
                {
                    annotations.Insert(0, graphSettings.Annotation);
                }

                foreach (var n in normalizationMethods)
                {
                    if (n.IsRatioToLabel && !document.Settings.PeptideSettings.Modifications.HasHeavyModifications)
                    {
                        continue;
                    }

                    foreach (var a in annotations)
                    {
                        var minDetections = GetMinDetectionsForAnnotation(document, graphSettings, a);

                        for (var i = 2; i <= minDetections; ++i)
                        {
                            yield return(new GraphDataProperties(graphSettings.Group, n, a, i));
                        }
                    }
                }
            }
예제 #10
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));
        }
예제 #11
0
 public AreaCVGraphData Get(ReplicateValue group, object annotation, int minimumDetections, NormalizeOption normalizeOption)
 {
     lock (_cacheInfo)
     {
         // Linear search, but very short list
         return(_cacheInfo.Data.FirstOrDefault(d => Equals(d._graphSettings.Group, group) &&
                                               Equals(d._graphSettings.Annotation, annotation) &&
                                               d._graphSettings.MinimumDetections ==
                                               minimumDetections &&
                                               d._graphSettings.NormalizeOption == normalizeOption));
     }
 }
예제 #12
0
        // Returns true if a normalizer was added.
        public static bool AddNormalizerIfNeeded(IHostEnvironment env, IChannel ch, ITrainer trainer, ref IDataView view, string featureColumn, NormalizeOption autoNorm)
        {
            Contracts.CheckValue(env, nameof(env));
            env.CheckValue(ch, nameof(ch));
            ch.CheckValue(trainer, nameof(trainer));
            ch.CheckValue(view, nameof(view));
            ch.CheckValueOrNull(featureColumn);
            ch.CheckUserArg(Enum.IsDefined(typeof(NormalizeOption), autoNorm), nameof(TrainCommand.Arguments.NormalizeFeatures),
                            "Normalize option is invalid. Specify one of 'norm=No', 'norm=Warn', 'norm=Auto', or 'norm=Yes'.");

            if (autoNorm == NormalizeOption.No)
            {
                ch.Info("Not adding a normalizer.");
                return(false);
            }

            if (string.IsNullOrEmpty(featureColumn))
            {
                return(false);
            }

            int featCol;
            var schema = view.Schema;

            if (schema.TryGetColumnIndex(featureColumn, out featCol))
            {
                if (autoNorm != NormalizeOption.Yes)
                {
                    var    nn           = trainer as ITrainerEx;
                    DvBool isNormalized = DvBool.False;
                    if (nn == null || !nn.NeedNormalization ||
                        (schema.TryGetMetadata(BoolType.Instance, MetadataUtils.Kinds.IsNormalized, featCol, ref isNormalized) &&
                         isNormalized.IsTrue))
                    {
                        ch.Info("Not adding a normalizer.");
                        return(false);
                    }
                    if (autoNorm == NormalizeOption.Warn)
                    {
                        ch.Warning("A normalizer is needed for this trainer. Either add a normalizing transform or use the 'norm=Auto', 'norm=Yes' or 'norm=No' options.");
                        return(false);
                    }
                }
                ch.Info("Automatically adding a MinMax normalization transform, use 'norm=Warn' or 'norm=No' to turn this behavior off.");
                // Quote the feature column name
                string        quotedFeatureColumnName = featureColumn;
                StringBuilder sb = new StringBuilder();
                if (CmdQuoter.QuoteValue(quotedFeatureColumnName, sb))
                {
                    quotedFeatureColumnName = sb.ToString();
                }
                var component = new SubComponent <IDataTransform, SignatureDataTransform>("MinMax", string.Format("col={{ name={0} source={0} }}", quotedFeatureColumnName));
                var loader    = view as IDataLoader;
                if (loader != null)
                {
                    view = CompositeDataLoader.Create(env, loader,
                                                      new KeyValuePair <string, SubComponent <IDataTransform, SignatureDataTransform> >(null, component));
                }
                else
                {
                    view = component.CreateInstance(env, view);
                }
                return(true);
            }
            return(false);
        }
예제 #13
0
 private static void NormalizeGraphToHeavy()
 {
     AreaGraphController.AreaNormalizeOption = NormalizeOption.FromIsotopeLabelType(IsotopeLabelType.heavy);
     Settings.Default.AreaLogScale           = false;
     SkylineWindow.UpdatePeakAreaGraph();
 }
예제 #14
0
        protected override void DoTest()
        {
            var folderAbsoluteQuant = UseRawFiles ? "AbsoluteQuant" : "AbsoluteQuantMzml";
            // Generating a Transition List, p. 5, 6
            {
                var doc = SkylineWindow.Document;
                var transitionSettingsUI = ShowDialog <TransitionSettingsUI>(SkylineWindow.ShowTransitionSettingsUI);
                RunUI(() =>
                {
                    // Prediction Settings
                    transitionSettingsUI.SelectedTab       = TransitionSettingsUI.TABS.Prediction;
                    transitionSettingsUI.PrecursorMassType = MassType.Monoisotopic;
                    transitionSettingsUI.FragmentMassType  = MassType.Monoisotopic;
                    transitionSettingsUI.RegressionCEName  = "Thermo TSQ Vantage";
                    transitionSettingsUI.RegressionDPName  = Resources.SettingsList_ELEMENT_NONE_None;
                });
                PauseForScreenShot <TransitionSettingsUI.PredictionTab>("Transition Settings - Prediction tab", 5);

                RunUI(() =>
                {
                    // Filter Settings
                    transitionSettingsUI.SelectedTab      = TransitionSettingsUI.TABS.Filter;
                    transitionSettingsUI.PrecursorCharges = "2";
                    transitionSettingsUI.ProductCharges   = "1";
                    transitionSettingsUI.FragmentTypes    = "y";
                    transitionSettingsUI.RangeFrom        = Resources.TransitionFilter_FragmentStartFinders_ion_3;
                    transitionSettingsUI.RangeTo          = Resources.TransitionFilter_FragmentEndFinders_last_ion_minus_1;
                    transitionSettingsUI.SpecialIons      = new string[0];
                });
                PauseForScreenShot <TransitionSettingsUI.FilterTab>("Transition Settings - Filter tab", 6);

                OkDialog(transitionSettingsUI, transitionSettingsUI.OkDialog);
                WaitForDocumentChange(doc);
            }

            // Configuring Peptide settings p. 7, 8
            PeptideSettingsUI peptideSettingsUi = ShowDialog <PeptideSettingsUI>(SkylineWindow.ShowPeptideSettingsUI);

            RunUI(() => peptideSettingsUi.SelectedTab = PeptideSettingsUI.TABS.Modifications);

            var modHeavyK = new StaticMod("Label:13C(6)15N(2) (C-term K)", "K", ModTerminus.C, false, null,
                                          LabelAtoms.C13 | LabelAtoms.N15, RelativeRT.Matching, null, null, null);

            AddHeavyMod(modHeavyK, peptideSettingsUi, "Edit Isotope Modification over Transition Settings", 7);
            RunUI(() => peptideSettingsUi.PickedHeavyMods = new[] { modHeavyK.Name });
            PauseForScreenShot <PeptideSettingsUI.ModificationsTab>("Peptide Settings - Modification tab with mod added", 8);

            OkDialog(peptideSettingsUi, peptideSettingsUi.OkDialog);

            // Inserting a peptide sequence p. 9
            using (new CheckDocumentState(1, 1, 2, 10))
            {
                RunUI(() => SetClipboardText("IEAIPQIDK\tGST-tag"));
                var pasteDlg = ShowDialog <PasteDlg>(SkylineWindow.ShowPastePeptidesDlg);
                RunUI(pasteDlg.PastePeptides);
                WaitForProteinMetadataBackgroundLoaderCompletedUI();
                RunUI(() => pasteDlg.Size = new Size(700, 210));
                PauseForScreenShot <PasteDlg.PeptideListTab>("Insert Peptide List", 9);

                OkDialog(pasteDlg, pasteDlg.OkDialog);
            }

            RunUI(SkylineWindow.ExpandPrecursors);
            RunUI(() => SkylineWindow.SaveDocument(GetTestPath(folderAbsoluteQuant + @"test_file.sky")));
            WaitForCondition(() => File.Exists(GetTestPath(folderAbsoluteQuant + @"test_file.sky")));
            RunUI(() => SkylineWindow.Size = new Size(840, 410));

            PauseForScreenShot("Main window with Targets view", 9);

            // Exporting a transition list p. 10
            {
                var exportMethodDlg = ShowDialog <ExportMethodDlg>(() => SkylineWindow.ShowExportMethodDialog(ExportFileType.List));
                RunUI(() =>
                {
                    exportMethodDlg.InstrumentType = ExportInstrumentType.THERMO;
                    exportMethodDlg.ExportStrategy = ExportStrategy.Single;
                    exportMethodDlg.OptimizeType   = ExportOptimize.NONE;
                    exportMethodDlg.MethodType     = ExportMethodType.Standard;
                });
                PauseForScreenShot <ExportMethodDlg.TransitionListView>("Export Transition List", 10);

                OkDialog(exportMethodDlg, () =>
                         exportMethodDlg.OkDialog(GetTestPath("Quant_Abs_Thermo_TSQ_Vantage.csv")));
            }

            // Importing RAW files into Skyline p. 11, 12
            var importResultsDlg = ShowDialog <ImportResultsDlg>(SkylineWindow.ImportResults);

            PauseForScreenShot <ImportResultsDlg>("Import Results - click OK to get shot of Import Results Files and then cancel", 11);

            RunUI(() =>
            {
                var rawFiles      = DataSourceUtil.GetDataSources(TestFilesDirs[0].FullPath).First().Value.Skip(1);
                var namedPathSets = from rawFile in rawFiles
                                    select new KeyValuePair <string, MsDataFileUri[]>(
                    rawFile.GetFileNameWithoutExtension(), new[] { rawFile });
                importResultsDlg.NamedPathSets = namedPathSets.ToArray();
            });
            RunDlg <ImportResultsNameDlg>(importResultsDlg.OkDialog,
                                          importResultsNameDlg => importResultsNameDlg.NoDialog());

            WaitForGraphs();

            RunUI(() =>
            {
                SkylineWindow.SelectedPath             = SkylineWindow.Document.GetPathTo((int)SrmDocument.Level.Molecules, 0);
                Settings.Default.ArrangeGraphsOrder    = GroupGraphsOrder.Document.ToString();
                Settings.Default.ArrangeGraphsReversed = false;
                SkylineWindow.ArrangeGraphsTiled();
                SkylineWindow.AutoZoomBestPeak();
            });
            WaitForCondition(() => Equals(8, SkylineWindow.GraphChromatograms.Count(graphChrom => !graphChrom.IsHidden)),
                             "unexpected visible graphChromatogram count");

            RunUI(() =>
            {               //resize the window and activate the first standard chromatogram pane.
                RunUI(() => SkylineWindow.Size = new Size(1330, 720));
                var chrom = SkylineWindow.GraphChromatograms.First();
                chrom.Select();
            });

            WaitForCondition(10 * 60 * 1000,    // ten minutes
                             () => SkylineWindow.Document.Settings.HasResults && SkylineWindow.Document.Settings.MeasuredResults.IsLoaded);
            PauseForScreenShot("Main window with imported data", 13);

            // Analyzing SRM Data from FOXN1-GST Sample p. 14
            RunDlg <ImportResultsDlg>(SkylineWindow.ImportResults,
                                      importResultsDlg1 =>
            {
                var rawFiles      = DataSourceUtil.GetDataSources(TestFilesDirs[0].FullPath).First().Value.Take(1);
                var namedPathSets = from rawFile in rawFiles
                                    select new KeyValuePair <string, MsDataFileUri[]>(
                    rawFile.GetFileNameWithoutExtension(), new[] { rawFile });
                importResultsDlg1.NamedPathSets = namedPathSets.ToArray();
                importResultsDlg1.OkDialog();
            });
            WaitForGraphs();
            CheckReportCompatibility.CheckAll(SkylineWindow.Document);
            WaitForCondition(5 * 60 * 1000, // five minutes
                             () =>
                             SkylineWindow.Document.Settings.HasResults &&
                             SkylineWindow.Document.Settings.MeasuredResults.IsLoaded);

            RunUI(() =>
            {
                SkylineWindow.ToggleIntegrateAll();
                SkylineWindow.ArrangeGraphsTabbed();
                SkylineWindow.ShowRTReplicateGraph();
                SkylineWindow.ShowPeakAreaReplicateComparison();
                // Total normalization
                SkylineWindow.NormalizeAreaGraphTo(NormalizeOption.TOTAL);
            });

            RunUI(() => SkylineWindow.ActivateReplicate("FOXN1-GST"));
            WaitForGraphs();
            RunUI(() => SkylineWindow.SelectedPath = SkylineWindow.DocumentUI.GetPathTo((int)SrmDocument.Level.TransitionGroups, 0));
            WaitForGraphs();
            RunUI(() =>
            {
                Assert.AreEqual(SkylineWindow.SelectedResultsIndex, SkylineWindow.GraphPeakArea.ResultsIndex);
                Assert.AreEqual(SkylineWindow.SelectedResultsIndex, SkylineWindow.GraphRetentionTime.ResultsIndex);
            });

            RunUI(() =>
            {
                int transitionCount = SkylineWindow.DocumentUI.PeptideTransitionGroups.First().TransitionCount;
                CheckGstGraphs(transitionCount, transitionCount);
            });
            RunUI(() => SkylineWindow.Size = new Size(1470, 656));
            RestoreViewOnScreen(14);
            PauseForScreenShot("Main window with Peak Areas, Retention Times and FOXN1-GST for light", 14);

            RunUI(() => SkylineWindow.SelectedPath = SkylineWindow.DocumentUI.GetPathTo((int)SrmDocument.Level.TransitionGroups, 1));
            WaitForGraphs();

            RunUI(() =>
            {
                int transitionCount = SkylineWindow.DocumentUI.PeptideTransitionGroups.ToArray()[1].TransitionCount;
                CheckGstGraphs(transitionCount, transitionCount);
            });
            PauseForScreenShot("Main window with Peak Areas, Retention Times and FOXN1-GST for heavy", 14);

            RunUI(() => SkylineWindow.SelectedPath = SkylineWindow.DocumentUI.GetPathTo((int)SrmDocument.Level.Molecules, 0));
            WaitForGraphs();
            // Heavy normalization
            RunUI(() => SkylineWindow.NormalizeAreaGraphTo(NormalizeOption.FromIsotopeLabelType(IsotopeLabelType.heavy)));
            WaitForGraphs();
            RunUI(() =>
            {
                int transitionGroupCount = SkylineWindow.DocumentUI.Peptides.First().TransitionGroupCount;
                CheckGstGraphs(transitionGroupCount, transitionGroupCount - 1);
            });
            PauseForScreenShot("Main window with totals graphs for light and heavy and FOXN1-GST", 15);

            // Peptide Quantitification Settings p. 16
            peptideSettingsUi = ShowDialog <PeptideSettingsUI>(SkylineWindow.ShowPeptideSettingsUI);
            RunUI(() => peptideSettingsUi.SelectedTab = (PeptideSettingsUI.TABS) 5);
            const string quantUnits = "fmol/ul";

            RunUI(() =>
            {
                peptideSettingsUi.QuantRegressionFit       = RegressionFit.LINEAR;
                peptideSettingsUi.QuantNormalizationMethod = new NormalizationMethod.RatioToLabel(IsotopeLabelType.heavy);
                peptideSettingsUi.QuantUnits = quantUnits;
            });
            PauseForScreenShot("Peptide Settings Quantification Tab", 16);
            OkDialog(peptideSettingsUi, peptideSettingsUi.OkDialog);

            // Specify analyte concentrations of external standards
            var documentGridForm = ShowDialog <DocumentGridForm>(() => SkylineWindow.ShowDocumentGrid(true));

            RunUI(() =>
            {
                documentGridForm.ChooseView(Resources.SkylineViewContext_GetDocumentGridRowSources_Replicates);
            });
            WaitForConditionUI(() => documentGridForm.IsComplete);
            var concentrations = new[] { 40, 12.5, 5, 2.5, 1, .5, .25, .1 };

            for (int iRow = 0; iRow < concentrations.Length; iRow++)
            {
                // ReSharper disable AccessToModifiedClosure
                RunUI(() =>
                {
                    var colSampleType = documentGridForm.FindColumn(PropertyPath.Root.Property("SampleType"));
                    documentGridForm.DataGridView.Rows[iRow].Cells[colSampleType.Index].Value = SampleType.STANDARD;
                });
                WaitForConditionUI(() => documentGridForm.IsComplete);
                RunUI(() =>
                {
                    var colAnalyteConcentration =
                        documentGridForm.FindColumn(PropertyPath.Root.Property("AnalyteConcentration"));
                    var cell = documentGridForm.DataGridView.Rows[iRow].Cells[colAnalyteConcentration.Index];
                    documentGridForm.DataGridView.CurrentCell = cell;
                    cell.Value = concentrations[iRow];
                });
                // ReSharper restore AccessToModifiedClosure
                WaitForConditionUI(() => documentGridForm.IsComplete);
            }

            if (IsPauseForScreenShots)
            {
                RunUI(() =>
                {
                    SkylineWindow.Width     = 500;
                    var gridFloatingWindow  = documentGridForm.Parent.Parent;
                    gridFloatingWindow.Size = new Size(370, 315);
                    gridFloatingWindow.Top  = SkylineWindow.Top;
                    gridFloatingWindow.Left = SkylineWindow.Right + 20;
                });
                PauseForScreenShot("Document grid with concentrations filled in", 17);
            }

            // View the calibration curve p. 18
            RunUI(() => SkylineWindow.ShowDocumentGrid(false));

            if (IsCoverShotMode)
            {
                RunUI(() =>
                {
                    Settings.Default.ChromatogramFontSize = 14;
                    Settings.Default.AreaFontSize         = 14;
                    SkylineWindow.ChangeTextSize(TreeViewMS.LRG_TEXT_FACTOR);
                    SkylineWindow.ShowPeakAreaLegend(false);
                    SkylineWindow.ShowRTLegend(false);
                });
                RestoreCoverViewOnScreen();
                RunUI(() =>
                {
                    var calibrationOpenForm        = WaitForOpenForm <CalibrationForm>();
                    var calibrationFloatingWindow  = calibrationOpenForm.Parent.Parent;
                    calibrationFloatingWindow.Top  = SkylineWindow.Bottom - calibrationFloatingWindow.Height - 35;
                    calibrationFloatingWindow.Left = SkylineWindow.Left + 15;
                });
                TakeCoverShot();
                return;
            }

            var calibrationForm = ShowDialog <CalibrationForm>(() => SkylineWindow.ShowCalibrationForm());

            if (IsPauseForScreenShots)
            {
                RunUI(() =>
                {
                    var calibrationFloatingWindow   = calibrationForm.Parent.Parent;
                    calibrationFloatingWindow.Width = 565;
                    calibrationFloatingWindow.Top   = SkylineWindow.Top;
                    calibrationFloatingWindow.Left  = SkylineWindow.Right + 20;
                });
                PauseForScreenShot("View calibration curve", 18);
            }

            Assert.AreEqual(CalibrationCurveFitter.AppendUnits(QuantificationStrings.Analyte_Concentration, quantUnits), calibrationForm.ZedGraphControl.GraphPane.XAxis.Title.Text);
            Assert.AreEqual(string.Format(QuantificationStrings.CalibrationCurveFitter_PeakAreaRatioText__0___1__Peak_Area_Ratio, IsotopeLabelType.light.Title, IsotopeLabelType.heavy.Title),
                            calibrationForm.ZedGraphControl.GraphPane.YAxis.Title.Text);
        }
예제 #15
0
        public RefineDlg(IDocumentUIContainer documentContainer)
        {
            _document         = documentContainer.DocumentUI;
            _settings         = documentContainer.DocumentUI.Settings;
            DocumentContainer = documentContainer;

            InitializeComponent();

            Icon = Resources.Skyline;

            // Save text for later use
            _removeLabelText = labelLabelType.Text;
            _removeTipText   = helpTip.GetToolTip(comboRefineLabelType);

            // Fill label type comb_o box
            comboRefineLabelType.Items.Add(string.Empty);
            comboRefineLabelType.Items.Add(IsotopeLabelType.LIGHT_NAME);
            foreach (var typedMods in _settings.PeptideSettings.Modifications.GetHeavyModifications())
            {
                comboRefineLabelType.Items.Add(typedMods.LabelType.Name);
            }
            comboRefineLabelType.SelectedIndex = 0;
            comboReplicateUse.SelectedIndex    = 0;

            if (!_settings.HasResults)
            {
                FormUtil.RemoveTabPage(tabResults, helpTip);
            }

            if (!_settings.HasResults || _settings.MeasuredResults.Chromatograms.Count < 2)
            {
                FormUtil.RemoveTabPage(tabConsistency, helpTip);
            }
            else
            {
                // Consistency tab
                textQVal.Enabled = _settings.PeptideSettings.Integration.PeakScoringModel.IsTrained;
                numericUpDownDetections.Enabled = textQVal.Enabled;
                if (numericUpDownDetections.Enabled)
                {
                    numericUpDownDetections.Minimum = 1;
                    numericUpDownDetections.Maximum = _document.MeasuredResults.Chromatograms.Count;
                    numericUpDownDetections.Value   = 1;
                }

                _normalizationMethods.Clear();
                _normalizationMethods.Add(NormalizeOption.DEFAULT);
                _normalizationMethods.AddRange(NormalizeOption.AvailableNormalizeOptions(_document));
                _normalizationMethods.Add(NormalizeOption.NONE);
                comboNormalizeTo.Items.Clear();
                comboNormalizeTo.Items.AddRange(_normalizationMethods.Select(option => option.Caption).ToArray());
                comboNormalizeTo.SelectedIndex = comboNormalizeTo.Items.Count - 1;

                comboTransitions.Items.Add(Resources.RefineDlg_RefineDlg_all);
                comboTransitions.Items.Add(Resources.RefineDlg_RefineDlg_best);
                comboTransitions.SelectedIndex = 0;

                var maxTrans = _document.MoleculeTransitionGroups.Select(g => g.TransitionCount).DefaultIfEmpty().Max();
                for (int i = 1; i <= maxTrans; i++)
                {
                    comboTransitions.Items.Add(i);
                }

                if (_document.MoleculeTransitions.Any(t => t.IsMs1))
                {
                    comboTransType.Items.Add(Resources.RefineDlg_RefineDlg_Precursors);
                    comboTransType.SelectedIndex = comboTransType.Items.Count - 1;
                }

                if (_document.MoleculeTransitions.Any(t => !t.IsMs1))
                {
                    comboTransType.Items.Add(Resources.RefineDlg_RefineDlg_Products);
                    comboTransType.SelectedIndex = comboTransType.Items.Count - 1;
                }

                if (comboTransType.Items.Count == 1)
                {
                    comboTransType.Enabled = false;
                }
            }

            if (_settings.PeptideSettings.Libraries.HasLibraries)
            {
                labelMinDotProduct.Enabled = textMinDotProduct.Enabled = groupLibCorr.Enabled = true;
            }
            if (_settings.TransitionSettings.FullScan.IsHighResPrecursor)
            {
                labelMinIdotProduct.Enabled = textMinIdotProduct.Enabled = groupLibCorr.Enabled = true;
            }

            // Group Comparisons
            _groupComparisonsListBoxDriver = new SettingsListBoxDriver <GroupComparisonDef>(
                checkedListBoxGroupComparisons, Settings.Default.GroupComparisonDefList);
            _groupComparisonsListBoxDriver.LoadList(
                _document.Settings.DataSettings.GroupComparisonDefs);

            if (_document.PeptideTransitions.Any(t => t.IsMs1))
            {
                comboMSGroupComparisons.Items.Add(Resources.RefineDlg_MSLevel_1);
                comboMSGroupComparisons.SelectedIndex = comboMSGroupComparisons.Items.Count - 1;
            }

            if (_document.PeptideTransitions.Any(t => !t.IsMs1))
            {
                comboMSGroupComparisons.Items.Add(Resources.RefineDlg_MSLevel_2);
                comboMSGroupComparisons.SelectedIndex = comboMSGroupComparisons.Items.Count - 1;
            }

            if (comboMSGroupComparisons.Items.Count == 1)
            {
                comboMSGroupComparisons.Enabled = false;
            }
        }
예제 #16
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);
        }
예제 #17
0
        public override void UpdateUI()
        {
            var document = _graphSummary.DocumentUIContainer.DocumentUI;

            if (!document.Settings.HasResults)
            {
                return;
            }

            var groupsVisible = AreaGraphController.GroupByGroup != null;

            toolStripLabel1.Visible = toolStripComboGroup.Visible = groupsVisible;

            var detectionsVisiblePrev = toolStripLabel2.Visible && toolStripNumericDetections.Visible && toolStripLabel3.Visible;
            var detectionsVisible     = AreaGraphController.ShouldUseQValues(document);

            toolStripLabel2.Visible = toolStripNumericDetections.Visible = toolStripLabel3.Visible = detectionsVisible;

            if (detectionsVisible)
            {
                toolStripNumericDetections.NumericUpDownControl.Minimum = 2;

                if (AreaGraphController.GroupByGroup == null || AreaGraphController.GroupByAnnotation == null)
                {
                    toolStripNumericDetections.NumericUpDownControl.Maximum = document.MeasuredResults.Chromatograms.Count;
                }
                else
                {
                    toolStripNumericDetections.NumericUpDownControl.Maximum = AnnotationHelper.GetReplicateIndices(document, ReplicateValue.FromPersistedString(document.Settings, AreaGraphController.GroupByGroup), AreaGraphController.GroupByAnnotation).Length;
                }

                if (!detectionsVisiblePrev)
                {
                    toolStripNumericDetections.NumericUpDownControl.Value = 2;
                }
            }

            if (groupsVisible)
            {
                var annotations = new[] { Resources.GraphSummary_UpdateToolbar_All }.Concat(
                    AnnotationHelper.GetPossibleAnnotations(document,
                                                            ReplicateValue.FromPersistedString(document.Settings, AreaGraphController.GroupByGroup))
                    .Except(new object[] { null })).ToArray();

                toolStripComboGroup.Items.Clear();
                // ReSharper disable once CoVariantArrayConversion
                toolStripComboGroup.Items.AddRange(annotations);

                if (AreaGraphController.GroupByAnnotation != null)
                {
                    toolStripComboGroup.SelectedItem = AreaGraphController.GroupByAnnotation;
                }
                else
                {
                    toolStripComboGroup.SelectedIndex = 0;
                }
                ComboHelper.AutoSizeDropDown(toolStripComboGroup);
            }

            toolStripComboNormalizedTo.Items.Clear();
            _normalizationMethods.Clear();
            _normalizationMethods.Add(NormalizeOption.DEFAULT);
            _normalizationMethods.AddRange(NormalizeOption.AvailableNormalizeOptions(_graphSummary.DocumentUIContainer.DocumentUI));
            _normalizationMethods.Add(NormalizeOption.NONE);
            toolStripComboNormalizedTo.Items.AddRange(_normalizationMethods.Select(item => item.Caption).ToArray());
            toolStripComboNormalizedTo.SelectedIndex = _normalizationMethods.IndexOf(AreaGraphController.AreaCVNormalizeOption);
            ComboHelper.AutoSizeDropDown(toolStripComboNormalizedTo);
        }
예제 #18
0
 /// <summary>
 /// Normalizes datetime.
 /// </summary>
 /// <param name="dateTime"><see cref="DateTime"/>.</param>
 /// <param name="baseSpan"><see cref="TimeSpan"/> for normalization base.It will be better to use multiples or divisors of 60 secs, 60 mins.</param>
 /// <param name="option"><see cref="NormalizeOption.Future"/> for nomalized future date.<see cref="NormalizeOption.Past"/> for normalized past date.</param>
 /// <returns>Normalized <see cref="DateTime"/>.</returns>
 public static DateTime Normalize(DateTime dateTime, TimeSpan baseSpan, NormalizeOption option = NormalizeOption.Future)
 {
     return(Normalize(dateTime, baseSpan, TimeSpan.Zero, option));
 }
예제 #19
0
        // Returns true if a normalizer was added.
        public static bool AddNormalizerIfNeeded(IHostEnvironment env, IChannel ch, ITrainer trainer, ref IDataView view, string featureColumn, NormalizeOption autoNorm)
        {
            Contracts.CheckValue(env, nameof(env));
            env.CheckValue(ch, nameof(ch));
            ch.CheckValue(trainer, nameof(trainer));
            ch.CheckValue(view, nameof(view));
            ch.CheckValueOrNull(featureColumn);
            ch.CheckUserArg(Enum.IsDefined(typeof(NormalizeOption), autoNorm), nameof(TrainCommand.Arguments.NormalizeFeatures),
                            "Normalize option is invalid. Specify one of 'norm=No', 'norm=Warn', 'norm=Auto', or 'norm=Yes'.");

            if (autoNorm == NormalizeOption.No)
            {
                ch.Info("Not adding a normalizer.");
                return(false);
            }

            if (string.IsNullOrEmpty(featureColumn))
            {
                return(false);
            }

            int featCol;
            var schema = view.Schema;

            if (schema.TryGetColumnIndex(featureColumn, out featCol))
            {
                if (autoNorm != NormalizeOption.Yes)
                {
                    if (!trainer.Info.NeedNormalization || schema.IsNormalized(featCol))
                    {
                        ch.Info("Not adding a normalizer.");
                        return(false);
                    }
                    if (autoNorm == NormalizeOption.Warn)
                    {
                        ch.Warning("A normalizer is needed for this trainer. Either add a normalizing transform or use the 'norm=Auto', 'norm=Yes' or 'norm=No' options.");
                        return(false);
                    }
                }
                ch.Info("Automatically adding a MinMax normalization transform, use 'norm=Warn' or 'norm=No' to turn this behavior off.");
                IDataView ApplyNormalizer(IHostEnvironment innerEnv, IDataView input)
                => NormalizeTransform.CreateMinMaxNormalizer(innerEnv, input, featureColumn);

                if (view is IDataLoader loader)
                {
                    view = CompositeDataLoader.ApplyTransform(env, loader, tag: null, creationArgs: null, ApplyNormalizer);
                }
                else
                {
                    view = ApplyNormalizer(env, view);
                }
                return(true);
            }
            return(false);
        }
예제 #20
0
        /// <summary>
        /// Normalizes datetime.
        /// </summary>
        /// <param name="dateTime"><see cref="DateTime"/>.</param>
        /// <param name="baseSpan"><see cref="TimeSpan"/> for normalization base.It will be better to use multiples or divisors of 60 secs, 60 mins.</param>
        /// <param name="minDiff">The minimal difference between source datetime and normalized datetime.</param>
        /// <param name="option"><see cref="NormalizeOption.Future"/> for nomalized future date.<see cref="NormalizeOption.Past"/> for normalized past date.</param>
        /// <returns>Normalized <see cref="DateTime"/>.</returns>
        public static DateTime Normalize(DateTime dateTime, TimeSpan baseSpan, TimeSpan minDiff, NormalizeOption option = NormalizeOption.Future)
        {
            long baseSpanTicks = baseSpan.Ticks;
            long minDiffTicks  = minDiff.Ticks;

            if (baseSpanTicks <= 0)
            {
                throw new ArgumentOutOfRangeException("baseSpan", ResourceMessage.ErrorMessages.BaseSpanLessThanOrEqualsZero);
            }

            if (minDiffTicks < 0)
            {
                throw new ArgumentOutOfRangeException("minDiff", ResourceMessage.ErrorMessages.MinDiffLessThanZero);
            }

            long ticks     = dateTime.Ticks;
            long direction = 1L;
            long addition  = baseSpanTicks;

            if (option == NormalizeOption.Past)
            {
                if (DateTime.MinValue.Ticks + minDiffTicks > ticks)
                {
                    throw new ArgumentOutOfRangeException("minDiff", ResourceMessage.ErrorMessages.MinDiffTooLarge);
                }

                direction = -1L;
                addition  = 0L;
            }
            else
            {
                if (DateTime.MaxValue.Ticks - minDiffTicks < ticks)
                {
                    throw new ArgumentOutOfRangeException("minDiff", ResourceMessage.ErrorMessages.MinDiffTooLarge);
                }
            }

            ticks = (((ticks + (minDiffTicks * direction)) / baseSpanTicks) * baseSpanTicks);

            if (DateTime.MaxValue.Ticks - addition < ticks)
            {
                throw new ArgumentOutOfRangeException("minDiff", ResourceMessage.ErrorMessages.MinDiffTooLarge);
            }

            return(new DateTime((ticks + addition), dateTime.Kind));
        }