Skip to content

Commit 824c9d5

Browse files
author
stefanks
authored
Ordinal and fix decon tools
* Ordinal * noice
1 parent ef28b76 commit 824c9d5

File tree

11 files changed

+42
-197
lines changed

11 files changed

+42
-197
lines changed

MS1decon/App.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<configuration>
33
<startup>
4-
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/>
4+
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1"/>
55
</startup>
66
</configuration>

MS1decon/MS1decon.csproj

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<OutputType>Exe</OutputType>
99
<RootNamespace>MS1Decon</RootNamespace>
1010
<AssemblyName>MS1Decon</AssemblyName>
11-
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
11+
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
1212
<FileAlignment>512</FileAlignment>
1313
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
1414
<TargetFrameworkProfile />
@@ -40,7 +40,7 @@
4040
<Reference Include="System" />
4141
<Reference Include="System.Core" />
4242
<Reference Include="System.ValueTuple, Version=4.0.2.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
43-
<HintPath>..\packages\System.ValueTuple.4.4.0\lib\netstandard1.0\System.ValueTuple.dll</HintPath>
43+
<HintPath>..\packages\System.ValueTuple.4.4.0\lib\net461\System.ValueTuple.dll</HintPath>
4444
</Reference>
4545
<Reference Include="System.Xml.Linq" />
4646
<Reference Include="System.Data.DataSetExtensions" />
@@ -73,6 +73,10 @@
7373
<Project>{B208FF5F-5A33-490D-9DDB-7C76F5600FC4}</Project>
7474
<Name>MzLibUtil</Name>
7575
</ProjectReference>
76+
<ProjectReference Include="..\MzML\MzML.csproj">
77+
<Project>{012434FB-88A9-4DEC-B887-5F64C0B481D4}</Project>
78+
<Name>MzML</Name>
79+
</ProjectReference>
7680
<ProjectReference Include="..\Spectra\Spectra.csproj">
7781
<Project>{088E4FCB-D580-4BAD-A811-A1796A7666D2}</Project>
7882
<Name>Spectra</Name>

MS1decon/Program.cs

Lines changed: 9 additions & 177 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1-
using Chemistry;
2-
using Fclp;
1+
using Fclp;
2+
using IO.MzML;
33
using IO.Thermo;
44
using MassSpectrometry;
5-
using MzLibUtil;
65
using System;
7-
using System.Collections.Generic;
86
using System.Globalization;
97
using System.IO;
108
using System.Linq;
@@ -21,177 +19,7 @@ private static void Main(string[] args)
2119
{
2220
Loaders.LoadElements("elements.dat");
2321

24-
if (args.Length > 0)
25-
{
26-
DoFileDecon(args);
27-
}
28-
else { DeconTest(); }
29-
}
30-
31-
private static void DeconTest()
32-
{
33-
List<string> files = new List<string>
34-
{
35-
//@"C:\Users\stepa\Desktop\Decon\04-29-13_B6_Frac5_4uL.raw",
36-
//@"C:\Users\stepa\Desktop\Decon\12-10-16_A17A_yeast_BU_fract9_rep1_8uL.raw",
37-
@"C:\Users\stepa\Desktop\Decon\120426_Jurkat_highLC_Frac17.raw",
38-
//@"C:\Users\stepa\Desktop\Decon\07-26-17_YL_150mins_steeper-grad_yeast.raw",
39-
//@"C:\Users\stepa\Desktop\Decon\07-28-17_19_rep2_mouse.raw",
40-
//@"C:\Users\stepa\Desktop\Decon\09-01-17_iodo_1-4th_rep1_human.raw",
41-
};
42-
43-
var sameMassTolerancePpm = new PpmTolerance(10);
44-
45-
var intensityRatio = 5;
46-
var deconvolutionTolerancePpm = 20;
47-
var maxAssumedChargeState = 10;
48-
49-
Tolerance deconvolutionTolerance = new PpmTolerance(deconvolutionTolerancePpm);
50-
51-
foreach (var file in files)
52-
{
53-
Console.WriteLine(file);
54-
ThermoStaticData a = ThermoStaticData.LoadAllStaticData(file);
55-
//ThermoDynamicData a = ThermoDynamicData.InitiateDynamicConnection(@"C:\Users\stepa\Desktop\Decon\09-01-17_iodo_1-4th_rep1_human.raw");
56-
57-
using (StreamWriter output = new StreamWriter(@"unmatched.tsv"))
58-
{
59-
output.WriteLine("Scan\tmatchToNewMinusMM\tmatchToNewPlusMM\tThermoMass");
60-
61-
//Console.WriteLine("intensityRatio, deconvolutionTolerancePpm, maxAssumedChargeState: " + (intensityRatio, deconvolutionTolerancePpm, maxAssumedChargeState));
62-
63-
//int goodScans = 0;
64-
65-
int numMatchToOnlyOld = 0;
66-
int numMatchToOnlyNew = 0;
67-
int numMatchToBoth = 0;
68-
int numScansWithThermoMasses = 0;
69-
70-
int numMatchToOld = 0;
71-
int numMatchToOldPlusMM = 0;
72-
int numMatchToOldMinusMM = 0;
73-
int numMatchToNew = 0;
74-
int numMatchToNewPlusMM = 0;
75-
int numMatchToNewMinusMM = 0;
76-
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>>>())
81-
{
82-
double thermoMz = double.NaN;
83-
if (ok.SelectedIonChargeStateGuess.HasValue)
84-
{
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"));
90-
}
91-
else
92-
{
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)
120-
{
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-
}
133-
}
134-
foreach (var hm in newResults)
135-
{
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-
}
148-
}
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)
163-
{
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)));
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 ");
179-
}
180-
}
181-
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-
}
194-
}
22+
DoFileDecon(args);
19523
}
19624

