Skip to content

Commit bb3f132

Browse files
author
stefanks
authored
Merge pull request #201 from smith-chem-wisc/StefanBranch
again
2 parents 5942993 + c0566b5 commit bb3f132

38 files changed

+178
-205
lines changed

CMD/Program.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ private static void Main(string[] args)
3838
MyEngine.OutProgressHandler += MyEngine_outProgressHandler;
3939
MyEngine.StartingSingleEngineHander += MyEngine_startingSingleEngineHander;
4040

41-
MyTaskEngine.FinishedSingleTaskHandler += MyTaskEngine_finishedSingleTaskHandler;
42-
MyTaskEngine.FinishedWritingFileHandler += MyTaskEngine_finishedWritingFileHandler;
43-
MyTaskEngine.StartingSingleTaskHander += MyTaskEngine_startingSingleTaskHander;
41+
MetaMorpheusTask.FinishedSingleTaskHandler += MyTaskEngine_finishedSingleTaskHandler;
42+
MetaMorpheusTask.FinishedWritingFileHandler += MyTaskEngine_finishedWritingFileHandler;
43+
MetaMorpheusTask.StartingSingleTaskHander += MyTaskEngine_startingSingleTaskHander;
4444
}
4545

4646
private static void MyTaskEngine_startingSingleTaskHander(object sender, SingleTaskEventArgs e)

