Skip to content

Commit

Permalink
minor changes before release
Browse files Browse the repository at this point in the history
  • Loading branch information
nielshulstaert committed Apr 1, 2021
1 parent 3265f38 commit f2c707e
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 54 deletions.
9 changes: 0 additions & 9 deletions ParseInput.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@ public string RawFilePath
if (value != null)
{
RawFileNameWithoutExtension = Path.GetFileNameWithoutExtension(value);
//do we need it?
var splittedPath = value.Split('/');
_rawFileName = splittedPath[splittedPath.Length - 1];
}
}
}
Expand Down Expand Up @@ -94,12 +91,6 @@ public string RawFilePath

public string BucketName { get; set; }

//this property assigned but never used
/// <summary>
/// The raw file name.
/// </summary>
private string _rawFileName;

/// <summary>
/// The RAW file name without extension.
/// </summary>
Expand Down
4 changes: 3 additions & 1 deletion ThermoRawFileParserTest/packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,6 @@
<package id="NUnit" version="3.13.1" targetFramework="net472" />
<package id="PSI_Interface" version="2.3.2" targetFramework="net472" />
<package id="zlib.net" version="1.0.4.0" targetFramework="net471" />
</packages>
<package id="ThermoFisher.CommonCore.Data" version="5.0.0.71" targetFramework="net472" />
<package id="ThermoFisher.CommonCore.RawFileReader" version="5.0.0.71" targetFramework="net472" />
</packages>
33 changes: 6 additions & 27 deletions Writer/MgfSpectrumWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,32 +108,11 @@ public override void Write(IRawDataPlus rawFile, int firstScanNumber, int lastSc
$"RTINSECONDS={(retentionTime * 60).ToString(CultureInfo.InvariantCulture)}");

// Trailer extra data list
var trailerData = rawFile.GetTrailerExtraInformation(scanNumber);
int? charge = null;
double? monoisotopicMz = null;
double? isolationWidth = null;
for (var i = 0; i < trailerData.Length; i++)
{
if (trailerData.Labels[i] == "Charge State:")
{
if (Convert.ToInt32(trailerData.Values[i]) > 0)
{
charge = Convert.ToInt32(trailerData.Values[i]);
}
}

if (trailerData.Labels[i] == "Monoisotopic M/Z:")
{
monoisotopicMz = double.Parse(trailerData.Values[i], NumberStyles.Any,
CultureInfo.CurrentCulture);
}

if (trailerData.Labels[i] == "MS" + (int) scanFilter.MSOrder + " Isolation Width:")
{
isolationWidth = double.Parse(trailerData.Values[i], NumberStyles.Any,
CultureInfo.CurrentCulture);
}
}
var trailerData = new ScanTrailer(rawFile.GetTrailerExtraInformation(scanNumber));
int? charge = trailerData.AsPositiveInt("Charge State:");
double? monoisotopicMz = trailerData.AsDouble("Monoisotopic M/Z:");
double? isolationWidth =
trailerData.AsDouble("MS" + (int) scanFilter.MSOrder + " Isolation Width:");

if (reaction != null)
{
Expand Down Expand Up @@ -261,7 +240,7 @@ private string ConstructPrecursorReference(MSOrderType msOrder, int scanNumber,

break;
}

return precursorReference;
}
}
Expand Down
16 changes: 6 additions & 10 deletions Writer/MzMlSpectrumWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1164,20 +1164,16 @@ private SpectrumType ConstructMSSpectrum(int scanNumber)

// Trailer extra data list
var trailerData = new ScanTrailer(_rawFile.GetTrailerExtraInformation(scanNumber));
int? charge;
double? monoisotopicMz;
double? ionInjectionTime;
double? isolationWidth;
double? FAIMSCV = null;
List<double> SPSMasses = new List<double>();

charge = trailerData.AsPositiveInt("Charge State:");
monoisotopicMz = trailerData.AsDouble("Monoisotopic M/Z:");
ionInjectionTime = trailerData.AsDouble("Ion Injection Time (ms):");
isolationWidth = trailerData.AsDouble("MS" + (int)scanFilter.MSOrder + " Isolation Width:");
int? charge = trailerData.AsPositiveInt("Charge State:");
double? monoisotopicMz = trailerData.AsDouble("Monoisotopic M/Z:");
double? ionInjectionTime = trailerData.AsDouble("Ion Injection Time (ms):");
double? isolationWidth = trailerData.AsDouble("MS" + (int)scanFilter.MSOrder + " Isolation Width:");
double? FAIMSCV = null;
if (trailerData.AsBool("FAIMS Voltage On:").GetValueOrDefault(false))
FAIMSCV = trailerData.AsDouble("FAIMS CV:");

List<double> SPSMasses = new List<double>();
//tune version < 3
if (trailerData.Has("SPS Mass 1:"))
{
Expand Down
27 changes: 20 additions & 7 deletions Writer/ScanTrailer.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text.RegularExpressions;
using ThermoFisher.CommonCore.Data.Business;
Expand All @@ -7,11 +8,20 @@ namespace ThermoRawFileParser.Writer
{
public class ScanTrailer
{
public int Length { get => data.Count; }
public int Length
{
get => data.Count;
}

public string[] Labels { get => data.Keys.ToArray(); }
public string[] Labels
{
get => data.Keys.ToArray();
}

public string[] Values { get => data.Values.ToArray(); }
public string[] Values
{
get => data.Values.ToArray();
}

private readonly Dictionary<string, string> data;

Expand All @@ -32,7 +42,7 @@ public ScanTrailer(LogEntry trailerData)
/// <param name="key">name of the element</param>
public bool? AsBool(string key)
{
if(data.ContainsKey(key))
if (data.ContainsKey(key))
{
var stringValue = data[key].ToLower();

Expand All @@ -59,8 +69,10 @@ public ScanTrailer(LogEntry trailerData)
{
if (data.ContainsKey(key))
{
if (double.TryParse(data[key], out var result)) return result;
if (double.TryParse(data[key], NumberStyles.Any,
CultureInfo.CurrentCulture, out var result)) return result;
}

return null;
}

Expand All @@ -75,6 +87,7 @@ public ScanTrailer(LogEntry trailerData)
{
if (int.TryParse(data[key], out var result)) return result;
}

return null;
}

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

if (value != null && value > 0) return value;
else return null;

}

/// <summary>
Expand All @@ -113,6 +125,7 @@ public string Get(string key)
{
return data[key];
}

return null;
}

Expand Down Expand Up @@ -143,4 +156,4 @@ public IEnumerable<string> MatchValues(Regex regex)
return data.Where(item => regex.IsMatch(item.Key)).Select(item => item.Value);
}
}
}
}

0 comments on commit f2c707e

Please sign in to comment.