19725
private static void DoFileDecon(string[] args)
@@ -227,12 +55,16 @@ private static void DoFileDecon(string[] args)
22755

22856
if (result.HasErrors == false)
22957
{
230-
ThermoStaticData a = ThermoStaticData.LoadAllStaticData(p.Object.FilePath);
58+
IMsDataFile<IMsDataScan<IMzSpectrum<IMzPeak>>> myMsDataFile;
59+
if (Path.GetExtension(p.Object.FilePath).Equals(".mzML", StringComparison.OrdinalIgnoreCase))
60+
myMsDataFile = Mzml.LoadAllStaticData(p.Object.FilePath);
61+
else
62+
myMsDataFile = ThermoStaticData.LoadAllStaticData(p.Object.FilePath);
23163

23264
using (StreamWriter output = new StreamWriter(@"DeconvolutionOutput-" + DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss", CultureInfo.InvariantCulture) + ".tsv"))
23365
{
23466
output.WriteLine("Mass\tNumPeaks\tNumScans\tMinScan\tMaxScan\tAverageElutionTime\tIntensity\tObservedCharges\tMostIntenseCharge\tMostIntenseMz\tNumPeaksInMostIntenseEnvelope");
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))
67+
foreach (var nice in myMsDataFile.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))
23668
{
23769
output.WriteLine(nice.OneLineString());
23870
}

MS1decon/packages.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<packages>
33
<package id="FluentCommandLineParser" version="1.4.3" targetFramework="net45" />
4-
<package id="System.ValueTuple" version="4.4.0" targetFramework="net45" />
4+
<package id="System.ValueTuple" version="4.4.0" targetFramework="net461" />
55
</packages>

MS2decon/App.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<configuration>
33
<startup>
4-
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/>
4+
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1"/>
55
</startup>
66
</configuration>

MS2decon/MS2decon.csproj

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<OutputType>Exe</OutputType>
99
<RootNamespace>MS2decon</RootNamespace>
1010
<AssemblyName>MS2decon</AssemblyName>
11-
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
11+
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
1212
<FileAlignment>512</FileAlignment>
1313
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
1414
<TargetFrameworkProfile />
@@ -40,7 +40,7 @@
4040
<Reference Include="System" />
4141
<Reference Include="System.Core" />
4242
<Reference Include="System.ValueTuple, Version=4.0.2.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
43-
<HintPath>..\packages\System.ValueTuple.4.4.0\lib\netstandard1.0\System.ValueTuple.dll</HintPath>
43+
<HintPath>..\packages\System.ValueTuple.4.4.0\lib\net461\System.ValueTuple.dll</HintPath>
4444
</Reference>
4545
<Reference Include="System.Xml.Linq" />
4646
<Reference Include="System.Data.DataSetExtensions" />
@@ -65,6 +65,10 @@
6565
<Project>{B208FF5F-5A33-490D-9DDB-7C76F5600FC4}</Project>
6666
<Name>MzLibUtil</Name>
6767
</ProjectReference>
68+
<ProjectReference Include="..\MzML\MzML.csproj">
69+
<Project>{012434FB-88A9-4DEC-B887-5F64C0B481D4}</Project>
70+
<Name>MzML</Name>
71+
</ProjectReference>
6872
<ProjectReference Include="..\Spectra\Spectra.csproj">
6973
<Project>{088E4FCB-D580-4BAD-A811-A1796A7666D2}</Project>
7074
<Name>Spectra</Name>

MS2decon/Program.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using Fclp;
2+
using IO.MzML;
23
using IO.Thermo;
34
using MassSpectrometry;
45
using System;
@@ -47,13 +48,17 @@ private static void Main(string[] args)
4748

4849
if (result.HasErrors == false)
4950
{
50-
ThermoStaticData a = ThermoStaticData.LoadAllStaticData(p.Object.FilePath);
51+
IMsDataFile<IMsDataScan<IMzSpectrum<IMzPeak>>> myMsDataFile;
52+
if (Path.GetExtension(p.Object.FilePath).Equals(".mzML", StringComparison.OrdinalIgnoreCase))
53+
myMsDataFile = Mzml.LoadAllStaticData(p.Object.FilePath);
54+
else
55+
myMsDataFile = ThermoStaticData.LoadAllStaticData(p.Object.FilePath);
5156

5257
using (StreamWriter output = new StreamWriter(@"MS2DeconvolutionOutput-" + DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss", CultureInfo.InvariantCulture) + ".tsv"))
5358
{
5459
output.WriteLine("Mass\tNumPeaks\tNumScans\tMinScan\tMaxScan\tAverageElutionTime\tIntensity\tObservedCharges\tMostIntenseCharge\tMostIntenseMz\tNumPeaksInMostIntenseEnvelope");
5560

56-
foreach (var ok in a.OfType<IMsDataScanWithPrecursor<IMzSpectrum<IMzPeak>>>())
61+
foreach (var ok in myMsDataFile.OfType<IMsDataScanWithPrecursor<IMzSpectrum<IMzPeak>>>())
5762
{
5863
if ((!p.Object.MinScan.HasValue || ok.OneBasedScanNumber >= p.Object.MinScan) && (!p.Object.MaxScan.HasValue || ok.OneBasedScanNumber <= p.Object.MaxScan))
5964
{

MS2decon/packages.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<packages>
33
<package id="FluentCommandLineParser" version="1.4.3" targetFramework="net45" />
4-
<package id="System.ValueTuple" version="4.4.0" targetFramework="net45" />
4+
<package id="System.ValueTuple" version="4.4.0" targetFramework="net461" />
55
</packages>

ManagedThermoHelperLayer/ClassLibrary1.vcxproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<Keyword>ManagedCProj</Keyword>
1818
<RootNamespace>ClassLibrary1</RootNamespace>
1919
<ProjectName>ManagedThermoHelperLayer</ProjectName>
20-
<WindowsTargetPlatformVersion>10.0.15063.0</WindowsTargetPlatformVersion>
20+
<WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
2121
</PropertyGroup>
2222
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
2323
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">

MzLibUtil/Tolerance.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ protected Tolerance(double value)
7373
public static Tolerance ParseToleranceString(string s)
7474
{
7575
Match m = StringRegex.Match(s);
76-
if (m.Groups[3].Value.Equals("PPM", StringComparison.InvariantCultureIgnoreCase))
76+
if (m.Groups[3].Value.Equals("PPM", StringComparison.OrdinalIgnoreCase))
7777
return new PpmTolerance(double.Parse(m.Groups[2].Value));
7878
else
7979
return new AbsoluteTolerance(double.Parse(m.Groups[2].Value));

0 commit comments

Comments
 (0)