Skip to content

Commit f2c707e

Browse files
minor changes before release
1 parent 3265f38 commit f2c707e

File tree

5 files changed

+35
-54
lines changed

5 files changed

+35
-54
lines changed

ParseInput.cs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,6 @@ public string RawFilePath
2929
if (value != null)
3030
{
3131
RawFileNameWithoutExtension = Path.GetFileNameWithoutExtension(value);
32-
//do we need it?
33-
var splittedPath = value.Split('/');
34-
_rawFileName = splittedPath[splittedPath.Length - 1];
3532
}
3633
}
3734
}
@@ -94,12 +91,6 @@ public string RawFilePath
9491

9592
public string BucketName { get; set; }
9693

97-
//this property assigned but never used
98-
/// <summary>
99-
/// The raw file name.
100-
/// </summary>
101-
private string _rawFileName;
102-
10394
/// <summary>
10495
/// The RAW file name without extension.
10596
/// </summary>

ThermoRawFileParserTest/packages.config

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,6 @@
1414
<package id="NUnit" version="3.13.1" targetFramework="net472" />
1515
<package id="PSI_Interface" version="2.3.2" targetFramework="net472" />
1616
<package id="zlib.net" version="1.0.4.0" targetFramework="net471" />
17-
</packages>
17+
<package id="ThermoFisher.CommonCore.Data" version="5.0.0.71" targetFramework="net472" />
18+
<package id="ThermoFisher.CommonCore.RawFileReader" version="5.0.0.71" targetFramework="net472" />
19+
</packages>

Writer/MgfSpectrumWriter.cs

Lines changed: 6 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -108,32 +108,11 @@ public override void Write(IRawDataPlus rawFile, int firstScanNumber, int lastSc
108108
$"RTINSECONDS={(retentionTime * 60).ToString(CultureInfo.InvariantCulture)}");
109109

110110
// Trailer extra data list
111-
var trailerData = rawFile.GetTrailerExtraInformation(scanNumber);
112-
int? charge = null;
113-
double? monoisotopicMz = null;
114-
double? isolationWidth = null;
115-
for (var i = 0; i < trailerData.Length; i++)
116-
{
117-
if (trailerData.Labels[i] == "Charge State:")
118-
{
119-
if (Convert.ToInt32(trailerData.Values[i]) > 0)
120-
{
121-
charge = Convert.ToInt32(trailerData.Values[i]);
122-
}
123-
}
124-
125-
if (trailerData.Labels[i] == "Monoisotopic M/Z:")
126-
{
127-
monoisotopicMz = double.Parse(trailerData.Values[i], NumberStyles.Any,
128-
CultureInfo.CurrentCulture);
129-
}
130-
131-
if (trailerData.Labels[i] == "MS" + (int) scanFilter.MSOrder + " Isolation Width:")
132-
{
133-
isolationWidth = double.Parse(trailerData.Values[i], NumberStyles.Any,
134-
CultureInfo.CurrentCulture);
135-
}
136-
}
111+
var trailerData = new ScanTrailer(rawFile.GetTrailerExtraInformation(scanNumber));
112+
int? charge = trailerData.AsPositiveInt("Charge State:");
113+
double? monoisotopicMz = trailerData.AsDouble("Monoisotopic M/Z:");
114+
double? isolationWidth =
115+
trailerData.AsDouble("MS" + (int) scanFilter.MSOrder + " Isolation Width:");
137116

138117
if (reaction != null)
139118
{
@@ -261,7 +240,7 @@ private string ConstructPrecursorReference(MSOrderType msOrder, int scanNumber,
261240

262241
break;
263242
}
264-
243+
265244
return precursorReference;
266245
}
267246
}

Writer/MzMlSpectrumWriter.cs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1164,20 +1164,16 @@ private SpectrumType ConstructMSSpectrum(int scanNumber)
11641164

