diff --git a/mzLib/Proteomics/ProteolyticDigestion/PeptideWithSetModifications.cs b/mzLib/Proteomics/ProteolyticDigestion/PeptideWithSetModifications.cs index 067aff6d7..1b7d32d61 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; } /// @@ -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 @@ -1140,17 +1133,15 @@ public PeptideWithSetModifications GetReverseDecoyFromTarget(int[] revisedAminoA 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; } @@ -1158,9 +1149,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 +1309,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 +1326,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 4fe80b848..355d9d27c 100644 --- a/mzLib/Test/TestPeptideWithSetMods.cs +++ b/mzLib/Test/TestPeptideWithSetMods.cs @@ -55,7 +55,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] @@ -765,8 +766,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); @@ -841,8 +842,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 @@ -871,8 +872,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