Skip to content
Open
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
2 changes: 2 additions & 0 deletions pwiz/data/vendor_readers/Agilent/Reader_Agilent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ void fillInMetadata(const string& rawpath, MassHunterDataPtr rawfile, MSData& ms
if (scanTypes & MSScanType_Scan) msd.fileDescription.fileContent.set(MS_MS1_spectrum);
if (scanTypes & MSScanType_ProductIon) msd.fileDescription.fileContent.set(MS_MSn_spectrum);
if (scanTypes & MSScanType_PrecursorIon) msd.fileDescription.fileContent.set(MS_precursor_ion_spectrum);
if (scanTypes & MSScanType_NeutralLoss) msd.fileDescription.fileContent.set(MS_constant_neutral_loss_spectrum);
if (scanTypes & MSScanType_NeutralGain) msd.fileDescription.fileContent.set(MS_constant_neutral_gain_spectrum);
// other scan types are not enumerated

if (!msd.fileDescription.fileContent.empty())
Expand Down
4 changes: 2 additions & 2 deletions pwiz/data/vendor_readers/Agilent/Reader_Agilent_Detail.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,8 @@ PWIZ_API_DECL CVID translateAsSpectrumType(MSScanType scanType)
if (scanType == MSScanType_SelectedIon) return MS_SIM_spectrum;
if (scanType == MSScanType_TotalIon) return MS_SIM_spectrum;
if (scanType == MSScanType_MultipleReaction) return MS_SRM_spectrum;
if (scanType == MSScanType_NeutralLoss) return MS_constant_neutral_loss_scan_OBSOLETE;
if (scanType == MSScanType_NeutralGain) return MS_constant_neutral_gain_scan_OBSOLETE;
if (scanType == MSScanType_NeutralLoss) return MS_constant_neutral_loss_spectrum;
if (scanType == MSScanType_NeutralGain) return MS_constant_neutral_gain_spectrum;
throw runtime_error("[translateAsSpectrumType] Error parsing spectrum type.");
}

Expand Down

Large diffs are not rendered by default.

9 changes: 8 additions & 1 deletion pwiz/data/vendor_readers/Agilent/SpectrumList_Agilent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ PWIZ_API_DECL SpectrumPtr SpectrumList_Agilent::spectrum(size_t index, DetailLev
}

double mzOfInterest = scanRecordPtr->getMZOfInterest();
bool isNeutralLossOrGainScan = scanType == MSScanType_NeutralLoss || scanType == MSScanType_NeutralGain;
if (msLevel > 1 && mzOfInterest > 0)
{
Precursor precursor;
Expand All @@ -232,6 +233,10 @@ PWIZ_API_DECL SpectrumPtr SpectrumList_Agilent::spectrum(size_t index, DetailLev
//product.isolationWindow.set(MS_isolation_window_lower_offset, isolationWidth/2, MS_m_z);
//product.isolationWindow.set(MS_isolation_window_upper_offset, isolationWidth/2, MS_m_z);
}
else if (isNeutralLossOrGainScan)
{
scan.set(MS_analyzer_scan_offset, mzOfInterest, MS_m_z); // Always positive, look at scan type to determine whether it's loss or gain
}
else
{
precursor.isolationWindow.set(MS_isolation_window_target_m_z, mzOfInterest, MS_m_z);
Expand Down Expand Up @@ -367,7 +372,7 @@ PWIZ_API_DECL SpectrumPtr SpectrumList_Agilent::spectrum(size_t index, DetailLev
}


if (reportMS2ForAllIonsScan)
if (reportMS2ForAllIonsScan || isNeutralLossOrGainScan)
{
// claim a target window that encompasses all ions
Precursor& precursor = result->precursors.back();
Expand Down Expand Up @@ -733,6 +738,8 @@ PWIZ_API_DECL void SpectrumList_Agilent::createIndex() const
scanTypes & MSScanType_ProductIon ||
scanTypes & MSScanType_PrecursorIon ||
scanTypes & MSScanType_SelectedIon ||
scanTypes & MSScanType_NeutralLoss ||
scanTypes & MSScanType_NeutralGain ||
scanTypes & MSScanType_MultipleReaction)
{

Expand Down
22 changes: 22 additions & 0 deletions pwiz_tools/Shared/CommonUtil/Spectra/SpectrumMetadata.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ private enum Flags
HasScanWindow = 2,
HasTotalIonCurrent = 4,
HasInjectionTime = 8,
HasConstantNeutralLoss = 16,
}
private ImmutableList<ImmutableList<SpectrumPrecursor>> _precursorsByMsLevel =
ImmutableList<ImmutableList<SpectrumPrecursor>>.EMPTY;
Expand Down Expand Up @@ -161,6 +162,27 @@ private set
}
}