11651165
// Trailer extra data list
11661166
var trailerData = new ScanTrailer(_rawFile.GetTrailerExtraInformation(scanNumber));
1167-
int? charge;
1168-
double? monoisotopicMz;
1169-
double? ionInjectionTime;
1170-
double? isolationWidth;
1171-
double? FAIMSCV = null;
1172-
List<double> SPSMasses = new List<double>();
11731167

1174-
charge = trailerData.AsPositiveInt("Charge State:");
1175-
monoisotopicMz = trailerData.AsDouble("Monoisotopic M/Z:");
1176-
ionInjectionTime = trailerData.AsDouble("Ion Injection Time (ms):");
1177-
isolationWidth = trailerData.AsDouble("MS" + (int)scanFilter.MSOrder + " Isolation Width:");
1168+
int? charge = trailerData.AsPositiveInt("Charge State:");
1169+
double? monoisotopicMz = trailerData.AsDouble("Monoisotopic M/Z:");
1170+
double? ionInjectionTime = trailerData.AsDouble("Ion Injection Time (ms):");
1171+
double? isolationWidth = trailerData.AsDouble("MS" + (int)scanFilter.MSOrder + " Isolation Width:");
1172+
double? FAIMSCV = null;
11781173
if (trailerData.AsBool("FAIMS Voltage On:").GetValueOrDefault(false))
11791174
FAIMSCV = trailerData.AsDouble("FAIMS CV:");
11801175

1176+
List<double> SPSMasses = new List<double>();
11811177
//tune version < 3
11821178
if (trailerData.Has("SPS Mass 1:"))
11831179
{

Writer/ScanTrailer.cs

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System.Collections.Generic;
2+
using System.Globalization;
23
using System.Linq;
34
using System.Text.RegularExpressions;
45
using ThermoFisher.CommonCore.Data.Business;
@@ -7,11 +8,20 @@ namespace ThermoRawFileParser.Writer
78
{
89
public class ScanTrailer
910
{
10-
public int Length { get => data.Count; }
11+
public int Length
12+
{
13+
get => data.Count;
14+
}
1115

12-
public string[] Labels { get => data.Keys.ToArray(); }
16+
public string[] Labels
17+
{
18+
get => data.Keys.ToArray();
19+
}
1320

14-
public string[] Values { get => data.Values.ToArray(); }
21+
public string[] Values
22+
{
23+
get => data.Values.ToArray();
24+
}
1525

1626
private readonly Dictionary<string, string> data;
1727

@@ -32,7 +42,7 @@ public ScanTrailer(LogEntry trailerData)
3242
/// <param name="key">name of the element</param>
3343
public bool? AsBool(string key)
3444
{
35-
if(data.ContainsKey(key))
45+
if (data.ContainsKey(key))
3646
{
3747
var stringValue = data[key].ToLower();
3848

@@ -59,8 +69,10 @@ public ScanTrailer(LogEntry trailerData)
5969
{
6070
if (data.ContainsKey(key))
6171
{
62-
if (double.TryParse(data[key], out var result)) return result;
72+
if (double.TryParse(data[key], NumberStyles.Any,
73+
CultureInfo.CurrentCulture, out var result)) return result;
6374
}
75+
6476
return null;
6577
}
6678

@@ -75,6 +87,7 @@ public ScanTrailer(LogEntry trailerData)
7587
{
7688
if (int.TryParse(data[key], out var result)) return result;
7789
}
90+
7891
return null;
7992
}
8093

@@ -89,7 +102,6 @@ public ScanTrailer(LogEntry trailerData)
89102

90103
if (value != null && value > 0) return value;
91104
else return null;
92-
93105
}
94106

95107
/// <summary>
@@ -113,6 +125,7 @@ public string Get(string key)
113125
{
114126
return data[key];
115127
}
128+
116129
return null;
117130
}
118131

@@ -143,4 +156,4 @@ public IEnumerable<string> MatchValues(Regex regex)
143156
return data.Where(item => regex.IsMatch(item.Key)).Select(item => item.Value);
144157
}
145158
}
146-
}
159+
}

0 commit comments

Comments
 (0)