Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allowed reading of scan descriptions from Raw Files #736

Merged
merged 2 commits into from
Nov 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion mzLib/MassSpectrometry/MsDataScan.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;

namespace MassSpectrometry
Expand All @@ -28,7 +29,7 @@ public class MsDataScan
{
public MsDataScan(MzSpectrum massSpectrum, int oneBasedScanNumber, int msnOrder, bool isCentroid, Polarity polarity, double retentionTime, MzRange scanWindowRange, string scanFilter, MZAnalyzerType mzAnalyzer,
double totalIonCurrent, double? injectionTime, double[,] noiseData, string nativeId, double? selectedIonMz = null, int? selectedIonChargeStateGuess = null, double? selectedIonIntensity = null, double? isolationMZ = null,
double? isolationWidth = null, DissociationType? dissociationType = null, int? oneBasedPrecursorScanNumber = null, double? selectedIonMonoisotopicGuessMz = null, string hcdEnergy = null)
double? isolationWidth = null, DissociationType? dissociationType = null, int? oneBasedPrecursorScanNumber = null, double? selectedIonMonoisotopicGuessMz = null, string hcdEnergy = null, string scanDescription = null)
{
OneBasedScanNumber = oneBasedScanNumber;
MsnOrder = msnOrder;
Expand All @@ -52,6 +53,7 @@ public MsDataScan(MzSpectrum massSpectrum, int oneBasedScanNumber, int msnOrder,
SelectedIonChargeStateGuess = selectedIonChargeStateGuess;
SelectedIonMonoisotopicGuessMz = selectedIonMonoisotopicGuessMz;
HcdEnergy = hcdEnergy;
ScanDescription = scanDescription;
}

/// <summary>
Expand Down Expand Up @@ -84,6 +86,7 @@ public MsDataScan(MzSpectrum massSpectrum, int oneBasedScanNumber, int msnOrder,
public double? SelectedIonMonoisotopicGuessIntensity { get; private set; } // May be refined
public double? SelectedIonMonoisotopicGuessMz { get; private set; } // May be refined
public string HcdEnergy { get; private set; }
public string ScanDescription { get; private set; }

private MzRange isolationRange;

Expand Down
9 changes: 8 additions & 1 deletion mzLib/Readers/Thermo/ThermoRawFileReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ private static MsDataScan GetOneBasedScan(IRawDataPlus rawFile, IFilteringParams
int? precursorScanNumber = null;
double? isolationMz = null;
string HcdEnergy = null;
string scanDescript = null;
ActivationType activationType = ActivationType.Any; // thermo enum
DissociationType dissociationType = DissociationType.Unknown; // mzLib enum

Expand Down Expand Up @@ -306,6 +307,11 @@ private static MsDataScan GetOneBasedScan(IRawDataPlus rawFile, IFilteringParams
{
HcdEnergy = values[i];
}

if (labels[i].StartsWith("Scan Description", StringComparison.Ordinal))
{
scanDescript = values[i].TrimEnd();
}
}

if (msOrder > 1)
Expand Down Expand Up @@ -397,7 +403,8 @@ private static MsDataScan GetOneBasedScan(IRawDataPlus rawFile, IFilteringParams
dissociationType: dissociationType,
oneBasedPrecursorScanNumber: precursorScanNumber,
selectedIonMonoisotopicGuessMz: precursorSelectedMonoisotopicIonMz,
hcdEnergy: HcdEnergy);
hcdEnergy: HcdEnergy,
scanDescription: scanDescript);
}

private static MzSpectrum GetSpectrum(IRawDataPlus rawFile, IFilteringParams filterParams,
Expand Down
Binary file added mzLib/Test/DataFiles/ScanDescriptionTestData.raw
Binary file not shown.
13 changes: 13 additions & 0 deletions mzLib/Test/FileReadingTests/TestRawFileReader.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Diagnostics;
using System.IO;
using System.Linq;
Expand Down Expand Up @@ -40,6 +41,18 @@ public void TestRawFileReaderFileNotFoundException()
#endregion


[Test]
public void TestScanDescription()
{
string filePath = Path.Combine(TestContext.CurrentContext.TestDirectory, "DataFiles", "ScanDescriptionTestData.raw");
var scans = MsDataFileReader.GetDataFile(filePath).GetAllScansList();
var ms1Scans = scans.Where(x => x.MsnOrder == 1).ToList();
var ms2Scans = scans.Where(x => x.MsnOrder == 2).ToList();

ms1Scans.ForEach(x => Assert.That(x.ScanDescription, Is.EqualTo(null)));
ms2Scans.ForEach(x => Assert.That(x.ScanDescription, Is.EqualTo("Testing2")));
}

/// <summary>
/// Tests LoadAllStaticData for ThermoRawFileReader
/// </summary>
Expand Down
3 changes: 3 additions & 0 deletions mzLib/Test/Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,9 @@
<None Update="DataFiles\GUACUG_NegativeMode_Sliced.mzML">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="DataFiles\ScanDescriptionTestData.raw">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="FileReadingTests\ExternalFileTypes\Ms1Feature_FlashDeconvOpenMs3.0.0_ms1.feature">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
Expand Down