private double _constantNeutralLoss;

public double? ConstantNeutralLoss // As found in Constant Neutral Loss scans, where Q1 peaks are only reported if there's a Q3 peak with this mz offset. Positive value implies loss, negative value implies gain
{
get
{
return GetFlag(Flags.HasConstantNeutralLoss) ? _constantNeutralLoss : (double?)null;
}
private set
{
_constantNeutralLoss = value.GetValueOrDefault();
SetFlag(Flags.HasConstantNeutralLoss, _constantNeutralLoss != 0);
}
}

public SpectrumMetadata ChangeConstantNeutralLoss(double? value)
{
return ChangeProp(ImClone(this), im => im.ConstantNeutralLoss = value);
}


public SpectrumMetadata ChangeTotalIonCurrent(double? value)
{
return ChangeProp(ImClone(this), im => im.TotalIonCurrent = value);
Expand Down
30 changes: 30 additions & 0 deletions pwiz_tools/Shared/ProteowizardWrapper/MsDataFileImpl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1397,6 +1397,7 @@ private SpectrumMetadata GetSpectrumMetadata(Spectrum spectrum)

metadata = metadata.ChangeTotalIonCurrent(GetTotalIonCurrent(spectrum));
metadata = metadata.ChangeInjectionTime(GetInjectionTime(spectrum));
metadata = metadata.ChangeConstantNeutralLoss(GetConstantNeutralLoss(spectrum));
return metadata;
}

Expand Down Expand Up @@ -1656,6 +1657,35 @@ private static string GetScanDescription(Spectrum spectrum)
return count == 0 ? (double?) null : total;
}

private double? GetConstantNeutralLoss(Spectrum spectrum) // If return value < 0, it's actually a neutral gain
{
try
{
if (spectrum.scanList.empty())
{
return null;
}

CVParam paramOffset = spectrum.scanList.scans[0].cvParam(CVID.MS_analyzer_scan_offset);
if (paramOffset.empty())
{
return null;
}

CVParam paramScanType = spectrum.scanList.scans[0].cvParam(CVID.MS_constant_neutral_gain_spectrum);
if (paramScanType.empty())
{
return (double)paramOffset.value; // ConstantNeutralLoss is positive for loss, negative for gain;
}

return -1.0 * (double)paramOffset.value; // ConstantNeutralLoss is positive for loss, negative for gain
}
catch (InvalidCastException)
{
return null;
}
}

