Skip to content

Commit

Permalink
Fix for Issue 967: Create matching small molecule versions of all sta…
Browse files Browse the repository at this point in the history
…ndard 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
  • Loading branch information
bspratt committed Oct 3, 2023
1 parent 6055531 commit 362f4b6
Show file tree
Hide file tree
Showing 5 changed files with 107 additions and 7 deletions.
42 changes: 41 additions & 1 deletion pwiz_tools/Skyline/Model/PersistedViews.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -194,6 +196,11 @@ public IEnumerable<KeyValuePair<ViewGroupId, ViewSpec>> 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<KeyValuePair<ViewGroupId, ViewSpec>>();
var xmlSerializer = new XmlSerializer(typeof(ViewSpecList));
foreach (var reportString in reportStrings)
Expand All @@ -212,6 +219,8 @@ public IEnumerable<KeyValuePair<ViewGroupId, ViewSpec>> 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
Expand Down Expand Up @@ -503,6 +512,37 @@ private List<KeyValuePair<ViewGroupId, ViewSpec>> RemoveDuplicates(
</view>
</views>";

private const string REPORTS_V13 = @"<views>
<view name='Molecule RT Results' rowsource='pwiz.Skyline.Model.Databinding.Entities.Peptide' sublist='Results!*' uimode='small_molecules'>
<column name='' />
<column name='Protein.Name' />
<column name='Results!*.Value.ResultFile.Replicate.Name' />
<column name='PredictedRetentionTime' />
<column name='Results!*.Value.PeptideRetentionTime' />
<column name='Results!*.Value.PeptidePeakFoundRatio' />
<filter column='Results!*.Value' opname='isnotnullorblank' />
</view>
<view name='Molecule Transition Results' rowsource='pwiz.Skyline.Model.Databinding.Entities.Transition' sublist='Results!*' uimode='small_molecules'>
<column name='Precursor.Peptide' />
<column name='Precursor.Peptide.Protein.Name' />
<column name='Results!*.Value.PrecursorResult.PeptideResult.ResultFile.Replicate.Name' />
<column name='Precursor.Mz' />
<column name='Precursor.Adduct' />
<column name='Precursor.Charge' />
<column name='FragmentIon' />
<column name='ProductMz' />
<column name='ProductAdduct' />
<column name='ProductCharge' />
<column name='Results!*.Value.RetentionTime' />
<column name='Results!*.Value.Area' />
<column name='Results!*.Value.Background' />
<column name='Results!*.Value.PeakRank' />
<filter column='Results!*.Value' opname='isnotnullorblank' />
</view>
</views>";



// ReSharper restore LocalizableElement

#region XML Serialization
Expand Down
18 changes: 18 additions & 0 deletions pwiz_tools/Skyline/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions pwiz_tools/Skyline/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -2568,6 +2568,12 @@ Are you sure you want to continue?</value>
<data name="ReportSpecList_GetDefaults_Peptide_RT_Results" xml:space="preserve">
<value>Peptide RT Results</value>
</data>
<data name="ReportSpecList_GetDefaults_Molecule_RT_Results" xml:space="preserve">
<value>Molecule RT Results</value>
</data>
<data name="ReportSpecList_GetDefaults_Molecule_Transition_Results" xml:space="preserve">
<value>Molecule Transition Results</value>
</data>
<data name="MessageBoxHelper_ValidateNameTextBox__0__cannot_be_empty" xml:space="preserve">
<value>{0} cannot be empty.</value>
</data>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand All @@ -42,6 +42,7 @@ public void TestSmallMoleculesDocumentGrid()
/// </summary>
protected override void DoTest()
{
TestSmallMoleculeResultsDoc();
TestMixedDoc();
TestPeptideOnlyDoc();
TestSmallMoleculeOnlyDoc();
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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);
Expand All @@ -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"));
Expand All @@ -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
Expand All @@ -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());
}

Expand Down
12 changes: 10 additions & 2 deletions pwiz_tools/Skyline/TestUtil/AbstractFunctionalTestEx.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,16 @@ public void Run(string zipFile = null)
/// <param name="documentPath">File path of document</param>
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));
Expand Down

0 comments on commit 362f4b6

Please sign in to comment.