1
1
using Chemistry ;
2
2
using MassSpectrometry ;
3
- using OldInternalLogic ;
4
3
using Spectra ;
5
4
using System ;
6
5
using System . Collections . Concurrent ;
@@ -15,6 +14,7 @@ public class ModernSearchEngine : MyEngine
15
14
16
15
#region Private Fields
17
16
17
+ private const double tolForModificationMassDiffMatch = 0.003 ;
18
18
private readonly List < int > [ ] fragmentIndex ;
19
19
20
20
private readonly double fragmentToleranceInDaltons ;
@@ -27,25 +27,18 @@ public class ModernSearchEngine : MyEngine
27
27
28
28
private readonly List < SearchMode > searchModes ;
29
29
30
- private readonly List < MorpheusModification > variableModifications ;
31
- private readonly List < MorpheusModification > localizeableModifications ;
32
-
33
- private const double tolForModificationMassDiffMatch = 0.003 ;
34
-
35
30
#endregion Private Fields
36
31
37
32
#region Public Constructors
38
33
39
- public ModernSearchEngine ( IMsDataFile < IMzSpectrum < MzPeak > > myMSDataFile , List < CompactPeptide > peptideIndex , float [ ] keys , List < int > [ ] fragmentIndex , double fragmentToleranceInDaltons , List < SearchMode > searchModes , List < MorpheusModification > variableModifications , List < MorpheusModification > localizeableModifications ) : base ( 2 )
34
+ public ModernSearchEngine ( IMsDataFile < IMzSpectrum < MzPeak > > myMSDataFile , List < CompactPeptide > peptideIndex , float [ ] keys , List < int > [ ] fragmentIndex , double fragmentToleranceInDaltons , List < SearchMode > searchModes ) : base ( 2 )
40
35
{
41
36
this . myMSDataFile = myMSDataFile ;
42
37
this . peptideIndex = peptideIndex ;
43
38
this . keys = keys ;
44
39
this . fragmentIndex = fragmentIndex ;
45
40
this . fragmentToleranceInDaltons = fragmentToleranceInDaltons ;
46
41
this . searchModes = searchModes ;
47
- this . variableModifications = variableModifications ;
48
- this . localizeableModifications = localizeableModifications ;
49
42
}
50
43
51
44
#endregion Public Constructors
@@ -87,41 +80,40 @@ protected override MyResults RunSpecific()
87
80
{
88
81
var consideredScore = fullPeptideScores [ possibleWinningPeptideIndex ] ;
89
82
CompactPeptide candidatePeptide = peptideIndex [ possibleWinningPeptideIndex ] ;
90
- if ( ! MatchModificationsMassShift ( candidatePeptide , thisScanprecursorMass ) )
91
- for ( int j = 0 ; j < searchModesCount ; j ++ )
83
+ for ( int j = 0 ; j < searchModesCount ; j ++ )
84
+ {
85
+ // Check if makes sense to add due to peptidescore!
86
+ var searchMode = searchModes [ j ] ;
87
+ double currentBestScore = bestScores [ j ] ;
88
+ if ( currentBestScore > 1 )
92
89
{
93
- // Check if makes sense to add due to peptidescore!
94
- var searchMode = searchModes [ j ] ;
95
- double currentBestScore = bestScores [ j ] ;
96
- if ( currentBestScore > 1 )
90
+ // Existed! Need to compare with old match
91
+ if ( Math . Abs ( currentBestScore - consideredScore ) < 1e-9 )
97
92
{
98
- // Existed! Need to compare with old match
99
- if ( Math . Abs ( currentBestScore - consideredScore ) < 1e-9 )
93
+ // Score is same, need to see if accepts and if prefer the new one
94
+ if ( searchMode . Accepts ( thisScanprecursorMass , candidatePeptide . MonoisotopicMass ) && FirstIsPreferableWithoutScore ( candidatePeptide , bestPeptides [ j ] , thisScanprecursorMass ) )
100
95
{
101
- // Score is same, need to see if accepts and if prefer the new one
102
- if ( searchMode . Accepts ( thisScanprecursorMass , candidatePeptide . MonoisotopicMass ) && FirstIsPreferableWithoutScore ( candidatePeptide , bestPeptides [ j ] , thisScanprecursorMass ) )
103
- {
104
- bestPeptides [ j ] = candidatePeptide ;
105
- bestScores [ j ] = consideredScore ;
106
- }
107
- }
108
- else if ( currentBestScore < consideredScore )
109
- {
110
- // Score is better, only make sure it is acceptable
111
- if ( searchMode . Accepts ( thisScanprecursorMass , candidatePeptide . MonoisotopicMass ) )
112
- {
113
- bestPeptides [ j ] = candidatePeptide ;
114
- bestScores [ j ] = consideredScore ;
115
- }
96
+ bestPeptides [ j ] = candidatePeptide ;
97
+ bestScores [ j ] = consideredScore ;
116
98
}
117
99
}
118
- // Did not exist! Only make sure that it is acceptable
119
- else if ( searchMode . Accepts ( thisScanprecursorMass , candidatePeptide . MonoisotopicMass ) )
100
+ else if ( currentBestScore < consideredScore )
120
101
{
121
- bestPeptides [ j ] = candidatePeptide ;
122
- bestScores [ j ] = consideredScore ;
102
+ // Score is better, only make sure it is acceptable
103
+ if ( searchMode . Accepts ( thisScanprecursorMass , candidatePeptide . MonoisotopicMass ) )
104
+ {
105
+ bestPeptides [ j ] = candidatePeptide ;
106
+ bestScores [ j ] = consideredScore ;
107
+ }
123
108
}
124
109
}
110
+ // Did not exist! Only make sure that it is acceptable
111
+ else if ( searchMode . Accepts ( thisScanprecursorMass , candidatePeptide . MonoisotopicMass ) )
112
+ {
113
+ bestPeptides [ j ] = candidatePeptide ;
114
+ bestScores [ j ] = consideredScore ;
115
+ }
116
+ }
125
117
}
126
118
for ( int j = 0 ; j < searchModesCount ; j ++ )
127
119
{
@@ -146,50 +138,6 @@ protected override MyResults RunSpecific()
146
138
return new ModernSearchResults ( newPsms , this ) ;
147
139
}
148
140
149
- private bool MatchModificationsMassShift ( CompactPeptide candidatePeptide , double thisScanprecursorMass )
150
- {
151
- if ( candidatePeptide . varMod1Loc != 0 )
152
- {
153
- if ( candidatePeptide . varMod1Type < 32767 )
154
- {
155
- if ( Math . Abs ( candidatePeptide . MonoisotopicMass - variableModifications [ candidatePeptide . varMod1Type - 1 ] . MonoisotopicMassShift - thisScanprecursorMass ) < tolForModificationMassDiffMatch )
156
- return true ;
157
- }
158
- else
159
- {
160
- if ( Math . Abs ( candidatePeptide . MonoisotopicMass - localizeableModifications [ candidatePeptide . varMod1Type - 1 - 32767 ] . MonoisotopicMassShift - thisScanprecursorMass ) < tolForModificationMassDiffMatch )
161
- return true ;
162
- }
163
- }
164
- if ( candidatePeptide . varMod2Loc != 0 )
165
- {
166
- if ( candidatePeptide . varMod2Type < 32767 )
167
- {
168
- if ( Math . Abs ( candidatePeptide . MonoisotopicMass - variableModifications [ candidatePeptide . varMod2Type - 1 ] . MonoisotopicMassShift - thisScanprecursorMass ) < tolForModificationMassDiffMatch )
169
- return true ;
170
- }
171
- else
172
- {
173
- if ( Math . Abs ( candidatePeptide . MonoisotopicMass - localizeableModifications [ candidatePeptide . varMod2Type - 1 - 32767 ] . MonoisotopicMassShift - thisScanprecursorMass ) < tolForModificationMassDiffMatch )
174
- return true ;
175
- }
176
- }
177
- if ( candidatePeptide . varMod3Loc != 0 )
178
- {
179
- if ( candidatePeptide . varMod3Type < 32767 )
180
- {
181
- if ( Math . Abs ( candidatePeptide . MonoisotopicMass - variableModifications [ candidatePeptide . varMod3Type - 1 ] . MonoisotopicMassShift - thisScanprecursorMass ) < tolForModificationMassDiffMatch )
182
- return true ;
183
- }
184
- else
185
- {
186
- if ( Math . Abs ( candidatePeptide . MonoisotopicMass - localizeableModifications [ candidatePeptide . varMod3Type - 1 - 32767 ] . MonoisotopicMassShift - thisScanprecursorMass ) < tolForModificationMassDiffMatch )
187
- return true ;
188
- }
189
- }
190
- return false ;
191
- }
192
-
193
141
#endregion Protected Methods
194
142
195
143
#region Private Methods
0 commit comments