EngineLayer/Analysis/AnalysisEngine.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -964,13 +964,13 @@ private void AddObservedPeptidesToDictionary()
964964
for (int i = fff.Item1; i < fff.Item2; i++)
965965
{
966966
var protein = proteinList[i];
967-
var digestedList = protein.Digest(protease, maximumMissedCleavages, InitiatorMethionineBehavior.Variable).ToList();
967+
var digestedList = protein.Digest(protease, maximumMissedCleavages, InitiatorMethionineBehavior.Variable, fixedModifications).ToList();
968968
foreach (var peptide in digestedList)
969969
{
970970
if (peptide.Length == 1 || peptide.Length > byte.MaxValue - 2) // 2 is for indexing terminal modifications
971971
continue;
972972

973-
var ListOfModifiedPeptides = peptide.GetPeptideWithSetModifications(variableModifications, maxModIsoforms, max_mods_for_peptide, fixedModifications).ToList();
973+
var ListOfModifiedPeptides = peptide.GetPeptideWithSetModifications(variableModifications, maxModIsoforms, max_mods_for_peptide).ToList();
974974
foreach (var yyy in ListOfModifiedPeptides)
975975
{
976976
HashSet<PeptideWithSetModifications> v;

EngineLayer/ClassicSearch/ClassicSearchEngine.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ protected override MyResults RunSpecific()
9393
for (int i = fff.Item1; i < fff.Item2; i++)
9494
{
9595
var protein = proteinList[i];
96-
var digestedList = protein.Digest(protease, maximumMissedCleavages, InitiatorMethionineBehavior.Variable).ToList();
96+
var digestedList = protein.Digest(protease, maximumMissedCleavages, InitiatorMethionineBehavior.Variable, fixedModifications).ToList();
9797
foreach (var peptide in digestedList)
9898
{
9999
if (peptide.Length == 1 || peptide.Length > byte.MaxValue - 2)
@@ -114,7 +114,7 @@ protected override MyResults RunSpecific()
114114
}
115115
}
116116

117-
var ListOfModifiedPeptides = peptide.GetPeptideWithSetModifications(variableModifications, maximumVariableModificationIsoforms, max_mods_for_peptide, fixedModifications).ToList();
117+
var ListOfModifiedPeptides = peptide.GetPeptideWithSetModifications(variableModifications, maximumVariableModificationIsoforms, max_mods_for_peptide).ToList();
118118
foreach (var yyy in ListOfModifiedPeptides)
119119
{
120120
if (peptide.OneBasedPossibleLocalizedModifications.Count > 0)

EngineLayer/Indexing/IndexingEngine.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ protected override MyResults RunSpecific()
8383
for (int i = fff.Item1; i < fff.Item2; i++)
8484
{
8585
var protein = proteinList[i];
86-
var digestedList = protein.Digest(protease, maximumMissedCleavages, initiatorMethionineBehavior).ToList();
86+
var digestedList = protein.Digest(protease, maximumMissedCleavages, initiatorMethionineBehavior, fixedModifications).ToList();
8787
foreach (var peptide in digestedList)
8888
{
8989
if (peptide.Length == 1 || peptide.Length > byte.MaxValue - 2)
@@ -101,7 +101,7 @@ protected override MyResults RunSpecific()
101101
}
102102
}
103103

104-
var ListOfModifiedPeptides = peptide.GetPeptideWithSetModifications(variableModifications, maximumVariableModificationIsoforms, max_mods_for_peptide, fixedModifications).ToList();
104+
var ListOfModifiedPeptides = peptide.GetPeptideWithSetModifications(variableModifications, maximumVariableModificationIsoforms, max_mods_for_peptide).ToList();
105105
foreach (var yyy in ListOfModifiedPeptides)
106106
{
107107
if (peptide.OneBasedPossibleLocalizedModifications.Count > 0)

EngineLayer/Proteomics/Peptide.cs

+2-15
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ protected Peptide(Protein protein, int oneBasedStartResidueInProtein, int oneBas
1717
this.Protein = protein;
1818
this.OneBasedStartResidueInProtein = oneBasedStartResidueInProtein;
1919
this.OneBasedEndResidueInProtein = oneBasedEndResidueInProtein;
20+
Length = OneBasedEndResidueInProtein - OneBasedStartResidueInProtein + 1;
2021
}
2122

2223
#endregion Protected Constructors
@@ -29,13 +30,7 @@ protected Peptide(Protein protein, int oneBasedStartResidueInProtein, int oneBas
2930

3031
public virtual string PeptideDescription { get; protected set; }
3132

32-
public int Length
33-
{
34-
get
35-
{
36-
return OneBasedEndResidueInProtein - OneBasedStartResidueInProtein + 1;
37-
}
38-
}
33+
public int Length { get; private set; }
3934

4035
public virtual char PreviousAminoAcid
4136
{
@@ -45,14 +40,6 @@ public virtual char PreviousAminoAcid
4540
}
4641
}
4742

48-
public virtual char NextAminoAcid
49-
{
50-
get
51-
{
52-
return OneBasedEndResidueInProtein < Protein.Length ? Protein[OneBasedEndResidueInProtein] : '-';
53-
}
54-
}
55-
5643
public string BaseSequence
5744
{
5845
get

EngineLayer/Proteomics/PeptideWithPossibleModifications.cs

+33-47
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,16 @@ namespace EngineLayer
77
public class PeptideWithPossibleModifications : Peptide
88
{
99

10+
private readonly Dictionary<int, MetaMorpheusModification> thisDictionaryOfFixedMods;
1011
#region Public Constructors
1112

12-
public PeptideWithPossibleModifications(int oneBasedStartResidueNumberInProtein, int oneBasedEndResidueNumberInProtein, Protein parentProtein, int missedCleavages, string peptideDescription)
13+
public PeptideWithPossibleModifications(int oneBasedStartResidueNumberInProtein, int oneBasedEndResidueNumberInProtein, Protein parentProtein, int missedCleavages, string peptideDescription, IEnumerable<MetaMorpheusModification> allKnownFixedModifications)
1314
: base(parentProtein, oneBasedStartResidueNumberInProtein, oneBasedEndResidueNumberInProtein)
1415
{
1516
OneBasedPossibleLocalizedModifications = Protein.OneBasedPossibleLocalizedModifications.Where(ok => ok.Key >= OneBasedStartResidueInProtein && ok.Key <= OneBasedEndResidueInProtein).ToDictionary(ok => ok.Key - OneBasedStartResidueInProtein + 1, ok => ok.Value);
1617
this.MissedCleavages = missedCleavages;
1718
this.PeptideDescription = peptideDescription;
19+
thisDictionaryOfFixedMods = AddFixedMods(allKnownFixedModifications);
1820
}
1921

2022
#endregion Public Constructors
@@ -28,7 +30,7 @@ public PeptideWithPossibleModifications(int oneBasedStartResidueNumberInProtein,
2830

2931
#region Public Methods
3032

31-
public IEnumerable<PeptideWithSetModifications> GetPeptideWithSetModifications(List<MetaMorpheusModification> variableModifications, int maximumVariableModificationIsoforms, int maxModsForPeptide, IEnumerable<MetaMorpheusModification> allKnownFixedModifications)
33+
public IEnumerable<PeptideWithSetModifications> GetPeptideWithSetModifications(List<MetaMorpheusModification> variableModifications, int maximumVariableModificationIsoforms, int maxModsForPeptide)
3234
{
3335
var two_based_possible_variable_and_localizeable_modifications = new Dictionary<int, UniqueModificationsCollection>(Length + 4);
3436

@@ -143,7 +145,10 @@ public IEnumerable<PeptideWithSetModifications> GetPeptideWithSetModifications(L
143145
int variable_modification_isoforms = 0;
144146
foreach (Dictionary<int, MetaMorpheusModification> kvp in GetVariableModificationPatterns(two_based_possible_variable_and_localizeable_modifications, maxModsForPeptide))
145147
{
146-
yield return new PeptideWithSetModifications(this, AddFixedMods(kvp, allKnownFixedModifications));
148+
foreach (var ok in thisDictionaryOfFixedMods)
149+
if (!kvp.ContainsKey(ok.Key))
150+
kvp.Add(ok.Key, ok.Value);
151+
yield return new PeptideWithSetModifications(this, kvp);
147152
variable_modification_isoforms++;
148153
if (variable_modification_isoforms == maximumVariableModificationIsoforms)
149154
yield break;
@@ -237,53 +242,34 @@ private static Dictionary<int, MetaMorpheusModification> GetNewVariableModificat
237242
return modification_pattern;
238243
}
239244

240-
private Dictionary<int, MetaMorpheusModification> AddFixedMods(Dictionary<int, MetaMorpheusModification> allModsOneIsNterminus, IEnumerable<MetaMorpheusModification> allKnownFixedModifications)
245+
private Dictionary<int, MetaMorpheusModification> AddFixedMods(IEnumerable<MetaMorpheusModification> allKnownFixedModifications)
241246
{
242-
MetaMorpheusModification val;
243-
for (int i = 0; i <= Length + 3; i++)
247+
var allModsOneIsNterminus = new Dictionary<int, MetaMorpheusModification>(Length + 3);
248+
foreach (MetaMorpheusModification mod in allKnownFixedModifications)
244249
{
245-
foreach (MetaMorpheusModification mod in allKnownFixedModifications)
250+
switch (mod.ThisModificationType)
246251
{
247-
if (i == 0 && (OneBasedStartResidueInProtein == 1 || OneBasedStartResidueInProtein == 2))
248-
{
249-
if (mod.ThisModificationType == ModificationType.ProteinNTerminus && (mod.AminoAcid.Equals(this[0]) || mod.AminoAcid.Equals('\0')))
250-
{
251-
if (!allModsOneIsNterminus.TryGetValue(1, out val))
252-
allModsOneIsNterminus.Add(1, mod);
253-
}
254-
}
255-
else if (i == 1)
256-
{
257-
if (mod.ThisModificationType == ModificationType.PeptideNTerminus && (mod.AminoAcid.Equals(this[0]) || mod.AminoAcid.Equals('\0')))
258-
{
259-
if (!allModsOneIsNterminus.TryGetValue(1, out val))
260-
allModsOneIsNterminus.Add(1, mod);
261-
}
262-
}
263-
else if (i >= 2 && i <= Length + 1)
264-
{
265-
if (mod.ThisModificationType == ModificationType.AminoAcidResidue && (mod.AminoAcid.Equals(this[i - 2]) || mod.AminoAcid.Equals('\0')))
266-
{
267-
if (!allModsOneIsNterminus.TryGetValue(i, out val))
268-
allModsOneIsNterminus.Add(i, mod);
269-
}
270-
}
271-
else if (i == Length + 2)
272-
{
273-
if (mod.ThisModificationType == ModificationType.PeptideCTerminus && (mod.AminoAcid.Equals(this[Length - 1]) || mod.AminoAcid.Equals('\0')))
274-
{
275-
if (!allModsOneIsNterminus.TryGetValue(Length + 2, out val))
276-
allModsOneIsNterminus.Add(Length + 2, mod);
277-
}
278-
}
279-
else if (i == Length + 3 && OneBasedEndResidueInProtein == Protein.Length)
280-
{
281-
if (mod.ThisModificationType == ModificationType.ProteinCTerminus && (mod.AminoAcid.Equals(this[Length - 1]) || mod.AminoAcid.Equals('\0')))
282-
{
283-
if (!allModsOneIsNterminus.TryGetValue(Length + 2, out val))
284-
allModsOneIsNterminus.Add(Length + 2, mod);
285-
}
286-
}
252+
case ModificationType.ProteinNTerminus:
253+
if ((OneBasedStartResidueInProtein == 1 || OneBasedStartResidueInProtein == 2) && (mod.AminoAcid.Equals('\0') || mod.AminoAcid.Equals(this[0])))
254+
allModsOneIsNterminus[1] = mod;
255+
break;
256+
case ModificationType.PeptideNTerminus:
257+
if (mod.AminoAcid.Equals('\0') || mod.AminoAcid.Equals(this[0]))
258+
allModsOneIsNterminus[1] = mod;
259+
break;
260+
case ModificationType.AminoAcidResidue:
261+
for (int i = 2; i <= Length + 1; i++)
262+
if (mod.AminoAcid.Equals(this[i - 2]) || mod.AminoAcid.Equals('\0'))
263+
allModsOneIsNterminus[i] = mod;
264+
break;
265+
case ModificationType.PeptideCTerminus:
266+
if (mod.AminoAcid.Equals('\0') || mod.AminoAcid.Equals(this[Length - 1]))
267+
allModsOneIsNterminus[Length + 2] = mod;
268+
break;
269+
case ModificationType.ProteinCTerminus:
270+
if (OneBasedEndResidueInProtein == Protein.Length && (mod.AminoAcid.Equals('\0') || mod.AminoAcid.Equals(this[Length - 1])))
271+
allModsOneIsNterminus[Length + 2] = mod;
272+
break;
287273
}
288274
}
289275
return allModsOneIsNterminus;

EngineLayer/Proteomics/PeptideWithSetModifications.cs

+3-23
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,7 @@ public class PeptideWithSetModifications : Peptide
2222

2323
private readonly PeptideWithPossibleModifications modPep;
2424
private double monoisotopicMass = double.NaN;
25-
26-
private string extendedSequence;
27-
25+
2826
private string sequence;
2927

3028
private PeptideFragmentMasses p;
@@ -57,25 +55,7 @@ public double MonoisotopicMass
5755
return monoisotopicMass;
5856
}
5957
}
60-
61-
public virtual string ExtendedSequence
62-
{
63-
get
64-
{
65-
if (extendedSequence == null)
66-
{
67-
var exSeq = new StringBuilder();
68-
exSeq.Append(PreviousAminoAcid);
69-
exSeq.Append(".");
70-
exSeq.Append(Sequence);
71-
exSeq.Append(".");
72-
exSeq.Append(NextAminoAcid);
73-
extendedSequence = exSeq.ToString();
74-
}
75-
return extendedSequence;
76-
}
77-
}
78-
58+
7959
public virtual string Sequence
8060
{
8161
get
@@ -251,7 +231,7 @@ public override bool Equals(object obj)
251231

252232
public override int GetHashCode()
253233
{
254-
return ExtendedSequence.GetHashCode();
234+
return Sequence.GetHashCode();
255235
}
256236

257237
#endregion Public Methods

0 commit comments

Comments
 (0)