From 25f55cec4e082000f47c0f7127dc8c23b83f20ea Mon Sep 17 00:00:00 2001 From: Alex Date: Thu, 7 Mar 2024 14:09:06 -0600 Subject: [PATCH 1/4] Broke tests --- .../PeptideWithSetModifications.cs | 34 ++++++++----------- mzLib/Test/TestPeptideWithSetMods.cs | 12 +++---- 2 files changed, 21 insertions(+), 25 deletions(-) diff --git a/mzLib/Proteomics/ProteolyticDigestion/PeptideWithSetModifications.cs b/mzLib/Proteomics/ProteolyticDigestion/PeptideWithSetModifications.cs index 067aff6d7..ce6fb1771 100644 --- a/mzLib/Proteomics/ProteolyticDigestion/PeptideWithSetModifications.cs +++ b/mzLib/Proteomics/ProteolyticDigestion/PeptideWithSetModifications.cs @@ -18,10 +18,10 @@ public class PeptideWithSetModifications : ProteolyticPeptide, IBioPolymerWithSe { public string FullSequence { get; private set; } //sequence with modifications public int NumFixedMods { get; } - // Parameter to store a hash code corresponding to a Decoy or a Target peptide + // Parameter to store the full sequence of the corresponding Target or Decoy peptide // If the peptide in question is a decoy, this pairs it to the target it was generated from // If the peptide in question is a target, this pairs it to its corresponding decoy - public int? PairedTargetDecoyHash { get; private set; } + public string PairedTargetDecoySequence { get; private set; } /// /// Dictionary of modifications on the peptide. The N terminus is index 1. /// The key indicates which residue modification is on (with 1 being N terminus). @@ -40,7 +40,7 @@ public class PeptideWithSetModifications : ProteolyticPeptide, IBioPolymerWithSe /// public PeptideWithSetModifications(Protein protein, IDigestionParams digestionParams, int oneBasedStartResidueInProtein, int oneBasedEndResidueInProtein, CleavageSpecificity cleavageSpecificity, string peptideDescription, int missedCleavages, - Dictionary allModsOneIsNterminus, int numFixedMods, string baseSequence = null, int? pairedTargetDecoyHash = null) + Dictionary allModsOneIsNterminus, int numFixedMods, string baseSequence = null, string pairedTargetDecoySequence = null) : base(protein, oneBasedStartResidueInProtein, oneBasedEndResidueInProtein, missedCleavages, cleavageSpecificity, peptideDescription, baseSequence) { _allModsOneIsNterminus = allModsOneIsNterminus; @@ -49,7 +49,7 @@ public PeptideWithSetModifications(Protein protein, IDigestionParams digestionPa FullSequence = this.DetermineFullSequence(); ProteinAccession = protein.Accession; UpdateCleavageSpecificity(); - PairedTargetDecoyHash = pairedTargetDecoyHash; // Added PairedTargetDecoyHash as a nullable integer + PairedTargetDecoySequence = pairedTargetDecoySequence; // Added PairedTargetDecoyHash as a nullable integer } /// @@ -59,7 +59,7 @@ public PeptideWithSetModifications(Protein protein, IDigestionParams digestionPa public PeptideWithSetModifications(string sequence, Dictionary allKnownMods, int numFixedMods = 0, IDigestionParams digestionParams = null, Protein p = null, int oneBasedStartResidueInProtein = int.MinValue, int oneBasedEndResidueInProtein = int.MinValue, int missedCleavages = int.MinValue, - CleavageSpecificity cleavageSpecificity = CleavageSpecificity.Full, string peptideDescription = null, int? pairedTargetDecoyHash = null) + CleavageSpecificity cleavageSpecificity = CleavageSpecificity.Full, string peptideDescription = null, string pairedTargetDecoySequence = null) : base(p, oneBasedStartResidueInProtein, oneBasedEndResidueInProtein, missedCleavages, cleavageSpecificity, peptideDescription) { if (sequence.Contains("|")) @@ -72,7 +72,7 @@ public PeptideWithSetModifications(string sequence, Dictionary>(), new Dictionary>(), null, null, null, true); DigestionParams d = _digestionParams; - // Creates a hash code corresponding to the target's sequence - int targetHash = GetHashCode(); PeptideWithSetModifications decoyPeptide; //Make the "peptideDescription" store the corresponding target's sequence if (newBaseString != this.BaseSequence) { decoyPeptide = new PeptideWithSetModifications(decoyProtein, d, this.OneBasedStartResidueInProtein, this.OneBasedEndResidueInProtein, this.CleavageSpecificityForFdrCategory, this.FullSequence, this.MissedCleavages, newModificationsDictionary, this.NumFixedMods, newBaseString); // Sets PairedTargetDecoyHash of the original target peptie to the hash hode of the decoy sequence - PairedTargetDecoyHash = decoyPeptide.GetHashCode(); + PairedTargetDecoySequence = decoyPeptide.FullSequence; // Sets PairedTargetDecoyHash of the decoy peptide to the hash code of the target sequence - decoyPeptide.PairedTargetDecoyHash = targetHash; + decoyPeptide.PairedTargetDecoySequence = this.FullSequence; return decoyPeptide; } @@ -1158,9 +1156,9 @@ public PeptideWithSetModifications GetReverseDecoyFromTarget(int[] revisedAminoA { //The reverse decoy procedure failed to create a PeptideWithSetModificatons with a different sequence. Therefore, //we retrun the mirror image peptide. - decoyPeptide = this.GetPeptideMirror(revisedAminoAcidOrder); - PairedTargetDecoyHash = decoyPeptide.GetHashCode(); - decoyPeptide.PairedTargetDecoyHash = targetHash; + decoyPeptide = this.GetPeptideMirror(revisedAminoAcidOrder); + PairedTargetDecoySequence = decoyPeptide.FullSequence; + decoyPeptide.PairedTargetDecoySequence = this.FullSequence; return decoyPeptide; } @@ -1318,17 +1316,15 @@ public PeptideWithSetModifications GetScrambledDecoyFromTarget(int[] revisedAmin Protein decoyProtein = new Protein(proteinSequence, "DECOY_" + this.Protein.Accession, null, new List>(), new Dictionary>(), null, null, null, true); DigestionParams d = _digestionParams; - // Creates a hash code corresponding to the target's sequence - int targetHash = GetHashCode(); PeptideWithSetModifications decoyPeptide; //Make the "peptideDescription" store the corresponding target's sequence if (newBaseString != this.BaseSequence) { decoyPeptide = new PeptideWithSetModifications(decoyProtein, d, this.OneBasedStartResidueInProtein, this.OneBasedEndResidueInProtein, this.CleavageSpecificityForFdrCategory, this.FullSequence, this.MissedCleavages, newModificationsDictionary, this.NumFixedMods, newBaseString); // Sets PairedTargetDecoyHash of the original target peptie to the hash hode of the decoy sequence - PairedTargetDecoyHash = decoyPeptide.GetHashCode(); + PairedTargetDecoySequence = decoyPeptide.FullSequence; // Sets PairedTargetDecoyHash of the decoy peptide to the hash code of the target sequence - decoyPeptide.PairedTargetDecoyHash = targetHash; + decoyPeptide.PairedTargetDecoySequence = this.FullSequence; return decoyPeptide; } @@ -1337,8 +1333,8 @@ public PeptideWithSetModifications GetScrambledDecoyFromTarget(int[] revisedAmin //The reverse decoy procedure failed to create a PeptideWithSetModificatons with a different sequence. Therefore, //we retrun the mirror image peptide. decoyPeptide = this.GetPeptideMirror(revisedAminoAcidOrder); - PairedTargetDecoyHash = decoyPeptide.GetHashCode(); - decoyPeptide.PairedTargetDecoyHash = targetHash; + PairedTargetDecoySequence = decoyPeptide.FullSequence; + decoyPeptide.PairedTargetDecoySequence = this.FullSequence; return decoyPeptide; } } diff --git a/mzLib/Test/TestPeptideWithSetMods.cs b/mzLib/Test/TestPeptideWithSetMods.cs index 549d504cf..c2036d8f5 100644 --- a/mzLib/Test/TestPeptideWithSetMods.cs +++ b/mzLib/Test/TestPeptideWithSetMods.cs @@ -763,8 +763,8 @@ public static void TestReverseDecoyFromTarget() int testTargetHash = p.GetHashCode(); // Hash code corresponding to the decoy sequence, should be PairedTargetDecoyHash for target int testDecoyHash = reverse.GetHashCode(); - Assert.AreEqual(reverse.PairedTargetDecoyHash, testTargetHash); - Assert.AreEqual(p.PairedTargetDecoyHash, testDecoyHash); + Assert.AreEqual(reverse.PairedTargetDecoySequence.GetHashCode(), testTargetHash); + Assert.AreEqual(p.PairedTargetDecoySequence.GetHashCode(), testDecoyHash); Assert.AreEqual("EDITPEPK", reverse.BaseSequence); Assert.AreEqual(new int[] { 6, 5, 4, 3, 2, 1, 0, 7 }, newAminoAcidPositions); Assert.IsTrue(reverse.Protein.IsDecoy); @@ -839,8 +839,8 @@ public static void TestReverseDecoyFromTarget() int testMirrorTargetHash = p_tryp.GetHashCode(); // Hash code corresponding to the decoy sequence, should be PairedTargetDecoyHash for target int testMirrorDecoyHash = p_tryp_reverse.GetHashCode(); - Assert.AreEqual(testMirrorTargetHash, p_tryp_reverse.PairedTargetDecoyHash); - Assert.AreEqual(testMirrorDecoyHash, p_tryp.PairedTargetDecoyHash); + Assert.AreEqual(testMirrorTargetHash, p_tryp_reverse.PairedTargetDecoySequence.GetHashCode()); + Assert.AreEqual(testMirrorDecoyHash, p_tryp.PairedTargetDecoySequence.GetHashCode()); Assert.AreEqual("RVTRITV", p_tryp_reverse.BaseSequence); Assert.AreEqual(new int[] { 6, 5, 4, 3, 2, 1, 0 }, newAminoAcidPositions); Assert.IsTrue(p_tryp_reverse.AllModsOneIsNterminus.ContainsKey(1));//n-term acetyl @@ -869,8 +869,8 @@ public static void TestScrambledDecoyFromTarget() int testTargetHash = p.GetHashCode(); // Hash code corresponding to the decoy sequence, should be PairedTargetDecoyHash for target int testDecoyHash = testScrambled.GetHashCode(); - Assert.AreEqual(testScrambled.PairedTargetDecoyHash, testTargetHash); - Assert.AreEqual(p.PairedTargetDecoyHash, testDecoyHash); + Assert.AreEqual(testScrambled.PairedTargetDecoySequence.GetHashCode(), testTargetHash); + Assert.AreEqual(p.PairedTargetDecoySequence.GetHashCode(), testDecoyHash); Assert.AreEqual("IDEETPPK", testScrambled.BaseSequence); Assert.AreEqual(new int[] { 4, 5, 6, 1, 3, 0, 2, 7 }, newAminoAcidPositions); // Check n-term acetyl From dc3095add2297e43e59563f37ca65995b8300b38 Mon Sep 17 00:00:00 2001 From: Alex Date: Thu, 7 Mar 2024 14:21:26 -0600 Subject: [PATCH 2/4] Pwsm GetHashCode now only considers Full Sequence --- .../ProteolyticDigestion/PeptideWithSetModifications.cs | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/mzLib/Proteomics/ProteolyticDigestion/PeptideWithSetModifications.cs b/mzLib/Proteomics/ProteolyticDigestion/PeptideWithSetModifications.cs index ce6fb1771..b2c31d44b 100644 --- a/mzLib/Proteomics/ProteolyticDigestion/PeptideWithSetModifications.cs +++ b/mzLib/Proteomics/ProteolyticDigestion/PeptideWithSetModifications.cs @@ -902,14 +902,7 @@ public override bool Equals(object obj) public override int GetHashCode() { - if (DigestionParams == null) - { - return FullSequence.GetHashCode(); - } - else - { - return FullSequence.GetHashCode() + DigestionParams.DigestionAgent.GetHashCode(); - } + return FullSequence.GetHashCode(); } /// From efebe25e3f4c9a086ac798bb291fba18cc731c32 Mon Sep 17 00:00:00 2001 From: Alex Date: Fri, 8 Mar 2024 10:44:23 -0600 Subject: [PATCH 3/4] Fixed broken test --- .../ProteolyticDigestion/PeptideWithSetModifications.cs | 2 +- mzLib/Test/TestPeptideWithSetMods.cs | 3 ++- mzLib/mzLib.nuspec | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/mzLib/Proteomics/ProteolyticDigestion/PeptideWithSetModifications.cs b/mzLib/Proteomics/ProteolyticDigestion/PeptideWithSetModifications.cs index b2c31d44b..1b7d32d61 100644 --- a/mzLib/Proteomics/ProteolyticDigestion/PeptideWithSetModifications.cs +++ b/mzLib/Proteomics/ProteolyticDigestion/PeptideWithSetModifications.cs @@ -49,7 +49,7 @@ public PeptideWithSetModifications(Protein protein, IDigestionParams digestionPa FullSequence = this.DetermineFullSequence(); ProteinAccession = protein.Accession; UpdateCleavageSpecificity(); - PairedTargetDecoySequence = pairedTargetDecoySequence; // Added PairedTargetDecoyHash as a nullable integer + PairedTargetDecoySequence = pairedTargetDecoySequence; } /// diff --git a/mzLib/Test/TestPeptideWithSetMods.cs b/mzLib/Test/TestPeptideWithSetMods.cs index c2036d8f5..d6d0e007b 100644 --- a/mzLib/Test/TestPeptideWithSetMods.cs +++ b/mzLib/Test/TestPeptideWithSetMods.cs @@ -53,7 +53,8 @@ public static void TestDifferentProteaseEquals() Assert.That(pep1.Parent.Equals(pep2.Parent)); Assert.That(!pep1.DigestionParams.DigestionAgent.Equals(pep2.DigestionParams.DigestionAgent)); Assert.That(!pep1.Equals(pep2)); - Assert.That(!pep1.GetHashCode().Equals(pep2.GetHashCode())); + // HashCode is only concerned with the full sequence, not the protease. Only the equals method is interested in the protease used + Assert.That(pep1.GetHashCode().Equals(pep2.GetHashCode())); } [Test] diff --git a/mzLib/mzLib.nuspec b/mzLib/mzLib.nuspec index 5d5400e95..cbdaa9b03 100644 --- a/mzLib/mzLib.nuspec +++ b/mzLib/mzLib.nuspec @@ -2,7 +2,7 @@ mzLib - 1.0.547 + 5.0.547.1 mzLib Stef S. Stef S. From 169a988f301da7cfe749a2201f4869470971e2b6 Mon Sep 17 00:00:00 2001 From: Alexander-Sol <41119316+Alexander-Sol@users.noreply.github.com> Date: Tue, 30 Jul 2024 09:47:42 -0500 Subject: [PATCH 4/4] Update mzLib.nuspec reverted changes to nuspec --- mzLib/mzLib.nuspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mzLib/mzLib.nuspec b/mzLib/mzLib.nuspec index 2fbe01597..f66fdbe95 100644 --- a/mzLib/mzLib.nuspec +++ b/mzLib/mzLib.nuspec @@ -2,7 +2,7 @@ mzLib - 5.0.547.1 + 1.0.547 mzLib Stef S. Stef S.