diff --git a/mzLib/Test/DatabaseTests/TestDatabaseLoaders.cs b/mzLib/Test/DatabaseTests/TestDatabaseLoaders.cs index 8925661cb..776c5686d 100644 --- a/mzLib/Test/DatabaseTests/TestDatabaseLoaders.cs +++ b/mzLib/Test/DatabaseTests/TestDatabaseLoaders.cs @@ -110,9 +110,8 @@ public void LoadingIsReproducible(string fileName, DecoyType decoyType) // check are equivalent lists of proteins Assert.AreEqual(proteins1.Count, proteins2.Count); - // Because decoys are written in a parallel environment, there is no guarantee that the orders will be the same - CollectionAssert.AreEquivalent(proteins1.Select(p => p.Accession), proteins2.Select(p => p.Accession)); - CollectionAssert.AreEquivalent(proteins1.Select(p => p.BaseSequence), proteins2.Select(p => p.BaseSequence)); + // Because decoys are sorted before they are returned, the order should be identical + Assert.AreEqual(proteins1, proteins2); } [Test] diff --git a/mzLib/UsefulProteomicsDatabases/DecoyProteinGenerator.cs b/mzLib/UsefulProteomicsDatabases/DecoyProteinGenerator.cs index 67a442782..07a90b6f0 100644 --- a/mzLib/UsefulProteomicsDatabases/DecoyProteinGenerator.cs +++ b/mzLib/UsefulProteomicsDatabases/DecoyProteinGenerator.cs @@ -180,6 +180,7 @@ private static List GenerateReverseDecoys(List proteins, int m lock (decoyProteins) { decoyProteins.Add(decoyProtein); } }); + decoyProteins = decoyProteins.OrderBy(p => p.Accession).ToList(); return decoyProteins; } @@ -359,6 +360,7 @@ private static List GenerateSlideDecoys(List proteins, int max protein.Name, protein.FullName, true, protein.IsContaminant, null, decoyVariationsSlide, null, protein.SampleNameForVariants, decoy_disulfides_slide, spliceSitesSlide, protein.DatabaseFilePath); lock (decoyProteins) { decoyProteins.Add(decoyProteinSlide); } }); + decoyProteins = decoyProteins.OrderBy(p => p.Accession).ToList(); return decoyProteins; }