Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Speedier gptmd again #2448

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 18 additions & 3 deletions MetaMorpheus/EngineLayer/Gptmd/GptmdEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ public static bool ModFits(Modification attemptToLocalize, IBioPolymer protein,

protected override MetaMorpheusEngineResults RunSpecific()
{
var modDict = new ConcurrentDictionary<string, ConcurrentBag<Tuple<int, Modification>>>();
var mergedDictionaries = new ConcurrentDictionary<string, ConcurrentBag<Tuple<int, Modification>>>();
int modsAdded = 0;

object lockObject = new object();
int maxThreadsPerFile = CommonParameters.MaxThreadsToUsePerFile;
var psms = AllIdentifications.Where(b => b.FdrInfo.QValueNotch <= 0.05 && !b.IsDecoy).ToList();
if (psms.Any() == false)
Expand All @@ -76,6 +76,7 @@ protected override MetaMorpheusEngineResults RunSpecific()
}
Parallel.ForEach(Partitioner.Create(0, psms.Count), new ParallelOptions() { MaxDegreeOfParallelism = maxThreadsPerFile }, (range) =>
{
var modDict = new ConcurrentDictionary<string, ConcurrentBag<Tuple<int, Modification>>>();
for (int i = range.Item1; i < range.Item2; i++)
{
foreach (var pepWithSetMods in psms[i].BestMatchingBioPolymersWithSetMods.Select(v => v.Peptide as PeptideWithSetModifications))
Expand Down Expand Up @@ -173,10 +174,24 @@ protected override MetaMorpheusEngineResults RunSpecific()
}
}
}
lock (lockObject)
{
foreach (var kvp in modDict)
{
mergedDictionaries.AddOrUpdate(kvp.Key, kvp.Value, (key, oldValue) =>
{
foreach (var item in kvp.Value)
{
oldValue.Add(item);
}
return oldValue;
});
}
}
});

// Convert ConcurrentDictionary to Dictionary with HashSet
var finalModDictionary = modDict.ToDictionary(
var finalModDictionary = mergedDictionaries.ToDictionary(
kvp => kvp.Key,
kvp => new HashSet<Tuple<int, Modification>>(kvp.Value)
);
Expand Down
Loading