1
- using System ;
1
+ using Spectra ;
2
+ using System ;
2
3
using System . Collections . Generic ;
3
4
using System . Linq ;
4
5
@@ -9,23 +10,24 @@ public class GptmdEngine : MyEngine
9
10
10
11
#region Private Fields
11
12
13
+ private const double missedMonoisopePeak = 1.003 ;
12
14
private readonly List < NewPsmWithFdr > allResultingIdentifications ;
13
15
private readonly IEnumerable < Tuple < double , double > > combos ;
14
16
private readonly List < MetaMorpheusModification > gptmdModifications ;
15
17
private readonly bool isotopeErrors ;
16
- private readonly double tolInDaltons ;
18
+ private readonly Tolerance precursorMassTolerance ;
17
19
18
20
#endregion Private Fields
19
21
20
22
#region Public Constructors
21
23
22
- public GptmdEngine ( List < NewPsmWithFdr > allResultingIdentifications , bool isotopeErrors , List < MetaMorpheusModification > gptmdModifications , IEnumerable < Tuple < double , double > > combos , double tolInDaltons ) : base ( 2 )
24
+ public GptmdEngine ( List < NewPsmWithFdr > allResultingIdentifications , bool isotopeErrors , List < MetaMorpheusModification > gptmdModifications , IEnumerable < Tuple < double , double > > combos , Tolerance precursorMassTolerance ) : base ( 2 )
23
25
{
24
26
this . allResultingIdentifications = allResultingIdentifications ;
25
27
this . isotopeErrors = isotopeErrors ;
26
28
this . gptmdModifications = gptmdModifications ;
27
29
this . combos = combos ;
28
- this . tolInDaltons = tolInDaltons ;
30
+ this . precursorMassTolerance = precursorMassTolerance ;
29
31
}
30
32
31
33
#endregion Public Constructors
@@ -46,7 +48,7 @@ protected override MyResults RunSpecific()
46
48
var peptide = theDict . First ( ) ;
47
49
var baseSequence = ye . thisPSM . BaseSequence ;
48
50
double massDiff = ye . thisPSM . ScanPrecursorMass - ye . thisPSM . PeptideMonoisotopicMass ;
49
- foreach ( MetaMorpheusModification mod in GetMod ( massDiff , isotopeErrors , gptmdModifications , combos , tolInDaltons ) )
51
+ foreach ( MetaMorpheusModification mod in GetMod ( massDiff , isotopeErrors , gptmdModifications , combos , precursorMassTolerance ) )
50
52
{
51
53
int proteinLength = peptide . Protein . Length ;
52
54
var proteinAcession = peptide . Protein . Accession ;
@@ -94,13 +96,13 @@ private static bool ModFits(MetaMorpheusModification attemptToLocalize, char v1,
94
96
return true ;
95
97
}
96
98
97
- private static IEnumerable < MetaMorpheusModification > GetMod ( double massDiff , bool isotopeErrors , IEnumerable < MetaMorpheusModification > allMods , IEnumerable < Tuple < double , double > > combos , double tolInDaltons )
99
+ private static IEnumerable < MetaMorpheusModification > GetMod ( double massDiff , bool isotopeErrors , IEnumerable < MetaMorpheusModification > allMods , IEnumerable < Tuple < double , double > > combos , Tolerance precursorTolerance )
98
100
{
99
101
foreach ( var Mod in allMods )
100
102
{
101
- if ( Mod . ObservedMassShift > massDiff - tolInDaltons && Mod . ObservedMassShift < massDiff + tolInDaltons )
103
+ if ( precursorTolerance . Within ( massDiff , Mod . ObservedMassShift ) )
102
104
yield return Mod ;
103
- if ( isotopeErrors && Mod . ObservedMassShift > massDiff - tolInDaltons - 1.003 && Mod . ObservedMassShift < massDiff + tolInDaltons - 1.003 )
105
+ if ( isotopeErrors && precursorTolerance . Within ( massDiff - missedMonoisopePeak , Mod . ObservedMassShift ) )
104
106
yield return Mod ;
105
107
}
106
108
@@ -109,18 +111,18 @@ private static IEnumerable<MetaMorpheusModification> GetMod(double massDiff, boo
109
111
var m1 = combo . Item1 ;
110
112
var m2 = combo . Item2 ;
111
113
var combined = m1 + m2 ;
112
- if ( combined > massDiff - tolInDaltons && combined < massDiff + tolInDaltons )
114
+ if ( precursorTolerance . Within ( massDiff , combined ) )
113
115
{
114
- foreach ( var mod in GetMod ( m1 , isotopeErrors , allMods , combos , tolInDaltons ) )
116
+ foreach ( var mod in GetMod ( m1 , isotopeErrors , allMods , combos , precursorTolerance ) )
115
117
yield return mod ;
116
- foreach ( var mod in GetMod ( m2 , isotopeErrors , allMods , combos , tolInDaltons ) )
118
+ foreach ( var mod in GetMod ( m2 , isotopeErrors , allMods , combos , precursorTolerance ) )
117
119
yield return mod ;
118
120
}
119
- if ( isotopeErrors && combined > massDiff - tolInDaltons - 1.003 && combined < massDiff + tolInDaltons - 1.003 )
121
+ if ( isotopeErrors && precursorTolerance . Within ( massDiff - missedMonoisopePeak , combined ) )
120
122
{
121
- foreach ( var mod in GetMod ( m1 , isotopeErrors , allMods , combos , tolInDaltons ) )
123
+ foreach ( var mod in GetMod ( m1 , isotopeErrors , allMods , combos , precursorTolerance ) )
122
124
yield return mod ;
123
- foreach ( var mod in GetMod ( m2 , isotopeErrors , allMods , combos , tolInDaltons ) )
125
+ foreach ( var mod in GetMod ( m2 , isotopeErrors , allMods , combos , precursorTolerance ) )
124
126
yield return mod ;
125
127
}
126
128
}
0 commit comments