@@ -54,136 +54,143 @@ private static void DeconTest()
54
54
ThermoStaticData a = ThermoStaticData . LoadAllStaticData ( file ) ;
55
55
//ThermoDynamicData a = ThermoDynamicData.InitiateDynamicConnection(@"C:\Users\stepa\Desktop\Decon\09-01-17_iodo_1-4th_rep1_human.raw");
56
56
57
- //using (StreamWriter output = new StreamWriter(@"output.tsv"))
58
- //{
59
- //Console.WriteLine("intensityRatio, deconvolutionTolerancePpm, maxAssumedChargeState: " + (intensityRatio, deconvolutionTolerancePpm, maxAssumedChargeState));
60
-
61
- //int goodScans = 0;
62
-
63
- int numMatchToOnlyOld = 0 ;
64
- int numMatchToOnlyNew = 0 ;
65
- int numMatchToBoth = 0 ;
66
- int numScansWithThermoMasses = 0 ;
67
-
68
- int numMatchToOld = 0 ;
69
- int numMatchToOldPlusMM = 0 ;
70
- int numMatchToOldMinusMM = 0 ;
71
- int numMatchToNew = 0 ;
72
- int numMatchToNewPlusMM = 0 ;
73
- int numMatchToNewMinusMM = 0 ;
74
-
75
- //output.WriteLine("Scan\tType");
76
- //foreach (var ok in a.OfType<IMsDataScanWithPrecursor<IMzSpectrum<IMzPeak>>>().Where(b => b.OneBasedScanNumber >= 8356))
77
- //foreach (var ok in a.OfType<IMsDataScanWithPrecursor<IMzSpectrum<IMzPeak>>>().Skip(2000))
78
- foreach ( var ok in a . OfType < IMsDataScanWithPrecursor < IMzSpectrum < IMzPeak > > > ( ) )
57
+ using ( StreamWriter output = new StreamWriter ( @"unmatched.tsv" ) )
79
58
{
80
- double thermoMz = double . NaN ;
81
- if ( ok . SelectedIonChargeStateGuess . HasValue )
82
- {
83
- thermoMz = ok . SelectedIonMZ ;
84
- if ( ok . SelectedIonMonoisotopicGuessMz . HasValue )
85
- thermoMz = ok . SelectedIonMonoisotopicGuessMz . Value ;
86
- //output.WriteLine(ok.OneBasedScanNumber + "\tThermoMz\t" + thermoMz.ToString("G6"));
87
- //output.WriteLine(ok.OneBasedScanNumber + "\tThermoMass\t" + thermoMz.ToMass(ok.SelectedIonChargeStateGuess.Value).ToString("G6"));
88
- }
89
- else
90
- {
91
- //output.WriteLine(ok.OneBasedScanNumber + "\tThermoMz\t" + " ");
92
- //output.WriteLine(ok.OneBasedScanNumber + "\tThermoMass\t" + " ");
93
- }
94
-
95
- var precursorSpectrum = a . GetOneBasedScan ( ok . OneBasedPrecursorScanNumber . Value ) . MassSpectrum ;
59
+ output . WriteLine ( "Scan\t matchToNewMinusMM\t matchToNewPlusMM\t ThermoMass" ) ;
96
60
97
- var oldResults = ok . GetIsolatedMassesAndChargesOld ( precursorSpectrum , maxAssumedChargeState , deconvolutionTolerance , intensityRatio ) . OrderBy ( b => b . Item1 . First ( ) . Mz . ToMass ( b . Item2 ) ) . ToList ( ) ;
61
+ //Console.WriteLine("intensityRatio, deconvolutionTolerancePpm, maxAssumedChargeState: " + (intensityRatio, deconvolutionTolerancePpm, maxAssumedChargeState) );
98
62
99
- //output.WriteLine(ok.OneBasedScanNumber + "\tOldMonoisotopicMzs\t" + string.Join("\t", oldResults.Select(b => b.Item1.First().Mz.ToString("G6"))));
100
- //output.WriteLine(ok.OneBasedScanNumber + "\tOldMonoisotopicMasses\t" + string.Join("\t", oldResults.Select(b => b.Item1.First().Mz.ToMass(b.Item2).ToString("G6"))));
63
+ //int goodScans = 0;
101
64
102
- var newResults = ok . GetIsolatedMassesAndCharges ( precursorSpectrum , maxAssumedChargeState , deconvolutionTolerancePpm , intensityRatio ) . OrderBy ( b => b . monoisotopicMass ) . ToList ( ) ;
65
+ int numMatchToOnlyOld = 0 ;
66
+ int numMatchToOnlyNew = 0 ;
67
+ int numMatchToBoth = 0 ;
68
+ int numScansWithThermoMasses = 0 ;
103
69
104
- //output.WriteLine(ok.OneBasedScanNumber + "\tNewLowestObservedMzs\t" + string.Join("\t", newResults.Select(b => b.peaks.OrderBy(c => c.Item1).First().Item1.ToString("G6"))));
105
- //output.WriteLine(ok.OneBasedScanNumber + "\tNewMonoisotopicMasses\t" + string.Join("\t", newResults.Select(b => b.monoisotopicMass.ToString("G6"))));
70
+ int numMatchToOld = 0 ;
71
+ int numMatchToOldPlusMM = 0 ;
72
+ int numMatchToOldMinusMM = 0 ;
73
+ int numMatchToNew = 0 ;
74
+ int numMatchToNewPlusMM = 0 ;
75
+ int numMatchToNewMinusMM = 0 ;
106
76
107
- if ( ok . SelectedIonChargeStateGuess . HasValue )
77
+ //output.WriteLine("Scan\tType");
78
+ foreach ( var ok in a . OfType < IMsDataScanWithPrecursor < IMzSpectrum < IMzPeak > > > ( ) . Where ( b => b . OneBasedScanNumber == 447 ) )
79
+ //foreach (var ok in a.OfType<IMsDataScanWithPrecursor<IMzSpectrum<IMzPeak>>>().Skip(2000))
80
+ //foreach (var ok in a.OfType<IMsDataScanWithPrecursor<IMzSpectrum<IMzPeak>>>())
108
81
{
109
- numScansWithThermoMasses ++ ;
110
- var thermoMass = thermoMz . ToMass ( ok . SelectedIonChargeStateGuess . Value ) ;
111
- bool matchToOld = false ;
112
- bool matchToNew = false ;
113
- bool matchToOldPlusMM = false ;
114
- bool matchToNewPlusMM = false ;
115
- bool matchToOldMinusMM = false ;
116
- bool matchToNewMinusMM = false ;
117
- foreach ( var hm in oldResults )
82
+ double thermoMz = double . NaN ;
83
+ if ( ok . SelectedIonChargeStateGuess . HasValue )
118
84
{
119
- if ( sameMassTolerancePpm . Within ( hm . Item1 . First ( ) . Mz . ToMass ( hm . Item2 ) , thermoMass ) )
120
- {
121
- matchToOld = true ;
122
- }
123
- if ( sameMassTolerancePpm . Within ( hm . Item1 . First ( ) . Mz . ToMass ( hm . Item2 ) + 1.0029 , thermoMass ) )
124
- {
125
- matchToOldPlusMM = true ;
126
- }
127
- if ( sameMassTolerancePpm . Within ( hm . Item1 . First ( ) . Mz . ToMass ( hm . Item2 ) - 1.0029 , thermoMass ) )
128
- {
129
- matchToOldMinusMM = true ;
130
- }
85
+ thermoMz = ok . SelectedIonMZ ;
86
+ if ( ok . SelectedIonMonoisotopicGuessMz . HasValue )
87
+ thermoMz = ok . SelectedIonMonoisotopicGuessMz . Value ;
88
+ //output.WriteLine(ok.OneBasedScanNumber + "\tThermoMz\t" + thermoMz.ToString("G6"));
89
+ //output.WriteLine(ok.OneBasedScanNumber + "\tThermoMass\t" + thermoMz.ToMass(ok.SelectedIonChargeStateGuess.Value).ToString("G6"));
131
90
}
132
- foreach ( var hm in newResults )
91
+ else
133
92
{
134
- if ( sameMassTolerancePpm . Within ( hm . monoisotopicMass , thermoMass ) )
93
+ //output.WriteLine(ok.OneBasedScanNumber + "\tThermoMz\t" + " ");
94
+ //output.WriteLine(ok.OneBasedScanNumber + "\tThermoMass\t" + " ");
95
+ }
96
+
97
+ var precursorSpectrum = a . GetOneBasedScan ( ok . OneBasedPrecursorScanNumber . Value ) . MassSpectrum ;
98
+
99
+ var oldResults = ok . GetIsolatedMassesAndChargesOld ( precursorSpectrum , maxAssumedChargeState , deconvolutionTolerance , intensityRatio ) . OrderBy ( b => b . Item1 . First ( ) . Mz . ToMass ( b . Item2 ) ) . ToList ( ) ;
100
+
101
+ //output.WriteLine(ok.OneBasedScanNumber + "\tOldMonoisotopicMzs\t" + string.Join("\t", oldResults.Select(b => b.Item1.First().Mz.ToString("G6"))));
102
+ //output.WriteLine(ok.OneBasedScanNumber + "\tOldMonoisotopicMasses\t" + string.Join("\t", oldResults.Select(b => b.Item1.First().Mz.ToMass(b.Item2).ToString("G6"))));
103
+
104
+ var newResults = ok . GetIsolatedMassesAndCharges ( precursorSpectrum , maxAssumedChargeState , deconvolutionTolerancePpm , intensityRatio ) . OrderBy ( b => b . monoisotopicMass ) . ToList ( ) ;
105
+
106
+ //output.WriteLine(ok.OneBasedScanNumber + "\tNewLowestObservedMzs\t" + string.Join("\t", newResults.Select(b => b.peaks.OrderBy(c => c.Item1).First().Item1.ToString("G6"))));
107
+ //output.WriteLine(ok.OneBasedScanNumber + "\tNewMonoisotopicMasses\t" + string.Join("\t", newResults.Select(b => b.monoisotopicMass.ToString("G6"))));
108
+
109
+ if ( ok . SelectedIonChargeStateGuess . HasValue )
110
+ {
111
+ numScansWithThermoMasses ++ ;
112
+ var thermoMass = thermoMz . ToMass ( ok . SelectedIonChargeStateGuess . Value ) ;
113
+ bool matchToOld = false ;
114
+ bool matchToNew = false ;
115
+ bool matchToOldPlusMM = false ;
116
+ bool matchToNewPlusMM = false ;
117
+ bool matchToOldMinusMM = false ;
118
+ bool matchToNewMinusMM = false ;
119
+ foreach ( var hm in oldResults )
135
120
{
136
- matchToNew = true ;
121
+ if ( sameMassTolerancePpm . Within ( hm . Item1 . First ( ) . Mz . ToMass ( hm . Item2 ) , thermoMass ) )
122
+ {
123
+ matchToOld = true ;
124
+ }
125
+ if ( sameMassTolerancePpm . Within ( hm . Item1 . First ( ) . Mz . ToMass ( hm . Item2 ) + 1.0029 , thermoMass ) )
126
+ {
127
+ matchToOldPlusMM = true ;
128
+ }
129
+ if ( sameMassTolerancePpm . Within ( hm . Item1 . First ( ) . Mz . ToMass ( hm . Item2 ) - 1.0029 , thermoMass ) )
130
+ {
131
+ matchToOldMinusMM = true ;
132
+ }
137
133
}
138
- if ( sameMassTolerancePpm . Within ( hm . monoisotopicMass + 1.0029 , thermoMass ) )
134
+ foreach ( var hm in newResults )
139
135
{
140
- matchToNewPlusMM = true ;
136
+ if ( sameMassTolerancePpm . Within ( hm . monoisotopicMass , thermoMass ) )
137
+ {
138
+ matchToNew = true ;
139
+ }
140
+ if ( sameMassTolerancePpm . Within ( hm . monoisotopicMass + 1.0029 , thermoMass ) )
141
+ {
142
+ matchToNewPlusMM = true ;
143
+ }
144
+ if ( sameMassTolerancePpm . Within ( hm . monoisotopicMass - 1.0029 , thermoMass ) )
145
+ {
146
+ matchToNewMinusMM = true ;
147
+ }
141
148
}
142
- if ( sameMassTolerancePpm . Within ( hm . monoisotopicMass - 1.0029 , thermoMass ) )
149
+ numMatchToOld += matchToOld ? 1 : 0 ;
150
+ numMatchToOldPlusMM += matchToOldPlusMM ? 1 : 0 ;
151
+ numMatchToOldMinusMM += matchToOldMinusMM ? 1 : 0 ;
152
+ numMatchToNew += matchToNew ? 1 : 0 ;
153
+ numMatchToNewPlusMM += matchToNewPlusMM ? 1 : 0 ;
154
+ numMatchToNewMinusMM += matchToNewMinusMM ? 1 : 0 ;
155
+ if ( matchToOld && ! matchToNew )
156
+ numMatchToOnlyOld ++ ;
157
+ if ( matchToNew && ! matchToOld )
158
+ numMatchToOnlyNew ++ ;
159
+ if ( matchToOld && matchToNew )
160
+ numMatchToBoth ++ ;
161
+
162
+ if ( ! matchToNew )
143
163
{
144
- matchToNewMinusMM = true ;
164
+ output . WriteLine ( ok . OneBasedScanNumber + " \t " + matchToNewMinusMM + " \t " + matchToNewPlusMM + " \t " + thermoMz . ToMass ( ok . SelectedIonChargeStateGuess . Value ) . ToString ( "G6" ) + " \t " + string . Join ( " \t " , newResults . Select ( b => b . monoisotopicMass ) ) ) ;
145
165
}
166
+ //if (matchToOld && !matchToNew && thermoMz > 500)
167
+ //{
168
+ // Console.WriteLine(ok.OneBasedScanNumber + "\tThermoMz\t" + thermoMz.ToString("G6"));
169
+ // Console.WriteLine(ok.OneBasedScanNumber + "\tThermoMass\t" + thermoMz.ToMass(ok.SelectedIonChargeStateGuess.Value).ToString("G6"));
170
+ // Console.WriteLine(ok.OneBasedScanNumber + "\tOldMonoisotopicMzs\t" + string.Join("\t", oldResults.Select(b => b.Item1.First().Mz.ToString("G6"))));
171
+ // Console.WriteLine(ok.OneBasedScanNumber + "\tOldMonoisotopicMasses\t" + string.Join("\t", oldResults.Select(b => b.Item1.First().Mz.ToMass(b.Item2).ToString("G6"))));
172
+ // Console.WriteLine(ok.OneBasedScanNumber + "\tNewLowestObservedMzs\t" + string.Join("\t", newResults.Select(b => b.peaks.OrderBy(c => c.Item1).First().Item1.ToString("G6"))));
173
+ // Console.WriteLine(ok.OneBasedScanNumber + "\tNewMonoisotopicMasses\t" + string.Join("\t", newResults.Select(b => b.monoisotopicMass.ToString("G6"))));
174
+
175
+ //}
176
+ //else
177
+ //{
178
+ // Console.WriteLine(ok.OneBasedScanNumber + " good ");
146
179
}
147
- numMatchToOld += matchToOld ? 1 : 0 ;
148
- numMatchToOldPlusMM += matchToOldPlusMM ? 1 : 0 ;
149
- numMatchToOldMinusMM += matchToOldMinusMM ? 1 : 0 ;
150
- numMatchToNew += matchToNew ? 1 : 0 ;
151
- numMatchToNewPlusMM += matchToNewPlusMM ? 1 : 0 ;
152
- numMatchToNewMinusMM += matchToNewMinusMM ? 1 : 0 ;
153
- if ( matchToOld && ! matchToNew )
154
- numMatchToOnlyOld ++ ;
155
- if ( matchToNew && ! matchToOld )
156
- numMatchToOnlyNew ++ ;
157
- if ( matchToOld && matchToNew )
158
- numMatchToBoth ++ ;
159
- //if (matchToOld && !matchToNew && thermoMz > 500)
160
- //{
161
- // Console.WriteLine(ok.OneBasedScanNumber + "\tThermoMz\t" + thermoMz.ToString("G6"));
162
- // Console.WriteLine(ok.OneBasedScanNumber + "\tThermoMass\t" + thermoMz.ToMass(ok.SelectedIonChargeStateGuess.Value).ToString("G6"));
163
- // Console.WriteLine(ok.OneBasedScanNumber + "\tOldMonoisotopicMzs\t" + string.Join("\t", oldResults.Select(b => b.Item1.First().Mz.ToString("G6"))));
164
- // Console.WriteLine(ok.OneBasedScanNumber + "\tOldMonoisotopicMasses\t" + string.Join("\t", oldResults.Select(b => b.Item1.First().Mz.ToMass(b.Item2).ToString("G6"))));
165
- // Console.WriteLine(ok.OneBasedScanNumber + "\tNewLowestObservedMzs\t" + string.Join("\t", newResults.Select(b => b.peaks.OrderBy(c => c.Item1).First().Item1.ToString("G6"))));
166
- // Console.WriteLine(ok.OneBasedScanNumber + "\tNewMonoisotopicMasses\t" + string.Join("\t", newResults.Select(b => b.monoisotopicMass.ToString("G6"))));
167
-
168
- //}
169
- //else
170
- //{
171
- // Console.WriteLine(ok.OneBasedScanNumber + " good ");
172
- //}
173
180
}
174
- }
175
181
176
- Console . WriteLine ( "numMatchToOld: " + numMatchToOld ) ;
177
- Console . WriteLine ( "numMatchToOldPlusMM: " + numMatchToOldPlusMM ) ;
178
- Console . WriteLine ( "numMatchToOldMinusMM: " + numMatchToOldMinusMM ) ;
179
- Console . WriteLine ( "numMatchToNew: " + numMatchToNew ) ;
180
- Console . WriteLine ( "numMatchToNewPlusMM: " + numMatchToNewPlusMM ) ;
181
- Console . WriteLine ( "numMatchToNewMinusMM: " + numMatchToNewMinusMM ) ;
182
-
183
- Console . WriteLine ( "numMatchToOnlyOld: " + numMatchToOnlyOld ) ;
184
- Console . WriteLine ( "numMatchToOnlyNew: " + numMatchToOnlyNew ) ;
185
- Console . WriteLine ( "numMatchToBoth: " + numMatchToBoth ) ;
186
- Console . WriteLine ( "numScansWithThermoMasses: " + numScansWithThermoMasses ) ;
182
+ Console . WriteLine ( "numMatchToOld: " + numMatchToOld ) ;
183
+ Console . WriteLine ( "numMatchToOldPlusMM: " + numMatchToOldPlusMM ) ;
184
+ Console . WriteLine ( "numMatchToOldMinusMM: " + numMatchToOldMinusMM ) ;
185
+ Console . WriteLine ( "numMatchToNew: " + numMatchToNew ) ;
186
+ Console . WriteLine ( "numMatchToNewPlusMM: " + numMatchToNewPlusMM ) ;
187
+ Console . WriteLine ( "numMatchToNewMinusMM: " + numMatchToNewMinusMM ) ;
188
+
189
+ Console . WriteLine ( "numMatchToOnlyOld: " + numMatchToOnlyOld ) ;
190
+ Console . WriteLine ( "numMatchToOnlyNew: " + numMatchToOnlyNew ) ;
191
+ Console . WriteLine ( "numMatchToBoth: " + numMatchToBoth ) ;
192
+ Console . WriteLine ( "numScansWithThermoMasses: " + numScansWithThermoMasses ) ;
193
+ }
187
194
}
188
195
}
189
196
@@ -224,7 +231,7 @@ private static void DoFileDecon(string[] args)
224
231
225
232
using ( StreamWriter output = new StreamWriter ( @"DeconvolutionOutput-" + DateTime . Now . ToString ( "yyyy-MM-dd-HH-mm-ss" , CultureInfo . InvariantCulture ) + ".tsv" ) )
226
233
{
227
- output . WriteLine ( "Mass\t NumPeaks\t NumScans\t MinScan\t MaxScan\t AverageElutionTime\t Intensity\t MostIntenseCharge\t MostIntenseMz\t NumPeaksInMostIntenseEnvelope" ) ;
234
+ output . WriteLine ( "Mass\t NumPeaks\t NumScans\t MinScan\t MaxScan\t AverageElutionTime\t Intensity\t ObservedCharges \ t MostIntenseCharge\t MostIntenseMz\t NumPeaksInMostIntenseEnvelope" ) ;
228
235
foreach ( var nice in a . Deconvolute ( p . Object . MinScan , p . Object . MaxScan , p . Object . MaxAssumedChargeState , p . Object . DeconvolutionTolerancePpm , p . Object . IntensityRatioLimit , p . Object . AggregationTolerancePpm , b => b . MsnOrder == 1 ) . OrderByDescending ( b => b . TotalIntensity ) )
229
236
{
230
237
output . WriteLine ( nice . OneLineString ( ) ) ;
0 commit comments