Skip to content

Commit c5cfc87

Browse files
committed
Small fixes
1 parent da4b53b commit c5cfc87

File tree

4 files changed

+19
-45
lines changed

4 files changed

+19
-45
lines changed

Writer/MetadataWriter.cs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
using System.IO;
55
using System.Linq;
66
using System.Reflection;
7-
using System.Web.WebSockets;
87
using log4net;
98
using Newtonsoft.Json;
109
using ThermoFisher.CommonCore.Data;
@@ -122,16 +121,14 @@ public void WriteMetadata(IRawDataPlus rawFile, int firstScanNumber, int lastSca
122121
switch (_parseInput.MetadataFormat)
123122
{
124123
case MetadataFormat.JSON:
125-
_metadataFileName = _parseInput.MetadataOutputFile != null
126-
? _parseInput.MetadataOutputFile
127-
: Path.Combine(_parseInput.OutputDirectory, _parseInput.RawFileNameWithoutExtension) +
124+
_metadataFileName = _parseInput.MetadataOutputFile ??
125+
Path.Combine(_parseInput.OutputDirectory, _parseInput.RawFileNameWithoutExtension) +
128126
"-metadata.json";
129127
WriteJsonMetada(rawFile, firstScanNumber, lastScanNumber);
130128
break;
131129
case MetadataFormat.TXT:
132-
_metadataFileName = _parseInput.MetadataOutputFile != null
133-
? _parseInput.MetadataOutputFile
134-
: Path.Combine(_parseInput.OutputDirectory, _parseInput.RawFileNameWithoutExtension) +
130+
_metadataFileName = _parseInput.MetadataOutputFile ??
131+
Path.Combine(_parseInput.OutputDirectory, _parseInput.RawFileNameWithoutExtension) +
135132
"-metadata.txt";
136133
WriteTextMetadata(rawFile, firstScanNumber, lastScanNumber);
137134
break;
@@ -371,7 +368,6 @@ private void WriteTextMetadata(IRawDataPlus rawFile, int firstScanNumber, int la
371368
output.Add("Firmware version=" + rawFile.GetInstrumentData().HardwareVersion);
372369
}
373370

374-
375371
// MS Data
376372
output.Add("#MsData");
377373
foreach (KeyValuePair<string, int> entry in msTypes)

Writer/MgfSpectrumWriter.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,9 @@
55
using System.Reflection;
66
using System.Text.RegularExpressions;
77
using log4net;
8-
using ThermoFisher.CommonCore.Data;
98
using ThermoFisher.CommonCore.Data.Business;
109
using ThermoFisher.CommonCore.Data.FilterEnums;
1110
using ThermoFisher.CommonCore.Data.Interfaces;
12-
using ThermoRawFileParser.Util;
1311

1412
namespace ThermoRawFileParser.Writer
1513
{

Writer/MzMlSpectrumWriter.cs

Lines changed: 14 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
using System;
22
using System.Collections.Generic;
33
using System.Collections.Specialized;
4-
using System.Diagnostics;
5-
using System.Diagnostics.Eventing.Reader;
64
using System.Globalization;
75
using System.IO;
86
using System.IO.Compression;
@@ -527,7 +525,7 @@ public override void Write(IRawDataPlus rawFile, int firstScanNumber, int lastSc
527525
_writer.WriteEndElement(); // spectrumList
528526

529527
index = 0;
530-
var chromatograms = ConstructChromatograms(firstScanNumber, lastScanNumber);
528+
var chromatograms = ConstructChromatograms();
531529
if (!chromatograms.IsNullOrEmpty())
532530
{
533531
// ChromatogramList
@@ -914,7 +912,7 @@ private void Serialize<T>(XmlSerializer serializer, T t)
914912
/// <param name="firstScanNumber">the first scan number</param>
915913
/// <param name="lastScanNumber">the last scan number</param>
916914
/// <returns>a list of chromatograms</returns>
917-
private List<ChromatogramType> ConstructChromatograms(int firstScanNumber, int lastScanNumber)
915+
private List<ChromatogramType> ConstructChromatograms()
918916
{
919917
var chromatograms = new List<ChromatogramType>();
920918

@@ -2470,15 +2468,14 @@ private PrecursorListType ConstructPrecursorList(int precursorScanNumber, IScanE
24702468
var SPSPrecursor = new PrecursorType
24712469
{
24722470
selectedIonList =
2473-
new SelectedIonListType {count = "1", selectedIon = new ParamGroupType[1]},
2474-
spectrumRef = spectrumRef
2475-
};
2476-
2477-
//Isolation window for SPS masses is the same as for the first precursor
2478-
SPSPrecursor.isolationWindow =
2471+
new SelectedIonListType { count = "1", selectedIon = new ParamGroupType[1] },
2472+
spectrumRef = spectrumRef,
2473+
//Isolation window for SPS masses is the same as for the first precursor
2474+
isolationWindow =
24792475
new ParamGroupType
24802476
{
24812477
cvParam = new CVParamType[3]
2478+
}
24822479
};
24832480

24842481
SPSPrecursor.isolationWindow.cvParam[0] =
@@ -2755,14 +2752,13 @@ private ScanListType ConstructScanList(int scanNumber, Scan scan)
27552752

27562753
var scanType = new ScanType
27572754
{
2758-
cvParam = scanTypeCvParams.ToArray()
2759-
};
2760-
2761-
// Scan window list
2762-
scanType.scanWindowList = new ScanWindowListType
2763-
{
2764-
count = 1,
2765-
scanWindow = new ParamGroupType[1]
2755+
cvParam = scanTypeCvParams.ToArray(),
2756+
// Scan window list
2757+
scanWindowList = new ScanWindowListType
2758+
{
2759+
count = 1,
2760+
scanWindow = new ParamGroupType[1]
2761+
}
27662762
};
27672763
var scanWindow = new ParamGroupType
27682764
{
@@ -2853,22 +2849,6 @@ private static byte[] GetZLib64BitArray(ICollection<double> array)
28532849
return bytes;
28542850
}
28552851

2856-
/// <summary>
2857-
/// Calculate the RAW file checksum
2858-
/// </summary>
2859-
/// <returns>the checksum string</returns>
2860-
private string CalculateMD5Checksum()
2861-
{
2862-
using (var md5 = MD5.Create())
2863-
{
2864-
using (var stream = File.OpenRead(ParseInput.RawFilePath))
2865-
{
2866-
var hash = md5.ComputeHash(stream);
2867-
return BitConverter.ToString(hash).Replace("-", "").ToLowerInvariant();
2868-
}
2869-
}
2870-
}
2871-
28722852
/// <summary>
28732853
/// Calculate the RAW file checksum
28742854
/// </summary>

Writer/SpectrumWriter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ private string NormalizeFileName(string outputFile, string extension, bool gzip)
107107
string tail = "";
108108

109109
string[] extensions;
110-
if (ParseInput.Gzip)
110+
if (gzip)
111111
extensions = new string[] { ".gz", extension };
112112
else
113113
extensions = new string[] { extension };

0 commit comments

Comments
 (0)