-
Notifications
You must be signed in to change notification settings - Fork 100
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix Audit Log error when copy/pasting protein groups (#2758)
Fixed unhandled error copying and pasting protein groups (reported by Philip) Fix "LogException" when copying and pasting protein groups. The audit log code was choking on the fact that ProteinGroupMetadata overrides the "Name" property which is marked with the "[Track]" attribute. The audit log code was calling using the accessor from the subclass instead of the accessor from the base class.
- Loading branch information
1 parent
53ce871
commit 4fd35e2
Showing
6 changed files
with
106 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
/* | ||
* Original author: Nicholas Shulman <nicksh .at. u.washington.edu>, | ||
* MacCoss Lab, Department of Genome Sciences, UW | ||
* | ||
* Copyright 2023 University of Washington - Seattle, WA | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
using System.Linq; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using pwiz.Common.SystemUtil; | ||
using pwiz.ProteomeDatabase.API; | ||
using pwiz.Skyline.EditUI; | ||
using pwiz.Skyline.Model; | ||
using pwiz.Skyline.Model.AuditLog; | ||
using pwiz.Skyline.Model.Proteome; | ||
using pwiz.SkylineTestUtil; | ||
|
||
namespace pwiz.SkylineTestFunctional | ||
{ | ||
[TestClass] | ||
public class CopyProteinGroupTest : AbstractFunctionalTest | ||
{ | ||
[TestMethod] | ||
public void TestProteinGroupCopy() | ||
{ | ||
TestFilesZip = @"TestFunctional\CopyProteinGroupTest.zip"; | ||
RunFunctionalTest(); | ||
} | ||
|
||
protected override void DoTest() | ||
{ | ||
SetClipboardText("ELVIS"); | ||
RunUI(()=>SkylineWindow.Paste()); | ||
var associateProteinsDlg = ShowDialog<AssociateProteinsDlg>(SkylineWindow.ShowAssociateProteinsDlg); | ||
RunUI(()=> | ||
{ | ||
associateProteinsDlg.FastaFileName = TestFilesDir.GetTestPath("elvis.fasta"); | ||
associateProteinsDlg.GroupProteins = true; | ||
}); | ||
WaitForConditionUI(() => associateProteinsDlg.IsOkEnabled); | ||
OkDialog(associateProteinsDlg, associateProteinsDlg.OkDialog); | ||
RunUI(() => | ||
{ | ||
SkylineWindow.SelectAll(); | ||
SkylineWindow.Copy(); | ||
SkylineWindow.EditDelete(); | ||
SkylineWindow.Paste(); | ||
}); | ||
|
||
// Verify that the "ProteinMetadata_Name" entry in the audit log has the correct | ||
// name of the protein group | ||
// This is to make sure that the ProteinGroupMetadata override of the Name property | ||
// was the one whose value got recorded in the audit log | ||
var document = SkylineWindow.Document; | ||
var firstProteinGroup = document.MoleculeGroups.First(); | ||
Assert.IsInstanceOfType(firstProteinGroup.PeptideGroup, typeof(FastaSequenceGroup)); | ||
Assert.IsInstanceOfType(firstProteinGroup.ProteinMetadata, typeof(ProteinGroupMetadata)); | ||
var proteinGroupName = firstProteinGroup.ProteinMetadata.Name; | ||
Assert.IsNotNull(document.AuditLog); | ||
var lastAuditLogEntry = document.AuditLog.AuditLogEntries; | ||
Assert.AreEqual(MessageType.pasted_targets, lastAuditLogEntry.UndoRedo.MessageInfo.Type); | ||
|
||
// Construct a PropertyName corresponding to "{0:Targets}{2:PropertySeparator}Protein1 / Protein2{2:PropertySeparator}{0:ProteinMetadata_Name}" which is the first "Name" entry of the detail line | ||
var propertyName = | ||
new PropertyName( | ||
new PropertyName( | ||
new PropertyName( | ||
AuditLogParseHelper.GetParseString(ParseStringType.property_names, nameof(Targets))), | ||
proteinGroupName), | ||
AuditLogParseHelper.GetParseString(ParseStringType.property_names, nameof(ProteinMetadata) + "_" + nameof(ProteinMetadata.Name))); | ||
|
||
var proteinMetadataNameDetails = lastAuditLogEntry.AllInfo.Where(detailLogMessage => detailLogMessage.Names.FirstOrDefault() == propertyName.ToString()).ToList(); | ||
Assert.AreEqual(1, proteinMetadataNameDetails.Count); | ||
|
||
var proteinMetadataNameDetail = proteinMetadataNameDetails[0]; | ||
Assert.AreEqual(MessageType.is_, proteinMetadataNameDetail.Type); | ||
Assert.AreEqual(2, proteinMetadataNameDetail.Names.Count); | ||
|
||
// Verify that the second "Name" value of the detail item is the quoted string "Protein1 / Protein2", so | ||
Assert.AreEqual(LogMessage.Quote(proteinGroupName), proteinMetadataNameDetail.Names[1]); | ||
} | ||
} | ||
} |
Binary file not shown.
Binary file added
BIN
+191 Bytes
pwiz_tools/Skyline/TestFunctional/CopyProteinGroupTest/CopyProteinGroupTest.zip
Binary file not shown.
4 changes: 4 additions & 0 deletions
4
pwiz_tools/Skyline/TestFunctional/CopyProteinGroupTest/elvis.fasta
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
>Protein1 | ||
ELVIS | ||
>Protein2 | ||
KELVIS |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters