Skip to content

Commit 6153039

Browse files
unique channel name
1 parent 878596b commit 6153039

File tree

1 file changed

+36
-35
lines changed

1 file changed

+36
-35
lines changed

Writer/MzMlSpectrumWriter.cs

Lines changed: 36 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public override void Write(IRawDataPlus rawFile, int firstScanNumber, int lastSc
8181
ConfigureWriter(".mzML");
8282

8383
XmlSerializer serializer;
84-
var settings = new XmlWriterSettings {Indent = true, Encoding = new UTF8Encoding()};
84+
var settings = new XmlWriterSettings { Indent = true, Encoding = new UTF8Encoding() };
8585
var sha1 = SHA1.Create();
8686
CryptoStream cryptoStream = null;
8787
if (_doIndexing)
@@ -410,7 +410,7 @@ public override void Write(IRawDataPlus rawFile, int firstScanNumber, int lastSc
410410
}
411411
}
412412
}
413-
413+
414414

415415
if (ParseInput.LogFormat == LogFormat.DEFAULT)
416416
{
@@ -435,7 +435,7 @@ public override void Write(IRawDataPlus rawFile, int firstScanNumber, int lastSc
435435
if (ParseInput.LogFormat == LogFormat.DEFAULT)
436436
{
437437
var scanProgress =
438-
(int) ((double) scanNumber / (lastScanNumber - firstScanNumber + 1) * 100);
438+
(int)((double)scanNumber / (lastScanNumber - firstScanNumber + 1) * 100);
439439
if (scanProgress % ProgressPercentageStep == 0)
440440
{
441441
if (scanProgress != lastScanProgress)
@@ -654,7 +654,7 @@ private string GetTotalScanNumber()
654654
var lastSelectedInstrument = _rawFile.SelectedInstrument;
655655
var numScans = 0;
656656

657-
if(_rawFile.GetInstrumentCountOfType(Device.MS) != 0)
657+
if (_rawFile.GetInstrumentCountOfType(Device.MS) != 0)
658658
{
659659
_rawFile.SelectInstrument(Device.MS, 1);
660660
var levelFilter = _rawFile.GetFilterFromString("");
@@ -923,7 +923,7 @@ private List<ChromatogramType> ConstructChromatograms()
923923

924924
var settings = new ChromatogramTraceSettings(TraceType.TotalAbsorbance);
925925

926-
var data = _rawFile.GetChromatogramData(new IChromatogramSettings[] {settings}, -1, -1);
926+
var data = _rawFile.GetChromatogramData(new IChromatogramSettings[] { settings }, -1, -1);
927927

928928
var trace = ChromatogramSignal.FromChromatogramData(data);
929929

@@ -969,7 +969,7 @@ private List<ChromatogramType> ConstructChromatograms()
969969

970970
var settings = new ChromatogramTraceSettings(TraceType.StartUVChromatogramTraces + channel + 1);
971971

972-
var data = _rawFile.GetChromatogramData(new IChromatogramSettings[] {settings}, -1, -1);
972+
var data = _rawFile.GetChromatogramData(new IChromatogramSettings[] { settings }, -1, -1);
973973

974974
var trace = ChromatogramSignal.FromChromatogramData(data);
975975

@@ -1019,7 +1019,7 @@ private List<ChromatogramType> ConstructChromatograms()
10191019
var settings = new ChromatogramTraceSettings(TraceType.StartPCA2DChromatogramTraces + channel +
10201020
1);
10211021

1022-
var data = _rawFile.GetChromatogramData(new IChromatogramSettings[] {settings}, -1, -1);
1022+
var data = _rawFile.GetChromatogramData(new IChromatogramSettings[] { settings }, -1, -1);
10231023

10241024
var trace = ChromatogramSignal.FromChromatogramData(data);
10251025

@@ -1055,6 +1055,7 @@ private List<ChromatogramType> ConstructChromatograms()
10551055
}
10561056
}
10571057

1058+
var channelNameIndex = 1
10581059
for (int nrI = 1; nrI < _rawFile.GetInstrumentCountOfType(Device.MSAnalog) + 1; nrI++)
10591060
{
10601061
_rawFile.SelectInstrument(Device.MSAnalog, nrI);
@@ -1067,7 +1068,7 @@ private List<ChromatogramType> ConstructChromatograms()
10671068

10681069
if (channelName.IsNullOrEmpty())
10691070
{
1070-
channelName = "Channel " + channel;
1071+
channelName = "Channel " + channelNameIndex++;
10711072
}
10721073

10731074
var settings = new ChromatogramTraceSettings(TraceType.StartAnalogChromatogramTraces + channel +
@@ -1153,7 +1154,7 @@ private ChromatogramType TraceToChromatogram(ChromatogramSignal trace, string ch
11531154
: GetZLib64BitArray(trace.Times)
11541155
};
11551156
timesBinaryData.encodedLength =
1156-
(4 * Math.Ceiling((double) timesBinaryData
1157+
(4 * Math.Ceiling((double)timesBinaryData
11571158
.binary.Length / 3)).ToString(CultureInfo.InvariantCulture);
11581159
var timesBinaryDataCvParams = new List<CVParamType>
11591160
{
@@ -1218,7 +1219,7 @@ private ChromatogramType TraceToChromatogram(ChromatogramSignal trace, string ch
12181219
: GetZLib64BitArray(trace.Intensities)
12191220
};
12201221
intensitiesBinaryData.encodedLength =
1221-
(4 * Math.Ceiling((double) intensitiesBinaryData
1222+
(4 * Math.Ceiling((double)intensitiesBinaryData
12221223
.binary.Length / 3)).ToString(CultureInfo.InvariantCulture);
12231224
var intensitiesBinaryDataCvParams = new List<CVParamType>
12241225
{
@@ -1291,7 +1292,7 @@ private SpectrumType ConstructMSSpectrum(int scanNumber)
12911292
var scanEvent = _rawFile.GetScanEventForScanNumber(scanNumber);
12921293
var spectrum = new SpectrumType
12931294
{
1294-
id = ConstructSpectrumTitle((int) Device.MS, 1, scanNumber),
1295+
id = ConstructSpectrumTitle((int)Device.MS, 1, scanNumber),
12951296
defaultArrayLength = 0
12961297
};
12971298

@@ -1324,7 +1325,7 @@ private SpectrumType ConstructMSSpectrum(int scanNumber)
13241325
int? charge = trailerData.AsPositiveInt("Charge State:");
13251326
double? monoisotopicMz = trailerData.AsDouble("Monoisotopic M/Z:");
13261327
double? ionInjectionTime = trailerData.AsDouble("Ion Injection Time (ms):");
1327-
double? isolationWidth = trailerData.AsDouble("MS" + (int) scanFilter.MSOrder + " Isolation Width:");
1328+
double? isolationWidth = trailerData.AsDouble("MS" + (int)scanFilter.MSOrder + " Isolation Width:");
13281329
double? FAIMSCV = null;
13291330
if (trailerData.AsBool("FAIMS Voltage On:").GetValueOrDefault(false))
13301331
FAIMSCV = trailerData.AsDouble("FAIMS CV:");
@@ -1336,7 +1337,7 @@ private SpectrumType ConstructMSSpectrum(int scanNumber)
13361337
foreach (var label in trailerData.MatchKeys(_spSentry))
13371338
{
13381339
var mass = trailerData.AsDouble(label).GetValueOrDefault(0);
1339-
if (mass > 0) SPSMasses.Add((double) mass); //zero means mass does not exist
1340+
if (mass > 0) SPSMasses.Add((double)mass); //zero means mass does not exist
13401341
}
13411342
}
13421343

@@ -1346,7 +1347,7 @@ private SpectrumType ConstructMSSpectrum(int scanNumber)
13461347
foreach (var labelvalue in trailerData.MatchValues(_spSentry3))
13471348
{
13481349
foreach (var mass in labelvalue.Trim()
1349-
.Split(new char[] {','}, StringSplitOptions.RemoveEmptyEntries))
1350+
.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries))
13501351
{
13511352
SPSMasses.Add(double.Parse(mass));
13521353
}
@@ -1375,14 +1376,14 @@ private SpectrumType ConstructMSSpectrum(int scanNumber)
13751376

13761377
}
13771378
else if (msLevel > 1)
1378-
{
1379+
{
13791380
spectrumCvParams.Add(new CVParamType
1380-
{
1381-
accession = "MS:1000580",
1382-
cvRef = "MS",
1383-
name = "MSn spectrum",
1384-
value = ""
1385-
});
1381+
{
1382+
accession = "MS:1000580",
1383+
cvRef = "MS",
1384+
name = "MSn spectrum",
1385+
value = ""
1386+
});
13861387

13871388
// Keep track of scan number and isolation m/z for precursor reference
13881389
var result = _filterStringIsolationMzPattern.Match(scanEvent.ToString());
@@ -1450,7 +1451,7 @@ private SpectrumType ConstructMSSpectrum(int scanNumber)
14501451
_precursorTree[scanNumber] = new PrecursorInfo(_precursorScanNumber, 1, 0, new PrecursorType[0]);
14511452

14521453
}
1453-
1454+
14541455
}
14551456
else
14561457
{
@@ -1525,7 +1526,7 @@ private SpectrumType ConstructMSSpectrum(int scanNumber)
15251526
double[] masses;
15261527
double[] intensities;
15271528

1528-
if (!ParseInput.NoPeakPicking.Contains((int) scanFilter.MSOrder))
1529+
if (!ParseInput.NoPeakPicking.Contains((int)scanFilter.MSOrder))
15291530
{
15301531
//Spectrum will be centroided
15311532
spectrumCvParams.Add(new CVParamType
@@ -1688,7 +1689,7 @@ private SpectrumType ConstructMSSpectrum(int scanNumber)
16881689
binary = ParseInput.NoZlibCompression ? Get64BitArray(masses) : GetZLib64BitArray(masses)
16891690
};
16901691
massesBinaryData.encodedLength =
1691-
(4 * Math.Ceiling((double) massesBinaryData
1692+
(4 * Math.Ceiling((double)massesBinaryData
16921693
.binary.Length / 3)).ToString(CultureInfo.InvariantCulture);
16931694
var massesBinaryDataCvParams = new List<CVParamType>
16941695
{
@@ -1750,7 +1751,7 @@ private SpectrumType ConstructMSSpectrum(int scanNumber)
17501751
: GetZLib64BitArray(intensities)
17511752
};
17521753
intensitiesBinaryData.encodedLength =
1753-
(4 * Math.Ceiling((double) intensitiesBinaryData
1754+
(4 * Math.Ceiling((double)intensitiesBinaryData
17541755
.binary.Length / 3)).ToString(CultureInfo.InvariantCulture);
17551756
var intensitiesBinaryDataCvParams = new List<CVParamType>
17561757
{
@@ -1993,7 +1994,7 @@ private SpectrumType ConstructPDASpectrum(int scanNumber, int instrumentNumber)
19931994

19941995
var spectrum = new SpectrumType
19951996
{
1996-
id = ConstructSpectrumTitle((int) Device.Pda, instrumentNumber, scanNumber),
1997+
id = ConstructSpectrumTitle((int)Device.Pda, instrumentNumber, scanNumber),
19971998
defaultArrayLength = 0
19981999
};
19992000

@@ -2112,7 +2113,7 @@ private SpectrumType ConstructPDASpectrum(int scanNumber, int instrumentNumber)
21122113
binary = ParseInput.NoZlibCompression ? Get64BitArray(positions) : GetZLib64BitArray(positions)
21132114
};
21142115
positionsBinaryData.encodedLength =
2115-
(4 * Math.Ceiling((double) positionsBinaryData
2116+
(4 * Math.Ceiling((double)positionsBinaryData
21162117
.binary.Length / 3)).ToString(CultureInfo.InvariantCulture);
21172118
var positionsBinaryDataCvParams = new List<CVParamType>
21182119
{
@@ -2173,7 +2174,7 @@ private SpectrumType ConstructPDASpectrum(int scanNumber, int instrumentNumber)
21732174
: GetZLib64BitArray(intensities)
21742175
};
21752176
intensitiesBinaryData.encodedLength =
2176-
(4 * Math.Ceiling((double) intensitiesBinaryData
2177+
(4 * Math.Ceiling((double)intensitiesBinaryData
21772178
.binary.Length / 3)).ToString(CultureInfo.InvariantCulture);
21782179
var intensitiesBinaryDataCvParams = new List<CVParamType>
21792180
{
@@ -2256,16 +2257,16 @@ private PrecursorListType ConstructPrecursorList(int precursorScanNumber, IScanE
22562257

22572258
spectrumRef = ConstructSpectrumTitle((int)Device.MS, 1, precursorScanNumber);
22582259
reaction = scanEvent.GetReaction(reactionCount);
2259-
2260+
22602261
precursorMz = reaction.PrecursorMass;
22612262

22622263
//if isolation width was not found in the trailer, try to get one from the reaction
22632264
if (isolationWidth == null) isolationWidth = reaction.IsolationWidth;
2264-
2265+
22652266
var precursor = new PrecursorType
22662267
{
22672268
selectedIonList =
2268-
new SelectedIonListType {count = "1", selectedIon = new ParamGroupType[1]},
2269+
new SelectedIonListType { count = "1", selectedIon = new ParamGroupType[1] },
22692270
spectrumRef = spectrumRef
22702271
};
22712272

@@ -2475,7 +2476,7 @@ private PrecursorListType ConstructPrecursorList(int precursorScanNumber, IScanE
24752476
var SPSPrecursor = new PrecursorType
24762477
{
24772478
selectedIonList =
2478-
new SelectedIonListType {count = "1", selectedIon = new ParamGroupType[1]},
2479+
new SelectedIonListType { count = "1", selectedIon = new ParamGroupType[1] },
24792480
spectrumRef = spectrumRef
24802481
};
24812482

@@ -2784,7 +2785,7 @@ private static byte[] Get64BitArray(ICollection<double> array)
27842785
memoryStream.Position = 0;
27852786
bytes = memoryStream.ToArray();
27862787
}
2787-
}
2788+
}
27882789

27892790
return (byte[])bytes;
27902791
}
@@ -2804,8 +2805,8 @@ private static byte[] GetZLib64BitArray(ICollection<double> array)
28042805
using (var memoryStream = new MemoryStream())
28052806
using (var outZStream = new ZOutputStream(memoryStream, zlibConst.Z_DEFAULT_COMPRESSION))
28062807
{
2807-
outZStream.Write(bytes, 0, bytes.Length);
2808-
2808+
outZStream.Write(bytes, 0, bytes.Length);
2809+
28092810
outZStream.finish();
28102811
memoryStream.Position = 0;
28112812
bytes = memoryStream.ToArray();

0 commit comments

Comments
 (0)