Skip to content
Open
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
24 changes: 3 additions & 21 deletions src/MSDIAL5/MsdialCore/Utility/DataAccess.cs
Original file line number Diff line number Diff line change
Expand Up @@ -332,10 +332,7 @@ public static List<ValuePeak[]> GetMs2ValuePeaks(IDataProvider provider, double
int startScanID, int endScanID, IReadOnlyList<double> pMzValues, ParameterBase param, AcquisitionType acquisitionType,
double targetCE = -1, ChromXType type = ChromXType.RT, ChromXUnit unit = ChromXUnit.Min) {

var counter = 0;
var arrayLength = GetTargetArrayLength(provider, startScanID, endScanID, precursorMz, targetCE, param, acquisitionType);
var valuePeakArrayList = new List<ValuePeak[]>(pMzValues.Count);
valuePeakArrayList.AddRange(pMzValues.Select(_ => new ValuePeak[arrayLength]));
var valuePeakLists = pMzValues.Select(_ => new List<ValuePeak>()).ToArray();

for (int i = startScanID; i <= endScanID; i++) {
var spec = provider.LoadMsSpectrumFromIndex(i);
Expand All @@ -348,27 +345,12 @@ public static List<ValuePeak[]> GetMs2ValuePeaks(IDataProvider provider, double
var intensities = RetrieveIntensitiesFromMzValues(pMzValues, spec.Spectrum, param.CentroidMs2Tolerance);

for (int j = 0; j < pMzValues.Count; j++) {
valuePeakArrayList[j][counter] = new ValuePeak(id, chromX, pMzValues[j], intensities[j]);
valuePeakLists[j].Add(new ValuePeak(id, chromX, pMzValues[j], intensities[j]));
}
counter++;
}
}
}
return valuePeakArrayList;
}

private static int GetTargetArrayLength(IDataProvider provider, int startScanID, int endScanID, double precursorMz, double targetCE, ParameterBase param, AcquisitionType type) {
var counter = 0;
for (int i = startScanID; i <= endScanID; i++) {
var spec = provider.LoadMsSpectrumFromIndex(i);
if (spec.MsLevel == 2 && spec.Precursor != null) {
if (targetCE >= 0 && spec.CollisionEnergy >= 0 && Math.Abs(targetCE - spec.CollisionEnergy) > 1) continue; // for AIF mode
if (IsInMassWindow(precursorMz, spec, param.CentroidMs1Tolerance, type)) {
counter++;
}
}
}
return counter;
return valuePeakLists.Select(peaks => peaks.ToArray()).ToList();
}

public static double[] RetrieveIntensitiesFromMzValues(
Expand Down
Loading