Skip to content

Commit 3e592f4

Browse files
committed
Add comment field to XIC
1 parent ca35579 commit 3e592f4

5 files changed

Lines changed: 38 additions & 16 deletions

File tree

ThermoRawFileParserTest/XicReaderTests.cs

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,10 @@ public void testXicReadFullRange()
3939
XicUnit xicUnit = xicData.Content[0];
4040
Assert.AreEqual(14, ((Array) xicUnit.RetentionTimes).Length);
4141
Assert.AreEqual(14, ((Array) xicUnit.Intensities).Length);
42-
Assert.AreEqual(140, xicUnit.Meta.MzStart, 0.01);
43-
Assert.AreEqual(2000, xicUnit.Meta.MzEnd, 0.01);
44-
Assert.AreEqual(0.004935, xicUnit.Meta.RtStart, 0.01);
45-
Assert.AreEqual(0.4872366666, xicUnit.Meta.RtEnd, 0.01);
42+
Assert.AreEqual(140, xicUnit.Meta.MzStart.Value, 0.01);
43+
Assert.AreEqual(2000, xicUnit.Meta.MzEnd.Value, 0.01);
44+
Assert.AreEqual(0.004935, xicUnit.Meta.RtStart.Value, 0.01);
45+
Assert.AreEqual(0.4872366666, xicUnit.Meta.RtEnd.Value, 0.01);
4646
}
4747

4848
[Test]
@@ -73,10 +73,10 @@ public void testXicRead()
7373
XicUnit xicUnit = xicData.Content[0];
7474
Assert.AreEqual(46, ((Array) xicUnit.RetentionTimes).Length);
7575
Assert.AreEqual(46, ((Array) xicUnit.Intensities).Length);
76-
Assert.AreEqual(749.786, xicUnit.Meta.MzStart, 0.01);
77-
Assert.AreEqual(749.8093, xicUnit.Meta.MzEnd, 0.01);
78-
Assert.AreEqual(10, xicUnit.Meta.RtStart, 0.01);
79-
Assert.AreEqual(10.98, xicUnit.Meta.RtEnd, 0.01);
76+
Assert.AreEqual(749.786, xicUnit.Meta.MzStart.Value, 0.01);
77+
Assert.AreEqual(749.8093, xicUnit.Meta.MzEnd.Value, 0.01);
78+
Assert.AreEqual(10, xicUnit.Meta.RtStart.Value, 0.01);
79+
Assert.AreEqual(10.98, xicUnit.Meta.RtEnd.Value, 0.01);
8080

8181
xicData = new XicData
8282
{
@@ -99,10 +99,10 @@ public void testXicRead()
9999
xicUnit = xicData.Content[0];
100100
Assert.AreEqual(1, ((Array) xicUnit.RetentionTimes).Length);
101101
Assert.AreEqual(1, ((Array) xicUnit.Intensities).Length);
102-
Assert.AreEqual(749.786, xicUnit.Meta.MzStart, 0.01);
103-
Assert.AreEqual(749.8093, xicUnit.Meta.MzEnd, 0.01);
104-
Assert.AreEqual(300, xicUnit.Meta.RtStart, 0.01);
105-
Assert.AreEqual(400, xicUnit.Meta.RtEnd, 0.01);
102+
Assert.AreEqual(749.786, xicUnit.Meta.MzStart.Value, 0.01);
103+
Assert.AreEqual(749.8093, xicUnit.Meta.MzEnd.Value, 0.01);
104+
Assert.AreEqual(300, xicUnit.Meta.RtStart.Value, 0.01);
105+
Assert.AreEqual(400, xicUnit.Meta.RtEnd.Value, 0.01);
106106
}
107107

108108
[Test]
@@ -131,6 +131,12 @@ public void testValidateJson()
131131
'tolerance':10,
132132
'rt_start':630,
133133
'rt_end':660
134+
},
135+
{
136+
'mz':575.2413,
137+
'tolerance':10,
138+
'tolerance_unit':'ppm',
139+
'comment': 'this is comment'
134140
}
135141
]";
136142

