From 362f4b6395b9432ee65c3aa5ce438a6e618dcd39 Mon Sep 17 00:00:00 2001 From: Brian Pratt Date: Mon, 2 Oct 2023 20:33:01 -0700 Subject: [PATCH] Fix for Issue 967: Create matching small molecule versions of all standard peptide reports in Document Grid (#2693) Our change to remove peptide-only features in small molecule UI mode resulted in the loss of some useful reports. There is currently no equivalent to: "Peptide RT Results", which has headers: Peptide,Protein,Replicate,Predicted Retention Time,Peptide Retention Time,Peptide Peak Found Ratio and "Transition Results", which has headers: Peptide,Protein,Replicate,Precursor Mz,Precursor Charge,Product Mz,Product Charge,Fragment Ion,Retention Time,Area,Background,Peak Rank Reported by several users including Thomas Eichmann --- pwiz_tools/Skyline/Model/PersistedViews.cs | 42 ++++++++++++++++++- .../Skyline/Properties/Resources.Designer.cs | 18 ++++++++ pwiz_tools/Skyline/Properties/Resources.resx | 6 +++ .../SmallMoleculesDocumentGridTest.cs | 36 ++++++++++++++-- .../TestUtil/AbstractFunctionalTestEx.cs | 12 +++++- 5 files changed, 107 insertions(+), 7 deletions(-) diff --git a/pwiz_tools/Skyline/Model/PersistedViews.cs b/pwiz_tools/Skyline/Model/PersistedViews.cs index b76fe9df52..e60e1851b0 100644 --- a/pwiz_tools/Skyline/Model/PersistedViews.cs +++ b/pwiz_tools/Skyline/Model/PersistedViews.cs @@ -130,7 +130,9 @@ private PersistedViews() } public int RevisionIndex { get; private set; } - public int RevisionIndexCurrent { get { return 12; } } // v12 adds small mol peak boundaries report + // v12 adds small mol peak boundaries report + // v13 adds small mol transitions report and small mol RT Results report + public int RevisionIndexCurrent { get { return 13; } } public override void ReadXml(XmlReader reader) { RevisionIndex = reader.GetIntAttribute(Attr.revision); @@ -194,6 +196,11 @@ public IEnumerable> GetDefaults(int revision reportStrings.Add(REPORTS_V12); // Including molecule peak boundaries export } + if (revisionIndex >= 13) + { + reportStrings.Add(REPORTS_V13); // Including molecule RT results and molecule transitions result report + } + var list = new List>(); var xmlSerializer = new XmlSerializer(typeof(ViewSpecList)); foreach (var reportString in reportStrings) @@ -212,6 +219,8 @@ public IEnumerable> GetDefaults(int revision {"Small Molecule Transition List", MainGroup.Id.ViewName(Resources.SkylineViewContext_GetTransitionListReportSpec_Small_Molecule_Transition_List)}, {"Molecule Quantification", MainGroup.Id.ViewName(Resources.PersistedViews_GetDefaults_Molecule_Quantification)}, {"Molecule Ratio Results", MainGroup.Id.ViewName(Resources.PersistedViews_GetDefaults_Molecule_Ratio_Results)}, + {"Molecule RT Results", MainGroup.Id.ViewName(Resources.ReportSpecList_GetDefaults_Molecule_RT_Results)}, + {"Molecule Transition Results", MainGroup.Id.ViewName(Resources.ReportSpecList_GetDefaults_Molecule_Transition_Results)}, {"SRM Collider Input", ExternalToolsGroup.Id.ViewName("SRM Collider Input")}, }; // ReSharper restore LocalizableElement @@ -503,6 +512,37 @@ private List> RemoveDuplicates( "; + private const string REPORTS_V13 = @" + + + + + + + + + + + + + + + + + + + + + + + + + + +"; + + + // ReSharper restore LocalizableElement #region XML Serialization diff --git a/pwiz_tools/Skyline/Properties/Resources.Designer.cs b/pwiz_tools/Skyline/Properties/Resources.Designer.cs index f7660bd44c..458c56a4d5 100644 --- a/pwiz_tools/Skyline/Properties/Resources.Designer.cs +++ b/pwiz_tools/Skyline/Properties/Resources.Designer.cs @@ -26588,6 +26588,24 @@ public static string ReportSpecList_GetDefaults_Molecule_Peak_Boundaries { } } + /// + /// Looks up a localized string similar to Molecule RT Results. + /// + public static string ReportSpecList_GetDefaults_Molecule_RT_Results { + get { + return ResourceManager.GetString("ReportSpecList_GetDefaults_Molecule_RT_Results", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Molecule Transition Results. + /// + public static string ReportSpecList_GetDefaults_Molecule_Transition_Results { + get { + return ResourceManager.GetString("ReportSpecList_GetDefaults_Molecule_Transition_Results", resourceCulture); + } + } + /// /// Looks up a localized string similar to Peak Boundaries. /// diff --git a/pwiz_tools/Skyline/Properties/Resources.resx b/pwiz_tools/Skyline/Properties/Resources.resx index 74d7bba336..b21936e004 100644 --- a/pwiz_tools/Skyline/Properties/Resources.resx +++ b/pwiz_tools/Skyline/Properties/Resources.resx @@ -2568,6 +2568,12 @@ Are you sure you want to continue? Peptide RT Results + + Molecule RT Results + + + Molecule Transition Results + {0} cannot be empty. diff --git a/pwiz_tools/Skyline/TestFunctional/SmallMoleculesDocumentGridTest.cs b/pwiz_tools/Skyline/TestFunctional/SmallMoleculesDocumentGridTest.cs index f65fb82c5c..13bb296167 100644 --- a/pwiz_tools/Skyline/TestFunctional/SmallMoleculesDocumentGridTest.cs +++ b/pwiz_tools/Skyline/TestFunctional/SmallMoleculesDocumentGridTest.cs @@ -33,7 +33,7 @@ public class SmallMoleculesDocumentGridTest : AbstractFunctionalTestEx [TestMethod] public void TestSmallMoleculesDocumentGrid() { - TestFilesZip = @"TestFunctional\SmallMoleculesDocumentGrid.zip"; + TestFilesZipPaths = new [] { @"TestFunctional\SmallMoleculesDocumentGrid.zip", @"TestFunctional\SmallMoleculeIrtTest.zip"} ; RunFunctionalTest(); } @@ -42,6 +42,7 @@ public void TestSmallMoleculesDocumentGrid() /// protected override void DoTest() { + TestSmallMoleculeResultsDoc(); TestMixedDoc(); TestPeptideOnlyDoc(); TestSmallMoleculeOnlyDoc(); @@ -82,7 +83,21 @@ private void TestSmallMoleculeOnlyDoc() CheckDocumentGridAndColumns(smallMoleculeSky, Resources.SkylineViewContext_GetDocumentGridRowSources_Molecules, 1, 10, SrmDocument.DOCUMENT_TYPE.small_molecules); + } + private void TestSmallMoleculeResultsDoc() + { + const string smallMoleculeSky = "DextranLadder.sky"; + CheckDocumentGridAndColumns(smallMoleculeSky, + Resources.ReportSpecList_GetDefaults_Molecule_RT_Results, + 113, 6, SrmDocument.DOCUMENT_TYPE.small_molecules, + null, null, null, null, null, + 14.64); + CheckDocumentGridAndColumns(smallMoleculeSky, + Resources.ReportSpecList_GetDefaults_Molecule_Transition_Results, + 113, 14, SrmDocument.DOCUMENT_TYPE.small_molecules, + null, null, null, null, null, + 14.64); } private void TestPeptideOnlyDoc() @@ -111,7 +126,8 @@ private void CheckDocumentGridAndColumns(string docName, string expectedFragmentIon = null, string expectedMolecularFormula = null, string expectedPrecursorNeutralFormula = null, - string expectedPrecursorIonFormula = null) + string expectedPrecursorIonFormula = null, + double? expectedRT = null) { var oldDoc = SkylineWindow.Document; OpenDocument(docName); @@ -133,6 +149,7 @@ private void CheckDocumentGridAndColumns(string docName, var colProductIonFormula = documentGrid.FindColumn(PropertyPath.Parse("ProductIonFormula")); var colProductNeutralFormula = documentGrid.FindColumn(PropertyPath.Parse("ProductNeutralFormula")); var colProductAdduct = documentGrid.FindColumn(PropertyPath.Parse("ProductAdduct")); + var colProductCharge = documentGrid.FindColumn(PropertyPath.Parse("ProductCharge")); var colFragmentIon = documentGrid.FindColumn(PropertyPath.Parse("FragmentIonType")); var colMoleculeFormula = documentGrid.FindColumn(PropertyPath.Parse("Precursor.Peptide.MoleculeFormula")); var colPrecursorNeutralFormula = documentGrid.FindColumn(PropertyPath.Parse("Precursor.NeutralFormula")); @@ -141,15 +158,16 @@ private void CheckDocumentGridAndColumns(string docName, { Assert.IsNull(colProductIonFormula); Assert.IsNull(colProductNeutralFormula); - Assert.IsNull(colProductAdduct); } else RunUI(() => { var formula = documentGrid.DataGridView.Rows[0].Cells[colProductIonFormula.Index].Value.ToString(); + var adduct = documentGrid.DataGridView.Rows[0].Cells[colProductAdduct.Index].Value.ToString(); + var z = documentGrid.DataGridView.Rows[0].Cells[colProductCharge.Index].Value; + Assert.AreEqual(z, Adduct.FromString(adduct, Adduct.ADDUCT_TYPE.non_proteomic, null).AdductCharge); if (expectedProductIonFormula.Contains("[")) { var formulaNeutral = documentGrid.DataGridView.Rows[0].Cells[colProductNeutralFormula.Index].Value.ToString(); - var adduct = documentGrid.DataGridView.Rows[0].Cells[colProductAdduct.Index].Value.ToString(); Assert.AreEqual(expectedProductIonFormula, formulaNeutral+adduct); } else @@ -170,6 +188,16 @@ private void CheckDocumentGridAndColumns(string docName, var frag = documentGrid.DataGridView.Rows[0].Cells[colFragmentIon.Index].Value.ToString(); Assert.AreEqual(expectedFragmentIon, frag); }); + if (expectedRT.HasValue) + { + var colRT = documentGrid.FindColumn(PropertyPath.Parse("Results!*.Value.PeptideRetentionTime")) ?? + documentGrid.FindColumn(PropertyPath.Parse("Results!*.Value.RetentionTime")); + RunUI(() => + { + Assert.AreEqual(expectedRT.Value, + (double)documentGrid.DataGridView.Rows[0].Cells[colRT.Index].Value, .001); + }); + } RunUI(() => documentGrid.Close()); } diff --git a/pwiz_tools/Skyline/TestUtil/AbstractFunctionalTestEx.cs b/pwiz_tools/Skyline/TestUtil/AbstractFunctionalTestEx.cs index 023ba062bf..0b75813a27 100644 --- a/pwiz_tools/Skyline/TestUtil/AbstractFunctionalTestEx.cs +++ b/pwiz_tools/Skyline/TestUtil/AbstractFunctionalTestEx.cs @@ -71,8 +71,16 @@ public void Run(string zipFile = null) /// File path of document public void OpenDocument(string documentPath) { - var documentFile = TestFilesDir.GetTestPath(documentPath); - WaitForCondition(() => File.Exists(documentFile)); + string documentFile = null; + foreach (var testFileDir in TestFilesDirs) + { + documentFile = testFileDir.GetTestPath(documentPath); + if (File.Exists(documentFile)) + { + break; + } + } + if (documentPath.EndsWith(@".zip", true, CultureInfo.InvariantCulture)) { RunUI(() => SkylineWindow.OpenSharedFile(documentFile));