Skip to content

Commit

Permalink
allow tab separated lines in mgf (#611)
Browse files Browse the repository at this point in the history
  • Loading branch information
trishorts authored Feb 22, 2022
1 parent 4f12380 commit 3f71372
Show file tree
Hide file tree
Showing 4 changed files with 112 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Mgf/Mgf.cs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ public static MsDataScan GetNextMsDataOneBasedScanFromConnection(StreamReader sr

private static void ParsePeakLine(string line, List<double> mzs, List<double> intensities)
{
var sArray = line.Split(' ', StringSplitOptions.RemoveEmptyEntries);
string[] sArray = line.Split(new Char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);

mzs.Add(Convert.ToDouble(sArray[0], CultureInfo.InvariantCulture));
intensities.Add(Convert.ToDouble(sArray[1], CultureInfo.InvariantCulture));
Expand Down
87 changes: 87 additions & 0 deletions Test/DataFiles/Tab_separated_peak_list.mgf
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
BEGIN IONS
TITLE=mutli_CE_Slot2-6_1_6878.2.2.2 File:"Mukhe004_humanPlasma_iSCE80_mutli_CE_Slot2-6_1_6878.raw", NativeID:"controllerType=0 controllerNumber=1 scan=2"
PEPMASS=354.800325189673 1046
ION_MOBILITY=354.800325189673 1046 1.37928581237793
CHARGE=2+
SCANS=2
RTINSECONDS=923.5895
RAWFILE=Mukhe004_humanPlasma_iSCE80_mutli_CE_Slot2-6_1_6878
MSORDER=2
USER00=354.800325189673
227.78699546734 58 0
263.077466562901 53 0
272.295743198382 124 0
273.810874645544 114 0
274.284891372401 102 0
274.777473658335 50 0
283.846043091957 87 0
290.80278660452 220 0
292.869011370296 140 0
301.315688794295 63 0
348.69354144214 73 0
352.722596276934 87 0
378.706341183468 64 0
412.744319503724 65 0
428.704105821685 64 0
490.674902503096 63 0
510.654611528048 63 0
527.616717516601 70 0
565.639749312051 177 2
END IONS



BEGIN IONS
TITLE=mutli_CE_Slot2-6_1_6878.3.3.2 File:"mutli_CE_Slot2-6_1_6878.raw", NativeID:"controllerType=0 controllerNumber=1 scan=3"
PEPMASS=356.163307924301 1475
ION_MOBILITY=356.163307924301 1475 1.19177198410034
CHARGE=2+
SCANS=3
RTINSECONDS=977.2935
RAWFILE=mutli_CE_Slot2-6_1_6878
MSORDER=2
USER00=356.163307924301
182.979220764347 93 0
194.067988609829 97 0
226.089865392531 72 0
232.964223424455 88 0
239.098818425428 81 0
264.925740951189 49 0
266.788152228119 155 0
279.044992236628 63 0
284.793211411101 134 0
290.632042944267 122 0
302.844050993589 50 0
302.865834947644 88 0
304.149746120338 54 0
311.637348772588 231 1
315.151801367068 98 0
320.852240828624 58 0
322.083820773715 93 0
326.154317316766 501 0
326.643363381427 383 0
336.131059622835 47 0
338.870480636718 87 0
339.184512227996 56 0
352.149794822285 64 0
354.140441728679 91 0
356.175086957589 73 0
380.158590566139 107 1
382.142719352064 60 0
384.87291341834 46 0
408.846758742278 57 0
420.155401268746 59 0
426.190534508141 95 0
436.132300768052 84 0
438.927356953954 60 0
444.059426881496 98 0
478.197990244431 62 0
486.21052101725 66 0
494.902068163664 64 0
502.800118432346 106 0
505.199310039657 119 0
513.902126928795 83 0
522.242933462631 65 0
581.240404202413 48 0
END IONS

3 changes: 3 additions & 0 deletions Test/Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,9 @@
<None Update="DataFiles\SmallCalibratibleYeast_mixed_bits.mzml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="DataFiles\Tab_separated_peak_list.mgf">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="DataFiles\tester.mgf">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
Expand Down
21 changes: 21 additions & 0 deletions Test/TestMgf.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,27 @@ public static void TestLoadMgf()
Assert.AreEqual(551, ya3.Size);
}

[Test]
public static void TestLoadMgfTabSeparated()
{

Mgf a = Mgf.LoadAllStaticData(Path.Combine(TestContext.CurrentContext.TestDirectory, "DataFiles", "Tab_separated_peak_list.mgf"));

var ya = a.GetOneBasedScan(2);
Assert.AreEqual(19, ya.MassSpectrum.Size);
Assert.AreEqual(2, ya.MsnOrder);
Assert.AreEqual(2, ya.OneBasedScanNumber);
Assert.AreEqual(MassSpectrometry.Polarity.Positive, ya.Polarity);
Assert.That(ya.RetentionTime, Is.EqualTo(15.393).Within(0.1));
Assert.That(ya.IsolationMz, Is.EqualTo(354.8).Within(0.1));
Assert.That(ya.SelectedIonMZ, Is.EqualTo(354.8).Within(0.1));
Assert.That(ya.SelectedIonChargeStateGuess, Is.EqualTo(2));
Assert.That(ya.SelectedIonMonoisotopicGuessMz, Is.EqualTo(354.8).Within(0.1));
Assert.That(ya.TotalIonCurrent, Is.EqualTo(1737).Within(0.1));
Assert.That(ya.ScanWindowRange.Minimum, Is.EqualTo(227.787).Within(0.1));
Assert.That(ya.ScanWindowRange.Maximum, Is.EqualTo(565.64).Within(0.1));
}

[Test]
public void EliminateZeroIntensityPeaksFromMgfOnFileLoad()
{
Expand Down

0 comments on commit 3f71372

Please sign in to comment.