XIC/JSONInputUnit.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ public class JSONInputUnit
4545
[DefaultValue(null)]
4646
public string Filter { get; set; }
4747

48+
[JsonProperty("comment", DefaultValueHandling = DefaultValueHandling.Populate)]
49+
[DefaultValue(null)]
50+
public string Comment { get; set; }
51+
4852
public bool HasMzRange()
4953
{
5054
return MzStart != null && MzEnd != null;

XIC/JSONParser.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,11 @@ public static class JSONParser
8484
'$id': '#/items/properties/scan_filter',
8585
'type': 'string',
8686
'title': 'The Filter Schema',
87+
},
88+
'comment': {
89+
'$id': '#/items/properties/comment',
90+
'type': 'string',
91+
'title': 'The Comment Schema',
8792
}
8893
}
8994
}
@@ -136,11 +141,11 @@ public static XicData ParseJSON(string jsonString)
136141
}
137142

138143
xicUnit = new XicUnit(xic.Mz.Value - delta, xic.Mz.Value + delta, xic.RtStart,
139-
xic.RtEnd, xic.Filter);
144+
xic.RtEnd, xic.Filter, xic.Comment);
140145
}
141146
else if (xic.HasMzRange())
142147
{
143-
xicUnit = new XicUnit(xic.MzStart.Value, xic.MzEnd.Value, xic.RtStart, xic.RtEnd, xic.Filter);
148+
xicUnit = new XicUnit(xic.MzStart.Value, xic.MzEnd.Value, xic.RtStart, xic.RtEnd, xic.Filter, xic.Comment);
144149
}
145150

146151
if (xicUnit == null || !xicUnit.HasValidRanges())

XIC/XicMeta.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ public class XicMeta
2525
[DefaultValue(null)]
2626
public string Filter { get; set; }
2727

28+
[JsonProperty(DefaultValueHandling = DefaultValueHandling.IgnoreAndPopulate)]
29+
[DefaultValue(null)]
30+
public string Comment { get; set; }
31+
2832

2933
public XicMeta()
3034
{
@@ -33,6 +37,7 @@ public XicMeta()
3337
RtStart = null;
3438
RtEnd = null;
3539
Filter = null;
40+
Comment = null;
3641
}
3742

3843
public XicMeta(XicMeta copy)
@@ -42,6 +47,7 @@ public XicMeta(XicMeta copy)
4247
RtStart = copy.RtStart;
4348
RtEnd = copy.RtEnd;
4449
Filter = copy.Filter;
50+
Comment = copy.Comment;
4551
}
4652
}
4753
}

XIC/XicUnit.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,15 @@ public XicUnit()
1616
Intensities = null;
1717
}
1818

19-
public XicUnit(double mzStart, double mzEnd, double? rtStart, double? rtEnd, string filter)
19+
public XicUnit(double mzStart, double mzEnd, double? rtStart, double? rtEnd, string filter=null, string comment=null)
2020
{
2121
Meta = new XicMeta();
2222
Meta.MzStart = mzStart;
2323
Meta.MzEnd = mzEnd;
2424
Meta.RtStart = rtStart;
2525
Meta.RtEnd = rtEnd;
2626
Meta.Filter = filter;
27+
Meta.Comment = comment;
2728
}
2829

2930
public bool HasValidRanges()
@@ -43,7 +44,7 @@ public bool HasValidRanges()
4344

4445
public string GetMeta()
4546
{
46-
return string.Format("Filter: \"{0}\"; m/z: [{1} - {2}]; RT: [{3} - {4}]", Meta.Filter, Meta.MzStart, Meta.MzEnd, Meta.RtStart, Meta.RtEnd);
47+
return string.Format("Filter: \"{0}\"; m/z: [{1} - {2}]; RT: [{3} - {4}]; Comment: {5}", Meta.Filter, Meta.MzStart, Meta.MzEnd, Meta.RtStart, Meta.RtEnd, Meta.Comment);
4748
}
4849

4950
public XicUnit(XicUnit copy)

0 commit comments

Comments
 (0)