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

Digestion Consolidation and Optimization #823

Merged
merged 27 commits into from
Jan 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
8620b8f
Added bassic object pools
nbollis Jan 14, 2025
be82276
Refactor DigestionAgent to use HashSetPool for indices
nbollis Jan 14, 2025
a5bc0b6
Merge branch 'master' into ObjectPools
nbollis Jan 14, 2025
2bfde71
string interpolation in BPWSM extensions
nbollis Jan 14, 2025
11ccba9
Adjusted IEnumerable return in Protease.GetUnmodified
nbollis Jan 14, 2025
72c9de6
Digestion Optimizations
nbollis Jan 14, 2025
d68e40f
Moved testing class to proper subdirectory
nbollis Jan 14, 2025
585ffc5
Adjusted ModFits to have the correct localization for peptide and pro…
nbollis Jan 14, 2025
513a12b
Cleaned up hashset return
nbollis Jan 14, 2025
cfe0586
Merge branch 'ObjectPools' of https://github.com/nbollis/mzLib into O…
nbollis Jan 14, 2025
b13e940
Digestion Agent Hashset Return Cleanup
nbollis Jan 14, 2025
db610b2
set fixed mods now modifies in place using a pooled dictionary
nbollis Jan 14, 2025
ce3b412
Merge branch 'master' into DigestionFixedFix
nbollis Jan 14, 2025
468c46d
Added comments to digeston
nbollis Jan 14, 2025
2c12e59
Refactor code for readability and efficiency
nbollis Jan 14, 2025
349d7b1
Merge branch 'DigestionFixedFix' of https://github.com/nbollis/mzLib …
nbollis Jan 14, 2025
81aefc5
Added many comments
nbollis Jan 15, 2025
51dfbfe
merged in pool comments
nbollis Jan 15, 2025
21ac5b1
Merge branch 'master' into DigestionFixedFix
nbollis Jan 15, 2025
43d6882
set fixed mods namechange
nbollis Jan 16, 2025
ddbcf01
Eliminated IsN or IS5' in favor of unified method
nbollis Jan 16, 2025
0b59b0b
Extracted all variable modification combination generation to parent …
nbollis Jan 16, 2025
9096c21
removed fixed mods changes
nbollis Jan 16, 2025
010f93f
removed unnecessary namespace
nbollis Jan 16, 2025
4e93b36
Extracted AppendFixedToVariabel
nbollis Jan 16, 2025
2171a73
Update mzLib.nuspec
nbollis Jan 16, 2025
bff563e
Added shortreed comment
nbollis Jan 16, 2025
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
34 changes: 19 additions & 15 deletions mzLib/Omics/BioPolymerWithSetModsExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ public static string FullSequenceWithMassShift(this IBioPolymerWithSetMods withS
var subsequence = new StringBuilder();

// modification on peptide N-terminus
if (withSetMods.AllModsOneIsNterminus.TryGetValue(1, out Modification mod))
if (withSetMods.AllModsOneIsNterminus.TryGetValue(1, out Modification? mod))
{
subsequence.Append('[' + mod.MonoisotopicMass.RoundedDouble(6).ToString() + ']');
subsequence.Append($"[{mod.MonoisotopicMass.RoundedDouble(6)}]");
}

for (int r = 0; r < withSetMods.Length; r++)
Expand All @@ -32,11 +32,11 @@ public static string FullSequenceWithMassShift(this IBioPolymerWithSetMods withS
{
if (mod.MonoisotopicMass > 0)
{
subsequence.Append("[+" + mod.MonoisotopicMass.RoundedDouble(6).ToString() + ']');
subsequence.Append($"[+{mod.MonoisotopicMass.RoundedDouble(6)}]");
}
else
{
subsequence.Append("[" + mod.MonoisotopicMass.RoundedDouble(6).ToString() + ']');
subsequence.Append($"[{mod.MonoisotopicMass.RoundedDouble(6)}]");
}
}
}
Expand All @@ -46,11 +46,11 @@ public static string FullSequenceWithMassShift(this IBioPolymerWithSetMods withS
{
if (mod.MonoisotopicMass > 0)
{
subsequence.Append("[+" + mod.MonoisotopicMass.RoundedDouble(6).ToString() + ']');
subsequence.Append($"[+{mod.MonoisotopicMass.RoundedDouble(6)}]");
}
else
{
subsequence.Append("[" + mod.MonoisotopicMass.RoundedDouble(6).ToString() + ']');
subsequence.Append($"[{mod.MonoisotopicMass.RoundedDouble(6)}]");
}
}
return subsequence.ToString();
Expand All @@ -68,14 +68,15 @@ public static string EssentialSequence(this IBioPolymerWithSetMods withSetMods,
string essentialSequence = withSetMods.BaseSequence;
if (modstoWritePruned != null)
{
var sbsequence = new StringBuilder();
var sbsequence = new StringBuilder(withSetMods.FullSequence.Length);

// variable modification on peptide N-terminus
if (withSetMods.AllModsOneIsNterminus.TryGetValue(1, out Modification pep_n_term_variable_mod))
{
if (modstoWritePruned.ContainsKey(pep_n_term_variable_mod.ModificationType))
{
sbsequence.Append('[' + pep_n_term_variable_mod.ModificationType + ":" + pep_n_term_variable_mod.IdWithMotif + ']');
sbsequence.Append(
$"[{pep_n_term_variable_mod.ModificationType}:{pep_n_term_variable_mod.IdWithMotif}]");
}
}
for (int r = 0; r < withSetMods.Length; r++)
Expand All @@ -86,7 +87,8 @@ public static string EssentialSequence(this IBioPolymerWithSetMods withSetMods,
{
if (modstoWritePruned.ContainsKey(residue_variable_mod.ModificationType))
{
sbsequence.Append('[' + residue_variable_mod.ModificationType + ":" + residue_variable_mod.IdWithMotif + ']');
sbsequence.Append(
$"[{residue_variable_mod.ModificationType}:{residue_variable_mod.IdWithMotif}]");
}
}
}
Expand All @@ -96,7 +98,8 @@ public static string EssentialSequence(this IBioPolymerWithSetMods withSetMods,
{
if (modstoWritePruned.ContainsKey(pep_c_term_variable_mod.ModificationType))
{
sbsequence.Append('[' + pep_c_term_variable_mod.ModificationType + ":" + pep_c_term_variable_mod.IdWithMotif + ']');
sbsequence.Append(
$"[{pep_c_term_variable_mod.ModificationType}:{pep_c_term_variable_mod.IdWithMotif}]");
}
}

Expand All @@ -112,12 +115,13 @@ public static string EssentialSequence(this IBioPolymerWithSetMods withSetMods,
/// <returns></returns>
public static string DetermineFullSequence(this IBioPolymerWithSetMods withSetMods)
{
var subSequence = new StringBuilder();
// start string builder with initial capacity to avoid resizing costs.
var subSequence = new StringBuilder(withSetMods.BaseSequence.Length + withSetMods.AllModsOneIsNterminus.Count * 30);

// modification on peptide N-terminus
if (withSetMods.AllModsOneIsNterminus.TryGetValue(1, out Modification mod))
if (withSetMods.AllModsOneIsNterminus.TryGetValue(1, out Modification? mod))
{
subSequence.Append('[' + mod.ModificationType + ":" + mod.IdWithMotif + ']');
subSequence.Append($"[{mod.ModificationType}:{mod.IdWithMotif}]");
}

for (int r = 0; r < withSetMods.Length; r++)
Expand All @@ -127,14 +131,14 @@ public static string DetermineFullSequence(this IBioPolymerWithSetMods withSetMo
// modification on this residue
if (withSetMods.AllModsOneIsNterminus.TryGetValue(r + 2, out mod))
{
subSequence.Append('[' + mod.ModificationType + ":" + mod.IdWithMotif + ']');
subSequence.Append($"[{mod.ModificationType}:{mod.IdWithMotif}]");
}
}

// modification on peptide C-terminus
if (withSetMods.AllModsOneIsNterminus.TryGetValue(withSetMods.Length + 2, out mod))
{
subSequence.Append('[' + mod.ModificationType + ":" + mod.IdWithMotif + ']');
subSequence.Append($"[{mod.ModificationType}:{mod.IdWithMotif}]");
}

return subSequence.ToString();
Expand Down
Loading
Loading