private static int GetPresetScanConfiguration(Spectrum spectrum)
{
try
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,9 @@
<data name="ConfidenceLevel">
<value>Confidence Level</value>
</data>
<data name="ConstantNeutralLoss">
<value>Constant Neutral Loss</value>
</data>
<data name="CountTruncated">
<value>Count Truncated</value>
</data>
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,9 @@ specific default collision energy equation within Skyline</value>
<data name="ConfidenceLevel">
<value>Confidence level which was used to determine the confidence interval around the fold change.</value>
</data>
<data name="ConstantNeutralLoss">
<value>Analyzer offset value for constant neutral loss scan - use a negative value for neutral gain.</value>
</data>
<data name="CountTruncated">
<value>The number of transitions for a precursor that integrate a peak with a
boundary at either end of the acquisition time range, where intensity at the end is
Expand Down
6 changes: 6 additions & 0 deletions pwiz_tools/Skyline/Model/FullScanProperties.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,11 @@ public static FullScanProperties CreateProperties(MsDataSpectrum spectrum)

res.IsCentroided = spectrum.Centroided.ToString(CultureInfo.CurrentCulture);

if (spectrum.Metadata.ConstantNeutralLoss.HasValue)
{
res.ConstantNeutralLoss = spectrum.Metadata.ConstantNeutralLoss.Value.ToString(Formats.Mz);
}

if (spectrum.WindowGroup > 0)
{
res.WindowGroup = spectrum.WindowGroup.ToString(CultureInfo.CurrentCulture); // For Bruker PASEF MS2
Expand All @@ -143,6 +148,7 @@ public static FullScanProperties CreateProperties(MsDataSpectrum spectrum)
[Category("AcquisitionInfo")] public string ScanId { get; set; }
[Category("AcquisitionInfo")] public string CE { get; set; }
[Category("AcquisitionInfo")] public string MSLevel { get; set; }
[Category("AcquisitionInfo")] public string ConstantNeutralLoss { get; set; }
[Category("AcquisitionInfo")] public InstrumentInfo Instrument { get; set; }
[Category("AcquisitionInfo")] public string DataPoints { get; set; }
[Category("AcquisitionInfo")] public string MzCount { get; set; }
Expand Down
18 changes: 18 additions & 0 deletions pwiz_tools/Skyline/Model/FullScanPropertiesRes.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions pwiz_tools/Skyline/Model/FullScanPropertiesRes.resx
Original file line number Diff line number Diff line change
Expand Up @@ -319,4 +319,10 @@
<data name="DissociationMethod" xml:space="preserve">
<value>Dissociation Method</value>
</data>
<data name="ConstantNeutralLoss" xml:space="preserve">
<value>Constant Neutral Loss</value>
</data>
<data name="Description_ConstantNeutralLoss" xml:space="preserve">
<value>Analyzer offset for Constant Neutral Loss spectrum (negative value for constant neutral gain)</value>
</data>
</root>
4 changes: 4 additions & 0 deletions pwiz_tools/Skyline/Model/Results/Spectra/SpectrumClass.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,5 +79,9 @@ public double? CompensationVoltage
public double? IsolationWindowWidth { get; private set; }

public string DissociationMethod { get; private set; }

[Format(Formats.Mz)]
public double? ConstantNeutralLoss { get; private set; } // Negative value means neutral gain

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,13 @@ public abstract class SpectrumClassColumn
public static readonly SpectrumClassColumn DissociationMethod = MakeColumn(
nameof(SpectrumClass.DissociationMethod), GetDissociationMethod);

public static readonly SpectrumClassColumn ConstantNeutralLoss = MakeColumn(
nameof(SpectrumClass.ConstantNeutralLoss), spectrum => spectrum.ConstantNeutralLoss);

public static readonly ImmutableList<SpectrumClassColumn> ALL = ImmutableList.ValueOf(new[]
{
Ms1Precursors, Ms2Precursors, ScanDescription, CollisionEnergy, ScanWindowWidth, CompensationVoltage,
PresetScanConfiguration, MsLevel, Analyzer, IsolationWindowWidth, DissociationMethod
PresetScanConfiguration, MsLevel, Analyzer, IsolationWindowWidth, DissociationMethod, ConstantNeutralLoss
});

public static readonly ImmutableList<SpectrumClassColumn> MS1 = ImmutableList.ValueOf(new[]
Expand Down
4 changes: 4 additions & 0 deletions pwiz_tools/Skyline/Model/Results/Spectra/SpectrumMetadatas.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public class SpectrumMetadatas : AbstractReadOnlyList<SpectrumMetadata>
private readonly ImmutableList<double?> _compensationVoltages;
private readonly ImmutableList<bool> _negativeCharges;
private readonly ImmutableList<int> _msLevels;
private readonly ImmutableList<double?> _constantNeutralLosses;

public SpectrumMetadatas(IEnumerable<SpectrumMetadata> enumerable)
{
Expand All @@ -65,6 +66,7 @@ public SpectrumMetadatas(IEnumerable<SpectrumMetadata> enumerable)
_compensationVoltages = collection.Select(m => m.CompensationVoltage).ToFactor().MaybeConstant();
_negativeCharges = collection.Select(m => m.NegativeCharge).ToFactor().MaybeConstant();
_msLevels = collection.Select(m => m.MsLevel).ToFactor().MaybeConstant();
_constantNeutralLosses = collection.Select(m => m.ConstantNeutralLoss).Nullables().MaybeConstant();
}

public SpectrumMetadatas(ResultFileMetaDataProto proto)
Expand Down Expand Up @@ -118,6 +120,7 @@ public SpectrumMetadatas(ResultFileMetaDataProto proto)
}
_spectrumPrecursors = spectrumPrecursorsList.ToFactor().MaybeConstant();
_msLevels = IntegerList.FromIntegers(msLevels);
_constantNeutralLosses = proto.Spectra.Select(s => s.ConstantNeutralLoss).Nullables().MaybeConstant();
}

public override SpectrumMetadata this[int index]
Expand All @@ -132,6 +135,7 @@ public override SpectrumMetadata this[int index]
.ChangePresetScanConfiguration(_presetScanConfigurations[index])
.ChangeScanDescription(_scanDescriptions[index])
.ChangeTotalIonCurrent(_totalIonCurrents[index])
.ChangeConstantNeutralLoss(_constantNeutralLosses[index])
.ChangeNegativeCharge(_negativeCharges[index]);
var precursorsByLevelLookup = _spectrumPrecursors[index].ToLookup(t=>t.MsLevel, t=>t.Precursor);
var precursors = Enumerable.Range(1, _msLevels[index] - 1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ message ResultFileMetaDataProto {
google.protobuf.DoubleValue compensationVoltage = 11;
bool negativeCharge = 12;
int32 msLevel = 13;
google.protobuf.DoubleValue constantNeutralLoss = 14;
}

message Precursor {
Expand Down