Skip to content

Commit

Permalink
Fixed decoy order (#809)
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander-Sol authored Nov 18, 2024
1 parent e5cf73e commit 6411360
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 2 additions & 3 deletions mzLib/Test/DatabaseTests/TestDatabaseLoaders.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
2 changes: 2 additions & 0 deletions mzLib/UsefulProteomicsDatabases/DecoyProteinGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ private static List<Protein> GenerateReverseDecoys(List<Protein> proteins, int m

lock (decoyProteins) { decoyProteins.Add(decoyProtein); }
});
decoyProteins = decoyProteins.OrderBy(p => p.Accession).ToList();
return decoyProteins;
}

Expand Down Expand Up @@ -359,6 +360,7 @@ private static List<Protein> GenerateSlideDecoys(List<Protein> 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;
}

Expand Down

0 comments on commit 6411360

Please sign in to comment.